Skip to content

cuba-labs/jmeter-guide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Performance Testing Using JMeter

For the performance testing of CUBA-based web application we use the following tools:

Apache JMeter

Mozilla Firefox

Application configuration

Add cuba.performanceTestMode = true to the web-app.properties file to disable “CSRF” security.

Firefox configuration

Need to set network.proxy.allow_hijacking_localhost to true in Firefox about:config in order to proxy localhost (it’s false by default)

JMeter scenario

Adding Elements to Test Plan

Add “Thread Group” to “Test Plan”:

Test Plan -> Add -> Threads (Users) -> Thread Group

Add “HTTP(S) Test Script Recorder” to “Test Plan”:

Test Plan -> Add -> Non-Test Elements -> HTTP(S) Test Script Recorder

Change the default port of the “HTTP(S) Test Script Recorder” proxy to 9090 or another required one. 8080 is used for our application.

On the ‘Requests Filtering’ tab, specify the following code to exclude unnecessary requests (JS, CSS, etc.):

(?i).*\.(bmp|css|js|gif|ico|jpe?g|png|swf|woff|txt)
(?i).*\.(bmp|css|js|gif|ico|jpe?g|png|swf|woff|txt)[\?;].*

Or you can add it separately:

.*\.png
.*\.jpg
.*\.gif

Also, add “View Results Tree” to “HTTP(S) Test Script Recorder”

HTTP(S) Test Script Recorder -> Add -> Listener -> View Results Tree

It shows data for all recorded requests.

Adding Elements to Thread Group

Add “HTTP Cookie Manager” to “Thread Group” :

Thread Group -> Add -> Config Element -> HTTP Cookie Manager

Check “Clear cookies each iteration” in this manager.

Add “User Defined Variables” to “Thread Group”:

Thread Group -> Add -> Config Element -> User Defined Variables

We will use two variables:

  • host address: ${__P(host, localhost)}
  • port: ${__P(port, 8080)}

Then add “Recording Controller” to “Thread Group”:

Thread Group -> Add -> Logic Controller -> Recording Controller

Requests from the application will be saved in this controller. Also, add a tree which shows info about all recorded requests when they are played.

Recording Controller -> Add -> Listener -> View Results Tree

So, the final scenario tree should look like the following:

Configure Firefox proxy

Configure Firefox to use localhost on port 9090 (like in HTTP(S) Test Script Recorder proxy):

  • Open Firefox
  • Open browser options
  • Go to proxy settings
  • Select the “Manual proxy configuration”
  • Set HTTP Proxy to “localhost” and Port to “9090”
  • Check “Use this proxy server for all protocols” option
  • Check that localhost and 127.0.0.1 NOT in “No Proxy for” list, otherwise remove them

  • Click OK and exit from the menu
  • Restart Firefox
Recording Requests

Our test will do 3 simple steps:

  1. Login to the application.
  2. Open “Users” screen.
  3. Logout.

To record request do the following steps:

  • In the “HTTP(S) Test Script Recorder” click “Start” button. We will see the information dialog: “Root CA certificate ApacheJMeterTemporaryRootCA created in bin directory”. Click the OK button.
  • In Firefox open http://localhost:8080/app. We can see that some requests have already saved in “Recording Controller”.

  • Login to the application. For the sake of convenience, rename the resulting request.

  • Open “Users” screen.
  • Logout.
  • Stop recording.

You can find the example of the scenario here.

Now we can delete unnecessary requests, for instance, app/Push. After that, the scenario looks as follows:

Play our recorded requests to test it. Click “Start” button on the top buttons panel.

The dialog will appear. It will ask you to save the test plan. Save it with the name “cuba-app-test-scenario”.

In the tomcat’s log, we can see that the admin user ‘logged in’ and ‘logged out’. “View result tree” shows info about request and response.

You can review responses in the results tree as shown on the picture:

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published