Apache JMeter
is a 100% pure Java desktop application designed
to load test client/server software. JMeter can be used to simulate a heavy
load on a server, network or object to test its strength or to analyze
overall performance under different load types.
Additionally, JMeter can help you regression test your application by letting you create
test scripts by putting assertions to validate that the application is returning the
results that are expected.
Web Services can be easily loaded and it s performance measured using JMeter. The typical steps for load testing using JMeter is as follows:
1) Create a test plan
2) Add a Thread Group
3) Add a WebSerice Request
4) Apply Assertions on the response
5) View results
Creating a Test Plan
In the default test plan that appears on opening the JMeter UI (from JMeter.bat in the bin directory) set the option of 'Functional Test Mode' as true. You may also want to add user defined variables. However for this example I will not be using any user defined variable.
Add a Thread Group
Add a Thread Group element by right clicking the test plan node and selecting 'Add-->Threads (Users)-->Thread Group'
Adding Thread Group |
Set the number of threads in the provided section and set the Ramp-up period as zero if you want all the users to be loaded without any lime lag. You can put a time lag between each user request by using the formula: Time Lag=Time/No. of users
You set the loop count to specify how many times do you want each user to hit the web service. If you want to continue loading the web service then you can check the 'Forever' option on the Thread Group element UI.
You can also schedule the load tests by using the 'Scheduler' option provided on the 'Thread Group' UI.
Add a WebService Request
Right click on the 'Thread Group' element and select ' Add --> Sampler --> WebService (SOAP) Request'
Adding WebService Request |
Copy the SOAP request XML in the 'Soap/XML-RPC Data' text box you provide the path of the file in the 'Filename' section. Make sure to check the 'Read SOAP Response' check box to ensure that the soap response is read for asserting the results.
Apply Assertions on the Response
Right click on the 'Thread Group' element and select ' Add --> Assertions --> Response Assertions'
Applying Assertion on Response |
Select the radio button 'Main Sample only' in the Apply to section. Then select the 'Text Response' radio button in the Response Field to Test section. Add the pattern to test in the response of the SOAP request. For example if you expect the text '<status>Completed</status>' in the response than you may want to add an assertion to check if the text: "<status>Completed</status>" is present in the response.
View Results
We can view the results of the tests in multiple format, such as Graph, Table or Tree structure. The results can also be stored in files at a specified location. In our case we will be using 'Graph Results' and 'View Results Tree' elements.
Graph Results element can be added from 'Add-->Listeners-->Graph Results' and View results tree element can be added at 'Add-->Listeners-->View Results Tree'.
Adding Graph Results |
Provide location of the results file in the 'Filename' section. You can create a new results file and point its location in the 'Filename' section.
You can now run the test and see the Graph and Results Tree as follows:
Graph Results |
The result tree is displayed as follows:
Results Tree |
Hi,
ReplyDeleteVery Good for content for those who are new to Jmeter like me.
It is easy to understand and follow.
Thanks a lot,
ArulRaj