Liferay Performance Testing using JMeter

blog-banner

The Apache JMeter™ desktop application is open source software, a 100% pure Java application designed to load test functional behavior and measure performance. It was originally designed for testing web applications but has since expanded to other test functions.

I am going to show how to use Jmeter for performance testing of liferay portal’s authenticated pages. Here I am going to use Apache Jmeter 2.11.

Here are Some Steps to follow :

Step: 1 - Disable p_auth

Make auth.token.check.enabled =false in portal-ext.properties file and then restart liferay. Liferay uses Portal Authentication Token p_auth to prevent CSRFattack. This token is included in every action request in the portal by including the "p_auth" parameter in URL.We are disabling it so JMeter can login. Here is detail about authtoken.

Step: 2 - Add Thread Group

Right click on Test Plan and then follow below path:

Add ? Threads(Users) ? Add Thread Group

In Thread Group there is Loop Count which tells how many loops to perform on request. Ramp up Period tells the time interval.

eg. if Number of Thread =1,Ramp up Period=1 and Loop Count=5 then it perform 5 iteration of request in 1 second for 1 user here is more detail about thread group.

Step 3 - Add Http Cookie Manager under Thread Group

Right click on Thread Group and then follow below path:

Add ? Config Element ? HTTP Cookie Manager.

HTTP Cookie Manager Stores Cookie and send cookie just like web browsers. Here is more detail about cookie manager.

Step: 4 - Add Once Only Controller

Right Click on Thread Group and then follow below path:

Add ? Logical Controller ? Once Only Controller

Once Only Controller run only once for any looping parent control. If parent control defines 5 loops then it will run for only first iteration. Mainly it is used for login purpose. Here is more detail about all controllers.

Step: 5 - Add Http Request under Once Only Controller

Right click on Once Only Controller and then follow below path:

Add ? Sampler ? HTTP Request

In this request you call the Login Portlet using below URL:

/web/guest/?p_p_id=58&p_p_state=maximized&_58_struts_action=%2Flogin%2Flogin

Below is Configuration for this Request.

  1. Server name or IP appropriate to your domain.
  2. Port number on which your liferay is running.
  3. URL of Login Portlet.

Add Http Request controller

Step: 6 - Add Regular Expression Extractor under Once Only Controller

Right click on Once Only Controller and then follow below path:

Add ? Post Processor ? Regular Expression Extractor

Extractor is used to extract parameter from first request to utilize it in the next request. Here we will capture authtoken from previous request using regular expression and use it in next request

The Extractor is configured as shown in the screenshot:

Add Regular Expression Extractor controller

Step: 7 - Add Http Request under Once Only Controller

Right click on Once Only Controller and then follow below path:

Add ? Sampler ? HTTP Request

Now you can take "authtoken" parameter for the second login request to use. The path for the request is:

/web/guest/?p_auth=${authtoken}&p_p_id=58&p_p_lifecycle=1&p_p_state=maximized&_58_struts_action=%2Flogin%2Flogin

The POST parameters can be found in the next Screenshot. The names of the parameters are below:

  • _58_login
  • _58_password
  • _58_rememberMe

The parameter "_58_login" and "_58_password" shall be filled with the existing credentials.

  1. Server name or IP appropriate to your domain.
  2. Port number on which your liferay is running.
  3. URL of Login Action.
  4. Credential of User.

Add Http Request controller

Step: 8 - Add Http Request under Thread Group.

Right click on Thread Group and then follow below path:

Add ? Sampler ? HTTP Request

This Request is for private page for which you want to test.

Step 9 - Add View Result Tree.

Right click on Thread Group and then follow below path:

Add ? Listener ? View Result Tree

The View Results Tree shows a tree of all sample responses, allowing you to view the response for any sample. Here is more detail about View Result Tree

The HTML content of private page in View Result Tree response proves that Jmeter successfully logged in Liferay. Other private pages can also be tested by putting friendly URL of those pages in HTTP Request from Step-8.

Note: For Security reasons don’t set auth.token.check.enabled property to false in production environment. Change this property to true after performance test.


Download:

JMeter Test File(jmx)

Contact us

For Your Business Requirements

: 0 / 65000

: 0 / 280

: 0 / 280

: 0 / 280

: 0 / 280

: 0 / 280

: 0 / 65000

Text to Identify Refresh CAPTCHA
Background Image Close Button

2 - 4 October 2024

Hall: 10, Booth: #B8 Brussels, Belgium