This document describes various logic controllers in JMeter including:
- Simple, Loop, Once Only, Interleave, Random, Random Order, Runtime, Throughput, If, While, Switch, ForEach, Module, Transaction, and Recording controllers. Each controller provides different functionality to organize, iterate through, and control the execution of samplers and sub-controllers.
2. Simple Controller
Loop Controller
Once Only Controller
Interleave Controller
Random Controller
Random Order Controller
Runtime Controller
Throughput Controller
If Controller
While Controller
Switch Controller
For Each Controller
Module Controller
Transaction Controller
Recording Controller
Confidential
3. The Simple Logic Controller lets you organize your Samplers and other Logic Controllers.
Unlike other Logic Controllers, this controller provides no functionality beyond that of a
storage device.
The Simple Logic Controller has no effect on how JMeter processes the controller(s) you
add to it. So, in this example, JMeter sends the requests in the following order: Ant Home
Page, Ant News Page, Log4J Home Page, Log4J History Page.
Confidential
4. If you add Generative or Logic Controllers to a Loop Controller, JMeter will loop
through them a certain number of times, in addition to the loop value you specified
for the Thread Group.
We configured the Thread Group for a single thread and a loop count value of one.
Instead of letting the Thread Group control the looping, we used a Loop Controller.
We added one HTTP Request to the Thread Group and another HTTP Request to a
Loop Controller. We configured the Loop Controller with a loop count value of five.
Confidential
5. Now JMeter will send the requests in the following order:
Home Page, News Page, News Page, News Page, News Page, and News Page.
Confidential
6. The Once Only Logic Controller tells JMeter to process the controller(s) inside it
only once, and pass over any requests under it during further iterations through the
test plan.
Confidential
7. We created a Test Plan that has a thread which sends a request to Home page and
followed by a Bug page.
Now we configured Thread group to iterate 3 times.
JMeter thread sends only one request to the Home page because it was in the
Once Only Controller.
JMeter will send the requests in the following order:
Home Page, Bug Page, Bug Page, Bug Page
This controller will be helpful for testing that requires login session once ( same as
vuser_init() in Load Runner)
Confidential
8. If we add an Interleave Controller , JMeter will alternate among each of the other
controllers for each loop iteration.
We configured the Thread Group and a loop count of five for a Test Plan.
Confidential
9. See the table below for the sequence JMeter sends the HTTP Requests.
Loop Iteration Each JMeter Thread Sends These HTTP Requests
1 News Page
1 Log Page
2 FAQ Page
2 Log Page
3 Gump Page
3 Log Page
4 Because there are no more requests in the controller,
JMeter starts over and sends the first HTTP Request, which is the News Page.
4 Log Page
5 FAQ Page
5 Log Page
Confidential
10. The Random Logic Controller acts similarly to the Interleave Controller, except that instead of
going in order through its sub-controllers and samplers, it picks one at random at each pass.
Confidential
11. The Random Order Controller is much like a Simple Controller in that it will execute each child
element at most once, but the order of execution of the nodes will be random
Confidential
12. The Throughput Controller allows the user to control how often it is executed. There are two
modes - percent execution and total executions. Percent executions causes the controller to
execute a certain percentage of the iterations through the test plan. Total executions causes the
controller to stop executing after a certain number of executions have occurred. Like the Once
Only Controller, this setting is reset when a parent Loop Controller restarts.
Confidential
13. The Runtime Controller controls how long its children are allowed to run.
Confidential
14. The If Controller allows the user to control whether the test elements below it (its children)
are run or not.
Confidential
15. The While Controller runs its children until the condition is "false".
Possible condition values:
1. blank - exit loop when last sample in loop fails
2. LAST - exit loop when last sample in loop fails. If the last sample just before the
loop failed, don't enter loop.
3. Otherwise - exit (or don't enter) the loop when the condition is equal to the
string "false"
Confidential
16. The Switch Controller acts like the Interleave Controller in that it runs one of the
subordinate elements on each iteration, but rather than run them in sequence, the
controller runs the element number defined by the switch value.
If the switch value is out of range, it will run the zeroth element, which therefore acts as
the default.
Confidential
17. ForEach controller loops through the values of a set of related variables. When you add samplers
(or controllers) to a ForEach controller, every sample sample (or controller) is executed one or
more times, where during every loop the variable has a new value.
The input should consist of several variables, each extended with an underscore and a number.
Each such variable must have a value .
We created a Test Plan that sends a particular HTTP Request only once and sends another HTTP
Request to every link that can be found on the page.
Confidential
18. We configured the Thread Group for a single thread and a loop count value of one. You can see
that we added one HTTP Request to the Thread Group and another HTTP Request to the
ForEach Controller.
After the first HTTP request, a regular expression extractor is added, which extracts all the html
links out of the return page and puts them in the inputVar variable
Confidential
19. The Module Controller provides a mechanism for substituting test plan fragments into the
current test plan at run-time. To use this module effectively, one might have a number of
Controllers under the WorkBench , each with a different series of samplers under them. The
module controller can then be used to easily switch between these multiple test cases
simply by choosing the appropriate controller in it's drop down box. This provides
convenience for running many alternate test plans quickly and easily.
Confidential
20. The Include Controller is designed to use an external jmx file. To use it, add samples to a simple
controller, then save the simple controller as a jmx file. The file can then be used in a test plan.
Confidential
21. The Transaction Controller times how long it takes for all its children to run. It then adds a
"sample" entry to the test output with the total elapsed time. The name of the element is used to
name the "sample".
Confidential
22. The Recording Controller is a place holder indicating where the proxy server should record
samples to.
During the test run, it has no effect, similar to the Simple Controller.
But during recording using the HTTP Proxy Server , all recorded samples will by default be saved
under the Recording Controller.
Confidential