jmeter workshop friday 1 december 2006 anthony colebourne it services the university of manchester

27
JMeter Workshop Friday 1 December 2006 Anthony Colebourne IT Services The University of Manchester

Post on 15-Jan-2016

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: JMeter Workshop Friday 1 December 2006 Anthony Colebourne IT Services The University of Manchester

JMeter WorkshopFriday 1 December 2006

Anthony Colebourne

IT Services

The University of Manchester

Page 2: 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.

Page 3: JMeter Workshop Friday 1 December 2006 Anthony Colebourne IT Services The University of Manchester

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/remote-test.html

• Highly Extensible– Custom Additions (Write your own samplers / listeners)– PlugIns

• Test plans stored in XML and can be version controlled.

Page 4: JMeter Workshop Friday 1 December 2006 Anthony Colebourne IT Services The University of Manchester

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.

Page 5: JMeter Workshop Friday 1 December 2006 Anthony Colebourne IT Services The University of Manchester

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

Page 6: JMeter Workshop Friday 1 December 2006 Anthony Colebourne IT Services The University of Manchester

JMeter Control Panel

Page 7: JMeter Workshop Friday 1 December 2006 Anthony Colebourne IT Services The University of Manchester

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.

Page 8: JMeter Workshop Friday 1 December 2006 Anthony Colebourne IT Services The University of Manchester
Page 9: JMeter Workshop Friday 1 December 2006 Anthony Colebourne IT Services The University of Manchester

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.

Page 10: JMeter Workshop Friday 1 December 2006 Anthony Colebourne IT Services The University of Manchester
Page 11: JMeter Workshop Friday 1 December 2006 Anthony Colebourne IT Services The University of Manchester

Elements of a Test Plan

• ThreadGroup– Set the number of threads – Set the ramp-up period – Set the number of times to execute the test

• Samplers– HTTP Request – JDBC Request – LDAP Request – WebService (SOAP) Request

• Logic Controllers– 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

http://jakarta.apache.org/jmeter/usermanual/component_reference.html

Page 12: JMeter Workshop Friday 1 December 2006 Anthony Colebourne IT Services The University of Manchester

Elements of a Test Plan

• 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

http://jakarta.apache.org/jmeter/usermanual/component_reference.html

Page 13: JMeter Workshop Friday 1 December 2006 Anthony Colebourne IT Services The University of Manchester

Execution order

• Timers

• Pre-Processors

• Sampler

• Post-Processors

• Assertions

• Listeners

Page 14: JMeter Workshop Friday 1 December 2006 Anthony Colebourne IT Services The University of Manchester

JMeter User Interface

The Test Plan Login Sequence

Page 15: JMeter Workshop Friday 1 December 2006 Anthony Colebourne IT Services The University of Manchester

View results summary

Page 16: JMeter Workshop Friday 1 December 2006 Anthony Colebourne IT Services The University of Manchester

View results as graph

Page 17: JMeter Workshop Friday 1 December 2006 Anthony Colebourne IT Services The University of Manchester

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

Page 18: JMeter Workshop Friday 1 December 2006 Anthony Colebourne IT Services The University of Manchester

Simplest web test

• Thread Group

• HTTP Request - Sampler

• View Results in Table - Listener

• Demo – workshop_demo1.jmx

Page 19: JMeter Workshop Friday 1 December 2006 Anthony Colebourne IT Services The University of Manchester

Simplest web test

• User Defined Variables – Configuration Element

• Constant Timer - Timer

• View Results in Tree Listener - Listener

• Demo – workshop_demo2.jmx

Page 20: JMeter Workshop Friday 1 December 2006 Anthony Colebourne IT Services The University of Manchester

Simplest web test

• HTTP Header Manager – Configuration Element

• Simple Controller - Controller

• Response Assertion - Assertion

• Demo – workshop_demo3.jmx

Page 21: JMeter Workshop Friday 1 December 2006 Anthony Colebourne IT Services The University of Manchester

Test Fragments for Portal

• Saved fragments of Test Plans– Login sequence– Response assertions– User agents– Load cluster settings

Page 22: JMeter Workshop Friday 1 December 2006 Anthony Colebourne IT Services The University of Manchester

Portal Performance Test A

Load cluster host names

Load test users

Do LoginTest LoginGenerate next url based on tabs

Loop:

1. Visit tab 1

2. Visit tab 2

3. Visit tab 1

4. Visit tab 3

Page 23: JMeter Workshop Friday 1 December 2006 Anthony Colebourne IT Services The University of Manchester

HTTP Proxy Recorder

• Workbench -> HTTP Proxy Server– Cannot be used with over SSL

Page 24: JMeter Workshop Friday 1 December 2006 Anthony Colebourne IT Services The University of Manchester

HTTP Proxy Recorder

• Configuring FireFox to use the Proxy

• Demo – workshop_demo_proxy.jmx

Page 25: JMeter Workshop Friday 1 December 2006 Anthony Colebourne IT Services The University of Manchester

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

Page 26: JMeter Workshop Friday 1 December 2006 Anthony Colebourne IT Services The University of Manchester

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.

Page 27: JMeter Workshop Friday 1 December 2006 Anthony Colebourne IT Services The University of Manchester

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]