You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Grzegorz Kończyk <gr...@marketplanet.pl> on 2008/04/03 11:49:02 UTC

saving some data between consecutive threads (users)

Hi all,
I'm new to JMeter, and also very new to Beanshell. I have to test a web application that presents auctions where some users can place bids (something like ebay). I'd like to save the value of the bids that each user placed. I wanted to do this in this way:
1. My test plan  tree looks like this (I simplified it a lot no to stir the view too much):
	Test Plan (it has one User Defindef Variable: name:bidValue   value:1000)
	  - Thread Group (Number of threads: 20,   Ramp-up period: 1000,   Loop count: 3)
	    - HTTP Request ( many parameters, in witch one is named BID, and the value is ${bidValue}
	    - BeanShell PostProcessor

I want to place a Beanshell script in the BeanShell PostProcessor element, which will decrement bidValue with a value of 5. So in sum, I want to do something like this:
BID value for user 1 (JMeter thread 1) in 1st loop - is 1000
BID value for user 2 (JMeter thread 2) in 1st loop - is 995
BID value for user 3 (JMeter thread 3) in 1st loop - is 990
BID value for user 20 (JMeter thread 20) in 1st loop - is 905

BID value for user 1 (JMeter thread 1) in 2nd loop - is 900
BID value for user 2 (JMeter thread 2) in 2nd loop - is 895
BID value for user 3 (JMeter thread 3) in 2nd loop - is 890
BID value for user 20 (JMeter thread 20) in 2nd loop - is 805

End so on. Here are my questions (all of them are related to writing script in the BeanShell PostProcessor element):
1. Can somebody explain how should I do this (what script should I)?
2. When should I fill Parameters field?
3. Do I have to import any packages in the script?
4. Am I allowed only to use those variables mentioned in JMeter documentation (log, ctx, vars, prev, data)?
5. What is SampleResult and how can I use this?

I know that there are a lot of questions, and some of them (if not every one ;) ) may seem a bit funny, but answers for that questions will help me to understand usage of Beanshell in JMeter. Please help ;)


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


Re: saving some data between consecutive threads (users)

Posted by sebb <se...@gmail.com>.
On 03/04/2008, Grzegorz Kończyk <gr...@marketplanet.pl> wrote:
> Hi all,
>  I'm new to JMeter, and also very new to Beanshell. I have to test a web application that presents auctions where some users can place bids (something like ebay). I'd like to save the value of the bids that each user placed. I wanted to do this in this way:
>  1. My test plan  tree looks like this (I simplified it a lot no to stir the view too much):
>         Test Plan (it has one User Defindef Variable: name:bidValue   value:1000)
>           - Thread Group (Number of threads: 20,   Ramp-up period: 1000,   Loop count: 3)
>             - HTTP Request ( many parameters, in witch one is named BID, and the value is ${bidValue}
>             - BeanShell PostProcessor
>
>  I want to place a Beanshell script in the BeanShell PostProcessor element, which will decrement bidValue with a value of 5. So in sum, I want to do something like this:
>  BID value for user 1 (JMeter thread 1) in 1st loop - is 1000
>  BID value for user 2 (JMeter thread 2) in 1st loop - is 995
>  BID value for user 3 (JMeter thread 3) in 1st loop - is 990
>  BID value for user 20 (JMeter thread 20) in 1st loop - is 905
>
>  BID value for user 1 (JMeter thread 1) in 2nd loop - is 900
>  BID value for user 2 (JMeter thread 2) in 2nd loop - is 895
>  BID value for user 3 (JMeter thread 3) in 2nd loop - is 890
>  BID value for user 20 (JMeter thread 20) in 2nd loop - is 805
>

Looks like the threads don't run in parallel, so why not just use a
single thread with a function that returns the next bid?

Or you can use a file containing the bid values, and read the values
for each sample.

In the real application, do the users place bids without seeing what
others have bid?
Or do they browse to a page, look at the current price, and bid accordingly?

In which case, just use an RE to extract the current bid value, and
write a simple function - or use __intSum() - to calculate the next
bid.

>  End so on. Here are my questions (all of them are related to writing script in the BeanShell PostProcessor element):
>  1. Can somebody explain how should I do this (what script should I)?
>  2. When should I fill Parameters field?

Only if you want to pass in parameters.

>  3. Do I have to import any packages in the script?

Only if you need them.

>  4. Am I allowed only to use those variables mentioned in JMeter documentation (log, ctx, vars, prev, data)?

No, you can create your own variables.

>  5. What is SampleResult and how can I use this?

See the Javadoc.

>  I know that there are a lot of questions, and some of them (if not every one ;) ) may seem a bit funny, but answers for that questions will help me to understand usage of Beanshell in JMeter. Please help ;)
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>