You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by waseemfa <fa...@gmail.com> on 2012/01/09 14:36:09 UTC

Re: How to capture a value in one of the thread and passing it to the other thread in the same test plan

HI,

Basically there is no way of doing this in JMeter.  the one thing i can
think of is use the appropriate method to get the data and store it in a
user defined property like

${__setProperty(input, ${input})};

and in the next thread group access the input variable just like any other
property variable

${__property(input)}

Hope this works.

-Waseem

--
View this message in context: http://jmeter.512774.n5.nabble.com/How-to-capture-a-value-in-one-of-the-thread-and-passing-it-to-the-other-thread-in-the-same-test-plan-tp5124673p5131347.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: How to capture a value in one of the thread and passing it to the other thread in the same test plan

Posted by Adrian Speteanu <as...@gmail.com>.
Hi,

You can also consider this:
http://jmeter.apache.org/usermanual/best-practices.html#beanshell_server

if you use the method described in previous mail by Robin.

Regards,
Adrian

On Mon, Jan 9, 2012 at 6:48 PM, Robin D. Wilson <rw...@gmail.com> wrote:

> I've used "Properties" before...
>
> I have this in one of my test plans (in a "User Parameters" pre-processor)
> :
>
>        threadStartTime = ${__javaScript(var ms = new Date; ms.getTime();)}
>
>        theTime = ${__setProperty(ThreadStartTime, ${threadStartTime})}
>
> (theTime variable isn't used anywhere).
> Then I use (in the next thread group - in a "User Parameter"
> pre-processor):
>
>        lastThreadStartTime = ${__P(ThreadStartTime,0)}
>
> This method only works when the thread groups run sequentially though...
>
> --
> Robin D. Wilson
> Sr. Director of Web Development
> KingsIsle Entertainment, Inc.
> VOICE: 512-777-1861
> www.KingsIsle.com
>
>
> -----Original Message-----
> From: Bruce Ide [mailto:flyingrhenquest@gmail.com]
> Sent: Monday, January 09, 2012 10:07 AM
> To: JMeter Users List
> Subject: Re: How to capture a value in one of the thread and passing it to
> the other thread in the same test plan
>
> Hmm. I'm not using semaphores in JmeterThreadSync, but you could easily
> modify just the CheckPointObject to acquire them. Though it might be easier
> to check for unreleased semaphores in the Config element at test start or
> test end time.
>
> The couple of tests I wrote with this code were very complex due to the
> threading and the stuff that was being tested should have been modified to
> allow for linear testing with a usability defect. I'm not entirely sure
> that
> level of IPC should be commonly available in the tool; if you really need
> it, you should probably have the technical skills to set it up. I think
> that
> gives you a better chance to understand and accept the risks involved.
>
> That being said, this is probably going to gnaw on me now, so I might end
> up
> taking a look at it over some weekend anyway. You know the next guy is
> going
> to want it to run across multiple machines, though...
>
> --
> Bruce Ide
> FlyingRhenquest@gmail.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
>

RE: How to capture a value in one of the thread and passing it to the other thread in the same test plan

Posted by "Robin D. Wilson" <rw...@gmail.com>.
I've used "Properties" before...

I have this in one of my test plans (in a "User Parameters" pre-processor) :

	threadStartTime = ${__javaScript(var ms = new Date; ms.getTime();)}

	theTime = ${__setProperty(ThreadStartTime, ${threadStartTime})}

(theTime variable isn't used anywhere).
Then I use (in the next thread group - in a "User Parameter" pre-processor):

	lastThreadStartTime = ${__P(ThreadStartTime,0)}

This method only works when the thread groups run sequentially though...

--
Robin D. Wilson
Sr. Director of Web Development
KingsIsle Entertainment, Inc.
VOICE: 512-777-1861
www.KingsIsle.com


-----Original Message-----
From: Bruce Ide [mailto:flyingrhenquest@gmail.com] 
Sent: Monday, January 09, 2012 10:07 AM
To: JMeter Users List
Subject: Re: How to capture a value in one of the thread and passing it to
the other thread in the same test plan

Hmm. I'm not using semaphores in JmeterThreadSync, but you could easily
modify just the CheckPointObject to acquire them. Though it might be easier
to check for unreleased semaphores in the Config element at test start or
test end time.

The couple of tests I wrote with this code were very complex due to the
threading and the stuff that was being tested should have been modified to
allow for linear testing with a usability defect. I'm not entirely sure that
level of IPC should be commonly available in the tool; if you really need
it, you should probably have the technical skills to set it up. I think that
gives you a better chance to understand and accept the risks involved.

That being said, this is probably going to gnaw on me now, so I might end up
taking a look at it over some weekend anyway. You know the next guy is going
to want it to run across multiple machines, though...

--
Bruce Ide
FlyingRhenquest@gmail.com


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


Re: How to capture a value in one of the thread and passing it to the other thread in the same test plan

Posted by Bruce Ide <fl...@gmail.com>.
Hmm. I'm not using semaphores in JmeterThreadSync, but you could easily
modify just the CheckPointObject to acquire them. Though it might be easier
to check for unreleased semaphores in the Config element at test start or
test end time.

The couple of tests I wrote with this code were very complex due to the
threading and the stuff that was being tested should have been modified to
allow for linear testing with a usability defect. I'm not entirely sure
that level of IPC should be commonly available in the tool; if you really
need it, you should probably have the technical skills to set it up. I
think that gives you a better chance to understand and accept the risks
involved.

That being said, this is probably going to gnaw on me now, so I might end
up taking a look at it over some weekend anyway. You know the next guy is
going to want it to run across multiple machines, though...

-- 
Bruce Ide
FlyingRhenquest@gmail.com

Re: How to capture a value in one of the thread and passing it to the other thread in the same test plan

Posted by Philippe Mouawad <ph...@gmail.com>.
Hello Bruce,

A little note about
FlyingRhenques<https://github.com/FlyingRhenquest/JmeterThreadGlobal>t,
looking at code it seems to me synchronization can only work if one JVM is
used right ?
Note that if you're willing to, your feature could be useful in JMeter and
answser user enhancement request:

   - https://issues.apache.org/bugzilla/show_bug.cgi?id=43384


And I agree with you sharing WRITE ALSO data between threads is a bad idea
and maybe reveals a Test Plan misconception.

Regards
Philippe
http://www.ubik-ingenierie.com

On Mon, Jan 9, 2012 at 3:58 PM, Bruce Ide <fl...@gmail.com> wrote:

> Usually you don't want to do that. Threads make your test much more
> complicated, and you must take into account timing, locking and
> synchronization issues that can make things very unpredictable. In the vast
> majority of cases where someone is attempting to use threads, there is no
> reason to. If your test has the same user doing things one after another
> and you're trying to use threads to do this, rewrite your test to be
> linear.
>
> If you really must use threads after all that discouraging, I wrote a small
> plugin that enables passing data between threads. There are probably more
> intuitive ways it could work, but it worked for what I needed it to. You
> can find it at https://github.com/FlyingRhenquest/JmeterThreadGlobal. You
> might also want to look at my thread synchronization plugin, which I like
> slightly more than the stock jmeter thread synchronization time.
> https://github.com/FlyingRhenquest/JmeterThreadSync.
>
> --
> Bruce Ide
> FlyingRhenquest@gmail.com
>



-- 
Cordialement.
Philippe Mouawad.

Re: How to capture a value in one of the thread and passing it to the other thread in the same test plan

Posted by Bruce Ide <fl...@gmail.com>.
Usually you don't want to do that. Threads make your test much more
complicated, and you must take into account timing, locking and
synchronization issues that can make things very unpredictable. In the vast
majority of cases where someone is attempting to use threads, there is no
reason to. If your test has the same user doing things one after another
and you're trying to use threads to do this, rewrite your test to be linear.

If you really must use threads after all that discouraging, I wrote a small
plugin that enables passing data between threads. There are probably more
intuitive ways it could work, but it worked for what I needed it to. You
can find it at https://github.com/FlyingRhenquest/JmeterThreadGlobal. You
might also want to look at my thread synchronization plugin, which I like
slightly more than the stock jmeter thread synchronization time.
https://github.com/FlyingRhenquest/JmeterThreadSync.

-- 
Bruce Ide
FlyingRhenquest@gmail.com