Something about JMeter

This post will be something different than the previous, because in this post we will learn something about JMeter basics.

We will focus on the topics below:
  1. What is JMeter?
  2. What can we do with JMeter?
  3. How are the JMeter features?
  4. How to use JMeter?
  5. JMeter Installation
  6. JMeter panel
  7. Example and components explanation
What is JMeter?

Apache JMeter is an Apache project that we can use as a load testing tool for analyzing and measuring the performance of a variety of services, with a focus on web applications.

What can we do with JMeter?

We can perform the load testing and performance testing both on static and dynamic resources. Moreover, we can simulate the heavy load on a server, group of servers, and network or object to test its strength. We may also analyze overall performance under different load types.

What are the JMeter features?

JMeter has a lot of features. We will tell ourselves about some of them now.

As we told before, we are able to load and performance test many different applications, server or protocol types. There are some of them:

  • Web – HTTP, HTTPS (Java, NodeJS, PHP, ASP.NET, …)
  • SOAP / REST Webservices
  • FTP
  • Database via JDBC
  • LDAP
  • Message-oriented middleware (MOM) via JMS
  • Mail – SMTP(S), POP3(S) and IMAP(S)
  • Native commands or shell scripts
  • TCP
  • Java Objects

JMeter has its own full-featured Test IDE that allows fast Test Plan recording (from Browsers or native applications), building, and debugging. It has also CLI mode (Command-line mode (previously called Non GUI) / headless mode) to load test from any Java compatible OS (Linux, Windows, Mac OSX, …). JMeter gives us the possibility to present the dynamic HTML reports and it’s complete portability and 100% of Java purity.

How to use JMeter?

Now we know what is JMeter, what can we do with it, and its main features, but we didn’t tell ourselves yet how to use that. Let’s start with an introduction to using JMeter. It will be a basic tutorial where you will get the basic knowledge about using JMeter and perform basic tests.

My environment in this tutorial:
System: macOS
Java version: java version “15.0.1” 2020-10-20
Java(TM) SE Runtime Environment (build 15.0.1+9-18)
Java HotSpot(TM) 64-Bit Server VM (build 15.0.1+9-18, mixed mode, sharing)

JMeter Installation
We need to enter the command: java -version
We need to enter the command: java -version

First of all, we need to check the java version on our machine.

We can see the java version in terminal.
We can see the java version in terminal.

If you don’t have java don’t worry, you can download it and install here.

JMeter Website
JMeter Website

First of all, we need to install JMeter Package. To do that, we need to enter the URL: https://jmeter.apache.org/download_jmeter.cgi and download the apache-jmeter-5.4.1.zip.

Open Downloads and move the zip folder to Desktop.
Open Downloads and move the zip folder to Desktop.
Terminal macOS
Terminal macOS

Once we’ve expanded the folder from zip folder, we can open terminal (MacOS/Linux) or Command Prompt (Windows).

Command: cd Desktop/apache-jmeter-5.4.1/bin has been entered.
Command: cd Desktop/apache-jmeter-5.4.1/bin has been entered.
Command: sh jmeter has been entered.
Command: sh jmeter has been entered.

Once we’ve opened the terminal, we can type: cd Desktop/apache-jmeter-5.4.1/bin and open JMeter by command: sh jmeter.

JMeter has been run.
JMeter has been run.
JMeter has been opened.
JMeter has been opened.

Great! We’ve opened JMeter successfully 🙂

Now we can focus on components of JMeter.

First thing what we will explain it’s the JMeter panel.

JMeter panel
JMeter panel
  1. New
  2. Templates
  3. Open
  4. Save
  5. Cut
  6. Copy
  7. Paste
  8. Expand all – showing all files in Test Plan if are hidden
  9. Collapse all – hiding the files in Test Plan if are showed
  10. Toggle – switching the file from enabled to disabled and mutually
  11. Start – running the JMeter script
  12. Start no pauses – running the JMeter script without pauses
  13. Stop – stopping the one thread group
  14. Shutdown – shutting down all threads
  15. Clear
  16. Clear all
  17. Search
  18. Reset Search
  19. Function Helper Dialog
  20. Help
How to make the first Test Case and test it?

We will make the example to better understanding the value of JMeter. To this, we will use the page https://testingtraveler.com/.
Let’s say, we need to ensure that the 200 users can use the contact form and send the message via the contact page within 3 minutes.
The specification is below:

MethodPOST
ProtocolHTTPS
Hosttestingtraveler.com
Pathcontact
The parameters for opening the registration page
ParameterValue
your-nameunique value
your-emailunique value
your-subjectunique value
your-messageunique value
Data for register

During doing the example we will explain ourselves the components of JMeter and see how it works in the example.

We will start from add the Thread Group.

The Thread Group is the beginning point of any Test Plan. It’s also referred to as a collection of threads, where each of them represents one user using up the application under Test.

Adding Thread Group

We can set in Thread Group the Number of Threads (users) – in this case, it will be 200, and the Ramp-up period (seconds), where we can set how long threads will be processed – in this case, 180. We can Specify Thread Lifetime but we won’t do that in this case.

Thread Group
Thread Group

Samplers hold the actual Work of JMeter i.e., by sending requests to the server and waiting for the responses.
We will tell us something about some of them.

FTP Request lets us send an FTP “download file” or “upload file” request to an FTP server.
HTTP Request lets us send an HTTP/HTTPS request to a web server (can also be used for SOAP or REST Webservice).
JDBC Request lets us execute Database Performance Testing. It sends a JDBC Request to a database.

Adding the Sampler
Adding the Sampler
We’ve added the HTTP Request and entered the data from specification.
HTTP Request

Pre-processor is used to take actions before any of the Sampler Requests sent to the server, like modifying settings of a Sample Request before it runs, or updating variables.

Adding Pre-processor
Adding Pre-Processor

In this case we’ve used the User Parameters to add the UUID which lets us to generate the unique value. So, we will name our Variable UserParametersUUID and enter the value ${__UUID()}. Once we’ve done it, we can enter the variable in HTTP Request Parameters (as in the above screenshot).

User Parameters

Assertions help to add up checks on the responses received from the Samplers. Using this, we can ensure that the application is returning up the responses as expected.

Adding an Assertion
Adding an Assertion

In this case we’ve added the Response Assertion to validate if the page will response code = 200.

Response Assertion
Response Assertion
We have also (we won’t use it in our example):

Logic Controllers, which determines which order in which samplers would actually process.

Adding Logic Controller
Adding Logic Controller
An example of Logic Controller - Simple Logic Controller
An example of Logic Controller – Simple Logic Controller

Configuration is used to add up variables used in the Samplers. Though it doesn’t send any requests it can modify the requests.

Adding Configuration
Adding Configuration
Example of Configuration - CSV Data Set Config
Example of Configuration – CSV Data Set Config

Timers are used to have user-defined timers between the Requests sent. By default, JMeter executes all the samplers in a Test Case in order without any pause. The timer will pause JMeter to delay for a certain amount of time before each of the samplers.

Adding the Timer
Adding the Timer
Example of Timer - Constant Timer
Example of Timer – Constant Timer

Post-processor is used to take actions after the Sampler Request has sent to the server, like extracting data from the response received.

Adding Post-Processor
Adding Post-Processor
Example of Post-Processor - CSS Selector Extractor
Example of Post-Processor – CSS Selector Extractor

And now we will go to the Listeners, which help to gather information about the Test Cases while JMeter runs. All the listeners have the same data but, the only difference in them is the way the data is presented up on the screen.

Adding Listener
Adding Listener

In this case we’ve used use the Results Tree to show the results.

View Results Tree
View Results Tree
Once we've clicked the Start button JMeter script has been run.
Once we’ve clicked the Start button JMeter script has been run.
Test Results
Test Results

As we can see, all tests have been passed, which means that the 200 users could use the contact form and send the message via the contact page within 3 minutes.

Now we know what is JMeter and what can we do with JMeter. Moreover, we got knowledge about JMeter features. We’ve installed JMeter and explained the JMeter components by doing the example.

I hope you’ve enjoyed the article and found some inspirational information.
The next post will arrive soon 🙂

Leave a Reply

Your email address will not be published.