2

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?

Alexandr
  • 345
  • 1
  • 6
  • 16

3 Answers3

6

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.

Alexandr
  • 345
  • 1
  • 6
  • 16
1

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.

CharlieS
  • 1,432
  • 1
  • 9
  • 10
  • Yes I was thinking about it but all post-processors is executed after each sample not after thred group is done – Alexandr Oct 21 '14 at 03:34
  • You can attach the post-processor to the thread group, and it will execute after all samplers. or you can attach it to the last sample in the group. – CharlieS Oct 21 '14 at 22:45
  • 1
    How can I attach to thread group post-processor? Help said that all pre/post processors executed before/after sample. You can check it by putting BeanShell PostProcessor with line `log.info("Run post-processing");` – Alexandr Oct 22 '14 at 04:54
  • right click thread group->add->post-processors->beanshell post-processor. this will run after the thread group – CharlieS Oct 23 '14 at 02:35
  • 1
    No. It will run after each sampler. – Alexandr Oct 26 '14 at 11:55
  • correct, after cheking this, it does.. you can attach it to the last sampler in the thread group, or create a beanshell sampler. I was trying to avoid creating an extra sample.. – CharlieS Oct 26 '14 at 22:58
1

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.

Zubair M Hamdani
  • 1,693
  • 1
  • 13
  • 14
  • No it doesn't fit my needs. If we have iterations in Thread Group 1 than we will have problems in Thread Group 2 – Alexandr Oct 26 '14 at 14:49