Table of contents
1.
Introduction
2.
About JMeter
2.1.
About JMeter Test Plan
3.
JMeter Controllers
3.1.
Samplers
3.2.
Logic Controllers
4.
Detailed View at Samplers
5.
Detailed View at Logic Controllers
5.1.
Simple Controller
5.2.
Transaction Controller
5.3.
Loop Controller
5.4.
While Controller
5.5.
ForEach Controller
5.6.
If Controller
5.7.
Once Only Controller
5.8.
Throughput Controller
5.9.
Interleave Controller  
5.10.
Random Controller
5.11.
Random Order Controller 
6.
Frequently Asked Questions
6.1.
What exactly are JMeter controllers?
6.2.
How many different sorts of controllers does JMeter support?
6.3.
What is Parallel Controller?
6.4.
What do JMeter samplers do?
6.5.
How does the transaction controller in JMeter operate?
7.
Conclusion
Last Updated: Mar 27, 2024

What do you mean by JMeter Controllers

Introduction

Hello Techies!

Have you been working with JMeter lately? Are you interested in knowing its vast potential and want to use the Test plan more efficiently with JMeter controllers? If yes, then we got you covered!

Introduction

Before moving forward with JMeter Controllers, let us have a view on what JMeter is and what we mean by JMeter Test Plan, and JMeter Controllers are a part of JMeter Test plan.

About JMeter

The Jmeter was initially developed to test web applications but was later modified to perform additional testing-related tasks. Stefano Mazzocchi of the Apache Software founding member developed JMeter. The first version, 1.0, was released in 1998. He created it solely to evaluate the performance of Apache JServ, and then the JMeter was redesigned to improve the user interface and include features for functional testing.

Jmeter logo

About JMeter Test Plan

A test plan is your JMeter script for running tests. Components like the Thread groups, logic controllers, controllers, listeners, timers, assertions, and configuration elements comprise a test plan.

A test plan includes all of the steps required to run the script. Everything in a test plan is executed in a top-to-bottom sequence or according to the test plan's defined sequence. The diagram below depicts the directory level of a test plan.

Test plan

 

Points to note on a Test Plan - 

  • Before running the entire test plan, the test plan is saved.
     
  • JMeter files or test plans are saved in the ‘.JMX’ extension. JMX is an open test format that allows the test plan to be run in a text editor.
     
  • Parts of the test plan can also be saved as a different selection. For instance, if you want to save an HTTP request sampler with a listener, you can save it as a test fragment and use it in other test scenarios.

Test plan panel

The above image shows the JMeter Test Plan Window.

JMeter Controllers

Broadly, the JMeter controllers can be divided into two types:

  • Samplers
  • Logic Controllers

Samplers

JMeter can send specific types of requests to a server using samplers. They simulate the request of a user for a page from the target server. For example, if you need to execute a POST, GET, or DELETE on an HTTP service, you can add an HTTP Request sampler.

Examples of some valuable samplers are −

  • HTTP Request
  • JDBC Request
  • Java Request
  • FTP Request
  • RPC Requests
  • SOAP/XML Request
  • JMS request
  • JUnit Test request
  • LDAP Request
  • Mail request
  • OS Process request
  • TCP request

 

For example:

HTTP REQUEST PANEL

Logic Controllers

Logic Controllers allow you to control the order in which Samplers in a Thread are processed. Logic controllers can reorder requests coming from any of their child elements. 

A few examples of logic controllers are:

  • ForEach Controller
  • While Controller
  • Loop Controller
  • Run Time Controller
  • IF Controller
  • Interleave Controller
  • Throughput Controller
  • Run Once Controller
  • Random Controller
  • Switch Controller
  • Transaction Controller
  • Once only Controller
  • Recording Controller

 

Let’s see the panel for while controller:

While Controller

Detailed View at Samplers

The path to launch the samplers in JMeter is as follows

  • First, click right on Thread Group 
  • Hover over the Add 
  • Hover Over the Sampler 
  • Click on the required Sampler

 

The image below shows the list of all the Samplers available under JMeter Controllers.

Thread Group

Let us look at some important Samplers, and what their panels look like.

 

  • HTTP Request- Sending HTTP/HTTPS requests to a server is made using an HTTP request. The most popular sampler for testing Web-based applications is this one.
     
JDBC Controller
  • JDBC Request- SQL queries are sent to database servers using JDBC requests.
     
JDBC Request
  • SOAP/XML-RPC Request- Sending SOAP requests to a SOAP web service is done using a SOAP/XML-RPC request.

     
  • Flow Control Action/Test Action- Test Action is a unique kind of Sampler that is used to insert pauses into a test rather than making a request to the server.
     
Test Action Controller
  • FTP Request- Sending file put and get requests to an FTP server via an FTP request.
     
FTP Controller
  • SMTP Sampler- A mail server that transmits emails using the SMTP/SMTPS protocol is tested using SMTP Sampler.
     
SMTP SAMPLER

 

Detailed View at Logic Controllers

The image below shows the list of all the Logic Controllers available under JMeter Controllers.

Logic Controllers

Now lets us explore some most used Logic JMeter Controllers along with a view at their panels.

Simple Controller

As the name signifies, this is the most basic of controllers and adds nothing to how your test executes other than acting as a storage space for samplers, pre-processors, post-processors, etc.

Simple Controller

Transaction Controller

This controller, which is once more quite simple, enables you to quickly select whether you want to include the time taken by a timer, pre- or post-processor, as well as the total duration of a series of samplers.

Transaction Controller

It is beneficial because performance metrics and response times at this level will be far more valuable to your business customers or product owners than they could be for the individual samplers that make up the high-level process. This is particularly true if you want to report performance just in relation to a high-level business process made up of a large number of samplers.

Loop Controller

To give you greater flexibility over your scenario profile, you may use the Loop Controller to move the number of iterations your samplers run away from the Thread Group.

Have a look at the Loop controller now:

Loop Controller

While Controller

JMeter documentation states, “Until the condition is "false," the While Controller runs its children.”

While Controller

Utilizing a counter to limit the number of iterations is one of the most effective methods for using a While Controller. The counter can be a variable or property created dynamically during test execution to give you even more control over your tests.

ForEach Controller

The ForEach Controller iterates through an array of values as suggested by its name. A variety of values is given to this controller, and the array is iterated until finished.

When coupled with a post-processor that pulls information from an earlier request, this controller is really helpful.

ForEach Controller

 

Examples from the real world include using an API or web page that returns data that you want to extract and test, such as several URLs, or using an endpoint that returns a list of customer records you want to pick each individually.

This controller works well in situations like this and whenever you need to iterate over a data array.

If Controller

If Controller

The if Logic Actions contains conditional expressions. These expressions are composed of:

  • variable references for instance ${myVariable},
  • constants such as the "test" string or the number 67,
  • comparison operators like < or >,
  • boolean operations && or ||.

Once Only Controller

This is a simple JMeter controller. It effectively executes only once, which is precisely what it says it does.

Once Only Controller

Throughput Controller

This controller has a terrible name because it doesn't regulate the test samplers' throughput; instead, it lets you choose how frequently its child samplers run.

Throughput Controller

Interleave Controller  

This is another pretty simple controller. Interleave Controller provides functionality to run all user request in each loop and requests in each loop will be in sequential order. One of the samplers stored in Interleave Controller will be made to run in each loop of the thread, but the samplers in each loop will be in sequential order. JMeter will alternate between each of the additional controllers for each loop iteration if you add Generative or Logic Controllers to an Interleave Controller.

Interleave Controller

Random Controller

Let's take a closer look at the Random Controller functions because it is very similar to the Interleave Controller.

In contrast to the Interleave Controller, the Random Controller chooses a Sub Controller at random for each cycle.

Random Controller

Random Order Controller 

Simply said, the samplers inside the Random Order Controller are executed in random order.

Random Order Controller

Frequently Asked Questions

What exactly are JMeter controllers?

To give you greater flexibility over your scenario profile, you may use the Loop Controller to move the number of iterations your samplers run away from the Thread Group. Examine the Loop Controller for JMeter. Consider a test plan that uses a thread group to manage the number of loops.

How many different sorts of controllers does JMeter support?

Samplers and logical controllers are the two different types of controllers in JMeter. These direct how a test is processed. JMeter is instructed to make requests to a server by samplers. If you want JMeter to send an HTTP request, add an HTTP Request Sampler.

What is Parallel Controller?

To create parallel requests, utilize the Parallel Controller. Submissions processed simultaneously rather than sequentially are referred to as similar requests. For instance, to manage AJAX requests or carry out other concurrent activities in a load script.

What do JMeter samplers do?

The actual requests made to the server by JMeter are known as samplers. Added to the Thread Groups are samplers. Users can select from requests in JMeter samplers based on their needs and send the request to the server.

How does the transaction controller in JMeter operate?

One of the controllers frequently utilized in JMeter scripts is the Transaction Controller. The purpose of it is to combine several sampler requests into one. The entire transaction is analyzed with the test result's response time and other performance indicators.

Conclusion

The foundation of your user scenarios and JMeter controllers can be incredibly potent when combined with other controllers in a single test plan. We hope this article has provided you with enough knowledge to experiment with JMeter Controllers.

For more information on JMeter, you can refer the following articles:

Please refer to our guided paths on Coding Ninjas Studio to learn more about DSA, Competitive Programming, JavaScript, System Design, etc. And also, enroll in our courses and refer to the mock test and problems available. Have a look at the interview experiences and interview bundle for placement preparations.

Keep learning, and Keep Growing!

Live masterclass