if (!empty($_SERVER['HTTP_CLIENT_IP']))
$ip=$_SERVER['HTTP_CLIENT_IP'];
else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
else
$ip=$_SERVER['REMOTE_ADDR'];
?>
Previously, Dennis Chen shared a small talk illustrating how you can execute a loading test with ZK applications using JMeter. Now, in this blog we will introduce how you can use ZK JMeter Plugin to simplify your work. With this JMeter Plugin, you no longer have to set user variables or parameter for each zkau request element.
For security reasons, ZK generates ID randomly. However to perform a record & reply test, it is mandatory to fix the IDs of the components. The IdGenerator here is used to create a predictable component id when testing.
public class SimpleIdGenerator implements IdGenerator {
private static final String PREFIX = "zk_comp_";
private static final String INDEX_KEY = "Id_Num";
public String nextComponentUuid(Desktop desktop, Component comp) {
int i = Integer.parseInt(desktop.getAttribute(INDEX_KEY).toString());
i++;// Start from 1
desktop.setAttribute(INDEX_KEY, String.valueOf(i));
return PREFIX + i;
}
public String nextComponentUuid(Desktop desktop, Component comp,
ComponentInfo info) {
return nextComponentUuid(desktop, comp);
}
public String nextDesktopId(Desktop desktop) {
System.out.println("new Desktop");
if (desktop.getAttribute(INDEX_KEY) == null) {
desktop.setAttribute(INDEX_KEY, "0");
}
return null;
}
public String nextPageUuid(Page page) {
return null;
}
}
To use this generator, we have to add a configuration to zk.xml
Download zk-jmeter-plugin-0.8.0.jar, then place the jar file in the following folder: JMETER_HOME\lib\ext.
Prepare a Test Plan
Create a Thread Group in Test Group.
Add HTTP Cookie Manager in Thread Group
Add HTTP Request Defaults in Thread Group.
Add Transaction Controller in Thread Group.
Edit HTTP Request Defaults, set the Server Name and Port Number.
Create a ZK HTTP Proxy Server (Add > Non-Test Elements) in WorkBench, and edit it as follows
Set Target Controller to Test Plan > Thread Group > Transaction Controller
Start the ZK HTTP Proxy Server
Start to Record Testing Scripts
Now, you are ready to record the request of the browser to a test case. Please switch the proxy of your browser to host:port (in this case, proxy is localhost:9999), and link it to the application ( in this case, it is http://localhost:8080/product-app/index.zul) . I did some selection, textbox typing, and button clicking , you will see not only the first zul request was recorded, but also zkau too. After this has been done, switch the proxy off.
and we need to tick off a checklist of the record:
Check that the uuid of zkau is created by SimpleIdGenerator (it will have prefix zk_comp_)
Check that there is no rmDesktop command in the zkau record, if you have one, please remove it. ( It is for removing previous tasks when we recorded the testcase, we don’t need it anymore)
Make sure Server Name and Port Number are recorded in zkau since we already set them in HTTP Request Defaults.
ZK JMeter Plugin now comes in and will replace dtid parameter value as ${dtid} automatically, we can then use this script to test ZK application immediately without any further tuning. You no longer need to set user variables or parameter for each zkau request manually.
Monitor Server Memory
This JMeter Plugin can also help you in monitoring Server Memory easily.
Add the following JVM arguments to the server start command, then restart the server.
Add JMX Visualizer (Add > Listener) in Thread Group.
In this case, we set JMX remote port as 1010, then we can start to run the JMeter script, after running the JMeter script, the memory usage chart will be plotted.
Summary
ZK JMeter Plugin can help you to perform stress tests on your ZK applications with JMeter easily; automating the process of replacing parameter values with user variables. It also provides a JMX Visualizer which can help users to monitor server memory usage during the test.
Hello , I’m trying to download the plugin with my user , but link always redirects to user/pass screen , despite user and pass are correct (“login succesfully in default screen”), is there any another register?
You should be able to download the file after logging into the website with your ZK forum account. To double check if you have successfully logged in, you can go to zk home page: http://www.zkoss.org/, then check the upper right corner and see if your user name is there: see http://screencast.com/t/Jh28gtUO
What’s the difference between JMeter’s default Proxy server and ZK Proxy server? It records Ajax or only XHR? I read about runing Selenium in JMeter so ZK JMeter plugin will replace all this stuff?
I tested my simple database application through the steps identified in this blog. I able to create the script and run it. But it is not creating the database record in db, that it is suppose to do through the script.
Can u please tell me the where can place this below code..?
i mean that server start command mean..?
Monitor Server Memory
—————————–
This JMeter Plugin can also help you in monitoring Server Memory easily.
Add the following JVM arguments to the server start command, then restart the server.
-Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=1010 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
I’m not sure if this is working, I’m running into the same issue. here is the response I get from the server for zkau
{“rs”:[[“cfmClose”,[“”]],[“obsolete”,[“z_zyg”,”The resource you request is no longer available: z_zyg.\nThis is normally caused by timeout, or opening too many Web pages.\nYou have to reload the page and try again.”]]]}
@Ramzi: the error means the desktop with ID “z_zyg” is not/no longer available on the server. this ID changes from testcase to testcase, please make sure it is not hard coded in your JMeter script, and resolved dynamically using the variable ${dtid}, also make sure the “rmDesktop” command has not been called for this desktop before it is used.
I have added the following JVM arguments to the JBoss EAP 6.4 server start command, then restart the server.
-Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=1010 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
However, when I start to run the JMeter, there is no result in JMX Visualizer. Please help.
hello,
I installed the jmeter jar and placed it in the jmeter/lib/ext folder. After that i want to record a test script, but the problem is, when i placed the jar in the respective folder, my jmeter got crashed and showing an error as: Uncaught Exception java.lang.NoClassDefFoundError: could not initialize class org.apache.jmeter.gui.util.MenuFactory. see log file for details.
Hello
I am trying to create a performance test script using Jmeter and this ZK plugin(The WEB site which I was testing is created using ZK AJAX framework). I am able to generate desktop Id(dtid) and component IDs. For some requests, I am getting the same response as a browser.
But for some requests, I am getting a blank response( {“rs”:[],”rid”:126} ). The script is sending same paramnets as browser. In failed requests some co-orinates like parameters are sending.( data_1 = {“top”:242,”left”:0} ). Is the test failing because of this co-ordinates?
Hello , I’m trying to download the plugin with my user , but link always redirects to user/pass screen , despite user and pass are correct (“login succesfully in default screen”), is there any another register?
Regards!!!
You should be able to download the file after logging into the website with your ZK forum account. To double check if you have successfully logged in, you can go to zk home page: http://www.zkoss.org/, then check the upper right corner and see if your user name is there: see http://screencast.com/t/Jh28gtUO
What’s the difference between JMeter’s default Proxy server and ZK Proxy server? It records Ajax or only XHR? I read about runing Selenium in JMeter so ZK JMeter plugin will replace all this stuff?
Hi Jimmy,
I tested my simple database application through the steps identified in this blog. I able to create the script and run it. But it is not creating the database record in db, that it is suppose to do through the script.
Not sure what I am missing.
Thanks,
Bilal
SimpleIdGenerator is of for simple page,but,if the page is created dynamicly as a tabpanel,the components ids are not predictable!!!!!
disable “Redirect Automatically” and “Follow Redirects for ZK Proxy Server
Hi guys,
Can u please tell me the where can place this below code..?
i mean that server start command mean..?
Monitor Server Memory
—————————–
This JMeter Plugin can also help you in monitoring Server Memory easily.
Add the following JVM arguments to the server start command, then restart the server.
-Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=1010 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
I’m not sure if this is working, I’m running into the same issue. here is the response I get from the server for zkau
{“rs”:[[“cfmClose”,[“”]],[“obsolete”,[“z_zyg”,”The resource you request is no longer available: z_zyg.\nThis is normally caused by timeout, or opening too many Web pages.\nYou have to reload the page and try again.”]]]}
Thanks,
Ramzi
@kumar: it depends on the application server where and how to add the JVM arguments in the startup scripts. e.g. here the documentation how to do it in Apache Tomcat http://tomcat.apache.org/tomcat-7.0-doc/monitoring.html#Enabling_JMX_Remote
@Ramzi: the error means the desktop with ID “z_zyg” is not/no longer available on the server. this ID changes from testcase to testcase, please make sure it is not hard coded in your JMeter script, and resolved dynamically using the variable ${dtid}, also make sure the “rmDesktop” command has not been called for this desktop before it is used.
The download link for the jmeter Plugin seems not to work at the time
I have added the following JVM arguments to the JBoss EAP 6.4 server start command, then restart the server.
-Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=1010 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
However, when I start to run the JMeter, there is no result in JMX Visualizer. Please help.
hello,
I installed the jmeter jar and placed it in the jmeter/lib/ext folder. After that i want to record a test script, but the problem is, when i placed the jar in the respective folder, my jmeter got crashed and showing an error as: Uncaught Exception java.lang.NoClassDefFoundError: could not initialize class org.apache.jmeter.gui.util.MenuFactory. see log file for details.
Please help me with this issue
Thank you
the plugin does not work with the latest version of JMeter 3.2+, versions up to 3.1.x still work.
Robert
Any idea how we use Jmeter to run on zk framework application
Is this Jmeter Plugin working
Version 3.2.0 has been released compatible with JMeter 3.2+ (tested up to 5.0)
source: https://github.com/zkoss/zkjmeterplugin
releases: https://github.com/zkoss/zkjmeterplugin/releases
Hello
I am trying to create a performance test script using Jmeter and this ZK plugin(The WEB site which I was testing is created using ZK AJAX framework). I am able to generate desktop Id(dtid) and component IDs. For some requests, I am getting the same response as a browser.
But for some requests, I am getting a blank response( {“rs”:[],”rid”:126} ). The script is sending same paramnets as browser. In failed requests some co-orinates like parameters are sending.( data_1 = {“top”:242,”left”:0} ). Is the test failing because of this co-ordinates?
Please help me with this issue
Thank you
Unless the server side event listener depends on the mouse coordinatest they don’t matter.