简体   繁体   English

如果控制器在jMeter线程组中

[英]If controller in jMeter thread group

I'm using jp@gc's Ultimate Thread Group and inside the thread group I have a if controller making sure only every other thread/user continues with 我使用的是jp @ gc的Ultimate Thread Group,并且在线程组内部,我有一个if控制器,以确保仅其他所有线程/用户继续执行

(${__threadNum}%2==0) 

There seems to be some issue closing the threads though because after the load has been held for the set amount of time I get as many errors as I have threads going into the controller. 关闭线程似乎有些问题,因为在将负载保持了设定的时间后,我得到的错误与将线程放入控制器的错误一样多。 I'm not sure what they are about and they don't seem to be about the contents of the if controller because I get them even after deactivating everything inside. 我不确定它们是关于什么的,它们似乎与if控制器的内容无关,因为即使停用了内部所有内容,我也仍然可以得到它们。

I'm on Windows 10 using jMeter 3.2 with Ultimate Thread Group 2.1. 我在Windows 10上使用带有终极线程组2.1的jMeter 3.2。

The error messages: 错误消息:

java.lang.StackOverflowError: null
at java.lang.invoke.MethodHandles.insertArguments(Unknown Source) ~[?:1.8.0_131]
at jdk.internal.dynalink.DynamicLinker.createRelinkAndInvokeMethod(DynamicLinker.java:224) ~[nashorn.jar:?]
at jdk.internal.dynalink.DynamicLinker.link(DynamicLinker.java:201) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.linker.Bootstrap.bootstrap(Bootstrap.java:208) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.linker.Bootstrap.createDynamicInvoker(Bootstrap.java:371) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.linker.Bootstrap.createDynamicInvoker(Bootstrap.java:345) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.linker.InvokeByName.<init>(InvokeByName.java:86) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.linker.InvokeByName.<init>(InvokeByName.java:73) ~[nashorn.jar:?]
at jdk.nashorn.internal.objects.Global.<init>(Global.java:96) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.Context.newGlobal(Context.java:1111) ~[nashorn.jar:?]
at jdk.nashorn.api.scripting.NashornScriptEngine$2.run(NashornScriptEngine.java:350) ~[nashorn.jar:?]
at jdk.nashorn.api.scripting.NashornScriptEngine$2.run(NashornScriptEngine.java:346) ~[nashorn.jar:?]
at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_131]
at jdk.nashorn.api.scripting.NashornScriptEngine.createNashornGlobal(NashornScriptEngine.java:346) ~[nashorn.jar:?]
at jdk.nashorn.api.scripting.NashornScriptEngine.createGlobalMirror(NashornScriptEngine.java:340) ~[nashorn.jar:?]
at jdk.nashorn.api.scripting.NashornScriptEngine.createBindings(NashornScriptEngine.java:170) ~[nashorn.jar:?]
at org.apache.jmeter.control.IfController$NashornJsEngine.evaluate(IfController.java:123) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.control.IfController.evaluateCondition(IfController.java:185) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.control.IfController.next(IfController.java:239) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.control.GenericController.nextIsAController(GenericController.java:219) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.control.GenericController.next(GenericController.java:173) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.control.LoopController.next(LoopController.java:123) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.control.LoopController.nextIsNull(LoopController.java:151) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.control.GenericController.next(GenericController.java:168) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.control.LoopController.next(LoopController.java:123) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.control.GenericController.nextIsAController(GenericController.java:222) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.control.GenericController.next(GenericController.java:173) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.control.LoopController.next(LoopController.java:123) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.control.LoopController.nextIsNull(LoopController.java:151) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.control.GenericController.next(GenericController.java:168) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.control.LoopController.next(LoopController.java:123) ~[ApacheJMeter_core.jar:3.2 r1790748]
at... etc etc

Edit: For now I'm abandoning this and just use the vanilla Thread Group since it does not give any errors. 编辑:现在我放弃了,只使用普通线程组,因为它没有任何错误。

There is a known issue with Ultimate plugin and If controller.you can check this in JSR 223 Element and check only the boolean result in If controller. Ultimate插件和If控制器存在一个已知问题 。您可以在JSR 223元素中检查此问题,并仅在If控制器中检查布尔结果。 eg save vars.putObject("myBoolean", isTrue); 例如保存vars.putObject("myBoolean", isTrue); and check ${myBoolean} as a condition. 并检查${myBoolean}作为条件。

EDIT 编辑

Better solution, you can check in if controller ${even} and before of it use JSR223 Element with defining even = true/false as String 更好的解决方案,您可以检查控制器${even}及其之前的控制器是否使用JSR223元素(将even = true / false定义为String)

if (ctx.getThreadNum() % 2 == 0) {
    vars.putObject("even", "true");
    log.info("even true");
} else {
    vars.putObject("even", "false");
        log.info("even false");
}

Since JMeter 3.1 it is recommended to use JSR223 Test Elements and __groovy function for any form of scripting in JMeter so I would recommend switching from JavaScript to Groovy and use __groovy() function in your If Controller's "Condition" area like: JMeter 3.1开始,建议对JMeter中的任何形式的脚本使用JSR223测试元素和__groovy函数 ,因此我建议从JavaScript切换到Groovy,并在If Controller的“ Condition”区域中使用__groovy()函数 ,例如:

${__groovy(ctx.getThreadNum() %2 == 0,)}

See Apache Groovy - Why and How You Should Use It article for more information on Groovy scripting in the context of JMeter tests, benchmarks, best practices, etc. 有关在JMeter测试,基准,最佳实践等方面的Groovy脚本的更多信息,请参见Apache Groovy-为什么和应该如何使用它

I fixed my problem by removing the if-controller for having every other user/thread make a new call. 我通过删除让所有其他用户/线程进行新调用的if-controller来解决了我的问题。 Instead of having this logic I made it so that only half of the threads are made and their number is instead multiplied by two, having the same effect. 我没有使用这种逻辑,而是只制作了一半的线程,而是将它们的数量乘以2,从而具有相同的效果。 This made all types of thread groups work. 这使所有类型的线程组都能正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM