You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Raihan Jamal <ja...@gmail.com> on 2013/02/13 20:41:22 UTC

Generate Random Unique numbers using JMeter

I am trying to insert into the below table currently using JMeter-

INSERT INTO XMP_TEST2 (id, a_sellers) values (?, ?)

Data Types for the above columns are-

*id                String*
*a_sellers     String*

In the above table *id is the Primary Key. *So I need some way to generate
unique id always either starting from 1 or any random unique numbers. Is
there any way I can do that in JMeter?

Currently in my Parameter Values, I am passing something like this to
insert in the above two columns-


${__BeanShell(UUID.randomUUID().toString())}
,"{""lv"":[{""v"":{""regId"":null,""
user"":null,""Id"":996},""cn"":1}],""lmd"":1360185}"


And Parameter types is-

VARCHAR,VARCHAR


One approach I am thinking of is keep on increment by one every time. But
how should I do in this JMeter?

Does anyone has any experience on this particular problem?


Looking forward for your replies.




*Raihan Jamal*

Re: Generate Random Unique numbers using JMeter

Posted by Deepak Shetty <sh...@gmail.com>.
if you arent running a multithreaded test , then your initial value needs
to be the maximum value in the DB + 1


On Wed, Feb 13, 2013 at 12:01 PM, Raihan Jamal <ja...@gmail.com>wrote:

> I made some progress on this. I have initialize counter variable like this-
>
>
> init variable (eg in "User Defined Variables"):
>
> Name:       | Value
> ------------+---------
> LoopCounter | 0
>
>
>
> And in my Parameter values I am using something like this now-
>
> *${__intSum(${LoopCounter},1,LoopCounter)}
> ,"{""lv"":[{""v"":{""regId"":null,""
> user"":null,""Id"":996},""cn"":1}],""lmd"":1360185}"*
> *
> *
>
> And my *LoopCounter* is something like this-
>
> Name:- LoopCounter
> Start:-  1
> Increment:- 1
> Maximum:- 1000
> Number format:- 000
>
>
> I have unchecked *Track counter independently for each user*
> *
> *
> But still I am getting exception thrown as Primary Key violation. Is there
> anything wrong I am doing here?
>
>
>
>
>
>
>
>
> *Raihan Jamal*
>
>
> On Wed, Feb 13, 2013 at 11:41 AM, Raihan Jamal <jamalraihan@gmail.com
> >wrote:
>
> > I am trying to insert into the below table currently using JMeter-
> >
> > INSERT INTO XMP_TEST2 (id, a_sellers) values (?, ?)
> >
> > Data Types for the above columns are-
> >
> > *id                String*
> > *a_sellers     String*
> >
> > In the above table *id is the Primary Key. *So I need some way to
> > generate unique id always either starting from 1 or any random unique
> > numbers. Is there any way I can do that in JMeter?
> >
> > Currently in my Parameter Values, I am passing something like this to
> > insert in the above two columns-
> >
> >
> > ${__BeanShell(UUID.randomUUID().toString())}
> > ,"{""lv"":[{""v"":{""regId"":null,""
> > user"":null,""Id"":996},""cn"":1}],""lmd"":1360185}"
> >
> >
> > And Parameter types is-
> >
> > VARCHAR,VARCHAR
> >
> >
> > One approach I am thinking of is keep on increment by one every time. But
> > how should I do in this JMeter?
> >
> > Does anyone has any experience on this particular problem?
> >
> >
> > Looking forward for your replies.
> >
> >
> >
> >
> > *Raihan Jamal*
> >
>

Re: Generate Random Unique numbers using JMeter

Posted by Raihan Jamal <ja...@gmail.com>.
I made some progress on this. I have initialize counter variable like this-


init variable (eg in "User Defined Variables"):

Name:       | Value
------------+---------
LoopCounter | 0



And in my Parameter values I am using something like this now-

*${__intSum(${LoopCounter},1,LoopCounter)}
,"{""lv"":[{""v"":{""regId"":null,""
user"":null,""Id"":996},""cn"":1}],""lmd"":1360185}"*
*
*

And my *LoopCounter* is something like this-

Name:- LoopCounter
Start:-  1
Increment:- 1
Maximum:- 1000
Number format:- 000


I have unchecked *Track counter independently for each user*
*
*
But still I am getting exception thrown as Primary Key violation. Is there
anything wrong I am doing here?








*Raihan Jamal*


On Wed, Feb 13, 2013 at 11:41 AM, Raihan Jamal <ja...@gmail.com>wrote:

> I am trying to insert into the below table currently using JMeter-
>
> INSERT INTO XMP_TEST2 (id, a_sellers) values (?, ?)
>
> Data Types for the above columns are-
>
> *id                String*
> *a_sellers     String*
>
> In the above table *id is the Primary Key. *So I need some way to
> generate unique id always either starting from 1 or any random unique
> numbers. Is there any way I can do that in JMeter?
>
> Currently in my Parameter Values, I am passing something like this to
> insert in the above two columns-
>
>
> ${__BeanShell(UUID.randomUUID().toString())}
> ,"{""lv"":[{""v"":{""regId"":null,""
> user"":null,""Id"":996},""cn"":1}],""lmd"":1360185}"
>
>
> And Parameter types is-
>
> VARCHAR,VARCHAR
>
>
> One approach I am thinking of is keep on increment by one every time. But
> how should I do in this JMeter?
>
> Does anyone has any experience on this particular problem?
>
>
> Looking forward for your replies.
>
>
>
>
> *Raihan Jamal*
>

Re: Generate Random Unique numbers using JMeter

Posted by Deepak Shetty <sh...@gmail.com>.
hi
since JMeter is a multithreaded environment  - increment by one logic needs
synchronization.
You can use threadnumber plus an incremented variable -
or you can just have your db have an autoincremented key , no?



On Wed, Feb 13, 2013 at 11:41 AM, Raihan Jamal <ja...@gmail.com>wrote:

> I am trying to insert into the below table currently using JMeter-
>
> INSERT INTO XMP_TEST2 (id, a_sellers) values (?, ?)
>
> Data Types for the above columns are-
>
> *id                String*
> *a_sellers     String*
>
> In the above table *id is the Primary Key. *So I need some way to generate
> unique id always either starting from 1 or any random unique numbers. Is
> there any way I can do that in JMeter?
>
> Currently in my Parameter Values, I am passing something like this to
> insert in the above two columns-
>
>
> ${__BeanShell(UUID.randomUUID().toString())}
> ,"{""lv"":[{""v"":{""regId"":null,""
> user"":null,""Id"":996},""cn"":1}],""lmd"":1360185}"
>
>
> And Parameter types is-
>
> VARCHAR,VARCHAR
>
>
> One approach I am thinking of is keep on increment by one every time. But
> how should I do in this JMeter?
>
> Does anyone has any experience on this particular problem?
>
>
> Looking forward for your replies.
>
>
>
>
> *Raihan Jamal*
>