Jmeter

Here some note I took while exploring Jmeter.

Pre-requirement

  • jmeter 5.0
  • Ensure to have added in PATH the location of the bin folder of jmeter
  • ¬†jre 1.8

How to start Jmeter GUI

  • Go where you have downloaded the binaries then run `jmeter.bat` using command line. Or type jmeter.bat if you have the bin folder of jmeter in the PATH.
  • Do not run performance test with GUI. Only for design and debugging purpose with low charge.

How to run Jmeter in command line

  • jmeter -n -e -l appLog.csv -o appReport -t app.jmx
    • `-n` to run in cli mode
    • `-e` to create a report at the end of the run. It requires `-l`
    • `-l` log file name and path
    • `-t` testplan file and path
    • `-o` path where the report is generated

Record script

  • Use the HTTP(S) test Script Recorder with the port 8000
    • On the Root > Add > Non-Test Elements > HTTP(S) test Script Recorder
  • Use firefox and setup the proxy to 8000
  • Record under the current : “HTTP(S) test Script Recorder” then copy the step in each “Recording Controller”
    • On a Thread Group > Add > Logic Controller > Recording Controller
  • Record each step with a different label
    • HTTP Sample settings : Prefix
    • Update each step with a meaning step name
    • Avoid to “Retrive All Embedded Ressources” to keep it simple.
    • Avoid “Redirect Automatically”
    • Allow “Follow Redirects”
    • Alkow “Use KeepAlive”

Thread Group structure

  • “HTTP Request Defaults” : to setup the default root url
    • On a Thread Group > Add > Config Elements > HTTP Request Defaults
  • “HTTP Cookie Manager” : to handle the cookie reset at each iteration
    • On a Thread Group > Add > Config Elements > HTTP Cookie Manager
  • “User Parameters” : to handle the variables and users
    • On a Thread Group > Add > Pro Processors > User Parameters
  • “Debug Sampler” : to retrieve all the variables for debug purpose
    • On a Thread Group > Add > Sampler > User Parameters
  • “View Results Tree” : to see all the step details
    • On a Thread Group > Add > Listener > View Results Tree
  • “Summary Report” : to see the metrics
    • On a Thread Group > Add > Listener > Summary Report

To catch value in response

  • Use Json Extractor : It allow to get a value in json by using JSON Path expression and assign to an existing (JMeter Variable Name to use) or new variables (Names of created variables) with n variables separated by coma.
    • On the http request > Add > Pro Processors > Json Extractor

Other references

  • master/slave architecture for distributed testing : https://jmeter.apache.org/usermanual/jmeter_distributed_testing_step_by_step.pdf