In the previous tutorial, we studied about Samplers and different types of Sampler requests avialable in JMeter. In this tutorial, we will be studying about Logic Controllers that customize the way different requests are sent to the server.
Logic Controllers are the Test Plan elements that are used to customize the order of processing of Samplers and other elements added as child. Primarily, Logic Controllers are used with Sampler requests to perform various customizations like - altering their order of processing, grouping them as a transaction or running the requests in loop etc.
Steps to launch a Logic Controller-
Performance test scripts are used to simulate the actions of real users. Just like a real user will perform multiple actions in different fashion like perform a set of operations sequentialy(e.g. navigate from login page to home page), perform similar types of operations in a loop(e.g. reading multiple unread mails), perform some random operations etc. For simulating these different types of actions, JMeter provides us different types of Logic Controllers which customize the element processing inside them.
Now, lets see various Logic Controllers provided by JMeter-
This is a newely added controller in JMeter. It ensures that the child elements of this controller are accessed by only one thread at a time.
This controller is used to perform the requests in loop, based on the values of a set of related variables.
Using If Controller, we can specify a condition whether the child element inside it will run or not based on a condition which should evaluate to true or false.
The Include Controller can be used to provide modularity in JMeter. Using this controller we can add an external .jmx file(a test fragment) to our existing script by loading the jmx file in the Include Controler's control panel.
Interleave Controller allow us to pick and execute a single child element out of multiple child in each loop iteration. Eor example- if we have three samplers added as child to an Interleave Controller than the in first iteration it will pick the first sampler request, in next iteration it will pick the next one and so on. Once the child elements are over, it again starts iteration from first element.
It allows to execute the operations specified as child elements in a loop with iteration value specified in its control panel.
Using Module Controller, we can reuse a test fragment(e.g. a sampler) into our script again by selecting the module from the Module Controller's control panel.
The once only controller is used in situation where we would like to perform an operation only once even if the operation is executed in a loop.
It is similar to random controller and picks a single child element in each iteration but unlike Interleave controller it picks the child element randomly.
The Random Order controller is used to execute each of its child element at most once in a random order.
This controller acts as a placeholder where the scripts recorded using HTTP Proxy Server are recorded by default(for details on Record and Playback in JMeter check our tutorial).
Runtime controller is used to limit the time of execution of its child elements. For example, if we have specified the value of 'Runtime' as 100 seconds then the elements inside the Runtime controller will run for 100 seconds with as much iteration as possible.
This controller is just a placeholder for grouping and ordering the different elements of test plan.
This controller is used to pick one element for processing out of its multiple child elements. The element are picked not in sequential order or random order instead it is based on a switch value defined in its cotrol panel. The switch value can be an variable with value evaluated to its index(position) of the element or name of the element. For example, if in first iteration the switch value is evaluated to '3' then the fourth element is picked for processing(index value starts from 0). Similarly, if switch value is evaluaetd to an element's name then that element is picked for processing.
The Throughput Controller is used to control the processing of its child elements in terms of the total number of executions or the percentage of execution specififed in its control panel.
The Transaction Controller is one of the widely used controller in JMeter scripts. It is used to group multiple sampler requests into one. The response time and other performance matrics of the test result are evaluated for the whole transaction. For example - while checking performance of home page of an application, we can notice that launching the home page generates numerous requests at the backend. Hence, this requires grouping all these request into one transaction, for this we have transaction controller in JMeter. Once we run the script, we can find the overall response time of the whole transaction.
The While controller is used to run the child elements inside it till the value specified in its control panel is evaluated to false.