jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ronan Klyne <>
Subject Re: Global data
Date Tue, 27 Oct 2009 15:29:52 GMT
Andy Bell wrote:
> Hi
> I'm writing concurrency tests for a data insertion web service.
> The database table has a unique key field (it cannot be autoincremented :-(
> ) so I'm trying to get JMeter to generate unique keys for me. I need to:
> 1) Have a starting vlue that is globally shared between all the threads
> 2) Have each thread increment its value between insert statements
> 3) Save the final value to a file so that the next test run can use it.
> Of course, this leads to difficulties with managing thread concurrency.
> Additionally, the database key field is an alph-numeric with a maximum of 6
> characters, so I don't have a vast range of values to play with...
> Can this be done with JMeter?
You can share data between threads using JMeter properties instead of 
variables. In BSF/beanshell/etc. you can access these through the 
'props' object.

I think there is another way too - if you have X threads, and a starting 
value of A, then you would be able to use A + 0 in thread 1, A + 1 in 
thread 2, up to A + X-1 in thread X. You could then increment these by X 
each iteration.

The thread count and thread number are available from the JMeterContext 
object available as 'ctx':
// Total threads
var thread_count = ctx.getThreadGroup().getNumThreads();
// Current thread number
var thread_num = ctx.getThreadNum();

Hope that helps,


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message