Before your application goes through it's final functional testing phase, it is advisable to perform a load test to check that the application will be able to handle the expected load. We do this by using jMeter to generate load on the application, and filling up the database with a realistic number of records. The procedure described below is a guide to performing such a load test.
Configuring jZeno
Because the HTML generated by jZeno is dynamic, client-side identifiers of components will vary as the application runs. in order to allow protocol level recording (which is what jMeter does) you need support from jZeno to allow translation of recorded HTML identifiers into identifiers that are valid at playback time. To use this you must apply a couple of changes to your project :
- Add a component of type net.sf.jzeno.echo.script.VugenRecord to your layout. Preferably make this component in your layout optional by checking the configuration option ConfigurationProperties.getInstance().isActivageVugenTranslation().
- Optionally add a component of type net.sf.jzeno.echo.ScriptRecorder to your layout. Preferably make this component in your layout optional by checking the configuration option ConfigurationProperties.getInstance().isEnabledScriptRecorder().
- Set the configuration options activate.vugen.translation=true and test.script.folder=[location of your project's test script folder]
- Set the configuration option enable.scriptrecorder=true
- Add code to your logout event handler that stops the current recording session on the VugenRecord component.
The default layout of the jZeno template project is pre-configured with both types of components. If you have a custom layout that does not yet contains the necessary code, please add the following code to your class's constructor :
Grid.Cell scriptRecorderCell = new Grid.Cell();
scriptRecorderCell.setHorizontalAlignment(EchoConstants.RIGHT);
scriptRecorderCell.setInsets(new Insets(2));
if (ConfigurationProperties.getInstance().isEnableScriptRecorder()) {
Component scriptRecorder = (Component) ReloadableClassManager
.newInstance("net.sf.jzeno.echo.script.ScriptRecorder");
scriptRecorderCell.add(scriptRecorder);
mainGrid.add(scriptRecorderCell);
}
if (ConfigurationProperties.getInstance().isActivateVugenTranslation()) {
Grid.Cell vugenRecorderCell = new Grid.Cell();
vugenRecorderCell.add(new VugenRecorder());
vugenRecorderCell.setHorizontalAlignment(EchoConstants.RIGHT);
mainGrid.add(vugenRecorderCell);
}
Where mainGrid was instantiated by your constructor before.
In the logout method of you application add the following code :
VugenRecorder recorder = (VugenRecorder)
EchoSupport.findComponentByType((Component) EchoSupport.getLayout(), VugenRecorder.class);
if (recorder != null) {
recorder.stop();
}
Configuring jMeter
After downloading jMeter, and starting it you need to create a basic jMeter project as follows. When opening jMeter you will see 2 items by default : Test Plan and Workbench.Right-click on Test Plan and select Add - Thread Group. This will give you the options that change the number of threads (concurrent user sessions) that will be running on your application, as well as the ramp-up period, and the amount of runs of the test scenario per thread.
After this right-click the new thread group and select Add - Config Element - HTTP Cookie Manager. This will make sure that jMeter will act enough like a regular browser to maintain HTTP cookies, and be able to interact with a single jZeno session.
We also need to configure the Workbench item : right-click and select Add - Non Test Elements - HTTP Proxy Server. We will configure our browser to use this new proxy. By default it is configured on port 8080. As most servlet containers already use this port, we'll change this to port 9090.(Change the value in the Port field). In order to record user think times we need to add a timer object to our new proxy element. Right-click on the proxy element and select Add - Timer - Constant Timer. Other than its name seems to suggests you can use this element for recording user think times. In the field Thread delay (in milliseconds): enter the expression ${T}. The latter will make sure that the recorded conversation will have constant timers added with the recorded think times.
After this we start our new proxy server by clicking on the Start button. This new HTTP proxy is used by jMeter to record the conversation between the browser and jZeno at HTTP protocol level.
Configuring the browser
After configuration of jMeter we still need to tell our browser to use the new proxy. In order to avoid recording your homepage it is a good idea to set your browser's homepage to about:blank. After this go to the network proxy setting of your browser and enter localhost as the proxy's hostname, and 9090 as the proxy's port. Alternatively, if you are using Firefox as your testing browser, it is a good idea to install the FoxyProxy plugin, and configure it to allow quick switching between your regular proxy and jMeter.
Determine the test scenario
A good level of though should go into determining the details of your test scenario. Much of the benefit of load testing depends on it. First of all you need to know the expected amount of data in your database for all of the tables in it. Secondly you need to insert (through a sql script, or a piece of custom hibernate code) the determined amounts of data. It is not necessary to have hyper-realistic data here, but the size of the data should be realistic. It is also advisable to do this at the start of the project, so that developers get a sense of the performance characteristics of queries.
Secondly you will need to determine the number of concurrent user sessions at peak load.
Thridly you will have to come up with realistic usage scenarios.
Recording the test scenario
Recording the test scenario is done in 7 steps :
- Start your application.
- Point your browser (with jMeter proxy configuration) at the application.
- Start a new translation map, by entering the translation map's name in the VugenRecorder, and clicking Record. Do not add any extension to the name of the translation map. This will (after recording) result in a file on disk with extension .translation.
- Log on to the application, execute the test script, and logout (which stops recording of the translation map)
- Stop jMeter's proxy server by clicking on Stop.
- Now select the first recorded POST entry (under the Thread Group item in jMeter). This will be the first item that ends in notuserrefresh=true. On this item add a new entry under Send Parameters With the Request. Name of the entry should be play and the value should be the name of the translation map (as you entered in step 3).
- Save your new load test scenario.
Playing back the test scenario
You are now ready to start doing your load test. Enter the desired number of threads on the Thread Group element, as well as the ramp up period in seconds. Then use the menu item Run - Start to start the playback. Check you application logs to verify that the test is running correctly.
Validation
During the playback of your load test, you can monitor you application's perfomance by using the built-in administrative screens of jZeno , as well as manually performing a test scenario on the application under load to get a feeling of the speed, etc... Besides this it is advisable to take heap and thread dumps and analyze these to get a different view on your application's performance under load.
| < Prev | Next > |
|---|





