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:
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:
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:
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.
Server name or IP appropriate to your domain.
Port number on which your liferay is running.
URL of Login Action.
Credential of User.
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.
We use cookies to deliver personalized content, analyze trends, administer the site, track user movements on the site, and collect demographic information about our user base as a whole. Accept all cookies for the best possible experience on our website or manage your preferences.
What For?