Transcript Slide 1

JMeter Workshop
Friday 1 December 2006
Anthony Colebourne
IT Services
The University of Manchester
What is JMeter
• Apache JMeter is a GUI desktop application
designed to load test functional behavior and measure
performance. It was originally designed for testing
Web Applications but has since expanded to other test
functions.
–
–
–
–
Has a rich graphical interface
Built in Java
Part of Apache Jakarta project
Can be distributed
• 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.
Features of JMeter
• Graphical Analysis / Exporting Test Results
• Remote Distributed Execution
– If you want to generate load using multiple test servers. You
can run multiple server components of JMeter remotely. And
you can control it by a single JMeter GUI to gather results.
• http://jakarta.apache.org/jmeter/usermanual/remotetest.html
• Highly Extensible
– Custom Additions (Write your own samplers / listeners)
– PlugIns
• Test plans stored in XML and can be version controlled.
What Can You Do With It?
• JMeter lets you set up test plans that
simulate logging into a web site, filling out
forms, clicking buttons, links, etc.
• You can simulate the number of users
doing this, the rate that they do it.
Setting Up and Running JMeter
• Download the binary from Jakarta
– http://jakarta.apache.org/jmeter/
– It’s platform independent, so the same download
will run on Windows, Linux, Mac.
– You need Java, with the JAVA_HOME
environment variable set.
– Uncomment SSL settings in jmeter.properties
• Unpack the zip or tar.gz and execute
jmeter.bat or jmeter.sh
JMeter Control Panel
Test Plan
• A complete test plan will consist of one
or more Thread Groups, logic controllers,
samplers, listeners, timers, assertions,
and configuration elements.
• Test Plans are represented as an
Ordered Tree.
Scoping Rules
• Some elements are primarily ordered (e.g.
controllers and samplers).
• Other elements are hierarchical. An Assertion,
for example, is hierarchical in the test tree. If
its parent is a request, then it is applied to that
request. If its parent is a Controller, then it
affects all requests that are descendants of
that Controller.
Elements of a Test Plan
http://jakarta.apache.org/jmeter/usermanual/component_reference.html
•
ThreadGroup
–
–
–
•
Samplers
–
–
–
–
•
HTTP Request
JDBC Request
LDAP Request
WebService (SOAP) Request
Logic Controllers
–
–
–
–
–
–
•
Set the number of threads
Set the ramp-up period
Set the number of times to execute the test
Simple Controller - The Simple Logic Controller lets you organize your Samplers and other
Logic Controllers
Loop Controller
Once Only Controller
Interleave Controller
Throughput Controller
Others … (e.g. Transaction Controller)
Listeners
–
–
Simple Data Writer
Graph Results
Elements of a Test Plan
http://jakarta.apache.org/jmeter/usermanual/component_reference.html
• Timers
– The timer will cause a delay between each request
that a thread makes.
• Assertions
– The ‘test’ of the response from the server
• Configuration Elements
– Sets default
• Pre-Processor / Post-Processor Elements
Execution order
•
•
•
•
•
•
Timers
Pre-Processors
Sampler
Post-Processors
Assertions
Listeners
JMeter User Interface
The Test Plan
Login Sequence
View results summary
View results as graph
Portal Test Plans
• Performance testing
– Real life usage
• Stress testing
– Increasing number of
users
• Soak testing
– Varying how long test
runs for, e.g. use loops
• System level testing
– Using assertions
Simplest web test
• Thread Group
• HTTP Request - Sampler
• View Results in Table - Listener
• Demo – workshop_demo1.jmx
Simplest web test
• User Defined Variables – Configuration
Element
• Constant Timer - Timer
• View Results in Tree Listener - Listener
• Demo – workshop_demo2.jmx
Simplest web test
• HTTP Header Manager – Configuration
Element
• Simple Controller - Controller
• Response Assertion - Assertion
• Demo – workshop_demo3.jmx
Test Fragments for Portal
• Saved fragments of Test Plans
– Login sequence
– Response assertions
– User agents
– Load cluster settings
Portal Performance Test A
Load cluster host names
Load test users
Do Login
Test Login
Generate next url based on tabs
Loop:
1. Visit tab 1
2. Visit tab 2
3. Visit tab 1
4. Visit tab 3
HTTP Proxy Recorder
• Workbench -> HTTP Proxy Server
– Cannot be used with over SSL
HTTP Proxy Recorder
• Configuring
FireFox to use the
Proxy
• Demo –
workshop_demo
_proxy.jmx
Using JMeter with Ant
• JMeter build.xml
– Single JMeter target with 2 arguments
• script
• Paramter list
• Portal testing build.xml
– One target for each scenario
– Parameter – Environment
– Parameters for e.g. number of users or running time
• Build.properties
– List of server to use
– List of users
• http://ant.apache.org
Tips
• Use timers to avoid hammering the server
• Limit the Number of Threads
– Hardware will limit the number of threads you can effectively
run. A faster machine makes JMeter work harder since it
returns request quicker.
• User variables
– Create a text file containing the user names and passwords.
– Add a CSV DataSet configuration element. Name the variables
USER and PASS. Use ${USER} and ${PASS} within samplers.
• Reducing resource requirements
– Use non-GUI mode.
– Use as few Listeners as possible.
– Reduce samplers by looping (by thread and by controller), and
use variables (CSV Data Set) to vary the sample.
– Use CSV output rather than XML.
Resources
• Apache JMeter Home
– http://jakarta.apache.org/jmeter/
• Useful Tutorials and Articles
– http://javaboutique.internet.com/tutorials/JMeter/
– http://venus.cs.depaul.edu/se591/JMeter11.ppt
• http://wiki.manchester.ac.uk/portal/
– See articles in the Testing category
• [email protected]