JMeter Tips and Tricks : Part-2

This is JMeter Tips and Tricks part-2. In this part I will share some finding of mine using Jmeter.

1. How to get Session id/ JSON id / Cookie id / token/ view state?

When these are generated dynamically, we have to parametrize those and use it with next requests. Without that , we will get session time out. To solve that, we need to extract those values from response data. So we will
- Add a Regular Expression Extractor as a child of the request(of which response data will contain those information)
- Use the variable mentioned in Regular Expression Extractor, in the requests send after getting.
[Note : I will provide separate regular expression related post]

1. How to test Web Service (SOAP) with HTTPS(with credential)?
- Add a HTTP Authorization Manager
- Add a SOAP/XML-RPC Request Sampler
- In Authorization Manager ,
---Provide service's url(without asmx or wsdl) where it prompt for credential.
---Provide user name and password
---leave domain/realm (if you do not need)
Then perform like normal SOAP request.
Note :
You may need to install SSL key. For that,  download from here and install from jmeter ssl manager(CTRL+M) , it is in option menu. for detail see this.
-you may need to change this in jmeter.properties
https.use.cached.ssl.context=false

Use Delay : (for stress only)
While testing for Stressing server, try to use delay to create real life user scenario. This will help keep test case like as real life. For example, you have weak log in database, and you want to avoid DB testing, add delay like 3/4 second after log in request(use constant timer, as a child of the next request of the log in request)

Recording & Parametrization : 

If you use HTTP proxy server for recording and want to parametrize the URL in the script, add the URL variable in the root test plan and then record under of that. After recording you will get every request using the URL will be parametrized.

Test Execution : 

1. Before running give more RAM to Jmeter . How to do that?
Open jmeter.bat(for windows) and jmeter.sh(for linux) with text editor
you will get a line for HEAP memory. default 512m. Make it 1024m or 2048
set HEAP=-Xms2048m -Xmx2048m
Why this is important, because, it will allocate JVM more space. When you try large test cases with many users, it will be needing more memory.

2. Before making the test plan, Configure jmeter.properties according to your need following the architecture of the application.

3. If you can not avoid listener during test execution, try only Summary Report and aggregated report.

4. Try use Google plugin's stepping thread for. There are some issues may arise for holding the thread for hours or more(due to garbage collector and time out). See those issues from jmeter log (see log file or click ! symbol during execution) and fix according to that.
Ex- if you get timeout exception, then change the ramp up time. If you get response exceptions from server(while testing soap, getting server busy) , you need to add some logical delay(use constant timer).

Thanks...:)