Hire QA – Specialized in QA Recruitment, Technical Interviews and Testing Solutions

What is Logic Controllers in JMeter?

Category: JMeter

Logic Controllers help you to control the flow of the order of processing of samplers in a thread. It can also change the order of requests coming from their child elements.

Interleave ControllerInterleave controller will select only one sample / request stored in it, to run in each loop of the thread. It will execute the samplers in sequentially.
Once Only ControllerRequests added to this controller will run only once irrespective of number of users/loop count specified in the thread group.

This comes into use, when one wants all other requests run more than once but a particular request or set of requests to run only once during the entire test plan.
Include ControllerInclude Controller is made to use an external test plan. This controller allows the usage of multiple test plans in JMeter.
Runtime ControllerRuntime 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.
Loop ControllerLoop Controller will run the samplers/requests stored in it for the definite number of times or forever (if forever checkbox is selected).
Module ControllerThe module controller adds modularity to the JMeter Test Plan.
Module controller allows you to redirect test execution to a given fragment of the test or you can say selected module.
Recording ControllerRecording Controller is a place holder where the proxy servers can save recorded requests. It has no effects on test execution.
Transaction ControllerUseful to measure over all time taken to perform complete transaction.
Transaction controller will add additional sample after nested samples to show total time taken by it’s nested samples.
Generate parent sample
Transaction controller has option “Generate parent sample” and “Include duration of timer and pre-post processors in generated sample”
Random Order Controller ExampleRandom order controller in apache jmeter is used to execute requests of jmeter software load test plan in random order. This is the only difference between simple controller and random order controller.
Random ControllerAs you know, controllers in jmeter are useful to control execution flow in different ways. Random controller will execute any request randomly. It will pick any request from it’s request tree and force to execute is. Every time it will pick different request randomly.
Switch ControllerAs name suggest, You can switch your targeted software application page request to run using Switch Controller.
IF ControllerIf controller in jmeter allows you to set condition to evaluate it and based on condition evaluation result it will decide to run or not to run if controller’s child elements. If condition evaluation result is positive then child elements of if controller will run else child elements of if controller will not run.
“${title}”==”Yahoo”
Throughput ControllerThis controller does not control the Throughput.
Primary objective of Throughput Controller is to define and control the User Load for each group separately under same Thread Group.

Throughput Controller has 2 options: Total Executions, Percent Executions.

1) Total Executions: All child requests placed under this controller will be executed as per defined number. The thread creation will stop after the defined number of execution have occurred.
– Per User Checked: The number given for throughput will be the total number of executions for current controller.
– Per User Unchecked: Total number of Threads(Users) given under Thread Group will be the total number of executions for current controller.
2) Percent Executions: All child requests placed under this controller will be executed according to the percentage defined under Throughput field.
While ControllerThe purpose of the While Controller is to repeat a given set of actions until the condition is broken.
For example, you simulate a user who buys all the goods within a random product category. The number of goods to buy varies depending on the category.

In JMeter, the While controller runs all the Samplers which are located underneath, unless some predetermined “Condition” is “true” where “Condition” could be:

blank: exits when the last sampler in the loop fails,
LAST: the same as blank, but with an additional check for the last Sampler before the loop result. If the preceding Sampler is not successful, the While Controller and its children won’t be executed at all,
JMeter Function or Variable: children will be run until a variable or function evaluation result is false,
JMeter Property: it works the same way as a Function or Variable, but assumes the value of a JMeter property instead.

“${myVar}” != “some value” – doesn’t work, as it is neither a function nor a single variable.
${__javaScript(“${myVar}” != “some value”,)} – works OK as the expression resolves it to either be “true” or “false”.
${__javaScript(${counter}<=5)}
${__javaScript(parseInt(vars.get(“counter”))<=5)}
${__javaScript(! “${CFY_g4}”.endsWith(‘label1’) || (! “${CFY_g6}”.match(‘Current Fiscal YTD’)) )}

Leave a Reply

Your email address will not be published. Required fields are marked *