[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jmeter-user
Subject:    Re: Global data
From:       Deepak Shetty <shettyd () gmail ! com>
Date:       2009-10-27 16:39:22
Message-ID: 4483c26c0910270939k612ed144xe4265a299b49b21 () mail ! gmail ! com
[Download RAW message or body]


hi
the other parts have been covered by previous posters.
The bits about reading the last value and saving it can be done by a BSH
sampler (you can also make a runtime call using the JDBC sampler to your
database if you wanted to find out what the last value was, which is better
in my opinion).

If you go the BSH way you would have to write code like  (Note only in a
single thread , perhaps as a separate thread group..

To read the sample
import java.io.BufferedReader;
import java.io.FileReader;

BufferedReader br = new BufferedReader(new
FileReader("../scripts/data/WebUserQueueData.csv"));
String line = null;
String webUserQueueId = null;
while((line = br.readLine()) != null){
     webUserQueueId = line.trim();
}
br.close();

vars.put("webUserQueueId",webUserQueueId);

To write the value
import java.io.BufferedWriter;
import java.io.FileWriter;
if(vars.get("lastWebUserId") != null) {
   BufferedWriter bw = new BufferedWriter(new
FileWriter("../scripts/data/WebUserQueueData.csv"));
   bw.write(vars.get("lastWebUserId"));
   bw.close();
}


The other option is to restore the database to a known point .
regards
deepak

On Tue, Oct 27, 2009 at 8:06 AM, Andy Bell
<andy.photos.bell@googlemail.com>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?
>
> --
> Andy
>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic