Controllers in JMeter: Loop, Simple, Transaction, Module, Random

Tram Ho

So what is Logic Controller? What types of Logic Controllers are commonly used? Frequently asked questions when you use JMeter. If the requests defined in the test plans to be executed depend on some logic, then Logic Controllers will be needed. Through the description below can partly help with the above questions.

1. What is Logic Controller?

Logic Controller allows to determine the order of request processing in a thread. It allows you to control when to send user requests to a web server. For example, you can use Random Controllers to randomly send HTTP requests to the server.

Logic Controllers determines the order in which the user requests are executed. Some of the commonly used Logic Controllers are below:

Recording Controller

JMeter can save Test steps; recording controller is a placeholder for recording steps.

Simple Controller

Simple Controller is a container that stores the user requests.

Loop Controller

The Loop Controller makes user requests run for a specified number of times or iterate infinitely as shown in the figure:

Random Controller

The Random Controller makes all user requests run in a random order in each loop.

For example, you have 3 user requests to the website http://www.google.com in the following order:

HTTP request FTP request JDBC request these 3 requests run 5 times; So a total of 5 user requests will be sent to Google servers by JMeter.

According to sequential, requests are sent in order of HTTP request -> FTP request-> JDBC request in each loop. If the order is random, the requests will be sent randomly, FTP request -> HTTP request-> JDBC request Or JDBC request -> FTP request-> HTTP request in each loop.

Controller module

Module Controller’s goal is to add modules to JMeter.

Web applications include small functional units (eg Login, Create Account, Sign Out …). This functionality can be stored in the Simple Controller as “modules”. The Controller module will select the module to run.

Consider the following scenario:

You want to simulate:

50 users logging out, 100 users logging in 30 users search www.google.com You can use JMeter to create 3 modules. Each module simulates each user activity: Login, Logout, and Search.

The controller module selects the module to run:

Other important controllers

Interleave Controller: selects and executes one of the user requests that run in each thread loop. Runtime Controller: controls the time allowed to run. For example, if you specify Runtime Controller to run for 10 seconds, JMeter will run the test for 10 seconds.

  • Transaction Controller: measures the total execution time to complete the test.
  • Include Controller: designed to use extensible testing package. This controller allows you to use multiple test plans in JMeter. See details in the article Using JMeter for performance testing

Loop Controller Example

This section describes step-by-step instructions for adding a Loop Controller to a test performance plan.

The Loop Controller causes the samplers to run according to the specified loop number or the loop value specified for the Thread Group. For example:

Add an HTTP Request to the Loop Controller with the loop number 50. Configure the Thread Group loop number to 2. After that, JMeter will send a total of 50 * 2 = 100 HTTP Requests. Here’s how it works:

Step 1. Configure Thread Group

1. Add Thread Group

Right click on Test Plan and add a new thread group: Add-> Threads (Users) -> Thread Group

But in the Thread Group panel, enter Thread Properties as follows:

It will send a user request to google.com web server and run 2 times.

2. Add JMeter elements

Add the default HTTP request which is www.google.com .

3. Add Loop Controller

Right click on Thread Group -> Logic Controller -> Loop Controller

Step 2. Configure Loop Controller

Add the value 50 to the Loop Count field as shown below. A user request sent to web server google.com will run 50 times. If loop value = 2, JMeter will send a total of 2 * 50 = 100 HTTP Requests.

Right click on Loop Controller, Add -> Sampler -> HTTP request

Step 3. Add View Results in Table

So the test plan is shown in the image below:

Step 4. Run the test

Now go back to View Results in Table, click the Start button on the Menu bar (Ctrl + R) to run the test.

As shown in the figure below, JMeter simulates a user request sent 100 times to the web server http://www.google.com/ . The test stops after the user request is sent 100 times.

Resovle problem:

If you encountered the problem while running the above scenario, please do as follows:

  1. Check if you are connecting to the internet through a proxy. If it does, remove the proxy.
  2. Start Jmeter.
  3. Open the TestPlan.jmx Driver in Jmeter.
  4. Click Topic Group -> View Results in Table.
  5. Test

References: https://www.guru99.com/controllers-in-jmeter.html

Share the news now

Source : Viblo