On 27/10/2009, Ronan Klyne <[email protected]> wrote: > 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(); >
Another method is to create a file (or set of files) with the unique ids and use CSV Dataset to read it. > Hope that helps, > > Ronan > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > [email protected] > For additional commands, e-mail: > [email protected] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

