JMeter (ix) Introduction of logic controller and its application direction

Source: Internet
Author: User

Previous blogs have introduced the scope of components in JMeter, where the scope of the logical controller (logic Controllers) is only valid for sampler of its child nodes, and the logical controller's role is to control the order in which the samplers are executed.

The JMeter provides 17 logic controllers, each of which can be divided into 2 types of use:

①. Control the sequence of logical execution of the nodes during the execution of the test plan, such as loop controller (looping controllers), if controller (if controllers), etc.;

②. Grouping scripts in the test plan to facilitate jmeter statistical execution results and run-time control of scripts, such as: Throughput controller (throughput controllers), Transaction controller (transaction Controller), etc.

The JMeter provides the following 17 types of logic controllers:

One, Critical Zone controller (critical section controllers )

Function: The critical zone Controller ensures that the sampler or controller under its sub-node will be executed (only one thread as a lock)

The name and the comment are simple to add a note to the controller to make sense of the meaning of the Controller's interpretation

Lock name : The name of the lock, which can be filled in with the names of the threads executing under its child nodes, which are present as a global lock

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

2. Traversing loop controller (ForEach controllers)

Function: Used to traverse all executable scenes of the current element, and to read a series of related variables in a user-defined variable, the sampler or controller under the controller is executed one or more times, each time it reads a different value of the variable, so it is always used with the user-defined variable

input variable prefix: Enter user parameters to traverse in it (user Parameter)

Start index for Loop (exclusive): Loop index Start (unique) → traverse the variable range of the query, starting with the value

End index for Loop (inclusive): loop exponential end (inclusive) → Traversal of variable range for query, end value

output Variable name: assigns a traversal query to the qualified user parameter to the input variable (vname), then can be used in the sampler under the controller, in the format of ${output variable name }

Add " _ "before number: Enter the variable name with"_ " in the interval

Reference blog:http://blog.sina.com.cn/s/blog_794d9c8801019dit.html

3, contains the controller (Include Controller)

function: used to refer to external jmx files, thereby controlling multiple test plan combinations

include test plan: Contains the file name of the beta program, you can click Browse, select the corresponding jmx file from the Jmx folder directory saved by the folder

How to use: Create a test plan, the following can add sampler/controller, and then save the test plan, for the sake of convenience, the thread group can also add external jmx file for debugging;

If the test uses cookies or user-defined variables, these should be placed at the top level (including files), otherwise it will not work properly; This element does not support variables/functions in the File Name field; Span id= "outfox_jtr_trans_node-3472" class= "Outfox_jtr_trans_node" > But if it belonged to contains controller

when using the include controller to include the same JMX file, make sure that the file name is different to avoid unreadable, and if the file cannot be found, then the controller tries to open the file name relative to the JMX startup directory.

4. Life cycle/Operating cycle controllers (Runtime Controller)

Function: Used to control the operating time of the sampler/controller under the controller

Runtime (seconds): elapsed time, in units of: seconds

5. Switch Controller

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

Switch Value: The Value field of the controller-specific assignment

There are two ways to assign values:

①. The first is the value, and the child node under the switch controller counts from 0, determining which element to execute by specifying the numeric value of the child node.

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

When value is empty, a 1th child node element is executed by default.

6, when/judging the controller (while controllers )

Function: Run the sampler/controller under its sub-node until the condition is "false"

Condition (function or variable): conditions (functions or variables): The conditions in which the judgment is to be filled in, reference

How to use: possible criteria values are:

①. Blank: Exit loop When last example loop fails

②. Last value: exits the loop when the last example loop fails. If the last example before is just a loop failure, do not enter the loop.

③. Otherwise: When exiting (or not entering) the loop condition equals the string " false "

The condition can be any variable or function, eventually equal to the string " false ". It is important to note that: conditions are evaluated two times, one sample before sampling, one random sampling

7. Transaction controllers (transaction Controller)

Function: Generate an additional sampler to measure the overall time of the test element under it; it is worth noting that this time contains all the processing time in the controller range, not just the sampler's

Generate Parent Sample: Generation of parents (different mode selection)

include duration of timer and pre-post processors in generated sample: Timer with time and pre-and post processor-generated samples (different mode selection)

For versions above Jmeter2.3, there are two modes of operation

①. The transaction sampler is the one that is added after the sampler below it.

②. The transaction sampler is the parent sampler for its down sampler

The measured time of the generated transaction sampler includes its down sampler and all other times. Due to the clock frequency problem, this time may be slightly larger than the sum of the time of a single sampler; the clock start time is between the start time of the controller record and the beginning of the first sampler, as well as the clock end time.

The transaction sampler only displays success if its sub-sampler is successful.

In parent mode, each sampler under the transaction controller is visible only in the result tree, and the data for the sub-sampler is not displayed in the CSV file, but it can be seen in the XML file.

8. Alternating controllers (Creatleave Controller)

Function: Alternate control that allows the controller to include sampler steps interleaved in each loop

Ignore sub-controller module (Ignore sub-contorller blocks): If checked, the interleaved controller will sub-controllers like a single request element, allowing only one request/controller at a time

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

9, only one time controller (once only controllers )

Function: In a multithreaded loop, the sampler request under its child nodes is run only once

10, Flow control (throughput Controller)

Role: JMeter comes with the translation here is wrong, because it does not control the throughput (the concept of throughput please own Baidu); its essential role is to allow the user to control the frequency of execution

There are a total of two execution modes: percent execution and total execution

Total Executions: Causes the controller to stop executing a certain number of test plans

percent Execution (Percent executions): A test plan that enables the controller to perform iterations at a certain scale

flow rate (throughput): Corresponds to the above execution quantity or proportion

per user : Per user

Checking this will cause the controller calculation to be performed on a per-user basis (per thread), and if not controlled, all users worldwide will be counted

11, if the controller (if controllers)

Function: Allows the user to control whether the sampler/controller below the controller performs the test

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

The condition is interpreted as a variable expression (interpret condition as variable expression): If the item is checked, the variable expression is evaluated and compared to "ture" or "false". Without the use of JavaScript

evaluate all sub-conditions (evaluate for all children): If the item is checked, the variable expression can return any value without comparing with "ture" or "false"

By default, the controller can evaluate all the operational elements contained under it, but only once

12, recording controller (recording controllers)

Role: Similar to the role of a proxy server, record test samples during test execution

clear samples of all records (Clear all the recorded samples): Click to clear all test samples that have been recorded

In general, it has no effect at the time of test execution, but when executing the HTTPS test script, all test samples are recorded

13. Loop Controller

Function: The sampler request under the controller can be run in a loop

Number of Cycles (Loop Count): Enter the number of times a loop is required in the input box, and the request under the controller can be run cyclically

Forever (Forever): If the item is checked, the request under the controller can be run continuously

14. Module Controller

Function: A module under the Sub-node of the test controller, not the entire test plan

finding the target element (Find target Element): Look for elements that require a specific test in a test plan, or it can be understood that the controller controls the module elements that are already encapsulated

: A test plan consists of a controller and all of the test elements (samplers, etc.) that can be in any thread group or workbench, and if the plan is in a thread group, you can disable other controllers to prevent the running test plan from being affected (in addition to the module controller)

The advantage of the module controller is that when there are multiple thread groups, the controller can easily switch, just choose the corresponding sampler, easy and quick, replacing the tedious operation of creating many test plans

: The controller name used by any module must be unique, because its name is used to reload the target controller, and for this reason, it is best to ensure that the controller name is different, otherwise the test may occur unexpectedly

: The module controller and the remote test should not be used or non-GUI tested with the Workbench component because the Workbench test element does not have a part of the test plan for jmx files. Any such tests will fail.

15. Simple Controller

Function: Used to combine samplers and other logic controllers

A simple controller is the most basic controller that has no effect on the JMeter test run and can be used to name certain operations

16. Stochastic controller (random controllers )

Function: Similar to the alternating controller, but the controller randomly selects a sampler request and executes

Ignore sub-controller modules (Ignore sub-controller blocks): If this is checked, the interleaved controller will sub-controllers like a single request element, allowing only one request/controller at a time

17. Random Order Controller

Function: Similar to a simple controller, the sampler request is executed once per child node, but execution is random

About the logical controller, the introduction here, there is a lot of information, reference to the content of other bloggers, can be said that the results are not ideal, most of the JMeter official website is directly translated into the translation of the document is posted, typos, interpretation of the statement is not, occasionally see an article, but also a few strokes,

About the specific use of these controllers, I also try to use a bit, or is not difficult, may be introduced in the essay will be a bit of error, I hope to see the person corrected out, thank you

JMeter (ix) Introduction of logic controller and its application direction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.