Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Getting Started: Scripting with JMeter

Getting Started: Scripting with JMeter

Apache JMeter is a great tool for simulating performance testing on web-applications, but it may seem tricky at first glance. Check out this presentation to learn how to create your first JMeter script from scratch.

BlazeMeter

June 24, 2014
Tweet

Other Decks in Programming

Transcript

  1. GETTING  STARTED:     SCRIPTING  WITH  JMETER Apache  JMeter  is

     a  great  tool  for  simulaAng   performance  tesAng  on  web-­‐applicaAons,  but   it  may  seem  tricky  at  first  glance.       Learn  how  to  create  your  first  JMeter  script   from  scratch.
  2. GETTING  STARTED •  Download  JMeter  from  the  official  Apache  JMeter

      website   •  Unzip  the  distribuAon  and  copy  it  into  a  folder  on   your  computer.   •  Make  sure  you  have  JRE  1.6  or  above  to  run  JMeter,   because  it's  wriTen  in  pure  JAVA.   •  If  you  are  running  WINDOWS-­‐  Go  to   $JMETER_HOME/bin  and  run  jMeter.bat  –  or  if   you’re  using  *nix  –Go  to  JMeter        
  3. TEST  PLAN  (1)   The  Test  Plan  is  the  core

     element  of  the  test  script. 2  tables  and  3check-­‐boxes.    
  4. TEST  PLAN  (2) #1  Table   •  User  Defined  Variables

     allow  us  to  set  variables,  which  can  be   used  in  any  other  part  of  the  script   •  These  values  can  be  set  up  as  a  variables  -­‐  eliminaAng  the   need  to  update  the  script.     #2  Table   •  Is  used  for  making  test  plan  databases  in  order  to  make  the   JDBC  driver  visible  for  JMeter  and  execute  the  SQL  queries.     •  Add  JDBC  *.jar  to  this  table,  and  JMeter  will  recognize  it.  
  5. CHECK  BOX  #1 If  this  opAon  is  checked,  than  all

     Thread  Groups  will   be  executed  one  by  one.       This  may  be  useful  in  cases  like  when  the  first  Thread   Group  prepares  test-­‐data  for  a  test,  and  the  next  one   uses  this  set. Run  Thread  Group  ConsecuAvely
  6. CHECK  BOX  #2 Some  acAons,  like  restoring  the  system  aier

     tesAng   to  a  default  state  may  be  assigned  to  tearDown   Thread  Groups.   Run  tearDown  Thread  Groups  aier  shutdown  of   main  threads
  7. CHECK  BOX  #3 JMeter  can  also  be  used  for  funcAonal

     tests  because   it  has  a  set  of  elements  which  allows  page  retrieval   from  the  server.     Using  the  funcAonal  test  mode  saves  more   informaAon  about  each  request.     Consumes  more  memory  for  processing    the  data   stream.   FuncAonal  Test  Mode
  8. THREAD  GROUPS Every  JMeter  test  plan  should  contain  at  least

     one  Thread   Group.  It  will  be  the  first  element  added  to  the  test  plan.  
  9. HTTP  REQUEST  DEFAULTS     Set  default  values  for  your

     HTTP  Request  controllers  use.     For  example:  if  you  are  creaAng  a  Test  Plan  with  25  HTTP   Request  controllers  and  all  of  the  requests  are  being  sent  to  the   same  server,  you  could  add  a  single  HTTP  Request  Defaults   element  with  the  "Server  Name  or  IP"  field  filled  in.         Use  the  same  URL  for  all  requests.    Add  that  the  site  that  will  be   stress  tested.  
  10. CONSTANT  TIMER  Users  never   click  links  one   by

     one,  without   any  delay. Naturally,  there  is  a  delay  between  thoughts  and   therefore  user  think-­‐Ame  needs  to  be  emulated.     JMeter  has  a  set  of  Timers,  which  allows  users  to  set  up  a   pause  between  different  requests.       Add  Constant  Timer  to  generate  the  delay  for  the  fixed   amount  of  Ame.  
  11. HTTP  COOKIE  AND  CACHE  MANAGER HTTP  Cookie  Manager:  used  for

      emulaAng  the  browser's  work   with  cookies.         HTTP  Cache  Manager:  used  for   saving  downloaded  pages  in  cache   during  the  first  request,  so  they   can  be  returned  to  Listener   without  downloading.  This   approach,  obviously,  has  influence   on  test  results.      
  12. VIEW  RESULTS  TREE This  element  is   only  needed  

    during  debugging   tests. View  Results  Tree  is  related  to  memory  consumpAon  because  it   stores,  in  memory,  all  the  results  of  requests.   If  it  is  used  while  there  are  many  virtual  users,  the    memory  will   run  out.  So  remove  or  disable  the  View  Results  Tree  all  other   graphic  listeners  before  running  a  test.  
  13. RUNNING  A  LOAD  TEST  WITH   BLAZEMETER   •  VL

    If  you  already  have  your  BlazeMeter  account  set  up,  you  can   simply  click  “Add  test”.     If  not,  create  your  FREE  account  now!  
  14. UPLOAD  TEST  SCRIPT Upload  the  JMeter  script  to  BlazeMeter  

    Adjust  the  test  plan  sesngs  using  the  controls  on  the  right  side  of   the  page.  Press  SAVE.  Press  START.      
  15. RESULTS WELL   DONE! Load  Report  Tab   All  graphs

     represent  KPIs   (Key  Performance   Indicators)  measured   during  the  load.