Building JMeter scripts with GXtest
Contents |
JMeter
JMeter is a free open source tool for performance (load / stress) testing and actually the most used tool in this area, enabling running http (or https) requests to the web server simulating a browser without actually using one. Using GXtest, you will able to build JMeter scripts with a simple click, and after that being able to adapt it in order to perform your own actions (such as introducing validations, conditions, parameterizations, etc.).
JMeter allows to run test scenarios defining a large amount of active users, iterations, and simulating environments under certain loads to represent a realistic scenario. The figure below shows an example of a JMeter test plan.
JMeter test case generation process is achieved by running the test case in the browser and capturing HTTP requests that were made automatically using a Proxy. This enable people without JMeter experience to first create the test case (flow and data using datapools) in GXtest, and to provide this script to a performance expert who will be able to finish the JMeter script properly (specially adding regular expressions and adding some hardcoded parameters) .
Without this process, it will be really difficult to identify steps and to identify what each request does in terms of functional /business rules. In order to have an understandable script it is possible to introduce comments between each step (during the recording), as well as timers to control each step.
Creating JMeter scripts without GXtest is usually a tedious task that can be hard to accomplish, specially when the application’s code is being constantly changing, which means that the scripts have to be almost complete re-generated. Also, please note that if you plan to run test scripts using Ajax encryption (enabled by default in GeneXus) it would be almost impossible to make it without GXtest generation due to encryption.
Tips for performance projects
By default it is very hard to make performance testing scripts in GeneXus since there are a lot of parameters that you will not control over HTTP request and HTTP responses. That said, it is almost a must to turn Ajax Security off to properly generate parametrized requests and avoiding STATUS CODE 403 - Not authorized results in GeneXus. http://wiki.genexus.com/commwiki/servlet/wiki?17384,Javascript+Debug+Mode+property,
Strongly consider to compliment test execution results with GeneXus monitoring tools, such as JMX or WMI.
If you want to simulate real behavior using Ajax Encryption, we have included in version 3.2 the ability to encrypt Ajax request in runtime as well as other common parametrizations like AJAX_KEY, AJAX_SECURITY_TOKEN, GX_WEBSOCKET_ID, and other variables.
Generating JMeter scripts with GXtest
GXtest can generate JMeter scripts from a previously recorded test case. This gives many advantages to users, including:
- Recording test cases with GXtest, which can be done by a functional without performance automation experience. (after generation, a performance tester will need to work on top of that).
- Automatic generation of the most tedious part of the script without wasting time running repetitive tasks.
- No need of introducing top validations manually, timers or basic parametrizations. Normally, this turns into a considerably long task and usually presents problems. GXtest automatically introduces all these elements.
- The use of debugging flags for think times and log messages.
- Support of NTLM authentication.
- Automatic management of redirection.
How does the script generator works?
The performance script is created by clicking the GXtest Designer button "Generate JMeter scripts".
When sending the request to create an JMeter script, the test case will start executing as usual in the user’s screen. Nevertheless, there are many different actions happening internally: in the course of the test case execution, a xml file is created with all the GXtest commands that are being used in the test, while http requests are recorded into a .saz extension file. This files are left inside a folder with the name of the test case, where the GXtest Designer is installed, normally in: Abstracta\GXtest Designer\Performance\ExecutionLog\.
The saz format belongs to the Fiddler tool, which is a proxy that records http traffic between Internet and the PC, that then can be analyzed by introducing breakpoints, editing requests at protocol level, etc. This file is very important to performance automators in order to compare original requests and understand how they should parametrize the rest of the script in Jmeter.
With these two files (xml and saz), the JMeter test plan is generated using GXtest commands from the xml file and http(s) requests from the saz file. Once the execution is completed, the resulting script will have each GXtest command that was executed, associated with the http(s) requests that are involved in each of them, with their appropriate timers, and in the case they have been introduced, the corresponding validations. The resulting file is created in the folder Abstracta\GXtest Designer\JMeter.
The resulting scripts may be ready to be executed without changes, but usually modifications and parametrizations needs to be done by a JMeter expert, specially if the system is using Ajax Encryption. Usually, there is need to: add some conditions, parametrize new variables, add system validations, etc. in order to make a performance script as real as possible.
GXtest Features for building JMeter scripts
As told, GXtest generates the majority of the work by creating the Jmeter script automatically and it is almost a must to make performance testing in GeneXus.
Top features are:
- Script readability
- The generated script is readable and modular.
- Traceability between user actions (GXtest commands) and HTTP request
- Global variable parametrization such as: webServer, port, webapp, threads, ramp up, etc.
- Introduction of Thinktimes between each user action
- Follow redirect:
- All requests that causes STATUS CODE 302 are discarded
- JMeter follow-redirect steps to improve robustness
- Deleted secondary requests. Using JMeter "Retrieve embedded resources" feature instead
- Error debugging
- All request and responses are logged in JMeter's log to enable an easy debugging
- DEBUG FLAG: enable to skip Think-times (faster execution running when building the script)
- Result analysis
- User actions are grouped to better understand response times.
- Automatic Parameters
- GX Variables and Test Data used by Datapools (when data used is bigger than 3 chars)
- Ajax security variables (GX_AJAX_KEY, AJAX_SECURITY_TOKEN)
- Common vars (GX_WEBSOCKET_ID)
- Beanshell generation to automatically encrypt URL parameters in AJAX requests
- Good practices
- Cookies are deleted before generation.
- Usage of Cookie Manager in JMeter
Unsupported items
There are some items that would be nice to include in next versions of GXtest that are currently not being generated:
- Uploading binaries
- More Genexus variables
- User / developers variables
How to import the generated file into JMeter?
After the test case is executed from GXtest Designer, the JMeter test plan generated will be available in GXtest installation folder Abstracta\GXtest Designer\JMeter.
The generated file will have the .jmx extension, and it can be open from the File -> Open JMeter's menu.
Installing JMeter
JMeter is a free tool and can be downloaded from its web site
Summary
GeneXus hides all complexity to developers as well as GXtest allows to create Jmeter scripts make performance testing in GeneXus. Generating scripts using the tool will save a lot of time and relieve headaches with handling GeneXus requests.
Also, if AJAX SECURITY is enabled, GXtest will be probably the only option to handle such complexity on scripts.