带有while循环控制器的第二个采样器在第一个线程之后停止 [英] Second sampler with while loop controller stops after first thread

查看:77
本文介绍了带有while循环控制器的第二个采样器在第一个线程之后停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个http请求sampler1,并使用正则表达式提取器提取了一个"JobID"值.现在,我有http请求sampler2来检查同一线程组中的工作状态,该线程组使用以前的正则表达式提取器中的"JobID".采样器2具有一个条件为$ {__ javaScript("$ {Status}"!="Ready",)}的while循环控制器,也就是说继续执行采样器,直到状态为Ready为止.变量状态"再次使用与sampler2相关联的常规压缩提取器获得.现在,问题是当我运行多个线程时,一旦作业状态为就绪,第二个采样器将在第一次运行后停止执行,并且不会使用sampler1的下一个JobID执行.是由于While控制器引起的吗?任何对此的投入将有很大帮助.谢谢!

解决方案

当然不是.

如果您在

在上面的代码片段中:

  • 第一行从Listeners/.jtl结果文件中删除JSR223采样器,(您对它的时间不感兴趣,是吗?)
  • 第二行使用vars 速记将 $ {Status} 变量设置为 Not ready .apache.org/api/org/apache/jmeter/threads/JMeterVariables.html"rel =" nofollow noreferrer> JMeterVariables 类实例(请参见 解决方案

Of course it doesn't.

If you have more than one iteration in Thread Group or your both Samplers live under the Loop Controller, when 2nd iteration starts your ${Status} variable has the value of Ready so JMeter doesn't enter the While Controller as the condition is not met.

If you want to run more than one iteration you need to reset the ${Status} variable value somehow, one of ways is using JSR223 Sampler and the following code:

 SampleResult.setIgnore()
 vars.put('Status', 'Not ready')  

Example setup:

In the above code snippet:

  • first line removes the JSR223 Sampler from Listeners/.jtl results file,( you're not interested in its timings, are you?)
  • second line sets ${Status} variable to Not ready using vars shorthand for JMeterVariables class instance (see Top 8 JMeter Java Classes You Should Be Using with Groovy article for more information on JMeter API shorthands available for JSR223 Test Elements)

这篇关于带有while循环控制器的第二个采样器在第一个线程之后停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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