jmeter table of contents

Upload: anonymous-3y4chyg

Post on 05-Jul-2018

228 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/16/2019 Jmeter Table of Contents

    1/36

    Table Of Contents1. Introduction2. Technologies used3. What is this article about?4. Installation5. GUI overview6. vailable re!uests". Test #lans and co$#onents

    ".1. %ubsection".2. %a$#lers".3. &ogic controllers".4. &isteners".5. Ti$ers".6. ssertions".". 'on(iguration nodes".). *re #rocessors

    ".+. *ost #rocessors). Test #lan ele$ents order o( e,ecution+. -un %to# test #lans1/. Web 0 TT* test #lan11. atabase test #lan tutorial12. unit test #lan13. -ecording TT* tests14. eter *lugins15. eter best #ractices16. %u$$ar1". ownload1). -esources

    1. introductioneter is an a##lication that o((ers several #ossibilities to con(igure and e,ecute load7

    #er(or$ance and stress tests using di((erent technologies and #rotocols.It allows si$ulating di((erent t #e o( re!uests against all 8ind o( databases7 9T*7 TT*7 TT*%or other 8ind o( servers.It is #robabl good to e,#lain brie(l what all these conce#ts $ean:

    • Load tests: These 8ind o( tests ta8e the s ste$s or a##lications tested to the e,tre$esthat the were designed and re!uired (or. The are used to $easure s ste$s and a##lications

    behavior under e,tre$e conditions.• Performance tests: These tests are used to chec8 how the s ste$ behaves in ter$s o(

    #er(or$ance7 that is7 how the s ste$ res#onds and how is its stabilit (or a s#eci(ic wor8load.• Stress tests: These tests tr to brea8 or overwhel$ the s ste$ b loading $ore resources

    and ta8ing its $odules outside the li$its that were designed.;riginall eter was designed to test web a##lications7 but its (unctionalit has e,#anded andnowada s allows testing against al$ost an 8ind o( #rogra$ and can be used to #er(or$(unctional tests in our a##lications.

    http://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#introductionhttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#Technologies%20usedhttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#What%20is%20this%20article%20about?http://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#Installationhttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#GUI%20overviewhttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#Available%20requestshttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#Test%20plans%20and%20componentshttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#ThreadGrouphttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#TSamplershttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#Logic%20controllershttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#Listenershttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#Timershttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#Assertionshttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#Configuration%20nodeshttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#Pre%20processorshttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#Post%20processorshttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#Test%20plan%20elements%20order%20of%20executionhttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#%20Run/Stop%20test%20planshttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#%20Web%20(HTTP)%20test%20planhttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#%20mysqlhttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#%20junithttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#%20recordinghttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#%20pluginshttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#%20best_practiceshttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#%20Summaryhttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#%20downloadhttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#%20resourceshttp://jmeter.apache.org/http://jmeter.apache.org/http://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#Technologies%20usedhttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#What%20is%20this%20article%20about?http://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#Installationhttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#GUI%20overviewhttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#Available%20requestshttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#Test%20plans%20and%20componentshttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#ThreadGrouphttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#TSamplershttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#Logic%20controllershttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#Listenershttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#Timershttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#Assertionshttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#Configuration%20nodeshttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#Pre%20processorshttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#Post%20processorshttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#Test%20plan%20elements%20order%20of%20executionhttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#%20Run/Stop%20test%20planshttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#%20Web%20(HTTP)%20test%20planhttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#%20mysqlhttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#%20junithttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#%20recordinghttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#%20pluginshttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#%20best_practiceshttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#%20Summaryhttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#%20downloadhttp://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#%20resourceshttp://jmeter.apache.org/http://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html#introduction

  • 8/16/2019 Jmeter Table of Contents

    2/36

    2. Technologies u sedeter is a ava des8to# a##lication. Its UI is i$#le$ented using the %wing ava *I. ue to

    these two #oints7 eter is $ulti#lat(or$ and runs in an 8ind o( $achine with a ava virtual$achine installed: Windows7 &inu,7 ac.

    Its (ra$ewor8 allows concurrenc and the e,ecution o( several Threads and Threads Grou#s.This is ver use(ul when tr ing to con(igure load and stress tests.It is e,tensible and there is a ver large list o( #lugins available.

    eter is #art o( the #ache so(tware (oundation and is co$#letel (ree and o#en source0htt#: www.a#ache.org licenses .

    3. What is this article about?This article is a tutorial about how to use eter (or develo#ers and so(tware engineers withoute,#erience on eter.It also #rovides e,a$#les and howou need to do the (ollowing ste#s in order to get eter installed and running in our co$#uter:

    • 9irst o( all ou have to install ava. >ou need a - 1.6 or above installed in our$achine. To do this7 @ust go to the ;racle download site and install the #ac8age suitable (or

    our s ste$: htt#: www.oracle.co$ technetwor8 @ava @avase downloads inde,.ht$l.• %et the JAVA_HOME environ$ent variable to #oint to the base director location7 where

    ava is installed on our $achine. 9or Windows users:1 JAVA_HOME=C:\Program Files\Java\jdk1.8. _!

    or whatever our ava version is.• ##end ava co$#iler location to % ste$ *ath. 9or Windows users:1 C:\Program Files\Java\jdk1.". _!#\$i%to the end o( the s ste$ variable7 *ath.

    • 'hec8 that ava is installed in our $achine b going to the co$$and line and t #ing1 java &versio%%o$ething li8e the (ollowing should co$e out:1 java versio% '1.8. _! '! Java()M* +E ,-% ime E%viro%me% ($-ild 1.8. _! &$!/*0 Java Ho + o ()M* /2&3i +erver VM ($-ild !#.! &$!04 mi5ed mode*

    • ownload the latest version o( eter (ro$ htt#: @$eter.a#ache.org downloadA@$eter.cgi• ,tract it to the (older C:\>JMeter (or e,a$#le 0in Windows .• The structure o( this (older should be so$ething li8e:

    1 a a67e&jme er&!.! 0 a a67e&jme er&!. \$i%2 # a a67e&jme er&!. \do6s

    http://www.apache.org/licenses/http://www.oracle.com/technetwork/java/javase/downloads/index.htmlhttp://jmeter.apache.org/download_jmeter.cgihttp://www.apache.org/licenses/http://www.oracle.com/technetwork/java/javase/downloads/index.htmlhttp://jmeter.apache.org/download_jmeter.cgi

  • 8/16/2019 Jmeter Table of Contents

    3/36

    / " a a67e&jme er&!. \e5 ras8

    a a67e&jme er&!. \li$\1

    11 a a67e&jme er&!. \li$\e51! 10 a a67e&jme er&!. \li$\j-%i12 1# a a67e&jme er&!. \ ri% a$le_do6s

    • Then ou can start eter b going to the (older C:\jmeter\apache-jmeter-2.11\bin 0Windows users and starting the #rogra$ jmeter.bat .

    • >ou should see the start screen o( the eter GUI:

    5. GUI overviewThe eter GUI is ver intuitive and eas to use7 co$$on $enus (or (ile handling li8e new7o#en7 save7 save as etc. and s#eci(ic $enus (or starting and sto##ing test #lans and con(iguringthe$ are available. ver test #lan7 thread grou# and test #lan node 0we will see these $ore indetail in the ne,t cha#ters o((er di((erent conte,t $enu o#tions b clic8ing the $ouse right

    button.It is also #ossible to change the language o( the UI and a big bunch o( languages are available.

  • 8/16/2019 Jmeter Table of Contents

    4/36

    s we said7 the GUI is ver intuitive and eas to use and o((ers (or ever $enu and action verunderstandable tool ti#s. This is one o( the reasons7 a#art (ro$ its !ualit 7 wh eter is so

    broadl used7 because it is reall eas to understand and learn how to wor8 with it.

    6. Available requestseter o((ers test con(igurations (or al$ost an 8ind o( s ste$7 but in general7 (ollowing

    #rotocols are covered out o( the bo,:• Web: TT*7 TT*% sites Bweb 1./C web 2./ 0a@a,7 (le, and (le,

  • 8/16/2019 Jmeter Table of Contents

    5/36

    Thread Grou# has also the start and end ti$e con(iguration o#tions. E clic8ing the chec8bo,%chedulerJ a new section with the schedule #ara$eters will a##ear and ou can con(igure the

    start and end ti$e o( our test.;nce this is con(igured ou can start adding other test #lan ele$ents to our Thread grou# li8esa$#lers7 listener and ti$ers. We are going to e,#lain all these in the ne,t cha#ters.

    7.2 Samplers%a$#lers are used (or sending re!uests to di((erent 8ind o( servers. The are the basic ele$ent o( ever test #lan and ever thing wor8s around the$: the e,ecute re!uests 0based on thecon(iguration #rovided and these re!uests #roduce one or $ore res#onses that are anal =eda(terwards.

    ere is a list o( the %a$#lers available in eter 0we are going to see so$e o( the$ in thistutorial :

    • ccess log sa$#ler • * sa$#ler • Eean shell sa$#ler • E%9 sa$#ler • ebug sa$#ler • 9T* sa$#ler • TT* sa$#ler • ava sa$#ler • E' sa$#ler • % 0several sa$#lers• %-223 sa$#ler • Unit sa$#ler • & * 0several sa$#lers• ail -eader • ongo E sa$#ler • ;% #rocess sa$#ler • % T* sa$#ler • %; *•

    T'* sa$#lers• Test action

    s we can see in the list above7 there are a lot o( di((erent t #es o( sa$#lersK this list is notco$#lete since there are several sa$#lers i$#le$ented in di((erent eter #lugins. Thecon(iguration o( each sa$#ler de#ends on the re!uest that it e,ecutes7 that $eans that so$esa$#lers have things in co$$on but others are co$#letel di((erent because o( the nature o(their re!uests.

  • 8/16/2019 Jmeter Table of Contents

    6/36

    7.3 Logic controllers&ogic controllers are ele$ents that allow ou to con(igure the order o( e,ecution o( di((erentsa$#lers inside a Thread grou#. This list contains all available logic controllers in eter:

    • %i$#le 'ontroller

    • &oo# 'ontroller • ;nce ;nl 'ontroller • Interleave 'ontroller • -ando$ 'ontroller • -ando$ ;rder 'ontroller • Through#ut 'ontroller • -unti$e 'ontroller • I( 'ontroller • While 'ontroller • %witch 'ontroller • 9or ach 'ontroller • odule 'ontroller • Include 'ontroller • Transaction 'ontroller • -ecording 'ontroller

    7.4 Listeners&isteners #rovide di((erent wa s to view the results #roduced b a %a$#ler re!uests. &isteners #arse results in (or$ o( tables7 trees or #lain log (iles.The can be added an where in a test #lan7 but the will onl #arse and collect result data (ro$the sa$#lers at their level or in the levels bellow.These are the available listeners in eter:

    • %a$#le -esult %ave 'on(iguration• Gra#h 9ull -esults• Gra#h -esults• %#line Lisuali=er • ssertion -esults• Liew -esults Tree• ggregate -e#ort• Liew -esults in Table• %i$#le ata Writer

  • 8/16/2019 Jmeter Table of Contents

    7/36

    • onitor -esults• istribution Gra#h 0al#ha• ggregate Gra#h• ailer Lisuali=er • Eean%hell &istener • %u$$ar -e#ort

    7.5 Timers>ou can de(ine the ti$e #eriod that ou want to wait between re!uests using ti$ers. I( ou do nots#eci( an 7 eter will e,ecute the ne,t re!uest i$$ediatel a(ter the current one is (inished7without an waiting ti$e.9ollowing ti$ers are available in eter:

    • 'onstant Ti$er • Gaussian -ando$ Ti$er • Uni(or$ -ando$ Ti$er • 'onstant Through#ut Ti$er • % nchroni=ing Ti$er • %-223 Ti$e• Eean%hell Ti$e• E%9 Ti$e• *oisson -ando$ Ti$e

    7.6 Assertionsssertions con(ir$ the validit o( the test #lan b validating the res#onse #roduced b a %a$#ler

    re!uest. Easicall assertions are si$ilar to unit test assertions and chec8 the !ualit o( the testeda##lication res#onse. >ou can con(igure what 8ind o( assertions is active (or ever test #lan.

    ere is a list o( available assertions in eter:• Eean shell ssertion• E%9 ssertion• 'o$#are ssertion• %-223 ssertion

    • -es#onse ssertion• uration ssertion• %i=e ssertion• D & ssertion• Eean%hell ssertion• 5 e, ssertion

  • 8/16/2019 Jmeter Table of Contents

    8/36

    • T & ssertion• D*ath ssertion• D & %che$a ssertion

    7.7 Conguration nodes>ou can #ass di((erent #ara$eters to the sa$#ler re!uests b using con(iguration ele$ents. The #rovide a wa to create variables 0di((erent and d na$icall that can be used b the sa$#lersa(terwards. The are e,ecuted at the beginning o( the node the belong to7 be(ore the sa$#lersare e,ecuted7 that is wh the sa$#lers can rel on these variables.

    ere is a list o( all the con(iguration nodes that can be used in eter:• 'ounter • '%L ata %et 'on(ig• 9T* -e!uest e(aults• TT* uthori=ation anager • TT* 'ache anager • TT* 'oo8ie anager • TT* *ro, %erver • TT* -e!uest e(aults• TT* eader anager • ava -e!uest e(aults• Me store 'on(iguration• E' 'onnection 'on(iguration• &ogin 'on(ig le$ent• & * -e!uest e(aults• & * ,tended -e!uest e(aults• T'* %a$#ler 'on(ig• User e(ined Lariables• %i$#le 'on(ig le$ent• -ando$ Lariable

    7.8 Pre processors*re #rocessors are ele$ents 0actions7 assertions or basicall whatever that is going to ha##en be(ore a sa$#ler is e,ecuted. The can be used to e,tract variables (ro$ a res#onse that can beused in the sa$#ler a(terwards via con(iguration ele$ents.These are the ele$ents that can be used as #re #rocessors:

    • T & &in8 *arser • TT* U-& -e

  • 8/16/2019 Jmeter Table of Contents

    9/36

    • TT* User *ara$eter odi(ier • User *ara$eters• E' *re*rocessor • %-223 *re*rocessor • -eg , User *ara$eters• Eean%hell *re*rocessor • E%9 *re*rocessor

    7.9 Post processorsIs basicall an ele$ent that is e,ecuted a(ter a sa$#ler e,ecution (inishes. It can be used to #arsethe res#onse data and e,tract values that can be used a(terwards.These ele$ents can be used as #ost #rocessors:

    • -egular ,#ression ,tractor •

    D*ath ,tractor • -esult %tatus ction andler • %-223 *ost*rocessor • E' *ost*rocessor • E%9 *ost*rocessor • '%% Fuer ,tractor • Eean%hell *ost*rocessor • ebug *ost*rocessor

    8. Test plan elements order of execution test #lan ele$ents are ordered and e,ecuted alwa s in the (ollowing wa :

    1 N 'on(iguration nodes2 N *re #rocessors3 N Ti$ers4 N %a$#ler 5 N *ost #rocessors 0onl e,ecuted i( there are results available6 N ssertions 0onl e,ecuted i( there are results available" N &isteners 0onl e,ecuted i( there are results availableIt is good to $ention that a test #lan can contain one or $ore test #lans inside it and that this is aco$$on #ractice to grou# tests b (unctional or technical logic together.

    9. Run/Stop test plansTo run a test #lan ou @ust need to clic8 in the "Pla " button:

  • 8/16/2019 Jmeter Table of Contents

    10/36

    It is #ossible to start a test and ignore all the #auses b clic8ing in the button "Pla n pa#$e$"

    >ou can sto# the test b clic8ing in the "%t p" button:

  • 8/16/2019 Jmeter Table of Contents

    11/36

    It is also #ossible to disable test #lans (or e,ecution. To do this ou @ust need to toogleJ thestatus o( the test #lan:

  • 8/16/2019 Jmeter Table of Contents

    12/36

    s ou can see in the screen ca#ture above7 the disabled #lans are rendered with gre color andthe cannot be e,ecuted but the can be $odi(ied or recon(igured.

    10. Web (HTTP) test planIn this cha#ter we are going to see how to create a #lan to test an s#eci(ic web #age via TT*.9or that #ur#ose i will use the htt#: www.wi8i#edia.org site.%o enough theor 7 now we are going to see how to con(igure an TT* re!uest test #lan.

    • -ena$e Test *lan to the na$e that ou li8e

    In this ste# is #ossible to con(igure the test #lan in general ter$s a((ecting the behavior o(Threads and ou can add e,ternal libraries that should be used. We are not going to do that in thise,a$#le.

    http://www.wikipedia.org/http://www.wikipedia.org/http://www.wikipedia.org/

  • 8/16/2019 Jmeter Table of Contents

    13/36

    • dd Thread Grou#

    In this ste# ou need to create a Thread grou# in charge o( e,ecuting all the co$#onents o( thetest and con(igure its $ain #ro#erties: nu$ber o( threads7 ra$# u# #eriod in seconds and nu$bero( iterations.Context Menu over Test Plan - !dd - Thread - Thread"roup

  • 8/16/2019 Jmeter Table of Contents

    14/36

    ou can also s#eci( the action ou want to ta8e in case o( error 0continue7 sto#7 sto# currentThreadH

    • dd %a$#ler TT* -e!uest

    In this ste# we add the sa$#ler with the in(or$ation o( the TT* -e!uest that we want to test:!dd Sampler- #TTP Re$uestWe need to set di((erent #ro#erties (or this t #e o( re!uest:%et the server na$e to the na$e o( the server we want to test: www.wi8i#edia.org 0without thehtt# or htt#s #rotocol in this case. >ou should $odi( the connection values (or #ort7 #rotocol7$ethod to e,ecute in the server7 etc. i( needed7 i( our case this is not necessar . There are several

    #ara$eters (or con(iguring #ro,ies7 ti$eouts and di((erent header in(or$ation as well7 but in ourcase7 we leave ever thing with the de(ault values

  • 8/16/2019 Jmeter Table of Contents

    15/36

    • dd -esults &istener

    This is needed to be able to see the results a(terwardsK there are several #ossibilities as we saw be(ore in this tutorial7 (or our TT* -e!uest test #lan we are going to use a Liew -esults Tree:!dd Listener - %ie& Results Tree9or our e,a$#le7 we do not change an thing there and leave all the con(iguration #ro#erties withthe de(ault values.

  • 8/16/2019 Jmeter Table of Contents

    16/36

    • %ave the test #lan and -un it

    'ile- Save 0or clic8 'ontrol O sJRun- Start 0or clic8 #la as e,#lained be(ore

    • 'hec8 results in the listener

  • 8/16/2019 Jmeter Table of Contents

    17/36

  • 8/16/2019 Jmeter Table of Contents

    18/36

    • dd duration assertion

    ;n the test #lan7 right clic8 and add a duration assertion7 we con(igure it to assert (alse i( theres#onse ta8es longer than 1// $s7 and we con(igure it (or the $ain sa$#le onl :!dd assertion- (uration assertion

    I( we re run the test #lan 0a(ter saving we will see that we have so$e issues with this assertion:

  • 8/16/2019 Jmeter Table of Contents

    19/36

    ;bviouls this ha##ens because we con(igure the duration assertion onl with 1// $s7 i( wechange this (igure to 2/// $s al$ost all re!uests will be served on ti$e.

    • dd si=e assertion

    !dd assertion- Si)e !ssertionand we assure that the res#onse has a si=e larger than 5/// b tes:

  • 8/16/2019 Jmeter Table of Contents

    20/36

    I( we run the test we will see that the res#onse is alwa s larger than that7 in case o( an errorres#onse the si=e would be7 #robabl 7 s$aller and our assertion will (ail.

    11. Database test plan tutorial ow we are going to see how to con(igure7 run and anal =e the results o( a test against a %F&

    atabase. This e,a$#le is about %F& but it can be done using an other 8ind o( E li8e;racle7 ongo E or others.

    • Install %F&

    I( ou do not have %F& installed in our co$#uter7 ou can download it(ro$ htt#: dev.$ s!l.co$ downloads and install the %F& server7 it is ver eas .

    • ownload the %F& driver

    ownload $ s!l connector 0 m $&l-c nnect r-ja'a-(.1.) and co# it in the lib director o( @$eter C:\jmeter\apache-jmeter-2.11\lib .• %tart %F&

    %tart the E server so that ou can $a8e !ueries against it.• 'reate database

    >ou can create a database as ou want7 here is @ust an e,a$#le o( a ver si$#le one:1 6rea e da a$ase jme er9! 0 -se jme er92

    # 6rea e a$le jme er_s - (id i% 4 %ame var67ar(# *4 des6ri io%var67ar(# **9

    /

    " i%ser i% o jme er_s - (id4 %ame4 des6ri io%*VA;

  • 8/16/2019 Jmeter Table of Contents

    21/36

    8 i%ser i% o jme er_s - (id4 %ame4 des6ri io%*VA;

  • 8/16/2019 Jmeter Table of Contents

    22/36

    ! ?a a$ase

  • 8/16/2019 Jmeter Table of Contents

    23/36

    In this case the out#ut is the results o( the select state$ent.>ou can use this 8ind o( sa$#lers (or u#dating data as well b changing the %F& state$ent in thesa$#ler con(iguration.In the (ollowing screen ca#ture is the basic in(or$ation about the re!uest res#onse results:

  • 8/16/2019 Jmeter Table of Contents

    24/36

    12. Junit test planIn this cha#ter we are going to e,#lain how to use eter in co$bination with Unit. This

    #rovides ver strong $echanis$s (or e,ecuting (unctional tests (ro$ a load and #er(or$ance #oint o( view.• 9irst o( all ou need to create a unit test li8e the (ollowing one:

    1 -$li6 6lass JMe er)es

    !0 2 -$li6 JMe er)es (*#/ BB j-s or es i%g -r oses" +@s em.o- . ri% l%( '6alli%g 7e 6o%s r-6 or' *98 D

  • 8/16/2019 Jmeter Table of Contents

    25/36

    1 3e ore11 -$li6 void se < (* 7ro s E56e io%1!10 BB j-s or es i%g -r oses12 +@s em.o- . ri% l%( '6alli%g se - ' *9

    1# D1/ 1" A er18 -$li6 void ear?o %(* 7ro s E56e io%1! BB j-s or es i%g -r oses!1 +@s em.o- . ri% l%( '6alli%g ear?o %' *9!! !0 D!2 !# )es

    !/ -$li6 void es Me(*!"!8 or( i% i = 9 i 0 9 iGG *!

    0 BB j-s asser i%g ra%doml@ i% order o 67e6k 7a 7a e%s i%ea67 6ase01 i% ra%dom -m$er = (i% *( Ma 7.ra%dom(* > 1 *90! +@s em.o- . ri% l%( ra%dom -m$er *900 asser E -als( 4 ra%dom -m$er I ! *902 D0# D

    0/ DThis test $ainl contains a cou#le o( assertions in order to chec8 how eter can use the$7 it isnot the #ur#ose o( this tutorial to e,#lain unit testing or Unit in detail.

    • dd test to Unit director

    *ac8age the unit test in a @ar (ile and co# it into the director jmeter*lib*j#nit . nsure that the @ar(ile contains the .class b tecode with the tests that ou want eter to e,ecute. t the end o( thisarticle ou can (ind a @ava #ro@ect with a #o$.,$l that ou can directl use to generate a @ar (ilethat can be used b eter. >ou @ust need to co$#ile the code:1 mv% 6om ile;r ou can e,#ort our #ro@ect as - (ile including the b tecode and generated (iles directl in

    cli#se or our (avorite I .• dd a Unit sa$#ler re!uest

  • 8/16/2019 Jmeter Table of Contents

    26/36

    'reate a test #lan as we saw be(ore and add a sa$#ler o( the t #e Unit re!uest: !dd Sampler-,unit Re$uest and con(igure it in order to e,ecute the $ethods that ou want (ro$ the test thatou @ust created above.

    In our case we are going to e,ecute Unit 4 based $ethods7 but ou can also do this using Unit3 b selecting the chec8 bo, (or this #ur#ose.

  • 8/16/2019 Jmeter Table of Contents

    27/36

    • dd a listener to view results as we did in #revious cha#ters• -un the test #lan• Liew the results

    ere we can see the results o( the Unit test that we have @ust created:

  • 8/16/2019 Jmeter Table of Contents

    28/36

    s we can see in the screenshot above7 all our tests 01 test7 1/ loo#s (ailed. This is the e,#ected behaviour since we wanted our test to (ail. ctuall the unit test that we @ust wrote has no(unctional $eaning and it is useless. Its #ur#ose is @ust to show how to con(igure eter to usethese 8ind o( unit tests.The stu(( e,#lained in this cha#ter $a be ver hel#(ul to test (unctional and business logic o(a##lication using eter with all the bene(its that this a##lication #rovides7 it is also verinteresting because it $a8es #ossible to co$bine all the ava language advantages with the$ultithreating ca#abilites o( eter.

    13. Recording HTTP tests ow we are going to e,#lain how to con(igure eter to record TT* re!uests. In order to dothat we need 9ire(o, installed in our $achine7 I a$ using the version 32.

    • Get 9ire(o, to use the eter #ro,

  • 8/16/2019 Jmeter Table of Contents

    29/36

    Go to our 9ire(o, networ8 settings and select the $anual #ro, o#tion and set as serverlocalhost and #ort )/)/ 0actuall this dee#ens on our eter con(iguration . (ter that7 chec8the o#tion Use this #ro, server (or all #rotocolsJ.

    • 9irst o( all we create a test #lan as we did be(ore.

    We add a new Thread Grou# and we give a na$e to it. We con(igure the Thread Grou# to have5/ threads7 1/ seconds as ra$#

  • 8/16/2019 Jmeter Table of Contents

    30/36

    • dd TT* -e!uest e(aults.

    ;n the Thread Grou# that we @ust created7 we add a new 'on(ig le$ent and we select TT*-e!uest e(aultsJ.

  • 8/16/2019 Jmeter Table of Contents

    31/36

    >ou should write here the server na$e that ou want to test.• dd -ecording 'ontroller

    ow we add a recording controller to the wor8bench.%elect the wor8bench7 not the test #lan7 and add a on Test le$ent o( the t #e Test %cri#t-ecorderJ.

  • 8/16/2019 Jmeter Table of Contents

    32/36

    >ou should now that the wor8bench has to be stored inde#endtl (ro$ our test #lan. %avingour test #lan does not save the wor8bench.

    'on(igure the -ecorder as (ollows:

  • 8/16/2019 Jmeter Table of Contents

    33/36

  • 8/16/2019 Jmeter Table of Contents

    34/36

    • -ecords should a##ear

    I( ou go to a web #age in order to $a8e an e,a$#le TT* re!uest7 (or e,a$#le goto htt#: www.oviedin.co$ using 9ire(o, 0a(ter con(iguring it as e,#lained in the (irst ste# o( this

    cha#ter ou will see that di((erent entries a##ear under the -ecording 'ontroller in our test #lan.

    http://www.oviedin.com/http://www.oviedin.com/http://www.oviedin.com/

  • 8/16/2019 Jmeter Table of Contents

    35/36

    These records are actuall TT* re!uests that have been done while !uer ing the web #age$entioned be(ore. ;nl records included in the (ilter con(igured in the Test %cri#t -ecorded will

    be stored. The can be recon(igured and used a(terwards in our test #lans.

    14. JMeter Pluginsi((erent #lugins are available (or advanced users and use cases7 so$e o( the$ need e,tra

    installation7 so$e not.There are ver use(ul #lugins that allow to #arse results using advanced o#tions and anal =ethe$ using gra#hs and charts li8e htt#: @$eter

  • 8/16/2019 Jmeter Table of Contents

    36/36

    %o that is all.We saw how to install eter and how to con(igure it (or e,ecuting di((erent 8ind o( tests li8e

    TT* re!uests7 tests against databases and (unctional tests against unit ones. There are $anothers 8ind o( tests and #ossibilities o((ered with eter that are not covered in this tutorial. Theob@ective o( this tutorial is to give a whole descri#tion o( the a##lication and to show how to

    con(igure our (irst test #lans.We also e,#lained the $ain #arts o( the eter UI and how to use it and also the test #lanele$ents that co$e with eter out o( the bo,.In the last cha#ter we $entioned the #ossibilit to e,#and eter with di((erent *luginsK this is aver interesting #oint (or e,#erience users with advanced needs.