Performance testing for Web UI with JMeter

Usually when you are deploying your app to a production environment you want to check if you have enough CPUs, memory and servers to deal with the load. In order to test this you have to do performance testing.

In case of performance testing of CUBA based web application we use the following tools:

This tutorials uses:

  • CUBA Platform 6.9.2
  • CUBA Studio 6.9.1

Configure application for testing

Add the following properties to the web-app.properties file to enable tests in your CUBA application:

  1. Enable cuba.testMode enables test ids for components;
  2. Enable cuba.performanceTestMode to disable “CSRF” security.

JMeter scenario

Adding Elements to Test Plan

  1. Add “Thread Group” to “Test Plan”:
    Test Plan -> Add -> Threads (Users) -> Thread Group
  1. 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.

jmeter3

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

jmeter5

  1. 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

  1. Add “HTTP Cookie Manager” to “Thread Group” :
    Thread Group -> Add -> Config Element -> HTTP Cookie Manager

Check “Clear cookies each iteration” in this manager.

jmeter1

  1. 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)}

jmeter2

  1. 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 is the following:

jmeter4

Configure Firefox proxy

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

  1. Open Firefox
  2. Open browser options
  3. Go to proxy settings
  4. Select the “Manual proxy configuration”
  5. Set HTTP Proxy to “localhost” and Port to “9090”
  6. Check “Use this proxy server for all protocols” option
  7. Check that localhost and 127.0.0.1 NOT in “No Proxy for” list, otherwise remove them
    jmeter10
  8. Click OK and exit from the menu
  9. Restart Firefox

Recording Requests

Our test will do 3 simple steps:

  • Login to the application;
  • Open “Users” screen;
  • Logout.

To record request do the following steps:

  1. 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;

  2. In Firefox open “http://localhost:8080/app”. We can see that some requests have already saved in “Recording Controller”;
    jmeter6

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

  4. Open “Users” screen;

  5. Logout;

  6. Stop recording.

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

jmeter8

Play our recorded requests to test it. Click “Start” button on the buttons panel above.
The warning 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.

jmeter9

Attached scenario:cuba-app-test-scenario.zip (3.6 KB)

4 Likes

Hi Roman, is this only apply to CUBA 6.9 or I can also take this approach with CUBA lower versions, e.g. 6.6/6.7?

Hi, Anjingjing!
Yes, you can try 6.6/6.7 versions.

Note, that cuba.testMode is required only for 6.9 and lower versions.

Since 6.10, performance test requires only cuba.performanceTestMode

Checked for Cuba 7.2.7, Jmeter 5.3, Firefox 80.0

1 Like

Need to set network.proxy.allow_hijacking_localhost to true in Firefox about:config in order to proxy localhost (it’s false by default). Otherwise, you won’t be able to record smth from your localhost app. Hope, this will save somebody’s time.

1 Like

Thanks @artemaa for the update.

Now you can find this guide at GitHub - cuba-labs/jmeter-guide - please feel free to update it if there are any issues with the guide.

1 Like