You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by David Bronner <db...@google.com> on 2006/05/24 23:05:40 UTC

Once Only Controller under Thread Group

Hi everyone,

I'm trying to use a "Once Only" controller to setup some variables for my
test run.  In the docs, it says, "Note this means the Once Only Controller
will still behave as previously expected if put under a Thread Group (runs
only once per test), but now the user has more flexibility in the use of the
Once Only Controller."

I took that to mean that I could have a test plan like the following:

Test plan
+ Thread Group
+ + Only Once Controller
+ + + Logic
...

And that Logic would only get run once for the entire test, even for
multiple threads in the thread group.  Am I misreading the purpose of the
Only Once controller, or is it not working correctly?  In the plan above,
Logic gets executed once per thread.  BTW...I just want to thank Sebb for
answering all of our hundreds of questions...browsing through your answers
has been VERY helpful.

-Dave

Re: Once Only Controller under Thread Group

Posted by sebb <se...@gmail.com>.
On 24/05/06, David Bronner <db...@google.com> wrote:
> Hi everyone,
>
> I'm trying to use a "Once Only" controller to setup some variables for my
> test run.  In the docs, it says, "Note this means the Once Only Controller

Variables can be set up on the test plan itself, or using User Defined
Variables or User Parameters.

But I guess you are intending to do some kind of sample to extract the
data from a remote system.

> will still behave as previously expected if put under a Thread Group (runs
> only once per test), but now the user has more flexibility in the use of the
> Once Only Controller."
>
> I took that to mean that I could have a test plan like the following:
>
> Test plan
> + Thread Group
> + + Only Once Controller
> + + + Logic
> ...
>
> And that Logic would only get run once for the entire test, even for
> multiple threads in the thread group.  Am I misreading the purpose of the
> Only Once controller, or is it not working correctly?  In the plan above,
> Logic gets executed once per thread.  BTW...I just want to thank Sebb for

Yes, it is once only per thread, because it is intended for things
such as logins.

Note that variables defined in a thread (e.g. extracted from a sample
result) will only apply to that thread.

The only "variables" that are global are properties; variables defined
at test plan level are made available to every thread (but if changed,
will only change for that thread).

Threads are for simulating independent users...

So although you can run the sampler once by adding an If Controller to
check for threadNum==1 (say), you'll still need to set the value in a
property.

You might do better to extract the values before starting the test,
and pass them in as properties.

Or you could set up another thread group to extract the data and store
it in a property, and run that thread group before the main one. You
can then set a variable from the property, if you don't want to use
the __P() function.

> answering all of our hundreds of questions...browsing through your answers
> has been VERY helpful.

Thanks!

> -Dave
>

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