You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Oliver Lloyd <ol...@hotmail.com> on 2012/01/20 19:06:49 UTC

Can you loop through thread groups dynamically?

If I have 1 to n threadgroups in a testplan is it possible to loop through
them setting a property for each?

So, what I want to do is pass in a property to the test - simple enough -
and then use this property to affect the number of threads per threadgroup.
Each group will have varying numbers of threads assigned to it and there may
be more or less thread groups per test plan. I want a way to, say, pass in a
value of 2 and divide the thread value for each thread group dynamically.

Imagine:

Test Plan
--TG1
----Some samples
--TG2
----Some samples
--TG3
----Some samples
...
etc.

I can set the value for each group to Number of Threads to
${__P(test.myvalue,10)} and then pass in myvalue but I'm using a script to
call JMeter and it is not aware of the testplan structure so it cannot
decide on the count of users to pass in - it can only decide that it wants
to divide every value by 2. Therefore the calculation must occur inside the
testplan.

Something like:
For each threadgroup in allThreadGroups
    tg.countOfThreads=tg.countOfThreads/test.myvalue
next

Ideally, this can be done using one preprocessor at the root of the main
testplan but maybe it has to be a separate preprocessor for each thread
group?

Thanks for your time
Oliver


-----
http://www.http503.com/
--
View this message in context: http://jmeter.512774.n5.nabble.com/Can-you-loop-through-thread-groups-dynamically-tp5161267p5161267.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: Can you loop through thread groups dynamically?

Posted by Oliver Lloyd <ol...@hotmail.com>.
OK, yes, I see. It also works with the last nightly build (1196526 from back
in December).

I think that for what we're doing with this internally a dev build will work
fine but I'm also planning on releasing something which would be dependent
on this functionality being present and that isn't ideal. Actually, I think
that for now I'll go with my backup option which is to sed on
ThreadGroup.num_threads in the jmx file from within my script and hack the
thread counts that way.

-----
http://www.http503.com/
--
View this message in context: http://jmeter.512774.n5.nabble.com/Can-you-loop-through-thread-groups-dynamically-tp5161267p5161682.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: Can you loop through thread groups dynamically?

Posted by sebb <se...@gmail.com>.
On 20 January 2012 18:38, Oliver Lloyd <ol...@hotmail.com> wrote:
> That looks perfect but does that go directly into the field for Number of
> Threads?

Yes.

> I did try this but it gives:

Sorry, looks like variable refs are not supported for Thread Number in 2.5.1.

I was trying with a current SVN build which does seem to support it
(though I don't recall what fix that was in).

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


Re: Can you loop through thread groups dynamically?

Posted by Oliver Lloyd <ol...@hotmail.com>.
That looks perfect but does that go directly into the field for Number of
Threads? I did try this but it gives:

2012/01/20 18:32:05 INFO  - jmeter.engine.StandardJMeterEngine: Running the
test! 
2012/01/20 18:32:05 INFO  - jmeter.gui.util.JMeterMenuBar:
setRunning(true,*local*) 
2012/01/20 18:32:06 INFO  - jmeter.engine.StandardJMeterEngine: Starting 0
threads for group tg-tnl. 
2012/01/20 18:32:06 INFO  - jmeter.engine.StandardJMeterEngine: Thread will
start next loop on error 
2012/01/20 18:32:06 INFO  - jmeter.engine.StandardJMeterEngine: All threads
have been started 
2012/01/20 18:32:06 INFO  - jmeter.engine.StandardJMeterEngine: Notifying
test listeners of end of test 
2012/01/20 18:32:06 INFO  - jmeter.reporters.Summariser: Generate Summary
Results =     0 in   0.0s = ******/s Avg:     0 Min:     0 Max:     0 Err:    
0 (0.00%) 
2012/01/20 18:32:06 INFO  - jmeter.gui.util.JMeterMenuBar:
setRunning(false,*local*) 
2012/01/20 18:32:06 INFO  - jmeter.engine.StandardJMeterEngine: Test has
ended on host null 

I also tried it in a User Params pre processor - same result.

-----
http://www.http503.com/
--
View this message in context: http://jmeter.512774.n5.nabble.com/Can-you-loop-through-thread-groups-dynamically-tp5161267p5161344.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: Can you loop through thread groups dynamically?

Posted by sebb <se...@gmail.com>.
On 20 January 2012 18:06, Oliver Lloyd <ol...@hotmail.com> wrote:
> If I have 1 to n threadgroups in a testplan is it possible to loop through
> them setting a property for each?
>
> So, what I want to do is pass in a property to the test - simple enough -
> and then use this property to affect the number of threads per threadgroup.
> Each group will have varying numbers of threads assigned to it and there may
> be more or less thread groups per test plan. I want a way to, say, pass in a
> value of 2 and divide the thread value for each thread group dynamically.
>
> Imagine:
>
> Test Plan
> --TG1
> ----Some samples
> --TG2
> ----Some samples
> --TG3
> ----Some samples
> ...
> etc.
>
> I can set the value for each group to Number of Threads to
> ${__P(test.myvalue,10)} and then pass in myvalue but I'm using a script to
> call JMeter and it is not aware of the testplan structure so it cannot
> decide on the count of users to pass in - it can only decide that it wants
> to divide every value by 2. Therefore the calculation must occur inside the
> testplan.

The following value for Number of threads:
${__jexl2(10/5)}
results in 2 threads being run

Replace 10 and or 5 with appropriate variable references.

> Something like:
> For each threadgroup in allThreadGroups
>    tg.countOfThreads=tg.countOfThreads/test.myvalue
> next
>
> Ideally, this can be done using one preprocessor at the root of the main
> testplan but maybe it has to be a separate preprocessor for each thread
> group?
>
> Thanks for your time
> Oliver
>
>
> -----
> http://www.http503.com/
> --
> View this message in context: http://jmeter.512774.n5.nabble.com/Can-you-loop-through-thread-groups-dynamically-tp5161267p5161267.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