UKCMG TEC 2010
Track P - Performance
Session P7
Low Cost Performance Testing
Paul Seaton-Smith
UKCMG TEC 2010 Track P - Performance Low Cost Performance Testing
Agenda
• Performance Testing Costs• Test Environment
• Scripting and Testing Resources • Automated Test Tools
• Installation • Test Plan Hierarchy • Thread Groups
• Recording a Browser Session • Script Parameterisation
• Regular Expression Extractor • Response Assertions • Assertion Results • CSV Data Set Config • View Results Tree • Simple Data Writer • View Results in a Table • Summary
Performance Testing Costs
• Test Environment
• System Under Test • Load Generators
• Scripting and Testing Resources • Load Testing Tools
© Capacitas 2002-2010 P7-3
UKCMG TEC 2010 Track P - Performance Low Cost Performance Testing
Test Environment
• Test environment does not need to be production size • Industry benchmarks
• Single full size server of each type • Test against production servers prior to delivery • Test against virtualised test environments
• Resource controls to guarantee CPU/Memory • Use virtualised servers as load injectors
• If collecting response times at least one physical load injector is required
Scripting and Testing Resources
• Ease of scripting
• Access to support and online help • Availability of skilled testers • Time to train testers
© Capacitas 2002-2010 P7-5
UKCMG TEC 2010 Track P - Performance Low Cost Performance Testing
Automated Test Tools
• Automated test tools are required to conduct performance testing, including:
• Stress Testing • Load Testing • Volume Testing • Soak Testing
• However, commercial automated test tools can be expensive • This remainder of this presentation will discuss how Apache JMeter
may be used to conduct performance testing and avoid costs associated with Automated Testing Tools
Installation
• JMeter is a free load testing tool from Apache that runs on Java Platform Standard Edition
• Download from
http://jakarta.apache.org/site/downloads/downloads_jmeter.cgi
• Management of test data, scripts and test results can be difficult
© Capacitas 2002-2010 P7-7
UKCMG TEC 2010 Track P - Performance Low Cost Performance Testing
Test Plan Hierarchy
• Test Plan
• HTTP Cookie Manager • HTTP Request Defaults • Thread Group
• HTTP Request
• Regular Expression Extractor • Response Assertion
• Assertion Results • Simple Data Writer • View Results Tree • Workbench
Thread Groups
• Each Thread Group should represent one use case or saga
• JMeter runs Thread Groups in parallel but runs the contents of each
Thread Group sequentially
• Each Thread Group can be controlled separately by • Number of Threads
• Ramp up period (time period to introduce all threads) • Loop count
• Scheduler
• 10 threads with ramp up period of 60 seconds means introduce 1 thread every 6 seconds
• 100 threads with ramp up period of 1 second does not take 100 seconds to ramp up
P7-9
© Capacitas 2002-2010
UKCMG TEC 2010 Track P - Performance Low Cost Performance Testing
Test Ramp Up
• Ramp up refers to increasing the number of threads during a test • Introducing all the threads at the same time is unrealistic and
could cause the service to fail or suffer poor performance • We can determine best-case performance on a lightly loaded
system
• Allow some time for the system to achieve a steady-state • Allow measurement of multiple points on the response time
curve
• Additional control could be achieved through multiple identical
Thread Groups with different start and end times
P7-11
© Capacitas 2002-2010
UKCMG TEC 2010 Track P - Performance Low Cost Performance Testing
Thread Groups - Scheduler
• Startup delayoverrides Start Time
• Durationoverrides End Time
HTTP Request Defaults
• Use HTTP Request Defaultsto specify a default URL for HTTP Requests
P7-13
© Capacitas 2002-2010
UKCMG TEC 2010 Track P - Performance Low Cost Performance Testing
Recording a Browser Session
• Add a Thread Group to the Test Plan
• Add a Recording Controller to the Thread Group
• Add a HTTP Proxy Server to the WorkBench
• Edit your LAN Connection to use a proxy on localhost:8080 • Start the HTTP Proxy Server
• Open a browser and navigate through the use case • Browser actions are recorded in the Recording Controller
• Stop the HTTP Proxy Server
• Delete the HTTP Proxy Server
Internet Explorer and Chrome LAN Settings
P7-15
© Capacitas 2002-2010
UKCMG TEC 2010 Track P - Performance Low Cost Performance Testing
Firefox Connection Settings Settings
Recording a Browser Session
P7-17
© Capacitas 2002-2010
UKCMG TEC 2010 Track P - Performance Low Cost Performance Testing
Recording a Browser Session
• It is possible to use URL Patterns to filter out images, CSS, etc. using URL Match Strings and URL Patterns to include or exclude certain content
• It is typically safer to record all requests and responses and then manually delete unwanted calls from the script afterwards
Remove Unwanted HTTP Requests
• Typically unwanted • .js files • .css files • .gif images • .jpg/.jpeg images • Typically wanted • .asp files • .php files • .htm files • .html files P7-19 © Capacitas 2002-2010UKCMG TEC 2010 Track P - Performance Low Cost Performance Testing
Remove Unwanted HTTP Requests
HTTP Header Manager
• Automatically added during the recording process • Should not need editing
P7-21
© Capacitas 2002-2010
UKCMG TEC 2010 Track P - Performance Low Cost Performance Testing
Demonstration
• Record the following use case into capacitas.jmx1. Navigate to http://www.capacitas.co.uk 2. Enter ‘virtualisation’ into the search box and
click search
http://www.capacitas.co.uk/results.php
P7-23
© Capacitas 2002-2010
UKCMG TEC 2010 Track P - Performance Low Cost Performance Testing
Demonstration
• Delete unwanted .css, .js, .gif, .jpg, .jpeg etc. HTTP Requests
• Move important HTTP Requests (.asp) under Thread Group
• Rename Thread Groupto capacitas.co.uk Search
Demonstration
P7-25
© Capacitas 2002-2010
UKCMG TEC 2010 Track P - Performance Low Cost Performance Testing
Script Parameterisation
• Many web sites manage the relationship between client and web server using session data
• Need to record the session data to send back to the web server • Important to check that the expected response is returned • May also wish to request different information in the scripts
P7-27
© Capacitas 2002-2010
UKCMG TEC 2010 Track P - Performance Low Cost Performance Testing
Regular Expression Extractor
• Use regular expressions to reference any data • (.+)
• Any brackets in the string (or )must be preceded by a \
Jakarta Regular Expressions
• JMeter uses is the Jakarta regular expression package
• For example, searching AaaaAaaaAfor A(.+)A matches aaaAaaa rather than aaa
• The solution is to say A([^A]+)A, which will match any number of NOT A
•http://jakarta.apache.org/regexp/applet.html is an applet that lets you test Jakarta regular expressions
P7-29
© Capacitas 2002-2010
UKCMG TEC 2010 Track P - Performance Low Cost Performance Testing
Response Assertions
• Response Assertions are used to check whether the response contains the expected result
• Pattern matching can be used to ensure that specific text either is, or is not displayed
• This is required to ensure the expected web page was returned when making a request
• Be wary when using Response Assertions to check that error messages are not returned, as they may be returned to a browser but not rendered on the screen
Response Assertions
P7-31
© Capacitas 2002-2010
UKCMG TEC 2010 Track P - Performance Low Cost Performance Testing
Assertion Results
• Allows you to check visually if the Response Assertions passed or failed
• If the Response Assertions passed it will just write a line with the name of the transaction
• It is possible to only write failures and ignore successes
Assertion Results
P7-33
© Capacitas 2002-2010
UKCMG TEC 2010 Track P - Performance Low Cost Performance Testing
HTTP Cookie Manager
• Nearly all web testing should use cookie support • Add an HTTP Cookie Manager to each Thread Group
• This will ensure that each thread gets its own cookies, shared across all HTTP Requests
HTTP Cookie Manager
P7-35
© Capacitas 2002-2010
UKCMG TEC 2010 Track P - Performance Low Cost Performance Testing
CSV Data Set Config
• Fully qualify the file location • Specify a .csv extension
CSV Data Set Config
• searchterm in searches.csv
P7-37
© Capacitas 2002-2010
UKCMG TEC 2010 Track P - Performance Low Cost Performance Testing
View Results Tree
• View Results Tree allows the user to see the response from the service during the tests
• Typically easiest to look at the Render HTML view under the
Response Data tab
P7-39
© Capacitas 2002-2010
UKCMG TEC 2010 Track P - Performance Low Cost Performance Testing
View Results Tree
:
Response Data
Simple Data Writer
• Used to save the results of the test
• Fully qualify the file location and specify a .csv extension
• D:\JMeter Tests\Capacitas Website Testing\Results\CAPACITAS_03.csv
P7-41
© Capacitas 2002-2010
UKCMG TEC 2010 Track P - Performance Low Cost Performance Testing
Saving Results
• To ensure results are written in .csv format rather than XML uncheck all of the XML options
Saving Results
• To write in a date format convenient for Excel uncomment the following line in jmeter.properties
#JMeter.save.saveservice.timestamp_format=yyyy/MM/dd HH:mm:ss.SSSS in JMeter.properties in jmeter.properties
P7-43
© Capacitas 2002-2010
UKCMG TEC 2010 Track P - Performance Low Cost Performance Testing
View Results in a Table
• Response times for HTTP Requests are collected by default
Summary
• Still need a test environment• System under test • Load injectors
• Still require skilled resources for scripting and testing • Test management is difficult
• Jmeter is free
• Scripting language is simple • Skills are in the marketplace
UKCMG TEC 2010 Track P - Performance Low Cost Performance Testing