You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Harperdev <hc...@gmail.com> on 2014/08/02 00:34:34 UTC

Stop Test when Thread Group #2 Stops

I have two threads groups:
Thread group #1 loops forever (in the Thread Group settings "Loop Count"
"Forever" is checked)
Thread group #2 has a loop count limit (say 1000)

How can I get thread group #1 to stop when thread group #2 stops? That is,
how can I get the entire test to stop when thread group #2 stops? Right now,
thread group #1 just keeps running after #2 stops.

Thanks,
Terry



--
View this message in context: http://jmeter.512774.n5.nabble.com/Stop-Test-when-Thread-Group-2-Stops-tp5720738.html
Sent from the JMeter - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org


Re: Stop Test when Thread Group #2 Stops

Posted by Harperdev <hc...@gmail.com>.
Thanks Sebb. I ended up using a BeanShell to calculate how many total threads
would run, like this:

int numThreads = ctx.getThreadGroup().getNumberOfThreads();
Controller ctrl = ctx.getThreadGroup().getSamplerController();
LoopController loopCtrl = (LoopController)ctrl;
int numLoops= loopCtrl.getLoops();
int totalThreads = numLoops * numThreads;

I also have a simple counter, and if the counter >= totalThreads it stops
the test:
SampleResult.setStopTest(true);

Too bad it doesn't work when TG2 is set to loop "Forever". In that case TG2
automatically stops when the csv data hits eof, but TG1 keeps going since my
code above doesn't know when TG2 will stop.



--
View this message in context: http://jmeter.512774.n5.nabble.com/Stop-Test-when-Thread-Group-2-Stops-tp5720738p5720841.html
Sent from the JMeter - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org


Re: Stop Test when Thread Group #2 Stops

Posted by sebb <se...@gmail.com>.
On 2 August 2014 01:22, Harperdev <hc...@gmail.com> wrote:
>
>> Change TG 2 to a single loop and use a Loop Controller.
>
> Thanks Seb-2-2. But, I want to have a different number of threads in each
> thread group. I want thread group #1 to have only 20 simultaneous threads,
> and #2 to have 200, for example. So, I think I need separate thread groups.

I did not suggest otherwise.

In a bit more detail:

TG1 (20 threads, forever)

TG2 (200 threads, loops 1)
+ Loop Controller (1000)
+ Test Action

> Thanks,
> Terry
>
>
>
> --
> View this message in context: http://jmeter.512774.n5.nabble.com/Stop-Test-when-Thread-Group-2-Stops-tp5720738p5720740.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org


Re: Stop Test when Thread Group #2 Stops

Posted by Harperdev <hc...@gmail.com>.
> Change TG 2 to a single loop and use a Loop Controller. 

Thanks Seb-2-2. But, I want to have a different number of threads in each
thread group. I want thread group #1 to have only 20 simultaneous threads,
and #2 to have 200, for example. So, I think I need separate thread groups.

Thanks,
Terry



--
View this message in context: http://jmeter.512774.n5.nabble.com/Stop-Test-when-Thread-Group-2-Stops-tp5720738p5720740.html
Sent from the JMeter - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org


Re: Stop Test when Thread Group #2 Stops

Posted by sebb <se...@gmail.com>.
On 1 August 2014 23:34, Harperdev <hc...@gmail.com> wrote:
> I have two threads groups:
> Thread group #1 loops forever (in the Thread Group settings "Loop Count"
> "Forever" is checked)
> Thread group #2 has a loop count limit (say 1000)
>
> How can I get thread group #1 to stop when thread group #2 stops? That is,
> how can I get the entire test to stop when thread group #2 stops? Right now,
> thread group #1 just keeps running after #2 stops.

Change TG 2 to a single loop and use a Loop Controller.

Follow the nested loop with a Test Action sampler:
http://jmeter.apache.org/usermanual/component_reference.html#Test_Action


> Thanks,
> Terry
>
>
>
> --
> View this message in context: http://jmeter.512774.n5.nabble.com/Stop-Test-when-Thread-Group-2-Stops-tp5720738.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org