JMeter Intro Final
JMeter Intro Final
JMeter Intro Final
● Performance testing
•Load Testing
•StressTesting
● What is JMeter
● JMeter basic elements
● Building a Script
●Running a Script
●Recording a Script (Bootstrapping)
Sam Varadarajan, for IEJUG
[email protected]
Performance Testing
What is Performance testing?
Performance testing is performed to determine how a system performs in terms of
responsiveness and stability under a particular workload. It is typically non-functional,
meaning, we only care about load on the system, scalability etc. Actual functionality is
not tested in this phase. (That will be done in Functional Test phase).
The real goal is to find that maximum load that the system can handle without
performance degradation or crashes.
Apache JMeter An Apache Jakarta open source project Java desktop application for load testing and performance measurement.
BlazeMeter BlazeMeter Ltd. BlazeMeter is a JMeter compatible, self-service, load testing platform.
Blitz Spirent Communications Blitz is a service for load and performance testing of websites, mobile, web apps
and REST APIs in the cloud.
Gatling Open Source JVM application with scenarios as code and portable HTML reports.
Load Impact Load Impact - AB Cloud based performance testing SaaS tool.
Login VSI Login VSI, Inc. Performance testing software for Windows based virtualized desktops. Licensed.
NeoLoad Neotys Load testing tool for web and mobile applications.
OpenSTA Open System Testing Architecture Open source web load/stress testing application, licensed under the Gnu GPL.
Rational Performance Tester IBM Eclipse based large scale performance testing tool
Silk Performer Borland Application performance tool with cloud and local virtual agents. Licensed
Visual StudioUltimate edition Microsoft Visual Studio Ultimate edition includes a load test tool
WebLOAD RadView Load testing tool for web and mobile applications Licensed.[3]
(Courtesy: Wikipedia)
JMeter
What is JMeter?
•JMeter is a free, open-source performance measurement tool
written in Java
User friendly GUI Design. Can be run in batch and distributed modes to handle more load.
Full multithreading framework allows concurrent sampling by many threads and simultaneous
sampling of different functions by separate thread groups.
Can mimick Web browser functionality including Caching and Cookies.
Controllers are configurable and can monitor the server performance.
Test results can be captured in various format like summary report, Graph, Aggregate report,
Aggregate graph, Results in tree and Results in Table. The results can be stored in files for later
review as well.
Extensible architecture. Supports plugins, bean shell etc to add more functionality.
Installing Jmeter
• Install Java (1.5 or higher)
• Download JMeter http://jmeter.apache.org/download_jmeter.cgi
• Add path of java installation in environment path variables.
JMeter Test Plan
•A test plan describes a series of steps
JMeter will execute when run.
•Thread Group
This is really the logic unit of a load test. There can be many thread
groups in a Test Plan.
–Setup number of thread
–Set up ramp up period
–No. of times test executes
•Controllers
–Sampler (Send Request to Server)
–Logical Controller (Customize logic to send request); includes
Loop Controller and One Time Controller.
•Listener
Help to capture and display results in various formats. For e.g.,
–Graph Result
–View Results Tree or Table format and many more.
•Timers
–Add a delay to the next request
Continued….
Elements of Test Plans
• Assertions
– Allow you to assert fact about responses received from HTTP request
• Configuration Elements
– Allow you configure settings
• Preprocessor
– Execute prior to sampler request
• Post Processor
– Execute some action after sampler request
Order of Execution
1. Config Element
2. Pre-Processor
3. Timer
4. Sampler
5. Post-Processor
6. Assertion
7. Listener
Building a Test Plan
Thread Group
● A Post-Processor executes some action after aSampler Request has been made.
●A Timer will cause JMeter to delay a certain amount of time before each sampler
which is in its scope.
Variables
JMeter allows
parameters,
properties and
variables to keep the
test scripts
generalized.
Syntax for Variable:
${VARIABLE}
• Variables can be
declared and used in
successive layers.
JMeter Test Plan Completed
JMeter Test Plan Completed
• Once you completed, you can save the
test plan with a meaningful name.
• The script file generated is an XML file
and will be saved with a .JMX
extension.
• You can run this script using command
line mode as well, so you don't have to
load GUI.
Running a Test Plan
Running in Batch Mode
On command line, in the JMeter\bin directory, you can type:
Where,
LT600_laweb2_test_syt6.jmx is the script I saved in the completion step above.
-n makes it non-GUI
-t name of the test script you want to use
-j for the JMeter.log (I change this to match my log file naming above)
-l for the JTL file - in XML format, has the same details we get in listeners above.
We may have some use for this, but for now I am just saving it.
You can put the above command inside a batch file to save typing!
Appendix
Non-Testing Elements
Non-Testing Elements Contd...
HTTP(S) Script Recording Element
Recording a Script
• Setup a non-test element, HTTP(S) Test
Script Recorder on the workbench.
• Setup all the inclusion, exclusion lists
and other properties.
• Click on Start.
Now, JMeter is running as a local proxy
server. If you adjust PC's proxy setting
to use this as the proxy server, all
requests will pass through JMeter.
Recording a Script Contd...
Next you need to setup the browser to use our JMeter listener as a
local proxy
Recording a Script Contd...
Recording a Script Contd...
• Now that we have captured all the
pages to be visited, we can clean it all
up. This is a good place to start.
• Parametrize and add variables
wherever possible and move the pages
(samplers) to a Thread Group and build
up our test plan.
•
Recording a script Contd...
An easier way is to use BadBoy software to capture the pages and export to
JMeter. Download and install Badboy software from
http://www.badboy.com.au/download/send?svId=124
Recording a Script Contd...
Real life Test Scenario
• Our App Servers kept crashing on
heavy load days. We had to constantly
restart the servers, bringing down all the
web users along with it. After making
some changes to the application, had to
simulate the huge load on the servers to
test if it will sustain the next tax season.
After reviewing various tools, we chose
JMEter.
Real life Test scenario
Contd...
• When we upgraded our infrastructure*
recently, we used JMEter to compare
old environment and new environment
for performance. We ran the same set
of scripts against old and new
environments to identify any
bottlenecks.