Professional Documents
Culture Documents
Performance Testing
&
Apache JMeter
Narasimha Nallabothula
ValueLabs
Performance Testing COE
Day 1: Agenda
What is
Performance
Testing?
Spike
Test
Load
Test
Stress Test
Volume
Test
Endurance
Test
Load Test
Load Test will be conducted to verify EUTs behavior under normal operational capacity.
o It would follow a ramp-up pattern where the load will be gradually increased. A steady
load state will be maintained for specified time and will be gradually ramped-down.
o Find out resource utilization of the servers under normal production load
o Identify functionality errors under load
Is my application is capable
to handle peak production
load? any errors will occur
under load?
ValueLabs | www.valuelabs.com | Confidential
Stress Test
Stress Test will be conducted to determine the stability of a given system or component
beyond normal operational capacity, often to find a breaking point of the system
o Initially, a low load will be applied on EUT and it would be constantly ramped up till it
reaches a breaking point (EUT stops responding or a steep hike in response time is
observed or environmental errors are observed because of load)
Spike Test
Spike Test will be conducted to determine the stability of a given system when there is a
increase/decrease in user load
Endurance/Soak Test
Endurance Test will be conducted to verify if the system can sustain continuous
expected load for prolonged period of time
o
o
Discover memory utilization issues and detect potential leaks (memory leaks) in
EUT under sustained use.
Volume Test
Volume Test will be conducted to test the application performance under varying database
volumes
JMeter Overview
JMeter store its test plans in XML format. This means you
What is this?
Let me
explore
Execution Environment
Virtual
Users
Statistics and
Performance Data
Installation
OS
File Name
Windows
Jmeter.bat
Linux
Jmeter.sh
Mac
Jmeter.sh
Day 2: Agenda
Elements of the JMeter
Steps to build a script
Steps to replay the script
18
Samplers
Elements of JMeter
Threads (Users)
Config Elements
Timers
Pre Processors
Logical Controllers
Post Processors
Assertions
Listeners
ValueLabs | www.valuelabs.com | Confidential
Request
Response
End User
System Under Test
JMeter
Proxy
Response
End User
System Under Test
JMeter Proxy feature allows you to record the traffic / requests simply
o While users navigate/browse the pages through a standard browser, JMeter
will watch and record the traffic
20
How to Record
(Contd)
21
How to Record
(Contd)
22
How to Record
(Contd)
23
How to Record
(Contd)
24
How to Replay
1. Right-click on the Test Plan element and select Add Thread Group . Now the Thread
group is created.
2. Thread Group is a pool of users that will execute a particular test case against your server.
Thread Group configurations will be explained during execution .
3. Right-click on the Thread Group element and select Add Config Element HTTP
Cookie Manager. Now the HTTP Cookie Manager is created.
4.
5.
25
(Contd)
How to Replay
6. Now the test plan contains the Thread Groups, Logic Controllers, Sampler
generating controllers & Listeners.
26
Day 3: Agenda
Correlation (Regular Expressions)
Parameterization
And other script customizations
27
Correlation
When you record a business scenario, JMeter generates a script that contains the actual values
used during recording. When you replay that script it will send the recorded values unless you
change them
It is useful to extract some information (like session id, timestamps, url links etc) from the
response of a request
During Recording the script in JMeter
Request 1 : Login
Response for Request 1 along with session id 1234567
Request 2: Session ID 1234567
Response for Request 2
User (Browser)
ValueLabs | www.valuelabs.com | Confidential
Server
JMeter Script
Server
Solution
Request 1 : Login
Response for Request 1 along with session id 999000
Capture the new session id from the above
response and use it in the next request(s)
JMeter Script
ValueLabs | www.valuelabs.com | Confidential
Server
Correlation
1. Right Click the Request Add Post Processors Regular Expression Extractor
2. Regular expressions are used to search and manipulate text.
3. Allows the user to extract values from a server response using regular expression.
4. Regular Expression Extractor extracts the requested values, generate the template
string, and store the result into the given variable name.
5. The Regular Expression Extractor needs to be added in the previous request to
capture the dynamically changing data in the current request.
6. Determine the pattern where the desired text will find.
30
Correlation
Reference Name: The name of the variable where the dynamically parameterized value get
stored, EX: Data
Regular Expression: This must contain at least one set of parentheses "()" to capture a portion
of the string, left and right boundary of the parameter to be correlated can also be given. The text
groups that will extracted are enclosed by the characters '(' and ')'. For Ex the expression is <td
id="ID">(.+?)</td>\s*<td id="Name">(.+?)</td>\s*, name of the expression is Data , using this
expression ID and Name is captured in the name like Data_1 (ID)& Data_2(Name) variables
ValueLabs | www.valuelabs.com | Confidential
31
Correlation
Template: Each group of text extracted will be placed as a member of the variable Data,
following the order of each group of pattern enclosed by '(' and ')'. Each group is stored as
refname_g#, where refname is the string you entered as the reference name, and # is the group
number. $1$ to refers to group 1, $2$ to refers to group 2, etc. $0$ refers to whatever the entire
expression matches. For Ex the template for the above example is $1$$2$
Match No: Indicates which match to use. The regular expression may match multiple times
Default Value: If no matches are found, then the value given in this field will be substituted
32
Parameterization
When you record a business process, JMeter generates a script that contains the actual values
used during recording
Lets say, JMeter generated the following recorded post parameters to login into the application
When you replay the script using multiple users and iterations, you do not want to repeatedly
use the same Username and Password values. Instead, you replace the values with a
parameter
The users substitute the parameter with values from a data source that specified
33
JMeter Parameterization
2. Static Value Parameterization
a) User Parameters
b) Function Helper Dialog (_StringFromFile, _CSVRead)
c) Config Elements CSV Data Set Config
34
Parameterization
User Parameters
1. Right Click the Request Add Pre Processors User Parameters
35
Parameterization
User Parameters:
1.
User Parameter are used to send the specify values for User Variables specific to individual threads
2.
Values can be accessed in any test component in the same thread group, using the syntax:
${<ParameterName>}.
3.
Make the number of users in Thread Properties to the number of users assigned in the User Parameter.
36
Parameterization
Function Helper Dialog : _StringFromFile
1. Create a Parameter txt File in desired/specific location .
2. Click Options Function Helper Dialog in JMeter.
3. Choose the function __StringFromFile.
37
Parameterization
Function Helper Dialog : _StringFromFile
1. Provide full path of the location of file.
2. Provide a name to the variable
3. Provide start file sequence Number as needed.
4. Click on Generate button.
5. Copy and paste the value generated to the value of the variable which has to be
38
Parameterization
Function Helper Dialog : _CSVRead
1. Create a CSV File with the parameters in desired/specific location.
2. Click Options Function Helper Dialog in JMeter.
39
Parameterization
Function Helper Dialog : _CSVRead
1. Provide full path of the location of file.
2. Provide the column number as needed.
3. Click on Generate button.
4. Copy and paste the value generated to the value of the variable which has to be
parameterized in the request.
5. Column number will start from 0
6. The data will be taken from the file while execution.
Note: StringFromFile function can be used to provide only one column of data, using
_CSVRead & CSV Data Set Config has facility to send multiple column data during
execution.
40
Parameterization
Config Elements CSV Data Set Config
1. Create a CSV File with the parameters in any location .
2. Right Click Test Group Add Config Element CSV Data Set Config.
41
Parameterization
Config Elements CSV Data Set Config
1. Name : Descriptive name for this element that is shown in the tree. .
2. Filename : Name of the file to be read
3. File Encoding : Generally its blank for windows
4. Variable Names: List of variable names (comma-delimited)
5. Delimiter: Delimiter to be used to split the records in the file, generally keep, for CSV file
6. Recycle on EOF: Should the file be re-read from the beginning on reaching EOF? (default is true)
7. Stop thread on EOF?: Should the thread be stopped on EOF, if Recycle is false? (default is false)
8. Sharing mode: How to share the CSV file to current thread/ Current thread group / Current thread
9. Values can be accessed in any test component in the same thread group, using the syntax:
${<ParameterName>}
42
Day 4 : Agenda
43
Test Execution
1.
Thread Group defines a pool of users that will execute a particular test case against your server .
2.
b.
Action to be taken after a Sampler error: If a sampler error occurs select any one option below as per
requirement
i.
ii.
Start Next Loop - ignore the error, start next loop and continue with the test
iii.
iv.
Stop Test - the entire test is stopped at the end of any current samples.
v.
Stop Test Now - the entire test is stopped abruptly. Any current samplers are interrupted if possible
c.
d.
e.
f.
Start Time & End Time: This is used to when to start the test and when to end.
g.
h.
44
Rename the Transaction Controller to appropriate name if transactions are defined in WorkBench.
45
Number of Threads
Ramp-up Period.
Loop Count.
46
Right click on Test plan Select Merge Select the another script.
47
Number of Threads
Ramp-up Period.
Loop Count.
Duration
Start up delay
48
Test Results
49
Test Results
50
View Results tree is used for debugging for the parameters that are substituted and the correlated value is passed in
the post request.
Add the View Results Tree listener to the Test plan/Thread group.
51
View Results Table contains Start time, Label, Response time(ms) and Bytes transferred
Add the View Results Table listener to the Test plan/Thread group
52
Summary Report shows Average, Minimum and Maximum response times along with Std deviation , Error % and
throughput
53
Thank you !
narasimha.nallabothula@valuelabs.com
Extension : 32167