Article directory
1. Interleave Controller parameter description
可以将内部的组件在线程迭代时交替执行;交替控制器内部一般会有多个取样器
Select the right button of the thread group >>> Add >>> Logic Controller >>> Interleave Controller
-
Ignore sub-controller blocks (Ignore sub-controller blocks): The sub-controller function fails and is replaced by an alternate controller
-
Interleave across threads: Cross-thread alternation, when the thread group is set to run with multiple threads, each round of the cycle, each thread gets a new request in the alternate controller
2. Test plan design
(1), right click on the test plan <<< add <<< thread (user) <<< thread group
-
Number of cycles: 6
-
Other parameters can be default
(2), right click on the thread group <<< add <<< sampler <<< JSR223 Sampler
- Name: JSR223 Sampler-1
log.info("JSR223 Sampler-1");
(3), right click on the thread group <<< add <<< sampler <<< JSR223 Sampler
- Name: JSR223 Sampler-2
log.info("JSR223 Sampler-2");
(4) Open the log, click Clear All, click Start, and view the log information
点击菜单选项按钮,点击日志查看,打开日志
如图,每个 JSR223 Sampler 取样器都迭代执行了6次,一共执行了12个取样器
(5) Right click on the thread group <<< Add <<< Logic Controller <<< Alternate Controller, put two JSR223 Samplers under the Alternate Controller
- The parameters are default
(6) Open the log, click Clear All, click Start, and view the log information
如图,每个 JSR223 Sampler 取样器都只迭代执行了3次,一共执行了6个取样器
(7), alternate controller right click <<< add <<< preprocessor <<< JSR223 preprocessor
log.info("JSR223 预处理程序");
(8) Open the log, click Clear All, click Start, and view the log information
如图,每个 JSR223 Sampler 取样器都只迭代执行了3次,一共执行了6个取样器,执行每个 JSR223 Sampler 取样器时,都会在之前执行一次 JSR223 预处理程序