You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by bvm101 <bo...@yahoo.com> on 2007/06/12 21:47:58 UTC
How to pass a variable as a parameter to random function
Within a BeanShell PreProcessor I have a following code:
java.util.List ids = new java.util.ArrayList();
ids.add("key1");
ids.add("key2");
ids.add("key3");
int clientSize = ids.size();
${__Random(0,3 ,myRandom)};
vars.put("Col_65537", ids.get(${myRandom}));
However, when calling random function I would like to pass a variable for
the max value, in this case "clientSize", instead of number 3.
Your help will be greatly appreciated.
Thanks,
Boban
--
View this message in context: http://www.nabble.com/How-to-pass-a-variable-as-a-parameter-to-random-function-tf3909593.html#a11085352
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
Re: How to pass a variable as a parameter to random function
Posted by sebb <se...@gmail.com>.
Sorry, that should have been:
print("Size=${clientSize}.");
This does not define clientSize; it displays the value in the console
window so you can check that you have defined it properly.
On 13/06/07, bvm101 <bo...@yahoo.com> wrote:
>
> I am sorry, I am looking at the example to define clientSize, but I can't
> figure it out: print("Size=${clientSize}.";.
> Will you elaborate?
>
>
>
> sebb-2 wrote:
> >
> > On 12/06/07, bvm101 <bo...@yahoo.com> wrote:
> >>
> >> I did try ${__Random(0,${clientSize} ,myRandom)};, however, I get
> >> following
> >> error (error log):
> >
> > There's a space after ${clientSize} - try removing it.
> >
> > If that does not help, make sure that clientSize is defined, e.g. by
> > adding the following to the BeanShell script:
> >
> > print("Size=${clientSize}.";
> >
> >>
> >> 2007/06/12 17:41:43 ERROR - jmeter.threads.JMeterThread:
> >> java.lang.NumberFormatException: For input string: "${clientSize}"
> >> at java.lang.NumberFormatException.forInputString(Unknown Source)
> >> at java.lang.Long.parseLong(Unknown Source)
> >> at java.lang.Long.parseLong(Unknown Source)
> >> at org.apache.jmeter.functions.Random.execute(Random.java:78)
> >> at
> >> org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:127)
> >> at
> >> org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:96)
> >> at
> >> org.apache.jmeter.testelement.property.FunctionProperty.getStringValue(FunctionProperty.java:85)
> >> at
> >> org.apache.jmeter.testbeans.TestBeanHelper.prepare(TestBeanHelper.java:69)
> >> at
> >> org.apache.jmeter.threads.TestCompiler.runPreProcessors(TestCompiler.java:109)
> >> at
> >> org.apache.jmeter.threads.TestCompiler.configureSampler(TestCompiler.java:98)
> >> at
> >> org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:236)
> >> at java.lang.Thread.run(Unknown Source)
> >>
> >> ${__Random(0,${clientSize} ,myRandom)};
> >>
> >> sebb-2 wrote:
> >> >
> >> > On 12/06/07, bvm101 <bo...@yahoo.com> wrote:
> >> >>
> >> >> Within a BeanShell PreProcessor I have a following code:
> >> >>
> >> >> java.util.List ids = new java.util.ArrayList();
> >> >> ids.add("key1");
> >> >> ids.add("key2");
> >> >> ids.add("key3");
> >> >>
> >> >> int clientSize = ids.size();
> >> >>
> >> >> ${__Random(0,3 ,myRandom)};
> >> >
> >> > The above line should give the clue ... try
> >> >
> >> > ${__Random(0,${clientSize} ,myRandom)};
> >> >
> >> >> vars.put("Col_65537", ids.get(${myRandom}));
> >> >>
> >> >>
> >> >> However, when calling random function I would like to pass a variable
> >> for
> >> >> the max value, in this case "clientSize", instead of number 3.
> >> >>
> >> >> Your help will be greatly appreciated.
> >> >
> >> > If your test uses this Pre-processor a lot, you may find you get memory
> >> > leaks.
> >> >
> >> > You could put the code in an init file, and then call a method passing
> >> > in the Random number.
> >> >
> >> >> Thanks,
> >> >>
> >> >> Boban
> >> >> --
> >> >> View this message in context:
> >> >>
> >> http://www.nabble.com/How-to-pass-a-variable-as-a-parameter-to-random-function-tf3909593.html#a11085352
> >> >> Sent from the JMeter - User mailing list archive at Nabble.com.
> >> >>
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> >> >> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> >> >>
> >> >>
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> >> > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> >> >
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/How-to-pass-a-variable-as-a-parameter-to-random-function-tf3909593.html#a11088976
> >> Sent from the JMeter - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/How-to-pass-a-variable-as-a-parameter-to-random-function-tf3909593.html#a11090492
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
Re: How to pass a variable as a parameter to random function
Posted by bvm101 <bo...@yahoo.com>.
I am sorry, I am looking at the example to define clientSize, but I can’t
figure it out: print("Size=${clientSize}.";.
Will you elaborate?
sebb-2 wrote:
>
> On 12/06/07, bvm101 <bo...@yahoo.com> wrote:
>>
>> I did try ${__Random(0,${clientSize} ,myRandom)};, however, I get
>> following
>> error (error log):
>
> There's a space after ${clientSize} - try removing it.
>
> If that does not help, make sure that clientSize is defined, e.g. by
> adding the following to the BeanShell script:
>
> print("Size=${clientSize}.";
>
>>
>> 2007/06/12 17:41:43 ERROR - jmeter.threads.JMeterThread:
>> java.lang.NumberFormatException: For input string: "${clientSize}"
>> at java.lang.NumberFormatException.forInputString(Unknown Source)
>> at java.lang.Long.parseLong(Unknown Source)
>> at java.lang.Long.parseLong(Unknown Source)
>> at org.apache.jmeter.functions.Random.execute(Random.java:78)
>> at
>> org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:127)
>> at
>> org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:96)
>> at
>> org.apache.jmeter.testelement.property.FunctionProperty.getStringValue(FunctionProperty.java:85)
>> at
>> org.apache.jmeter.testbeans.TestBeanHelper.prepare(TestBeanHelper.java:69)
>> at
>> org.apache.jmeter.threads.TestCompiler.runPreProcessors(TestCompiler.java:109)
>> at
>> org.apache.jmeter.threads.TestCompiler.configureSampler(TestCompiler.java:98)
>> at
>> org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:236)
>> at java.lang.Thread.run(Unknown Source)
>>
>> ${__Random(0,${clientSize} ,myRandom)};
>>
>> sebb-2 wrote:
>> >
>> > On 12/06/07, bvm101 <bo...@yahoo.com> wrote:
>> >>
>> >> Within a BeanShell PreProcessor I have a following code:
>> >>
>> >> java.util.List ids = new java.util.ArrayList();
>> >> ids.add("key1");
>> >> ids.add("key2");
>> >> ids.add("key3");
>> >>
>> >> int clientSize = ids.size();
>> >>
>> >> ${__Random(0,3 ,myRandom)};
>> >
>> > The above line should give the clue ... try
>> >
>> > ${__Random(0,${clientSize} ,myRandom)};
>> >
>> >> vars.put("Col_65537", ids.get(${myRandom}));
>> >>
>> >>
>> >> However, when calling random function I would like to pass a variable
>> for
>> >> the max value, in this case "clientSize", instead of number 3.
>> >>
>> >> Your help will be greatly appreciated.
>> >
>> > If your test uses this Pre-processor a lot, you may find you get memory
>> > leaks.
>> >
>> > You could put the code in an init file, and then call a method passing
>> > in the Random number.
>> >
>> >> Thanks,
>> >>
>> >> Boban
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/How-to-pass-a-variable-as-a-parameter-to-random-function-tf3909593.html#a11085352
>> >> Sent from the JMeter - User mailing list archive at Nabble.com.
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>> >> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>> > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/How-to-pass-a-variable-as-a-parameter-to-random-function-tf3909593.html#a11088976
>> Sent from the JMeter - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/How-to-pass-a-variable-as-a-parameter-to-random-function-tf3909593.html#a11090492
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
Re: How to pass a variable as a parameter to random function
Posted by sebb <se...@gmail.com>.
On 12/06/07, bvm101 <bo...@yahoo.com> wrote:
>
> I did try ${__Random(0,${clientSize} ,myRandom)};, however, I get following
> error (error log):
There's a space after ${clientSize} - try removing it.
If that does not help, make sure that clientSize is defined, e.g. by
adding the following to the BeanShell script:
print("Size=${clientSize}.";
>
> 2007/06/12 17:41:43 ERROR - jmeter.threads.JMeterThread:
> java.lang.NumberFormatException: For input string: "${clientSize}"
> at java.lang.NumberFormatException.forInputString(Unknown Source)
> at java.lang.Long.parseLong(Unknown Source)
> at java.lang.Long.parseLong(Unknown Source)
> at org.apache.jmeter.functions.Random.execute(Random.java:78)
> at
> org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:127)
> at
> org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:96)
> at
> org.apache.jmeter.testelement.property.FunctionProperty.getStringValue(FunctionProperty.java:85)
> at
> org.apache.jmeter.testbeans.TestBeanHelper.prepare(TestBeanHelper.java:69)
> at
> org.apache.jmeter.threads.TestCompiler.runPreProcessors(TestCompiler.java:109)
> at
> org.apache.jmeter.threads.TestCompiler.configureSampler(TestCompiler.java:98)
> at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:236)
> at java.lang.Thread.run(Unknown Source)
>
> ${__Random(0,${clientSize} ,myRandom)};
>
> sebb-2 wrote:
> >
> > On 12/06/07, bvm101 <bo...@yahoo.com> wrote:
> >>
> >> Within a BeanShell PreProcessor I have a following code:
> >>
> >> java.util.List ids = new java.util.ArrayList();
> >> ids.add("key1");
> >> ids.add("key2");
> >> ids.add("key3");
> >>
> >> int clientSize = ids.size();
> >>
> >> ${__Random(0,3 ,myRandom)};
> >
> > The above line should give the clue ... try
> >
> > ${__Random(0,${clientSize} ,myRandom)};
> >
> >> vars.put("Col_65537", ids.get(${myRandom}));
> >>
> >>
> >> However, when calling random function I would like to pass a variable for
> >> the max value, in this case "clientSize", instead of number 3.
> >>
> >> Your help will be greatly appreciated.
> >
> > If your test uses this Pre-processor a lot, you may find you get memory
> > leaks.
> >
> > You could put the code in an init file, and then call a method passing
> > in the Random number.
> >
> >> Thanks,
> >>
> >> Boban
> >> --
> >> View this message in context:
> >> http://www.nabble.com/How-to-pass-a-variable-as-a-parameter-to-random-function-tf3909593.html#a11085352
> >> Sent from the JMeter - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/How-to-pass-a-variable-as-a-parameter-to-random-function-tf3909593.html#a11088976
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
Re: How to pass a variable as a parameter to random function
Posted by bvm101 <bo...@yahoo.com>.
I did try ${__Random(0,${clientSize} ,myRandom)};, however, I get following
error (error log):
2007/06/12 17:41:43 ERROR - jmeter.threads.JMeterThread:
java.lang.NumberFormatException: For input string: "${clientSize}"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Long.parseLong(Unknown Source)
at java.lang.Long.parseLong(Unknown Source)
at org.apache.jmeter.functions.Random.execute(Random.java:78)
at
org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:127)
at
org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:96)
at
org.apache.jmeter.testelement.property.FunctionProperty.getStringValue(FunctionProperty.java:85)
at
org.apache.jmeter.testbeans.TestBeanHelper.prepare(TestBeanHelper.java:69)
at
org.apache.jmeter.threads.TestCompiler.runPreProcessors(TestCompiler.java:109)
at
org.apache.jmeter.threads.TestCompiler.configureSampler(TestCompiler.java:98)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:236)
at java.lang.Thread.run(Unknown Source)
${__Random(0,${clientSize} ,myRandom)};
sebb-2 wrote:
>
> On 12/06/07, bvm101 <bo...@yahoo.com> wrote:
>>
>> Within a BeanShell PreProcessor I have a following code:
>>
>> java.util.List ids = new java.util.ArrayList();
>> ids.add("key1");
>> ids.add("key2");
>> ids.add("key3");
>>
>> int clientSize = ids.size();
>>
>> ${__Random(0,3 ,myRandom)};
>
> The above line should give the clue ... try
>
> ${__Random(0,${clientSize} ,myRandom)};
>
>> vars.put("Col_65537", ids.get(${myRandom}));
>>
>>
>> However, when calling random function I would like to pass a variable for
>> the max value, in this case "clientSize", instead of number 3.
>>
>> Your help will be greatly appreciated.
>
> If your test uses this Pre-processor a lot, you may find you get memory
> leaks.
>
> You could put the code in an init file, and then call a method passing
> in the Random number.
>
>> Thanks,
>>
>> Boban
>> --
>> View this message in context:
>> http://www.nabble.com/How-to-pass-a-variable-as-a-parameter-to-random-function-tf3909593.html#a11085352
>> Sent from the JMeter - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/How-to-pass-a-variable-as-a-parameter-to-random-function-tf3909593.html#a11088976
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
Re: How to pass a variable as a parameter to random function
Posted by sebb <se...@gmail.com>.
On 12/06/07, bvm101 <bo...@yahoo.com> wrote:
>
> Within a BeanShell PreProcessor I have a following code:
>
> java.util.List ids = new java.util.ArrayList();
> ids.add("key1");
> ids.add("key2");
> ids.add("key3");
>
> int clientSize = ids.size();
>
> ${__Random(0,3 ,myRandom)};
The above line should give the clue ... try
${__Random(0,${clientSize} ,myRandom)};
> vars.put("Col_65537", ids.get(${myRandom}));
>
>
> However, when calling random function I would like to pass a variable for
> the max value, in this case "clientSize", instead of number 3.
>
> Your help will be greatly appreciated.
If your test uses this Pre-processor a lot, you may find you get memory leaks.
You could put the code in an init file, and then call a method passing
in the Random number.
> Thanks,
>
> Boban
> --
> View this message in context: http://www.nabble.com/How-to-pass-a-variable-as-a-parameter-to-random-function-tf3909593.html#a11085352
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
Pointing to multiple server names in HTTP Request Defaults.
Posted by "Ankem, Balaji" <ba...@amazon.com>.
Hi,
I want to record when I am testing on my desktop browser.
My website is linked to different servers. Once the request is changed
to different server I am not getting the page as I kept the server name
in HTTP Request defaults to a single server.
Is there any way to direct the request to any server name?
Thanks in advance.
Regards
Balaji
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org