Testing: Test Tools…Part 5 * JMeter *
I’m continuing with my blog series on testing tools. Apache JMeter may be used to test performance both on static and dynamic resources (files, Servlets, Perl scripts, Java Objects, Data Bases and Queries, FTP Servers and more). It 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. You can use it to make a graphical analysis of performance or to test server/script/object behavior under heavy concurrent load.
It requires a JAVA JRE. Go to http://jmeter.apache.org/>Download>Download Releases. Download the zip file and extract it. Now run JMeter by executing the file “jmeter.bat”. Its probably worth creating shortcut to this batch file on your desktop.
To create a simple test plan you will need the following objects
HTTP Authorisation Manager – This contains details of the target system and credentials to be used
Thread Group – Defines the number of executions and threads to be created
Sampler(s) – This contains the actual request
Listener(s) –Analyses the execution and provide various reports
Right Click on Test plan and select Add, Config Element, HTTP Authorisation manager. Now add the Base URL of the PO system in which the interfaces exist.
Right click on the Test Plan and add a thread group. Select Add, Threads, Thread Group. Once you add the thread group there are certain parameters which need to be set.
Number of threads–Each thread will execute the test plan in its entirety and completely independently of other test threads. Multiple threads are used to simulate concurrent connections to your server application.
Ramp-up period–The ramp-up period tells JMeter how long to “ramp-up” to the full number of threads. If 10 threads are used, and the ramp-up period is 100 seconds, then JMeter will take 100 seconds to get all 10 threads up and running. Each thread will start 10 (100/10) seconds after the previous thread was begun. If there are 30 threads and a ramp-up period of 120 seconds, then each successive thread will be delayed by 4 seconds.
Loop By default, the thread group is configured to loop once through its elements.
Version 1.9 introduces a test run scheduler. Click the checkbox at the bottom of the Thread Group panel to reveal extra fields in which you can enter the start and end times of the run. When the test is started, JMeter will wait if necessary until the start-time has been reached. At the end of each cycle, JMeter checks if the end-time has been reached, and if so, the run is stopped, otherwise the test is allowed to continue until the iteration limit is reached.
Once the thread group is added, you need to Add a sampler to actually send the request. Right click on the Thread Group and select Add, Sampler, HTTP Request. Below is an example.
The Samples should be named to reflect the interface being testing. In this example an Inbound HTTP interface was tested.
The following a parameters were added.
- Server Name:
- Port Num:
- Protocol: http
- Method: Post
- Content encoding: utf-8
- URL Path:
- Body: XML Payload
Save the test plan and click on Start and the messages should start flowing.
So if we have 2 threads and the loop count =5 then 10 messages will be posted to PI.
To test another interface just add another Sampler by right clicking on the Thread group and selecting Add, Sampler, WebService.
To analyze the result from Jmeter you will need to add listeners under each Sampler or Thread. The following listeners may prove useful.
Here we can see the number of samples message posted, average, size, throughput etc.
Summery result at log file.
Blogs in Series
Blog 1: HTTP Post Testing: Test Tools…Part 1
Blog 2: SFTP Testing: Test Tools…Part 2
Blog 3: REST Testing: Test Tools…Part 3
Blog 4: SOAP Testing: Test Tools…Part 4 * SOAP *
Blog 5: SOAP Testing: Test Tools…Part 5 * JMeter *