Thread Groups based initialization for each thread group

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Thread Groups based initialization for each thread group

Tong Sun
Hi,

I need to do some initialization for each thread group before they
start, by calling several groovy functions.

I know there is a setup thread group, which is run once before all
thread groups, but how can I do setup once for each thread group?

Say for the following groovy script,

---------------------------
import C1
import C2
import C3

c1 = C1.init()
c2 = C2.init()
jdbc =C3.getjdbc(c1, c2)
---------------------------

how can I call it only once for each thread group?

thx!

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Thread Groups based initialization for each thread group

glinius@live.com
If you need to call it once per thread (virtual user), i.e. only at first
iteration of each virtual user - put this code under the  Once Only
Controller
<https://jmeter.apache.org/usermanual/component_reference.html#Once_Only_Controller>  


If you need to call it once per thread group (i.e. first iteration of first
thread) - put it under the  If Controller
<https://www.blazemeter.com/blog/six-tips-for-jmeter-if-controller-usage>  
and use the following  __groovy() function
<https://jmeter.apache.org/usermanual/functions.html#__groovy>   as the
condition:


> ${__groovy((vars.getIteration() == 1 && ctx.getThreadNum() == 0),)}

 



--
Sent from: http://www.jmeter-archive.org/JMeter-User-f512775.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]