If controller in jMeter thread group

Viewed 976

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

(${__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.

I'm on Windows 10 using jMeter 3.2 with Ultimate Thread Group 2.1.

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.

3 Answers

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. e.g save vars.putObject("myBoolean", isTrue); and check ${myBoolean} as a condition.

EDIT

Better solution, you can check in if controller ${even} and before of it use JSR223 Element with defining even = true/false as String

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

I fixed my problem by removing the if-controller for having every other user/thread make a new call. 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. This made all types of thread groups work.

Related