You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Harry_ <ha...@gmail.com> on 2009/12/04 13:05:27 UTC

How to declare a variable at thread level and assign it value in one time controller

Hi,

I have made a test plan in which I login in one time controller  from one IP
which is read from csv file (on a machine having multiple IP's) and then I
have to fire requests to server from that IP. 

But for this I have to store the value of IP in a variable in one time
controller and use it outside at the thread level where I have other
requests.

So how do I  declare a variable at thread level and assign it value in one
time controller.

And use it at thread level...

Regards
-- 
View this message in context: http://old.nabble.com/How-to-declare-a-variable-at-thread-level-and-assign-it-value-in-one-time-controller-tp26635872p26635872.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: How to declare a variable at thread level and assign it value in one time controller

Posted by Harry_ <ha...@gmail.com>.
Hi,

I am able to do this as follow:

Define a user parameter in the one time and if controller and set its value
equal to the value read from csv during login. 

Thanks for all the help.

Regards


Harry_ wrote:
> 
> Thank you so much for responding.
> 
> Please see attached jmeter file for the structure of the plan. Please use
> nightly build to open this plan. In  HTTP Request HTTPClient request
> sampler, you will find a filed for Source IP address. I am using that. 
> 
>  http://old.nabble.com/file/p26656903/LoggedOnUser.jmx LoggedOnUser.jmx 
> 
> In each thread the user Logs in first in One Time controller. And reads
> the value for Source IP from CSV file. Now I want this IP to be used for
> URL requests made by this user for rest of the thread loop cycles. (URL's
> are also read from file). 
> 
> Now I want I store a value of Source IP Address used in a variable when
> user login In and use that variable in the Source IP for URL requests made
> for that user. 
> 
> If a user logs out for some reason, I check for response code 403 and logs
> the user back in in If controller. I will reset the value to new Source IP
> in the variable again.
> 
> But I do not know how to declare and change the value of this variable. Is
> someone can add a sample plan to set and change variable value, then I can
> move on from there.
> 
> Any help would be priceless.
> 
> Thanks and Regards
> 
> 
> mwolfe38 wrote:
>> 
>> Is each thready going to test a potentially different IP address? If not
>> then you could put it in a property.. 
>> Can you show like a tree view of what your test plan looks like so we can
>> get a better Idea what the problem is..
>> Just write it like this:
>> -TestPlan
>>  - Thread Group
>>   - Controller
>>    - Sample
>>   - Controller
>>    - Sample
>>  - Thread Group
>> ....
>> 
>> 
>> 
>> Harry_ wrote:
>>> 
>>> Hi,
>>> 
>>> I have made a test plan in which I login in one time controller  from
>>> one IP which is read from csv file (on a machine having multiple IP's)
>>> and then I have to fire requests to server from that IP. 
>>> 
>>> But for this I have to store the value of IP in a variable in one time
>>> controller and use it outside at the thread level where I have other
>>> requests.
>>> 
>>> So how do I  declare a variable at thread level and assign it value in
>>> one time controller.
>>> 
>>> And use it at thread level...
>>> 
>>> Regards
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://old.nabble.com/How-to-declare-a-variable-at-thread-level-and-assign-it-value-in-one-time-controller-tp26635872p26657565.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: How to declare a variable at thread level and assign it value in one time controller

Posted by Harry_ <ha...@gmail.com>.
Thank you so much for responding.

Please see attached jmeter file for the structure of the plan. Please use
nightly build to open this plan. In  HTTP Request HTTPClient request
sampler, you will find a filed for Source IP address. I am using that. 

http://old.nabble.com/file/p26656903/LoggedOnUser.jmx LoggedOnUser.jmx 

In each thread the user Logs in first in One Time controller. And reads the
value for Source IP from CSV file. Now I want this IP to be used for URL
requests made by this user for rest of the thread loop cycles. (URL's are
also read from file). 

Now I want I store a value of Source IP Address used in a variable when user
login In and use that variable in the Source IP for URL requests made for
that user. 

If a user logs out for some reason, I check for response code 403 and logs
the user back in in If controller. I will reset the value to new Source IP
in the variable again.

But I do not know how to declare and change the value of this variable. 

Any help would be priceless.

Thanks and Regards


mwolfe38 wrote:
> 
> Is each thready going to test a potentially different IP address? If not
> then you could put it in a property.. 
> Can you show like a tree view of what your test plan looks like so we can
> get a better Idea what the problem is..
> Just write it like this:
> -TestPlan
>  - Thread Group
>   - Controller
>    - Sample
>   - Controller
>    - Sample
>  - Thread Group
> ....
> 
> 
> 
> Harry_ wrote:
>> 
>> Hi,
>> 
>> I have made a test plan in which I login in one time controller  from one
>> IP which is read from csv file (on a machine having multiple IP's) and
>> then I have to fire requests to server from that IP. 
>> 
>> But for this I have to store the value of IP in a variable in one time
>> controller and use it outside at the thread level where I have other
>> requests.
>> 
>> So how do I  declare a variable at thread level and assign it value in
>> one time controller.
>> 
>> And use it at thread level...
>> 
>> Regards
>> 
> 
> 

-- 
View this message in context: http://old.nabble.com/How-to-declare-a-variable-at-thread-level-and-assign-it-value-in-one-time-controller-tp26635872p26656903.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: How to declare a variable at thread level and assign it value in one time controller

Posted by mwolfe38 <mw...@gmail.com>.
Is each thready going to test a potentially different IP address? If not then
you could put it in a property.. 
Can you show like a tree view of what your test plan looks like so we can
get a better Idea what the problem is..
Just write it like this:
-TestPlan
 - Thread Group
  - Controller
   - Sample
  - Controller
   - Sample
 - Thread Group
....



Harry_ wrote:
> 
> Hi,
> 
> I have made a test plan in which I login in one time controller  from one
> IP which is read from csv file (on a machine having multiple IP's) and
> then I have to fire requests to server from that IP. 
> 
> But for this I have to store the value of IP in a variable in one time
> controller and use it outside at the thread level where I have other
> requests.
> 
> So how do I  declare a variable at thread level and assign it value in one
> time controller.
> 
> And use it at thread level...
> 
> Regards
> 

-- 
View this message in context: http://old.nabble.com/How-to-declare-a-variable-at-thread-level-and-assign-it-value-in-one-time-controller-tp26635872p26636157.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: How to declare a variable at thread level and assign it value in one time controller

Posted by Deepak Shetty <sh...@gmail.com>.
Hi
you arent clear in what you want.
Any JMeter variable is available to the entire thread, whether it is set in
One Time Controllers or not . If you need to manage some custom access to
variables then beanshell(pre /post processor , sampler , listener) has
access to the vars object which has methods put and get

http://jakarta.apache.org/jmeter/api/org/apache/jmeter/threads/JMeterVariables.html

regards
deepak

On Fri, Dec 4, 2009 at 4:05 AM, Harry_ <ha...@gmail.com> wrote:

>
> Hi,
>
> I have made a test plan in which I login in one time controller  from one
> IP
> which is read from csv file (on a machine having multiple IP's) and then I
> have to fire requests to server from that IP.
>
> But for this I have to store the value of IP in a variable in one time
> controller and use it outside at the thread level where I have other
> requests.
>
> So how do I  declare a variable at thread level and assign it value in one
> time controller.
>
> And use it at thread level...
>
> Regards
> --
> View this message in context:
> http://old.nabble.com/How-to-declare-a-variable-at-thread-level-and-assign-it-value-in-one-time-controller-tp26635872p26635872.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
>
>