jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: Sharing Variables Between Thread-Group
Date Tue, 17 Jul 2012 09:35:29 GMT
On 17 July 2012 08:32, Sergio Boso <sergio@bosoconsulting.it> wrote:
> Il 16/07/2012 20:42, unjc email ha scritto:
>
>> Guys, thanks for your replies.
>>
>> I don't know if anyone have this experience.  I found that
>> ${__setProperty}/${__P} pair would work between thread groups IF I use
>> constant value ("abc" like below example) or system variables (like
>> $__time(HMS). When I use a local variable ("tmp" as like in my
>> example) in the $__setProperty call, it doesn't work.
>>
>>                tmp = "abc";
>>                ${__setProperty(key,tmp)};                           //
>> THAT DOES NOT WORK!!
>
> hi
> I think it should be:
>
>               ${__setProperty(key,${tmp})};

That won't work, because tmp is not a JMeter variable, it is a
BeanShell variable.
Besides, the entire construct is resolved before it is passed to
BeanShell for processing - BSH will see the return value from the
function which is the empty string.

> regards
>
>
>>                ${__setProperty(key,"abc")};
>> // THAT WORKS!!
>>
>>
>> I also found that it is NOT the variable value that is shared between
>> the thread group, it's the reference.  When I put ${__time(HMS)} in
>> the __setProperty call and run the test, the "key" values are
>> different between the two thread group.  Does anyone know how to pass
>> a local-defined variable value using setProperty call?
>>
>>
>> Test Plan (with 2 thread groups)
>>
>> Thread-Group1 (with 1 thread)
>>>
>>> Dubug Sampler
>>> BeanShell PreProcessor
>>
>>     Script:
>>                ${__setProperty(key,${__time(HMS)})};
>>         // USING TIMESTAMP
>>                log.info("Group 1 key = " + ${__P(key)});
>>          //2012/07/16 18:31:36 INFO  -
>> jmeter.util.BeanShellTestElement: Group 1 key = 183136
>>
>>
>> Thread-Group2 (with 2 threads)
>>>
>>> HTTP Sampler
>>> BeanShell PreProcessor
>>
>>     Script:
>>                log.info("Group 2 key = " + ${__P(key)});
>>           //2012/07/16 18:31:36 INFO  -
>> jmeter.util.BeanShellTestElement: Group 2 key = 183119
>>
>> Note that it is not the same value being logged.
>>
>>
>>
>> Regards,
>> Jacky
>>
>> On Mon, Jul 16, 2012 at 12:48 PM, Jomebrew <aielloster@gmail.com> wrote:
>>
>
> --
>
> Ing. Sergio Boso
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> 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


Mime
View raw message