The Apache JMeter™ desktop application is open source software, a 100% pure Java application designed to load test functional behavior and measure performance. ( http://jmeter.apache.org/index.html )
Apache JMeter may be used to test performance both on static and dynamic resources (Files, Web dynamic languages - PHP, Java, ASP.NET, etc. -, Java Objects, Data Bases and Queries, FTP Servers and more). It can be used to simulate a heavy load on a server, group of servers, network or object to test its strength or to analyze overall performance under different load types.
In this article I will be explaining how to load test a URL by hitting it with multiple requests configured as different query parameters in the URL. The query parameters are in a csv file. JMeter will pick the query parameters and prepare the URL and hit the server and record the results.
We will write a test plan to hit URL http://testapp.testco.com/service?param1=<var1>¶m2=<var2> multiple times using multiple threads using var1 and var2 values configured in csv file and stress test it.
So lets starts configuring JMeter for our test case.
Apache JMeter may be used to test performance both on static and dynamic resources (Files, Web dynamic languages - PHP, Java, ASP.NET, etc. -, Java Objects, Data Bases and Queries, FTP Servers and more). It can be used to simulate a heavy load on a server, group of servers, network or object to test its strength or to analyze overall performance under different load types.
In this article I will be explaining how to load test a URL by hitting it with multiple requests configured as different query parameters in the URL. The query parameters are in a csv file. JMeter will pick the query parameters and prepare the URL and hit the server and record the results.
We will write a test plan to hit URL http://testapp.testco.com/service?param1=<var1>¶m2=<var2> multiple times using multiple threads using var1 and var2 values configured in csv file and stress test it.
So lets starts configuring JMeter for our test case.
Download JMeter
You can download JMeter from http://jmeter.apache.org. And install it on you local. It is very simple. Just follow the wizard for installation.
Launch JMeter
Incase you are on Windows, Go to <jmeter home>/bin and double click on jmeter.bat. This will launch JMeter standalone console.
Create new Test Plan
Once JMeter console is open, you will see in the left navigation tree, a Test Plan.
Right click on the Test Plan go to Add -> Thread Group and click on it. This will add a Thread Group element for you. For doing anything on JMeter you need to start with adding a Thread Group element.
Once you have added the Thread Group now we need to add some more elements to generate HTTP request and add CSV config elements.
1. Add HTTP Request
Right click on Thread Group element and Add->Sampler->HTTP Request. Click on it to add it to your thread group.
2. CSV Data Set Config
Right click on Thread Group element and Add->Config Element->CSV Data Set Config. Click on it to add it to your thread group.
3. View Results Tree
Right click on Thread Group element and Add->Listener->View Results Tree. Click on it to add it to your thread group.
Now your Thread Group navigation on left should look like this.
Once we have added all the elements that we require for testing our Test Plan now we will go and configure them.
1. Configure HTTP Request element
Now suppose you want to test a URL http://testapp.testco.com/service?param1=<var1>¶m2=<var2>, where the URL can have multiple var1 & var2 values. We will configure the test plan to read the var1 and var2 values from a csv file and hit http://testapp.testco.com/service with these values using multiple threads.
- Add you Server Name or IP without http or https.
- In Path add service
- In the Parameters section add param1 & param2 and values as $(param1} and ${param2}. These will be picked up at runtime from csv file.
These configurations will create a URL like http://testapp.testco.com/service?param1=<var1>¶m2=<var2>
2. Configure CSV Data Set Config
Now open notepad and create a csv file new.csv with param1 and param2 values seperated by tab, like below
param1a param2a
param1b param2b
param1c param2c
Using this file we will configure CSV data set config element.
Put the file name in the Filename section as c:\temp\new.csv ( where csv file is located)
Add Variable Names param1, param2
Add Delimiter \t
The section looks as follows:
Once all this is setup, you can run the Test Plan using Start ( green play button on top) or go to Run->Start.
The results will be captured in View Results Tree element that we had added.
That is all. You can test your REST web services or any configurable URL using this.
Pls leave your comments incase you need further assistance.
No comments:
Post a Comment