0
votes

The accepted answer in this thread is from 2014 and does not seem to work any more. I can't figure out why: JMeter. How to determine when thread group is finished

JMeter

I have 2 threadgroups (ignore the setUp group)

Based on the accepted answer in the thread above I added

  • A BeanShell Preprocessor vars.put("DONE", "FALSE");
  • A BeanShell Postprocessor
    int activeThreadCount = org.apache.jmeter.threads.JMeterContextService.getNumberOfThreads();
    if (activeThreadCount <= 1)
    {
      vars.put("DONE", "TRUE");
    }
    
  • A If Controller ${__BeanShell(vars.get("DONE") != null && vars.get("DONE")=="TRUE")};
  • ... with a Flow Control Action terminating all threads via Stop now if triggered.

via print statements in the postprocessor I was able to verify that the variable "DONE" is correctly set and the condition vars.get("DONE") != null && vars.get("DONE")=="TRUE" is evaluated correctly (when used in the postprocessor).

However when I use the condition inside of the If Controller it does not seem to be evaluated correctly no code inside of child elements of the If Controller is executed. The "Thred Group: ETL" just keeps on going even if the condition should evaluate to true.

My assumption would be that this has to do with the "Interpret Condition as Vairable Expression"-checkbox or the interpreter behind the If Controller. But unfortunately I don't know enough about JMeter to figure this out.

another screenshot

2
linked answer uses props and not varsuser7294900
I tried both, makes no difference.Lennart

2 Answers

0
votes

No Semicolon at the end of an If Controller expression is allowed. After removing the semicolon the controller works as intended

0
votes
  1. First of all get familiarized with JMeter Scoping Rules as your Beanshell Pre and Post processors are executed before/after each Sampler and it doesn't seem to me that this is something you really want to achieve
  2. Second, since JMeter 3.1 you should be using JSR223 Test Elements and Groovy language for scripting
  3. If Controller accepts something which resolves to true or false, in your case it's true; so If Controller's children will never be executed
  4. It is possible to stop all the threads directly from the PostProcessor itself as simple as prev.setStopTest(true)