You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Eric Gandt <er...@fatwire.com> on 2011/05/06 20:31:25 UTC

Setting a varaiable on a thread group stopping

I have 3 thread groups defined they consist of:
Caching: to ensure the server is properly setup for Test
Monitor: to monitor the health of apache, which should run as long as Test
is running
Test: Test thread group

What I have are 2 variables defined:
 PreCache = 1
 RunTest = 0
I have it setup using an If Controller so that the pre-cache is only
executed when PreCache=1
When PreCache is finished I want it to set PreCache=0 and set RunTest=1
When Test is done I want it to set RunTest=0  so that the Monitor thread is
stopped automatically.

Basically this all depends upon setting a variable when a Thread Group
finishes executing, which I'm unsure how to do, or even if there is a better
way to do this, as this seems imperfect, but I did not see a better way
within the Jmeter framework to do this.

Thanks,
ERIC



--
View this message in context: http://jmeter.512774.n5.nabble.com/Setting-a-varaiable-on-a-thread-group-stopping-tp4376764p4376764.html
Sent from the JMeter - User mailing list archive at Nabble.com.

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


Re: Setting a varaiable on a thread group stopping

Posted by Eric Gandt <er...@fatwire.com>.
The link here explains in detail how to do this.

http://jmeter-tips.blogspot.com/2010/02/tip-5-how-to-run-test-plan-for-certain.html

--
View this message in context: http://jmeter.512774.n5.nabble.com/Setting-a-varaiable-on-a-thread-group-stopping-tp4376764p4382186.html
Sent from the JMeter - User mailing list archive at Nabble.com.

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


Re: Setting a varaiable on a thread group stopping

Posted by sebb <se...@gmail.com>.
On 6 May 2011 19:31, Eric Gandt <er...@fatwire.com> wrote:
> I have 3 thread groups defined they consist of:
> Caching: to ensure the server is properly setup for Test

So this could be run as a separate JMeter test.

> Monitor: to monitor the health of apache, which should run as long as Test
> is running
> Test: Test thread group

These can be run together, but the Test needs to be able to shut the
monitor down.

> What I have are 2 variables defined:
>  PreCache = 1
>  RunTest = 0
> I have it setup using an If Controller so that the pre-cache is only
> executed when PreCache=1
> When PreCache is finished I want it to set PreCache=0 and set RunTest=1
> When Test is done I want it to set RunTest=0  so that the Monitor thread is
> stopped automatically.
>
> Basically this all depends upon setting a variable when a Thread Group
> finishes executing, which I'm unsure how to do, or even if there is a better
> way to do this, as this seems imperfect, but I did not see a better way
> within the Jmeter framework to do this.

As indicated above, I would probably create a separate JMX file to do
the test setup.

Then have two thread groups running in parallel:

Test (loop = 1)
+ Loop controller (as desired)
+ + Samplers etc
+ + ...
+ Test Action: Stop/Stop All Threads

Monitor (run forever)

The next release of JMeter will have setUp/tearDown thread groups; the
setUp TG is intended for setting up tests; in your case the Caching TG

You would still need to use the Test Action (or similar) to stop the Monitor.

> Thanks,
> ERIC
>
>
>
> --
> View this message in context: http://jmeter.512774.n5.nabble.com/Setting-a-varaiable-on-a-thread-group-stopping-tp4376764p4376764.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

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


Re: Setting a varaiable on a thread group stopping

Posted by Bruce Ide <fl...@gmail.com>.
I usually set variables with a BSF sampler and groovy --
vars.put("variablename", "value");

Variables are thread local so if you're running more than one thread you'll
need a different strategy.

I always have to stop and think if I really want to do something as a thread
when I'm writing tests. They often make things much more complicated and a
lot of the time you can use a loop instead. You can group code into simple
controllers inside your loops, which make it easier to read at a high level.

If using threads is how you want (or need) to do it, I have a couple of
jmeter plugins for thread sync and (very) basic cross-thread data sharing at
https://github.com/FlyingRhenquest/ that might come in handy. If you're got
Jmeter 2.3.4 or 2.4 you should be able to install them by dropping the jar
files in  your jmeter lib/ext directory, or you can try to build them from
source if you want to.

My thread-sync plugin could be used to insure that your setup thread runs
prior to your test threads. If you have 3 test threads in different thread
groups, you could create a thread sync data element and set its starting
value to 3. Then you'd put a thread sync sampler at the start of  your test
threads and at the end of your setup thread. When it runs, the first two
threads will decrement the counter to 1 and go to sleep. When the setup
thread hits the sampler, it'll decrement to 0 and wake the sleeping threads.

-- 
Bruce Ide
FlyingRhenquest@gmail.com