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/15 01:12:17 UTC

Clearing variables each thread

I thought using vars.put in a BeanShell Sampler to set a variable was scoped
only in that thread. My variables are all already set when subsequent
threads in the same thread group run - they have values from past threads. 

I have a Debug Sampler near the beginning of my thread group. When the 2nd
thread starts, the Debug Sampler shows it's completely full of variables and
values from the previous thread. 

How can I make all the variables clear out and reset for each thread in a
thread group?



--
View this message in context: http://jmeter.512774.n5.nabble.com/Clearing-variables-each-thread-tp5720840.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: Clearing variables each thread

Posted by Ryabtsev Vladimir <v....@pflb.ru>.
Yes, Harperdev, each separate thread has its own set of values. They are initialized by User Defined Variables element or root element. Then values (changed or not) proceed to the next iteration of the same thread.

As you are talking about variables of form ZZZ_matchNr I suppose you are using RegEx extractor with Match No=-1. You can easily clear all generated values by applying the same RegEx Extractor to an empty input. For example you can add empty BeanShell sampler and child RegEx extractor at the beginning of the thread. The only left value will be ZZZ_matchNr=0.

As another option you can iterate through your variables in BeanShell sampler and initialize or remove them.

-----
VR


-----Original Message-----
From: Harperdev [mailto:hcappdev2@gmail.com] 
Sent: Friday, August 15, 2014 7:51 AM
To: jmeter-user@jakarta.apache.org
Subject: Re: Clearing variables each thread

Oh, I understand now it is keeping separate variables per thread...

What I want is to clear the variables each time a thread in my threadgroup loops. So, maybe my threadgroup is set to use 2 threads and loop forever, every time one of those threads starts over, I would like the variables cleared out.

Is that possible?

My only thought was to use a BeanShell Sampler to go through all the known ZZZ_i_gi (i from 1 to ZZZ_matchNr), etc., variables and remove them at the beginning of the thread. Is that the best option?

Thanks.



--
View this message in context: http://jmeter.512774.n5.nabble.com/Clearing-variables-each-thread-tp5720840p5720842.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: Clearing variables each thread

Posted by Harperdev <hc...@gmail.com>.
Oh, I understand now it is keeping separate variables per thread...

What I want is to clear the variables each time a thread in my threadgroup
loops. So, maybe my threadgroup is set to use 2 threads and loop forever,
every time one of those threads starts over, I would like the variables
cleared out.

Is that possible?

My only thought was to use a BeanShell Sampler to go through all the known
ZZZ_i_gi (i from 1 to ZZZ_matchNr), etc., variables and remove them at the
beginning of the thread. Is that the best option?

Thanks.



--
View this message in context: http://jmeter.512774.n5.nabble.com/Clearing-variables-each-thread-tp5720840p5720842.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