Hello! I'm Chamal Asela Perera.

I test code for living.

Performance Testing with JMeter – Part I

JMeter is a tool that can be used as a load testing tool for analyzing and measuring the performance of various services/web based applications. JMeter is a 100% pure Java application -that means you can run JMeter anywhere you can run Java. JMeter can be used to load and performance test in many different servers/protocols such as including SOAP/REST/HTTP/HTTPS/FTP.

Latest Apache JMeter version is 3.2 – Latest version can be downloaded from here (This requires Java 8 or later version)

Requirements

  • JRE (Java Runtime Environment) – Fully compliant Java 8 (or later)
  • Optional: JMeter – Plugins
  1. Update the Java version to the latest If it is not the latest
  2. Download Apache-jmeter-3.2.zip file – You may note that there is no setup file, just set of files and folder. because of this, you can put this in to anywhere. Put the zip file anywhere you want and extract.
  3. Go the bin folder, you may find jmeter.bat file – Double click it and it will open the JMeter ( This is called running JMeter on GUI mode. GUI mode should only be used for creating the test script, NON-GUI mode must be used for load testing )

There are some additional scripts available in the bin folder.

  • jmeter-server.bat – Start JMeter in server mode
  • jmeter-n.cmd – drop a JMX file to run a non-GUI
  • jmeter-t.cmd – drop a JMX file on this to load it in GUI mode
  • shutdown.cmd – Run the shutdown client to stop a non-GUI instance gracefully

The environment variable JVM_ARGS can be used to override JVM settings in the jmeter.bat script

Installing Plugins

There are two ways to install plugins to JMeter.

First, let’s look at the old way to do this!

  1. Download the required plugin from https://jmeter-plugins.org/ 
  2. Unzip and place the file /lib/ext folder
  3. Quit and restart the JMeter

New way of doing this is using the plugin manager,

  1. Download the plugins-manager.jar file from https://jmeter-plugins.org/
  2. Put into the /lib/ext folder
  3. Then use the Options -> Plugins manager option from the UI

 

Understanding the basic concepts in JMeter

When you open up JMeter, you will see a Test Plan and WorkbBench elements, TestPlan is the root of the entire script. Everything you do will live under the Test Plan. Using a WorkBench is optional.

Thread Group

The job of the Thread Group is to create threads. They are the virtual users performing the actions. You can add a Thread Group by right click Test Plan -> Add -> Threads -> Thread Groups.

Few of the important thread properties are,

  • Number of Threads: Number of users
  • Ramp-up Period: How long would it take the number of threads ( Number of users ) to come up full speed ( EX: If the #of threads equal 100 and ramp up time is 60 seconds, it means that over the course of 60 seconds, Script will execute from 0 to 100 threads(users)
  • Loop Count: How many iterations you need to execute

Also, we can configure what we can do when we encounter an error. That can be configured in Actions to be taken after a Sampler error section. Available options are;

  • Continue: Nothing to worry, just proceed the test
  • Start Next Thread Loop: Gonna stop and continue to next loop
  • Stop Thread: Kills off the thread group
  • Stop Test: Stops entire test gracefully
  • Stop Test Now: Stop the test right abruptly

Sampler

A sampler is an example of how the load is delivered to a target/how the request is made. There are so many different Samples available in Jmeter.

You can configure the web server details/protocol details in this area (If you use HTTP Request as a Sampler by right click on the added Thread Group)

Timer

A timer is used to introduce an intentional delay/or wait before the execution takes place. Reason to do this is to add a realism to our script.

Simplest timer you can use is Constant timer ( Right click the Thread group or/Sampler request and select Add -> Timer -> Constant Timer )

Assertions

Assertions used to make sure that the script is working as we want/or the server is behaving as we want.

One of the simplest assertions you can use is Response assertion ( to make sure you are receiving what you want when sending HTTP request a.k.a Sampler ). An assertion can be added by Right click on the Sampler and Add -> Assertions -> Response Assertions. There are different fields available in Assertions to assert.

We will talk about JMeter functions/properties in the next article 🙂