JMeter. How to determine when thread group is finished

孤街浪徒 提交于 2020-01-14 04:03:47

问题


I need two separate thread groups to be run(Second group have infinite loop count). And when the first group is done stop the second one. How can I determine when the first group is done?


回答1:


That's work for me:

  • Crete "BeanShell PreProcessor" with this code:
    props.put("DONE", "FALSE");
  • Create "BeanShell PostProcessor" with this code:
    int activeThreadCount = org.apache.jmeter.threads.JMeterContextService.getNumberOfThreads(); if (activeThreadCount <= 1) { props.put("DONE", "TRUE"); }

Add If Controller with:
${__BeanShell( props.get("DONE") != null && props.get("DONE")=="TRUE")}

Stop Current Thread inside If Controller.




回答2:


You can attach a post-processor to the first threadgroup, which sets a flag value in a property.

Your second threadgroup will contain a loop until the property contains the flag value you are waiting for.




回答3:


You can use the following solution:

Thread Group 1
Beanshell Sampler - props.put("finish", "FALSE");
HTTP1
HTTP2
....
Beanshell Sampler - props.put("finish", "TRUE");

Thread Group 2
While Controller - ${__BeanShell( props.get("finish") != null || props.get("finish")=="TRUE" )}
HTTP1
HTTP2
....

Hope this will help.



来源:https://stackoverflow.com/questions/26465338/jmeter-how-to-determine-when-thread-group-is-finished

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!