Jmeter Controllers | Logic controller in jmeter - jmeter - jmeter tutorial



What is Logic controller in jmeter?

  • Logic Controller let you handle the order of processing Samplers/Requests in a Thread. Logic Controllers will decide “When & How” to send a request to a web server.
  • learn apache jmeter tutorials - jmeter-performance-testing test execution and test plan

    learn apache jmeter tutorials - jmeter-performance-testing test execution and test plan Example

JMeter provides several Logic Controller, which are as follows:

  • Critical Section Controller
  • ForEach Controller
  • If Controller
  • Include Controller
  • Interleave Controller
  • Loop Controller
  • Module controller
  • Once Only Controller
  • Random Controller
  • Random Order Controller
  • Recording Controller
  • Runtime Controller
  • Simple Controller
  • Switch Controller
  • Throughput Controller
  • Transaction Controller
  • While Controller

Let’s discuss some of the important Logic Controllers:

1: Include Controller

Include Controller is made to use an external test plan. This controller allows the usage of multiple test plans in JMeter.

 process of include controller
jmeter tutorials - jmeter load testing - jmeter download - download jmeter - apache jmeter

2: Interleave Controller

Interleave Controller will select only one samplers/requests stored in it, to run in each loop of the thread. It will execute the samplers sequentially.

 process of interleave controller
  • You can give descriptive name for the controller (optional)
  • If checkbox is selected, the interleave controller will consider sub-controllers as single request elements and permit only one request per controller at a time (optional)

Let’s consider an example of Interleave Controller, where Thread Group contains “Number of Threads” to “1”, “Loop Count” to 5, and a total of “4” Samplers (Http requests).Total 1 * 5 * 4 = “20” requests will be sent to web server under test without using any Logic Controller. You can see details in the below figure:

 logic controller without using in interleave controller

Total “5” requests will be sent to web server under test by using Interleave Controller in sequential order i.e. 1 request per loop. You can see details in the below figure:

 sequential order in interleave controller
  • You can see “4” Http Requests/Samplers under Interleave Controller node on the left panel.
  • Only 5 Http Requests are being sent to the web server (one request for each loop)

3: Loop Controller

Loop Controller will run the samplers/requests stored in it for the definite number of times or forever (if forever checkbox is selected).

  • Select Forever checkbox to run tests for infinite times
  • Enter loop count number to run tests for a fixed number of times
 process of loop controller

For Example, Thread Group loop count is set to “2”, Loop Controller loop count is set to “2”, and “3” requests are present under Loop Controller node, then JMeter will send a total of “30” Http Requests to the web server under test.Total Requests (12) = Thread Group loop count (2) * Loop Controller loop count (2) * Number of Requests inside Loop Container (3)Let’s compare the requests sent with or without Loop Controller:Without Loop Controller, “6” requests are sent to the web server:

After adding Loop Controller with Loop Count to “2”, a total of “12” Http requests are sent to the web server.

 usage of loop controller
 web server access view

4: Module Controller

  • Module controller adds modularity to the JMeter Test Plan.
  • Normally we construct test plan consists of small units of functionality like Login, Add Product, Logout.
  • The functionality can be stored inside Controllers as modules e.g. “Simple Controller” can be used to store each module inside it.
  • In order to run modules by only Module controller, don’t forget to disable Simple Controller.

Select Controller > Right Click > Select “Disable” Option

 process of module controller
  • Simpler Controller has been disabled, in order to run this fragment by “Module Controller” only.

In our example, only the selected Module will run:

 access of module controller
  1. Select any listed Module e.g. “Login Simple Controller 1”
  2. Run

5: Random Controller

  • Random Controller is similar to “Interleave Controller” except that it makes samplers/requests to run in random order in each loop.
  • For Example, you have defined “4” Http requests under “Random Controller”, then these requests will be sent in random order and their order of execution will be decided on run-time.
 process of random controller
  1. Random Controller contains “4” samplers/requests in the left panel
  2. You can give descriptive name for the controller (optional)
  3. If checkbox is selected, the Random Controller will consider sub-controllers as single request elements and permit only one request per controller at a time (optional)

Let’s consider an example of Random Controller, where Thread Group contains “Number of Threads” to “1”, “Loop Count” to 5, and a total of “4” Samplers (Http requests).

As you can see in the following figure:
 access of random controller

6: Random Order Controller

  • Random Order controller is similar to “Simple Controller”, it will make all samplers to run in random order in each thread loop.
  • Let’s consider an example of Random Order Controller, where Thread Group contains “Number of Threads” to “1”, “Loop Count” to 5, and a total of “4” Samplers (Http requests). A total of 1 * 5 * 4 = “20” requests will be sent to the web server under test. The order of execution will be random.

as you can see in the following figure:

 process of random order controller
jmeter tutorials - jmeter load testing - jmeter download - download jmeter - apache jmeter

7: Recording Controller

Recording Controller is a place holder where proxy server can save recorded requests. It has no effects on test execution. As you can see in the following figure:

 process of recording controller
  1. Recording Controller node has all the recorded steps/requests
  2. For recording, “HTTP(S) Test Script Recorder” by default use “Recording Controller”, to store recorded steps
  3. Click to clean all the steps recorded inside “Recording Controller”

8: Runtime Controller

Runtime Controller controls the execution of its samplers/requests for the given time. For example, if you have specified Runtime(seconds) to “20”, JMeter will run your test for 20 seconds only.

 process of runtime controller

9: Simple Controller

Simple Controller helps in organizing and storing the Samplers and other Logic Controllers. It doesn’t offer any other functionality like other controllers.

 process of simple controller

This jmeter tutorial site provides you to the following keypoints on meter interview questions , apache jmeter download , apache jmeter , jmeter load testing , jmeter plugins , jmeter download , download jmeter , jmeter tutorials , load testing jmeter , jmeter summary report , jmeter apache , jmeter api testing , what is jmeter , jmeter load testing example , learn jmeter , how jmeter works , jmeter web service testing , jmeter example , jmeter load testing tutorial , install jmeter , load testing with jmeter , download jmeter for windows , performance testing using jmeter , jmeter functions , mobile app performance testing using jmeter , jmeter gui , install jmeter ubuntu , jmeter stress test , how to use jmeter

Related Searches to Jmeter Controllers | Logic controller in jmeter