7/25/2019 Jmeter Day1 Material
1/32
Jmeter Day 1 Material
7/25/2019 Jmeter Day1 Material
2/32
Introduction: -
Apache JMeter is a 100% pure Java desktop application designed to load test
client/server software (such as a we application!" JMeter can e used to simulate a
heavy load on a server# network or o$ect to test its strength or to analye overall
performance under di&erent load types" Additionally# Jmeter can helps you regression
test your application y create test scripts with assertions (content check points! to
validate that your application is returning the results you e'pect
Pre-requisites: -
nstall latest version of JA)A/J*+ 1", or later followed y set the JA)A in and
JA)A-.M+ path as shown elow
My ComputersRight ClickPropertiesAdvance TabEnvironment Variables
Jmeter HTTP Performance Testing Process
Page 2 of 32
7/25/2019 Jmeter Day1 Material
3/32
Getting started:-
1) Download the ipped inary(Apache JMeter "! from
http2//$akarta"apache"org/$meter/
2) +'tract the 34 5les to any speci5ed location in the local host
3) n 6indows# launch JMeter y running $meter"at
4) After running $meter"at# Jmeter console will open up y default 7est 4lan#
6orkench nodes shown up as seen in the elow snapshot
Jmeter HTTP Performance Testing Process
Page 3 of 32
http://jakarta.apache.org/jmeter/http://jakarta.apache.org/jmeter/7/25/2019 Jmeter Day1 Material
4/32
Note:8
TestPlan Node Permanent workspace or created scripts !Reer Terminology section or TestPlan"
#orkbench Temperary work space or creating scripts !Reer Terminology section or
#orkbench"
Jmeter supports the low list of protocols for performance testing of any we/client
server applications
HTTP/HTTPS, FTP, JDBC, JMS, LDAP, SOAP, RMI
7his whitepaper will e'plains the .774/.7749 performance testing process for :;oogle
6e 9earch< Application with e&ective utiliation of Jmeter features/add8ons facility
What is HTTP/HTTPS Protoco: -
.774 4rotocol stands for .yper 7e't 7ransfer 4rotocol" t is the protocol used to convey
information of 6orld 6ide 6e (666!" .774 protocol is a stateless and
connectionless protocol" .774/.7749 protocol is ased on a re=uest/response
paradigm" n this protocol the communication generally takes place over a 7>4/4
protocol
!"eters Ter"inoog#2 -
?efore we go further it would proaly e helpful to discuss some asic Jmeter
terminology" @ou may also want to refer to the Jmeter ; for more information
Thread:Bor all intents and purposes# a thread can e thought of as a user
(virtual user in C*!
Thread Grou$:7hink of a thread group as the scenario" A ?usiness 9cenario
that has a user log in to 6e 7ours application# ook a ight# and logout might
e recorded in a test script called one thread group" During a test there mighte one or several hundred users e'ecuting a thread group" 7he thread group
might contain conditional logic that loops through parts of the we application
Test $an:A test plan is one or more thread groups" n the aove# we discussed
a thread group that performing some actions as part of :$ooking a %lightrete custom re=uest forspeci5c protocol (we-custom-re=uest!
%istener: A listener listens to the responses generated y samplers" Cisteners
can e used to compile the results of the test run and to check that a sampler
generates the e'pected response
&ssertion: An Assertion is used to specify what a response should or should
not contain" 7here are several di&erent types of assertions depending on what
kind of response you are e'pecting and what sort of check youEd like to perform(we-reg-5nd in C*!
%ogic 'ontroer: Cogic controllers provide a mechanism for controlling the
ow of the thread group" Adding a logic controller to your thread group is like
adding if8then or do8while logic to a program" @our test script can make run8time
decisions aout how to e'ecute" 9uppose you want to open every o$ect in a list
ut you do not know how many o$ects will e in the list ahead of time" A FCoop
>ontrollerF could e used to e'ecute an action (opening an o$ect! a certain
numer of times without re=uiring you to hard8code the re=uests into the script
Wor(ench: 7he 6orkench is like a working area" 6hen recording scripts#
JMeter places the automatically8generated samplers under the workench" 7hey
will not get e'ecuted as part of a thread group until you move them from the
workench to a thread group ()irtual ser ;enerator!
Transaction 'ontroer: 7he 7ransaction >ontroller generates an additional
sample which measures the overall time taken to perform the nested test
elements" Gote that this time y default includes all processing within the
controller scope# not $ust the samples
!*eter Test Pan Process2
Jmeter HTTP Performance Testing Process
Page 5 of 32
7/25/2019 Jmeter Day1 Material
6/32
7here are several steps for achieving end8to8end we performance testing using .774
9ampler
Test Pan 'reation: -
1) Add a 7hread ;roup to 7est 4lan
!Right click on Test Plan and select AddThreads !&sers"Thread 'roup"
2) Add .774 4ro'y server to the 6orkench
!Right click on #ork$ench and select AddNon(Test Elements)TTP Pro*y +erver"
Jmeter HTTP Performance Testing Process
Page 6 of 32
7/25/2019 Jmeter Day1 Material
7/32
3) .774 4ro'y 9erver node is added under 6ork?ench node
Jmeter HTTP Performance Testing Process
Page 7 of 32
7/25/2019 Jmeter Day1 Material
8/32
4) pen the internet rowser and con5gure the pro'y setting as shown in elow
snapshot" Make sure that the port numer should e same as the port numer
given in the ;loal 9ettings in Jmeter"
Tools,nternet -ptionsConnections.AN +ettings
+) 9elect :4ut each group in new transaction controller< as ;rouping option" 7herefore
every single click can be recorded as one business transaction!lr/start/transaction
in .R"
,) 9elect the .774 4ro'y 9erver node under 6ork?ench
9elect Htt$'ient4as 7ype in .774 9ampler 9ettings (*ecording ptions in C*!
Jmeter HTTP Performance Testing Process
Page 8 of 32
7/25/2019 Jmeter Day1 Material
9/32
9elect TestPan Thread Grou$ as 7arget >ontroller in 7est plan content
(lr-start-transaction in C*!
>lick on 9tart utton
.) Gow start recording y opening the rowser and enter the *C
http2//www"google"comwhich will access the ;oogle .ome page
) +nter any search string in the te't o' and click on ;oogle 9earch
Jmeter HTTP Performance Testing Process
Page 9 of 32
http://www.google.com/http://www.google.com/7/25/2019 Jmeter Day1 Material
10/32
0) >lick on 5rst link
1) 9elect the .774 4ro'y 9erver node under 6ork?ench and click on 9top utton
Jmeter HTTP Performance Testing Process
Page 10 of 32
7/25/2019 Jmeter Day1 Material
11/32
7ill the aove step# *ecording process is completed"
11) All the aove usiness scenario can e recorded in $meter as shown in the
elow snapshot# where all the 7ransaction >ontroller names can e renamed in the
following way2
/ 01-;oogle-.omepage
/search 0-;oogle-9earch and
/url 0H-;oogle->lick5rstCink
'orreation2
>orrelation is the most important aspect of scripting" t generally includes fetching
dynamic data from preceding re=uests/calls and posting it to the suse=uent re=uests
1) >orrelate the *C (http2//$meter"apache"org/ ! I *C(dynamic content! will e
di&erent for every iteration ased on 9earch string
Jmeter HTTP Performance Testing Process
Page 11 of 32
http://jmeter.apache.org/http://jmeter.apache.org/7/25/2019 Jmeter Day1 Material
12/32
2) >opy the *C(Dynamic >ontent!and go to *esponse ta (7e't mode! in :)iew
*esult 7ree< listener of search operation" n order to see the *esponse Data in
:)iew *esults 7ree< listerner# we need to e'ecute script y at least one time
followed y adding :)iew *esults 7ree< listener
Right click on Thread 'roup .isternersView Results Tree
Note:-,n .R0 there is a 1Tree View2 mode to see the server response where as in
3meter0 Thread 'roup !script" should be e*ecuted at least once to see the server
response
3) Dynamic >ontent from *esponse ta is a hre5/ur6qhtt$://7"eter8a$ache8org/9
>apture the Dynamic value that is to e correlated along with its left and rightoundaries" n this e'ample
Jmeter HTTP Performance Testing Process
Page 12 of 32
7/25/2019 Jmeter Day1 Material
13/32
Dynamic )alue2 8 htt$://7"eter8a$ache8org/
Ceft ound2 8 a hre5/ur6q
*ight ound2 8 9
*eplace the dynamic value with a regular e'pression i"e"# ("K! y adding *egular+'pression +'tractor as e'plained in the ne't step
*egular+'pression2 a hre5/ur6q;8
7/25/2019 Jmeter Day1 Material
14/32
=eerence Na"e:t is the name of the JMeter variale which stores the dynamic
value"
*atch No8 : ndicates which match to use" 7he regular e'pression may match
multiple times"
se a value of >eroto indicate JMeter should choose a match at
random"
A positive numer Nmeans to select the nth match"
Gegative numers are used in con$unction with the Bor+ach controller?eaut @aue: f the regular e'pression does not match# then the reference variale
will e set to the default value" 7his is particularly useful for deugging testsTe"$ate:attriute should e default as AB1BC
& s"a eDa"$e to understand de$th o 'orreation : ;I"$act oTe"$ate &ttriute)9ome times we want to capture multiple strings which are changing dynamically in the
same CG+ B >D+ like
7/25/2019 Jmeter Day1 Material
15/32
test-g1N7o7o nametest-gN 2+ agetest-gHN +8. heighttest-gN 3 Gumer of groups in regular e'pression
Para"eteri>ation:
4arameterie the search string :!"eterlick on add
7/25/2019 Jmeter Day1 Material
19/32
7 *un your script" f any of the assertions fail# a message will show up in the
Assertion *esults listener as shown in elow snapshot !lr/output/message 8
lr/error/message in .R"
Jmeter HTTP Performance Testing Process
Page 19 of 32
7/25/2019 Jmeter Day1 Material
20/32
'oo(ie *anager:
Many 6e applications use cookies" JMeter provides cookie capailities through a
>ookie Manager" Adding this element to a thread group allows us to send cookies to
the application eing tested# $ust as 6e rowsers do"
Add .774 >ookie Manager!Right click the Thread 'roup and select AddCon5g
Element)TTP Cookie Manager" and set >ookie policy of the cookie manager to e
:co"$atiiit#
7/25/2019 Jmeter Day1 Material
21/32
;ive the constant delay as shown in elow snapshot
ser ?eFned @ariaes:
ser De5ned )ariale element is used to initialie set of variales"
Add ser ?eFned @ariaeselement under 7hread ;roup
(RightClick on Thread 'roup AddCon5g Element&ser 6e5ned Variables!
n our e'ample we can de5ne the 9erver Game as ser De5ned )ariale"
Jmeter HTTP Performance Testing Process
Page 21 of 32
7/25/2019 Jmeter Day1 Material
22/32
;o to ser De5ned )ariales element and 5ll the 5elds as shown in the elow
snapshot
*eplace JJJ8googe8co8in with BKSererNa"eL in .774 *e=uest as show in the
elow snapshot
After aove enhancements# e'ecute the script for multiple iteration to validate thefuncitonlity of the application
1) Add @ieJ =esuts TreeCistener element to the thread group
Add(4.istener(4View Results Tree
2) *un the script(ctrR*! and oserve the result in result tree
Jmeter HTTP Performance Testing Process
Page 22 of 32
7/25/2019 Jmeter Day1 Material
23/32
=esuts Mut$ut:- +very iteration it will fetch di&erent search string followed y
accessing 7heir respected search string irst %in(only
Thread Grou$:
A 7hread ;roup de5nes a pool of users that will e'ecute a particular test case against
your server" n the 7hread ;roup ;# you can control the numer of threads (numer
of users!# the ramp ramp8up period (how long it takes to start all the threads!# 7he
loop count (how many times the thread group will e e'ecuted!# and optionally# a start
and stop time for the test"
Jmeter HTTP Performance Testing Process
Page 23 of 32
7/25/2019 Jmeter Day1 Material
24/32
Set$ Thread Grou$:
A special type of thread group that can e utilied to perform 4re87est Actions" 7he
ehavior of these threads is e'actly like a normal 7hread ;roup element" 7he
di&erence is that these types of threads e'ecute efore the test proceeds to the
e'ecuting of regular 7hread ;roups"
ODa"$e: 8 >onsider two thread groups of 6e tours scenario i"e" Blight creation and
Blight deletion" 7herefore# we need to e'ecute the test plan with these two thread
groups" 7he 5rst thread group is Blight creation# where the user reserves the ights"
7he second thread group is Blight deletion# where the user cancels all the reserved
ights" n this case# the thread group Blight deletion must have always a speci5c
numer of reserved ights to e cancelled" 9o to schedule a test plan with these two
thread groups# we have to make the Blight creation thread group as :9etup 7hread
;roup
7/25/2019 Jmeter Day1 Material
25/32
group Blight deletion can e made as actual thread group" 7herefore# when the test
plan is scheduled Blight creation thread group will e'ecute followed y Blight Deletion
thread group will e e'ecuted where the >reated Blights will e D+C+7+D"
TeardoJn Thread Grou$:
A special type of 7hread ;roup that can e utilied to perform 4ost87est Actions" 7he
ehavior of these threads is e'actly like a normal 7hread ;roup element" 7he
di&erence is that these types of threads e'ecute after the test has 5nished e'ecuting
its regular 7hread ;roups" n other words we can call it as vice versa of setu$thread
grou$8
=e"ote %oad Testing: -
Ste$ 1: 'onFgure the nodes
9ame version of Java installed on all slave machines for est recommendation
>on5gure the >9) param 5les in the appropriate directory on Jmeter MasterMachine
>on5gure the numer of Coad ;enerators machine 4Ss in the properties"t't to
simulate the 7hreads activity during the test" 7hese properties will e picked up
Jmeter HTTP Performance Testing Process
Page 25 of 32
7/25/2019 Jmeter Day1 Material
26/32
when the server is started and may e used in the test plan to a&ect its ehavior
(e"g" connecting to a di&erent remote server!
Ste$ 2: Start the serers
7o run JMeter in remote node# start the JMeter server component on all machines you
wish to run on y running the !*OTO=HM*O/in/7"eter-serer8at (windows!
script"
Ste$ 3: &dd the serer IP to #our cients Pro$erties ie
+dit the properties 5le on the controlling 3Meter machine" n /in/$meter"properties# 5nd
the property named# Fremote hostsF# and add the value of running Jmeter slave
serverEs 4 address" Multiple such salve servers can e added# comma8delimited" f we
de5ne the JMeter property server"e'itaftertestNtrue# then the server will e'it after it
runs a single test"
Ste$ 4: Start the !*eter 'ient ro" a GI cient
Gow you are ready to start the controlling JMeter client" Bor M986indows# start the
client with the script Fin/$meter"atF" @ou will notice that the *un menu contains two
new su8menus2 F*emote 9tartF and F*emote 9topF (see elow 5gure!" 7hese menus
contain the client that you set in the properties 5le" se the remote start and stop
instead of the normal JMeter start and stop menu items
Bigure 1 8 *un Menu
&dd Mn to !"eter:
Jmeter has several add8ons which will e providing the options as compare with
Cicensed performance test tools"
niversal9erverAgent 2 8 6indows and ni' servers monitoring
Jmeter HTTP Performance Testing Process
Page 26 of 32
7/25/2019 Jmeter Day1 Material
27/32
9tepping 7hread ;roup# tilmate thread group 2 8 7ypes of 7hread groups for
simulating di&erent load test ramp up patterns during test
Active thread over time 2 8 7ype of Cistener to see the numer of users status during
test
Discussed aove add8ons installtion procedure followed y their Beatures
>opying !*eterPugins87ar 5le inside the !*OTO=INST&%%?I=/i/eDt" 6e can
oserve two thread groups (ie"#9tepping 7hread ;roup#ltimate 7hread ;roup! are
added to 7est 4lan"
Ste$$ing Thread Grou$:
JMeter have only one out8of8the8o' option for threads (users! scheduling2 simpleramp8up" ?ut many users# especially with .4 Coad*unner e'perience miss more
e'ile thread scheduling algorythm" 9tepping 7hread ;roup adds to JMeter thread
scheduling similar to Coad*unnerEs" t allows to set up the *amp up# *amp down#
Duration e'plicitly where as in Gormal 7hread ;roup allows GC@ to con5gure Duration
along with the starting of 7otal 7hreads
9napshot as follows
ti"ate Thread Grou$:8
t allows to seeing the e'pected ehavior of the test which was designed for di&erent
*amp up# Duration# *amp down for single thread group
Jmeter HTTP Performance Testing Process
Page 27 of 32
7/25/2019 Jmeter Day1 Material
28/32
OD: -f we have single 7hread group (one script! whereas di&erent scheduler needs it
;+Q o threads si"uate diRerent ra"$ u$ duration ra"$ doJn ro" tota
nu"er o threads)
&ctie Threads Mer Ti"e: -
t allows seeing the 7hreads ()irtual sers! running status as per design the load
pattern schedulers in Gormal 7hread or 9tepping up thread group or 9et up or 7ear
Down thread groups ()irtual sers graph in C*!
%isteners:
Jmeter HTTP Performance Testing Process
Page 28 of 32
7/25/2019 Jmeter Day1 Material
29/32
7hese are used to view and store the results of our test plan"*unning a load test
without capturing performance metrics is kind of pointless" JMeter o&ers a variety of
listeners to capture metrics"
Right click Thread 'roup then click Add.istenerView Results Tree
9imilarly we can add the listners such as )iew *esuits 7ree#9ummary *eports#
Aggregate *eports etc"
@ieJ =esuts Tree(7ree view in C*!
@ieJ =esuts in Tae
Jmeter HTTP Performance Testing Process
Page 29 of 32
7/25/2019 Jmeter Day1 Material
30/32
Su""ar# =e$ort
9ome additional listeners are added to the Jmeter ; y copyingJMeter4lugins"$ar 5le
from JMeter4lugins8)+*9G"ip to3METER/,N+TA..E6/6,RECT-R9:lib:e*t" 9ome of the
listeners are listed elow
7$gc - Per*on *etrics 'oector:?y using this listener we can monitor the >4
utiliation# Memory# 9wap# Disks /# Getworks / and so on" Bor monitoring >4
utiliation# Memory# Disk / and so on# we have to start the start&gent8at5le in
3MeterPlugins(;
7/25/2019 Jmeter Day1 Material
31/32
7$gc - &ctie Threads oer Ti"e:Active 7hreads over 7ime is a listener showing
how many active threads are there in each thread group during test run" 7he plugin
produces graph like shown elow2
7$gc - &uto Sto$ %istener: Auto 9top Cistener is used when we want to stop the
test on some runtime criteria" >urrently H criteria availale2 average res$onse ti"e
aerage atenc# and error rate" 7hese criteria are used in * logic# the component
will ask JMeter to stop test if one of the criteria has een met"
i! Auto 9top on *esponse 7ime/Catency2 7here is como8o' switching which
result parameter to use in conditions2 response time or latency" 7est will e
stopped only if speci5ed response time/latency e'ceeded for se=uentially G
seconds" 7o disale auto8stop on time criteria# $ust set time value to ero
ii! Auto 9top on +rror *ate2 +rror rate speci5ed in percent" *ate can e oat
numer" 7est will e stopped only if speci5ed error rate e'ceeded for
se=uentially G seconds" 7o disale auto8stop on rate criteria# $ust set error
rate to ero
7$gc - U#tes Through$ut Mer Ti"e:7his graph will display the amount of ytes
sent and received y JMeter during the load test
Jmeter HTTP Performance Testing Process
Page 31 of 32
7/25/2019 Jmeter Day1 Material
32/32
7$gc - Hits $er Second:7his graph will display the hits generated y the test plan
to the server per second
7$gc - Transactions $er Second:7his graph shows the numer of transactions per
second for each sampler