内部控制器,而jmeter中的控制器 [英] Controller inside While Controller in jmeter

查看:136
本文介绍了内部控制器,而jmeter中的控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个while控制器,它重复相同的请求,直到满足条件为止.在此控制器内,我想根据

I have a while controller that repeats the same request until a condition is met. Inside this controller, I want to select a specific HTTP request depending on a JSON response given by a GET request outside the while loop.

因此,我的逻辑是设置一个while控制器(当前正在工作)

Hence my logic is to set up a while controller (currently working)

${__javaScript(parseInt(${counterApis})<=parseInt(vars.get("FirstNames_matchNr")),)}

内部具有一个JSR223预处理器,其中包含以下内容:

which inside has a JSR223 PreProcessor with the following:

vars.put("TypeCode",vars.get("TypeCodes_"+vars.get("counterApis")));

想法很简单,while循环使用预处理器检查变量TypeCode的值(取决于JSON响应,它可以是ADT,CHD或INF),然后使用此变量来根据此变量在特定的POST请求之间进行选择.

The Idea is simple, the while loop uses the preprocessor to check the value of the variable TypeCode (which can be ADT, CHD or INF depending on the JSON response) and then use this variable to select between a specific POST request depending on this variable.

问题:由于某些原因,当我尝试在while控制器内添加IF CONTROLLER或SWITCH CONTROLLER时,脚本崩溃,无法访问任何POST请求.

The Problem: For some reason when I try to add an IF CONTROLLER or a SWITCH CONTROLLER inside the while controller, script crashes an does not access any of the POST requests.

它是这样的:

推荐答案

您使用了错误的JSR223测试元素. JSR223预处理程序将在之前采样器中执行,因此您的Switch Controller根本不会接收到必要的输入.

You're using wrong JSR223 Test Element. JSR223 PreProcessors are being executed before samplers so your Switch Controller simply does't receive necessary input.

将JSR223预处理器更改为 JSR223采样器,我相信您的脚本将启动按预期工作.如果您不想在测试结果"中看到JSR223采样器,则可以将以下行放在某处:

Change JSR223 PreProcessor to JSR223 Sampler and I believe your script will start working as expected. If you don't want to see the JSR223 Sampler in Test Results you can put the following line somewhere:

SampleResult.setIgnore()

还可以考虑在While控制器中切换为 __groovy()函数 建议使用

Also consider switching to __groovy() function in your While Controller as it is recommended to use the most performing scripting option

对于JMeter中的性能而言,javaScript不是最佳的脚本语言.如果您的计划需要大量线程,建议使用__jexl3__groovy函数.

这篇关于内部控制器,而jmeter中的控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆