jmeter (nine) logic controller

The scope of Logic Controllers in jmeter is only valid for the sampler of its child nodes, and its role is to control the execution order of the sampler.

jmeter provides 17 kinds of logic controllers, each of which has different functions, and can be roughly divided into 2 types of use:

①. Control the logical execution sequence of nodes during the execution of the test plan, such as: Loop Controller (loop controller), If Controller (if if controller), etc.;

②. Group the scripts in the test plan to facilitate JMeter to count the execution results and perform runtime control of the scripts, such as: Throughput Controller (throughput controller), Transaction Controller (transaction controller), etc.

 

jmeter provides the following 17 logic controllers:

 

1. Critical section Controller

Role: The critical section controller ensures that the sampler or controller under its child nodes will be executed (only one thread acts as a lock)

The name and comment are very simple, it is to add a comment to the controller, so that people can understand the meaning of the explanation of the controller

Lock name: lock name, here you can fill in the name of the thread executed under its child node, this thread is stored as a global lock

 

2. ForEach Controller

Function: used to traverse all executable scenes of the current element; read a series of related variables in user-defined variables, the sampler or controller under the controller will be executed one or more times, each time a different read the value of the variable;

Input variable prefix: enter the user parameter (User Parameter) that needs to be traversed in it

Start index for loop (exclusive): the loop index starts (unique) → traverse the variable range of the query, the starting value (if not filled here, the default starts from 1, if there is no variable starting from 1, an error will be reported during execution)

End index for loop (inclusive): the end of the loop index (inclusive) → traverse the variable range of the query, the end value

Output variable name: Assign the qualified user parameters obtained from the traversal query to the input variable (Vname), and then use it in the sampler under the controller, the format is ${output variable name }

Add " _" before number: Whether to use "_" in the input variable name for interval

PS: This controller is generally used in conjunction with the configuration element → regular expression extractor, which can repeatedly process certain elements on the page.

 

3. Include Controller

Role: used to reference external Jmx files; thus controlling the combination of multiple test plans

include Test Plan: contains the file name of the test plan, you can click to browse and select the corresponding JMX file from the JMX folder directory saved in the folder

How to use: Create a test plan, add samplers/controllers, etc. below, and then save the test plan. For convenience,  thread groups can also be added to external JMX files for debugging;

If the test uses cookies or user-defined variables, these should be placed at the top level (including the file), otherwise it will not work; this element does not support variables/functions in the filename field; however, if it belongs to something that contains controller definitions, then Use prefix pathnames.

When using an include controller to include the same JMX file, make sure the filename is different to avoid being unreadable; if the file cannot be found, then the controller will try to open the filename relative to the JMX startup directory.

 

4. Lifecycle/ Runtime Controller

Function: used to control the running time of the sampler/controller under this controller

Runtime (seconds): running time, in seconds

 

5. Switch Controller

Function: Specify which sampler to run by assigning a value to the value in the controller (it can also be understood as a switch controller)

Switch value: The value field of the controller's specific assignment

There are two assignment methods:

①. The first is the numerical value. The child nodes under the Switch controller are counted from 0, and which element to execute is determined by specifying the numerical value of the child node.

②. The second is to directly specify the name of the child element, such as the name of the sampler, to match. When the specified name does not exist, no element is executed.

When Value is empty, the first child node element is executed by default.

 

6. While Controller (While Controller)

 Action: run the sampler/controller under its child node until the condition is "false"

Condition(function or variable): Condition (function or variable): The condition of the judgment basis can be filled in, refer to

How to use: Possible condition values ​​are:

①. Blank: Exit the loop when the last example loop fails

②.Last value: Exit the loop when the last example loop fails. If the last example before just failed the loop, don't enter the loop.

③. Else: when exiting (or not entering) the loop condition is equal to the string "  false  "

Condition can be any variable or function that eventually equals the string "  false  ". It should be noted that the condition is evaluated twice, once before sampling, and once at random

 

7. Transaction controller

What it does: Generates an additional sampler to measure the overall time of the test element under it; it is worth noting that this time includes all processing time within the scope of this controller, not just the sampler's

Generate parent sample: Generate parent sample (different mode choices)

include duration of timer and pre-post processors in generated sample: a sample generated by timer and pre-post processors including time (different mode choices)

For versions above Jmeter 2.3, there are two modes of operation

①. The transaction sampler is added to the back of its downsampler

②. The transaction sampler is the parent sampler as its downsampler

The measured time of the generated transaction sampler includes its downsampler and everything else. Due to clock frequency issues, this time may be slightly larger than the sum of the individual sampler times;

The clock start time is between the controller recording start time and the start of the first sampler, and the clock end time is also the same.

A transaction sampler only shows success if all of its subsamplers succeed.

In parent mode, each sampler under the transaction controller can only be seen in the result tree; at the same time, the data of subsamplers will not be displayed in the CSV file, but can be seen in the XML file.

 

8. creatleave controller

Effect: Alternate control, so that the sampler steps contained in this controller are interleaved in each cycle

Ignore sub- controller blocks: If checked, interleaved controllers treat sub-controllers like single request elements, allowing only one request/controller at a time

How to use: If there are 2 samplers A and B under the controller, execute A and B 2 requests alternately, that is, pass a sub-request to this test each time, according to the order of the sub-components

 

9. Once only controller

Function: When the multi-threaded loop is running, the sampler request under its child node will only run once

 

10. Throughput controller

Function: The translation that comes with jmeter is wrong here, because it does not control throughput (please Baidu for the concept of throughput); its essential function is to allow users to control the frequency of execution

There are two execution modes in total: percent execution and total execution

Total Executions: Stop the controller from executing a certain number of test plans

Percent Executions: Causes the controller to execute an iterative test plan at a certain percentage

Throughput : corresponds to the number or proportion of the above execution

Per User: per user

If checked, will cause the controller to calculate whether the calculation should be performed on a per-user (per-thread) basis; if left unchecked, it will be calculated for all users globally

 

11. If Controller

Function: Allow the user to control whether the sampler/controller under the controller executes the child nodes under the node;

Condition (default JavaScript) ( Condition(default javascript) ) : Use JavaScript functions or variables to evaluate to determine whether the condition is true or false

interpret condition as variable expression: If checked, the variable expression is evaluated and compared to "true" or "false" without using JavaScript

Execute for all children (evaluate for all children): If this option is checked, the controller will be executed once when no child nodes are executed;

By default, the controller can execute all runnable elements contained below it, but only once at the entry point

 

12. Recording Controller

Role: similar to the role of a proxy server, recording test samples during test execution

Clear all the recorded samples: Click to clear all recorded test samples

In general, when the test is executed, it has no effect, but when the HTTPS test script is executed, all test samples are recorded

 

13. Loop Controller

Role: The sampler request under this controller can run cyclically

Loop Count: Enter the number of loops required in the input box, and the request under the controller can run in a loop

Forever : If this option is checked, the request under the controller can always run

 

14. Module Controller

Role: test a module under the controller sub-node, not the entire test plan

 

Find target element (Find target element): Find the element, module in the test plan that needs a specific test; it can also be understood that the controller can control the module element that has been encapsulated

△ : A test plan consists of a controller and all test elements (samplers, etc.), the test plan can be in any thread group or workbench; if the plan is in a thread group, other controllers can be disabled to prevent running tests Plans are affected (except for module controllers)

     The advantage of the module controller is that when there are multiple thread groups, the controller can be easily switched, and only the corresponding sampler needs to be selected, which is convenient and fast, and replaces the tedious operation of creating many test plans

△ : The controller name used by any one module must be unique, because its name is used to find the target controller when reloading; for this reason, it is best to ensure that the controller names are different, otherwise there may be accidents when executing the test

△: The module controller and remote tests should not use or non-gui tests and workbench components, because the workbench test element is not part of the test plan  jmx  file. Any such test will fail

 

15. Simple Controller

 Function: used to combine samplers and other logic controllers

Simple controller is the most basic controller and has no effect on the jmeter test run and can be used to name certain actions

 

16. Random Controller

Function: similar to the alternate controller, but the controller randomly selects a sampler request and executes it

Ignore sub-controller blocks: If checked, interleaved controllers treat sub-controllers like a single request element, allowing only one request/controller at a time

 

17. Random Order Controller

Role: Similar to a simple controller, the sampler request under each child node will be executed once, but the execution is random

After inquiring a lot of information and referring to the content of other bloggers, it can be said that the results are not ideal. Most of the documents on the official website of jmeter are translated directly with the translation dictionary and then posted.

Occasionally see an article, but also a few strokes, about the specific use of these controllers, I also tried to use it, it is not difficult, there may be a little error, please forgive me. . .

Official website document address: http://jmeter.apache.org/usermanual/component_reference.html#logic_controllers

Reference blog: http://www.cnblogs.com/kuihua/p/5537083.html

         http://www.cnblogs.com/puresoul/p/4886574.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324746860&siteId=291194637