Discussion:
Passing variables to Random function
David Fertig
2018-08-21 19:32:20 UTC
Permalink
I have a variable called numFiles, which I can print and verify contains an integer.
Integer numFiles = vars.getObject("numFiles");

I want to make a random number between 0 and that value. But all of the following fail
${__Random(0,__ ${numFiles},docIndex)};

Integer docIndex = ${__Random(0,${numFiles})};

${__Random(0,__ numFiles,docIndex)};

Integer docIndex = ${__Random(0,numFiles)};

All with an errors like:
Uncaught Exception java.lang.NumberFormatException: For input string: "${NUMFILES}". See log file for details.

Uncaught Exception java.lang.NumberFormatException: For input string: "numFiles". See log file for details.

How do I pass a variable into the random() function?



Thank you
David



This email, including attachments, may contain information that is privileged, confidential or is exempt from disclosure under applicable law (including, but not limited to, protected health information). It is not intended for transmission to, or receipt by, any unauthorized persons. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you believe this email was sent to you in error, do not read it. Please notify the sender immediately informing them of the error and delete all copies and attachments of the message from your system. Thank you.
Deepak Shetty
2018-08-21 20:04:33 UTC
Permalink
${__Random(0,${numFiles},docIndex)} should work Where are you specifying
this ? Note special considerations apply if you are trying this within for
e.g. a beanshell sampler
Post by David Fertig
I have a variable called numFiles, which I can print and verify contains an integer.
Integer numFiles = vars.getObject("numFiles");
I want to make a random number between 0 and that value. But all of the following fail
${__Random(0,__ ${numFiles},docIndex)};
Integer docIndex = ${__Random(0,${numFiles})};
${__Random(0,__ numFiles,docIndex)};
Integer docIndex = ${__Random(0,numFiles)};
"${NUMFILES}". See log file for details.
"numFiles". See log file for details.
How do I pass a variable into the random() function?
Thank you
David
This email, including attachments, may contain information that is
privileged, confidential or is exempt from disclosure under applicable law
(including, but not limited to, protected health information). It is not
intended for transmission to, or receipt by, any unauthorized persons. If
the reader of this message is not the intended recipient, or the employee
or agent responsible for delivering the message to the intended recipient,
you are hereby notified that any dissemination, distribution or copying of
this communication is strictly prohibited. If you believe this email was
sent to you in error, do not read it. Please notify the sender immediately
informing them of the error and delete all copies and attachments of the
message from your system. Thank you.
Felix Schumacher
2018-08-22 15:06:03 UTC
Permalink
Post by David Fertig
I have a variable called numFiles, which I can print and verify contains an integer.
Integer numFiles = vars.getObject("numFiles");
I want to make a random number between 0 and that value. But all of the following fail
${__Random(0,__ ${numFiles},docIndex)};
Integer docIndex = ${__Random(0,${numFiles})};
${__Random(0,__ numFiles,docIndex)};
Integer docIndex = ${__Random(0,numFiles)};
Uncaught Exception java.lang.NumberFormatException: For input string: "${NUMFILES}". See log file for details.
Uncaught Exception java.lang.NumberFormatException: For input string: "numFiles". See log file for details.
How do I pass a variable into the random() function?
It seems that this is a bug. At the moment the Strings given to __Random
will not be evaluated (and therefore the Integer will not be transformed
into a String).

Till the bug is fixed, you will have to transform the Integer into a
String by yourself.

Regards,
 Felix
Post by David Fertig
Thank you
David
This email, including attachments, may contain information that is privileged, confidential or is exempt from disclosure under applicable law (including, but not limited to, protected health information). It is not intended for transmission to, or receipt by, any unauthorized persons. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you believe this email was sent to you in error, do not read it. Please notify the sender immediately informing them of the error and delete all copies and attachments of the message from your system. Thank you.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@jmeter.apache.org
For additional commands, e-mail: user-***@jmeter.apache.org
Felix Schumacher
2018-08-22 15:14:14 UTC
Permalink
Post by Felix Schumacher
Post by David Fertig
I have a variable called numFiles, which I can print and verify contains an integer.
Integer numFiles = vars.getObject("numFiles");
I want to make a random number between 0 and that value.  But all of
the following fail
${__Random(0,__ ${numFiles},docIndex)};
Integer docIndex  = ${__Random(0,${numFiles})};
${__Random(0,__ numFiles,docIndex)};
Integer docIndex  = ${__Random(0,numFiles)};
"${NUMFILES}". See log file for details.
"numFiles". See log file for details.
How do I pass a variable into the random() function?
It seems that this is a bug. At the moment the Strings given to
__Random will not be evaluated (and therefore the Integer will not be
transformed into a String).
On second thought "bug" might be a bit harsh, as no function in JMeter
will currently transform those values by itself (yet?).

To answer your question, you could use __evalVar function to convert
your Integer into a String:

${__Random(0,${__evalVar(numFiles)})}

Regards,
 Feli


---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@jmeter.apache.org
For additional commands, e-mail: user-***@jmeter.apache.org
sebb
2018-08-22 15:50:24 UTC
Permalink
On 22 August 2018 at 16:14, Felix Schumacher
Post by Felix Schumacher
Post by David Fertig
I have a variable called numFiles, which I can print and verify contains an integer.
Integer numFiles = vars.getObject("numFiles");
I want to make a random number between 0 and that value. But all of the following fail
${__Random(0,__ ${numFiles},docIndex)};
Integer docIndex = ${__Random(0,${numFiles})};
${__Random(0,__ numFiles,docIndex)};
Integer docIndex = ${__Random(0,numFiles)};
"${NUMFILES}". See log file for details.
"numFiles". See log file for details.
How do I pass a variable into the random() function?
It seems that this is a bug. At the moment the Strings given to __Random
will not be evaluated (and therefore the Integer will not be transformed
into a String).
On second thought "bug" might be a bit harsh, as no function in JMeter will
currently transform those values by itself (yet?).
It's not a bug (or even a feature). It's not supported.

Variables were designed to be used for replacement of fixed text in test plans.
e.g.. instead of

http://a.b.c:80/

one could have the following textual definitions (e.g. on the Test Plan):

HOST=a.b.c
PORT=80

and use the following instead:
http://${HOST}:${PORT}/

It so happens that the variables are stored in a structure that allows
the values to be arbitrary objects.

This proved useful for passing data between scripts
(putObject/getObject), but was never intended for use in the test plan
textual substitution functionality.

Variables that are used in test plan elements must have values that are Strings.

A simple way to fix the errors is to ensure that the script stores the
value as a String (e.g. using a new variable name).
To answer your question, you could use __evalVar function to convert your
${__Random(0,${__evalVar(numFiles)})}
Regards,
Feli
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@jmeter.apache.org
For additional commands, e-mail: user-***@jmeter.apache.org
David Fertig
2018-08-23 15:34:06 UTC
Permalink
Post by Felix Schumacher
${__Random(0,${__evalVar(numFiles)})}
Unfortunately this also does not work.

2018-08-23 11:32:53,096 ERROR o.a.j.JMeter: Uncaught exception: java.lang.NumberFormatException: For input string: ""



-----Original Message-----
From: Felix Schumacher <***@internetallee.de>
Sent: Wednesday, August 22, 2018 11:14 AM
To: ***@jmeter.apache.org
Subject: Re: Passing variables to Random function
Post by Felix Schumacher
Post by David Fertig
I have a variable called numFiles, which I can print and verify contains an integer.
Integer numFiles = vars.getObject("numFiles");
I want to make a random number between 0 and that value. But all of
the following fail ${__Random(0,__ ${numFiles},docIndex)};
Integer docIndex = ${__Random(0,${numFiles})};
${__Random(0,__ numFiles,docIndex)};
Integer docIndex = ${__Random(0,numFiles)};
"${NUMFILES}". See log file for details.
"numFiles". See log file for details.
How do I pass a variable into the random() function?
It seems that this is a bug. At the moment the Strings given to
__Random will not be evaluated (and therefore the Integer will not be
transformed into a String).
On second thought "bug" might be a bit harsh, as no function in JMeter will currently transform those values by itself (yet?).

To answer your question, you could use __evalVar function to convert your Integer into a String:

${__Random(0,${__evalVar(numFiles)})}

Regards,
Feli


---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@jmeter.apache.org
For additional commands, e-mail: user-***@jmeter.apache.org

This email, including attachments, may contain information that is privileged, confidential or is exempt from disclosure under applicable law (including, but not limited to, protected health information). It is not intended for transmission to, or receipt by, any unauthorized persons. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you believe this email was sent to you in error, do not read it. Please notify the sender immediately informing them of the error and delete all copies and attachments of the message from your system. Thank you.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@jmeter.apache.org
For additional commands, e-mail: user-***@jmeter.apache.org
Felix Schumacher
2018-08-23 19:15:32 UTC
Permalink
Post by David Fertig
Post by Felix Schumacher
${__Random(0,${__evalVar(numFiles)})}
Unfortunately this also does not work.
2018-08-23 11:32:53,096 ERROR o.a.j.JMeter: Uncaught exception: java.lang.NumberFormatException: For input string: ""
Are you sure, that your variable numFiles is spelled correct? Try to add
a debug sampler to check.

Felix
Post by David Fertig
-----Original Message-----
Sent: Wednesday, August 22, 2018 11:14 AM
Subject: Re: Passing variables to Random function
Post by Felix Schumacher
Post by David Fertig
I have a variable called numFiles, which I can print and verify contains an integer.
Integer numFiles = vars.getObject("numFiles");
I want to make a random number between 0 and that value. But all of
the following fail ${__Random(0,__ ${numFiles},docIndex)};
Integer docIndex = ${__Random(0,${numFiles})};
${__Random(0,__ numFiles,docIndex)};
Integer docIndex = ${__Random(0,numFiles)};
"${NUMFILES}". See log file for details.
"numFiles". See log file for details.
How do I pass a variable into the random() function?
It seems that this is a bug. At the moment the Strings given to
__Random will not be evaluated (and therefore the Integer will not be
transformed into a String).
On second thought "bug" might be a bit harsh, as no function in JMeter will currently transform those values by itself (yet?).
${__Random(0,${__evalVar(numFiles)})}
Regards,
Feli
---------------------------------------------------------------------
This email, including attachments, may contain information that is privileged, confidential or is exempt from disclosure under applicable law (including, but not limited to, protected health information). It is not intended for transmission to, or receipt by, any unauthorized persons. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you believe this email was sent to you in error, do not read it. Please notify the sender immediately informing them of the error and delete all copies and attachments of the message from your system. Thank you.
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@jmeter.apache.org
For additional commands, e-mail: user-***@jmeter.apache.org
Deepak Shetty
2018-08-23 19:41:46 UTC
Permalink
Hi
here is my example that works

https://onedrive.live.com/?cid=1BD02FE33F80B8AC&id=1BD02FE33F80B8AC%211557&parId=1BD02FE33F80B8AC%21268&o=OneUp
Post by David Fertig
Post by Felix Schumacher
${__Random(0,${__evalVar(numFiles)})}
Unfortunately this also does not work.
java.lang.NumberFormatException: For input string: ""
-----Original Message-----
Sent: Wednesday, August 22, 2018 11:14 AM
Subject: Re: Passing variables to Random function
Post by Felix Schumacher
Post by David Fertig
I have a variable called numFiles, which I can print and verify contains an integer.
Integer numFiles = vars.getObject("numFiles");
I want to make a random number between 0 and that value. But all of
the following fail ${__Random(0,__ ${numFiles},docIndex)};
Integer docIndex = ${__Random(0,${numFiles})};
${__Random(0,__ numFiles,docIndex)};
Integer docIndex = ${__Random(0,numFiles)};
"${NUMFILES}". See log file for details.
"numFiles". See log file for details.
How do I pass a variable into the random() function?
It seems that this is a bug. At the moment the Strings given to
__Random will not be evaluated (and therefore the Integer will not be
transformed into a String).
On second thought "bug" might be a bit harsh, as no function in JMeter
will currently transform those values by itself (yet?).
To answer your question, you could use __evalVar function to convert your
${__Random(0,${__evalVar(numFiles)})}
Regards,
Feli
---------------------------------------------------------------------
This email, including attachments, may contain information that is
privileged, confidential or is exempt from disclosure under applicable law
(including, but not limited to, protected health information). It is not
intended for transmission to, or receipt by, any unauthorized persons. If
the reader of this message is not the intended recipient, or the employee
or agent responsible for delivering the message to the intended recipient,
you are hereby notified that any dissemination, distribution or copying of
this communication is strictly prohibited. If you believe this email was
sent to you in error, do not read it. Please notify the sender immediately
informing them of the error and delete all copies and attachments of the
message from your system. Thank you.
---------------------------------------------------------------------
LERBSCHER JEAN-PIERRE
2018-08-27 07:13:14 UTC
Permalink
Hi,

Is numFiles an expression?

There is a gap in user manual between eval function and evalVar function.


Variables eval<https://jmeter.apache.org/usermanual/functions.html#__eval> evaluate a variable expression 2.3.1
Variables evalVar<https://jmeter.apache.org/usermanual/functions.html#__evalVar> evaluate an expression stored in a variable 2.3.1



________________________________
De : David Fertig <***@navihealth.com>
Envoyé : jeudi 23 août 2018 17:34
À : JMeter Users List
Objet : RE: Passing variables to Random function
Post by Felix Schumacher
${__Random(0,${__evalVar(numFiles)})}
Unfortunately this also does not work.

2018-08-23 11:32:53,096 ERROR o.a.j.JMeter: Uncaught exception: java.lang.NumberFormatException: For input string: ""



-----Original Message-----
From: Felix Schumacher <***@internetallee.de>
Sent: Wednesday, August 22, 2018 11:14 AM
To: ***@jmeter.apache.org
Subject: Re: Passing variables to Random function
Post by Felix Schumacher
Post by David Fertig
I have a variable called numFiles, which I can print and verify contains an integer.
Integer numFiles = vars.getObject("numFiles");
I want to make a random number between 0 and that value. But all of
the following fail ${__Random(0,__ ${numFiles},docIndex)};
Integer docIndex = ${__Random(0,${numFiles})};
${__Random(0,__ numFiles,docIndex)};
Integer docIndex = ${__Random(0,numFiles)};
"${NUMFILES}". See log file for details.
"numFiles". See log file for details.
How do I pass a variable into the random() function?
It seems that this is a bug. At the moment the Strings given to
__Random will not be evaluated (and therefore the Integer will not be
transformed into a String).
On second thought "bug" might be a bit harsh, as no function in JMeter will currently transform those values by itself (yet?).

To answer your question, you could use __evalVar function to convert your Integer into a String:

${__Random(0,${__evalVar(numFiles)})}

Regards,
Feli


---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@jmeter.apache.org
For additional commands, e-mail: user-***@jmeter.apache.org

This email, including attachments, may contain information that is privileged, confidential or is exempt from disclosure under applicable law (including, but not limited to, protected health information). It is not intended for transmission to, or receipt by, any unauthorized persons. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you believe this email was sent to you in error, do not read it. Please notify the sender immediately informing them of the error and delete all copies and attachments of the message from your system. Thank you.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@jmeter.apache.org
For additional commands, e-mail: user-***@jmeter.apache.org
David Fertig
2018-08-27 14:28:43 UTC
Permalink
numFIles is an Integer.

I've made a workaround on this by generating a random 0-1 million, creating a fraction, and then multiplying by my original value. Just a workout, but works in my case.


-----Original Message-----
From: LERBSCHER JEAN-PIERRE <***@hotmail.com>
Sent: Monday, August 27, 2018 3:13 AM
To: JMeter Users List <***@jmeter.apache.org>
Subject: RE: Passing variables to Random function

Hi,

Is numFiles an expression?

There is a gap in user manual between eval function and evalVar function.


Variables eval<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fjmeter.apache.org%2Fusermanual%2Ffunctions.html%23__eval&amp;data=02%7C01%7CDavid.Fertig%40navihealth.com%7C065d5908de1a45f21ad008d60bec951b%7C6e94af0345c143158632e1c94ce46b97%7C1%7C0%7C636709508094251230&amp;sdata=Sls%2BioMpQ7866EyE%2Falv0A%2Fex7Ix52TzgguUZELRHbU%3D&amp;reserved=0> evaluate a variable expression 2.3.1
Variables evalVar<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fjmeter.apache.org%2Fusermanual%2Ffunctions.html%23__evalVar&amp;data=02%7C01%7CDavid.Fertig%40navihealth.com%7C065d5908de1a45f21ad008d60bec951b%7C6e94af0345c143158632e1c94ce46b97%7C1%7C0%7C636709508094251230&amp;sdata=l%2FQaMA6czWkYhHefPHwsM9Wh%2BmlLqTQGOjlgjT5N3VE%3D&amp;reserved=0> evaluate an expression stored in a variable 2.3.1



________________________________
Post by Felix Schumacher
${__Random(0,${__evalVar(numFiles)})}
Unfortunately this also does not work.

2018-08-23 11:32:53,096 ERROR o.a.j.JMeter: Uncaught exception: java.lang.NumberFormatException: For input string: ""



-----Original Message-----
From: Felix Schumacher <***@internetallee.de>
Sent: Wednesday, August 22, 2018 11:14 AM
To: ***@jmeter.apache.org
Subject: Re: Passing variables to Random function
Post by Felix Schumacher
Post by David Fertig
I have a variable called numFiles, which I can print and verify contains an integer.
Integer numFiles = vars.getObject("numFiles");
I want to make a random number between 0 and that value. But all of
the following fail ${__Random(0,__ ${numFiles},docIndex)};
Integer docIndex = ${__Random(0,${numFiles})};
${__Random(0,__ numFiles,docIndex)};
Integer docIndex = ${__Random(0,numFiles)};
"${NUMFILES}". See log file for details.
"numFiles". See log file for details.
How do I pass a variable into the random() function?
It seems that this is a bug. At the moment the Strings given to
__Random will not be evaluated (and therefore the Integer will not be
transformed into a String).
On second thought "bug" might be a bit harsh, as no function in JMeter will currently transform those values by itself (yet?).

To answer your question, you could use __evalVar function to convert your Integer into a String:

${__Random(0,${__evalVar(numFiles)})}

Regards,
Feli


---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@jmeter.apache.org
For additional commands, e-mail: user-***@jmeter.apache.org

This email, including attachments, may contain information that is privileged, confidential or is exempt from disclosure under applicable law (including, but not limited to, protected health information). It is not intended for transmission to, or receipt by, any unauthorized persons. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you believe this email was sent to you in error, do not read it. Please notify the sender immediately informing them of the error and delete all copies and attachments of the message from your system. Thank you.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@jmeter.apache.org
For additional commands, e-mail: user-***@jmeter.apache.org

This email, including attachments, may contain information that is privileged, confidential or is exempt from disclosure under applicable law (including, but not limited to, protected health information). It is not intended for transmission to, or receipt by, any unauthorized persons. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you believe this email was sent to you in error, do not read it. Please notify the sender immediately informing them of the error and delete all copies and attachments of the message from your system. Thank you.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@jmeter.apache.org
For additional commands, e-mail: user-***@jmeter.apache.org

Deepak Shetty
2018-08-23 01:42:14 UTC
Permalink
Hi
I initially tried this with a string , but I dont get this issue with an
integer either - How were you able to replicate
Thread group
+Bean Shell sampler // vars.putObject("numFiles",new Integer(10));
+Http Request
++ParamValue - ${__Random(0,${numFiles},docIndex)}

which works fine.

On Wed, Aug 22, 2018 at 8:06 AM Felix Schumacher <
Post by David Fertig
Post by David Fertig
I have a variable called numFiles, which I can print and verify contains
an integer.
Post by David Fertig
Integer numFiles = vars.getObject("numFiles");
I want to make a random number between 0 and that value. But all of the
following fail
Post by David Fertig
${__Random(0,__ ${numFiles},docIndex)};
Integer docIndex = ${__Random(0,${numFiles})};
${__Random(0,__ numFiles,docIndex)};
Integer docIndex = ${__Random(0,numFiles)};
"${NUMFILES}". See log file for details.
"numFiles". See log file for details.
Post by David Fertig
How do I pass a variable into the random() function?
It seems that this is a bug. At the moment the Strings given to __Random
will not be evaluated (and therefore the Integer will not be transformed
into a String).
Till the bug is fixed, you will have to transform the Integer into a
String by yourself.
Regards,
Felix
Post by David Fertig
Thank you
David
This email, including attachments, may contain information that is
privileged, confidential or is exempt from disclosure under applicable law
(including, but not limited to, protected health information). It is not
intended for transmission to, or receipt by, any unauthorized persons. If
the reader of this message is not the intended recipient, or the employee
or agent responsible for delivering the message to the intended recipient,
you are hereby notified that any dissemination, distribution or copying of
this communication is strictly prohibited. If you believe this email was
sent to you in error, do not read it. Please notify the sender immediately
informing them of the error and delete all copies and attachments of the
message from your system. Thank you.
---------------------------------------------------------------------
Felix Schumacher
2018-08-23 08:43:11 UTC
Permalink
Post by Deepak Shetty
Hi
I initially tried this with a string , but I dont get this issue with an
integer either - How were you able to replicate
Thread group
+Bean Shell sampler // vars.putObject("numFiles",new Integer(10));
+Http Request
++ParamValue - ${__Random(0,${numFiles},docIndex)}
Try to use the title of a sampler. Parameters seem to be handled
differently.

Felix
Post by Deepak Shetty
which works fine.
On Wed, Aug 22, 2018 at 8:06 AM Felix Schumacher <
Post by David Fertig
Post by David Fertig
I have a variable called numFiles, which I can print and verify contains
an integer.
Post by David Fertig
Integer numFiles = vars.getObject("numFiles");
I want to make a random number between 0 and that value. But all of the
following fail
Post by David Fertig
${__Random(0,__ ${numFiles},docIndex)};
Integer docIndex = ${__Random(0,${numFiles})};
${__Random(0,__ numFiles,docIndex)};
Integer docIndex = ${__Random(0,numFiles)};
"${NUMFILES}". See log file for details.
"numFiles". See log file for details.
Post by David Fertig
How do I pass a variable into the random() function?
It seems that this is a bug. At the moment the Strings given to __Random
will not be evaluated (and therefore the Integer will not be transformed
into a String).
Till the bug is fixed, you will have to transform the Integer into a
String by yourself.
Regards,
Felix
Post by David Fertig
Thank you
David
This email, including attachments, may contain information that is
privileged, confidential or is exempt from disclosure under applicable law
(including, but not limited to, protected health information). It is not
intended for transmission to, or receipt by, any unauthorized persons. If
the reader of this message is not the intended recipient, or the employee
or agent responsible for delivering the message to the intended recipient,
you are hereby notified that any dissemination, distribution or copying of
this communication is strictly prohibited. If you believe this email was
sent to you in error, do not read it. Please notify the sender immediately
informing them of the error and delete all copies and attachments of the
message from your system. Thank you.
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@jmeter.apache.org
For additional commands, e-mail: user-***@jmeter.apache.org
Deepak Shetty
2018-08-23 14:07:45 UTC
Permalink
Hi
title worked too

regards
deepak

On Thu, Aug 23, 2018 at 1:43 AM Felix Schumacher <
Post by Felix Schumacher
Post by Deepak Shetty
Hi
I initially tried this with a string , but I dont get this issue with an
integer either - How were you able to replicate
Thread group
+Bean Shell sampler // vars.putObject("numFiles",new Integer(10));
+Http Request
++ParamValue - ${__Random(0,${numFiles},docIndex)}
Try to use the title of a sampler. Parameters seem to be handled
differently.
Felix
Post by Deepak Shetty
which works fine.
On Wed, Aug 22, 2018 at 8:06 AM Felix Schumacher <
Post by David Fertig
Post by David Fertig
I have a variable called numFiles, which I can print and verify
contains
Post by Deepak Shetty
Post by David Fertig
an integer.
Post by David Fertig
Integer numFiles = vars.getObject("numFiles");
I want to make a random number between 0 and that value. But all of
the
Post by Deepak Shetty
Post by David Fertig
following fail
Post by David Fertig
${__Random(0,__ ${numFiles},docIndex)};
Integer docIndex = ${__Random(0,${numFiles})};
${__Random(0,__ numFiles,docIndex)};
Integer docIndex = ${__Random(0,numFiles)};
"${NUMFILES}". See log file for details.
"numFiles". See log file for details.
Post by David Fertig
How do I pass a variable into the random() function?
It seems that this is a bug. At the moment the Strings given to __Random
will not be evaluated (and therefore the Integer will not be transformed
into a String).
Till the bug is fixed, you will have to transform the Integer into a
String by yourself.
Regards,
Felix
Post by David Fertig
Thank you
David
This email, including attachments, may contain information that is
privileged, confidential or is exempt from disclosure under applicable
law
Post by Deepak Shetty
Post by David Fertig
(including, but not limited to, protected health information). It is not
intended for transmission to, or receipt by, any unauthorized persons.
If
Post by Deepak Shetty
Post by David Fertig
the reader of this message is not the intended recipient, or the
employee
Post by Deepak Shetty
Post by David Fertig
or agent responsible for delivering the message to the intended
recipient,
Post by Deepak Shetty
Post by David Fertig
you are hereby notified that any dissemination, distribution or copying
of
Post by Deepak Shetty
Post by David Fertig
this communication is strictly prohibited. If you believe this email was
sent to you in error, do not read it. Please notify the sender
immediately
Post by Deepak Shetty
Post by David Fertig
informing them of the error and delete all copies and attachments of the
message from your system. Thank you.
---------------------------------------------------------------------
---------------------------------------------------------------------
Felix Schumacher
2018-08-23 19:22:14 UTC
Permalink
Post by Deepak Shetty
Hi
title worked too
For me now, too.

The test cases I used - and the reported stacktraces - showed that an
Integer will not be converted automatically to a String by the Random
function. And I probably misspelled my variable name and got the error
when I tested it through the GUI. It seems that the GUI is trying harder
to convert the complete function string components to string values
before giving the values to the Random function.

Thanks for your double checking and insistence.
 Felix
Post by Deepak Shetty
regards
deepak
On Thu, Aug 23, 2018 at 1:43 AM Felix Schumacher <
Post by Felix Schumacher
Post by Deepak Shetty
Hi
I initially tried this with a string , but I dont get this issue with an
integer either - How were you able to replicate
Thread group
+Bean Shell sampler // vars.putObject("numFiles",new Integer(10));
+Http Request
++ParamValue - ${__Random(0,${numFiles},docIndex)}
Try to use the title of a sampler. Parameters seem to be handled
differently.
Felix
Post by Deepak Shetty
which works fine.
On Wed, Aug 22, 2018 at 8:06 AM Felix Schumacher <
Post by David Fertig
Post by David Fertig
I have a variable called numFiles, which I can print and verify
contains
Post by Deepak Shetty
Post by David Fertig
an integer.
Post by David Fertig
Integer numFiles = vars.getObject("numFiles");
I want to make a random number between 0 and that value. But all of
the
Post by Deepak Shetty
Post by David Fertig
following fail
Post by David Fertig
${__Random(0,__ ${numFiles},docIndex)};
Integer docIndex = ${__Random(0,${numFiles})};
${__Random(0,__ numFiles,docIndex)};
Integer docIndex = ${__Random(0,numFiles)};
"${NUMFILES}". See log file for details.
"numFiles". See log file for details.
Post by David Fertig
How do I pass a variable into the random() function?
It seems that this is a bug. At the moment the Strings given to __Random
will not be evaluated (and therefore the Integer will not be transformed
into a String).
Till the bug is fixed, you will have to transform the Integer into a
String by yourself.
Regards,
Felix
Post by David Fertig
Thank you
David
This email, including attachments, may contain information that is
privileged, confidential or is exempt from disclosure under applicable
law
Post by Deepak Shetty
Post by David Fertig
(including, but not limited to, protected health information). It is not
intended for transmission to, or receipt by, any unauthorized persons.
If
Post by Deepak Shetty
Post by David Fertig
the reader of this message is not the intended recipient, or the
employee
Post by Deepak Shetty
Post by David Fertig
or agent responsible for delivering the message to the intended
recipient,
Post by Deepak Shetty
Post by David Fertig
you are hereby notified that any dissemination, distribution or copying
of
Post by Deepak Shetty
Post by David Fertig
this communication is strictly prohibited. If you believe this email was
sent to you in error, do not read it. Please notify the sender
immediately
Post by Deepak Shetty
Post by David Fertig
informing them of the error and delete all copies and attachments of the
message from your system. Thank you.
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@jmeter.apache.org
For additional commands, e-mail: user-***@jmeter.apache.org
Deepak Shetty
2018-08-23 19:42:07 UTC
Permalink
Thank you for confirming!

On Thu, Aug 23, 2018 at 12:22 PM Felix Schumacher <
Post by Felix Schumacher
Post by Deepak Shetty
Hi
title worked too
For me now, too.
The test cases I used - and the reported stacktraces - showed that an
Integer will not be converted automatically to a String by the Random
function. And I probably misspelled my variable name and got the error
when I tested it through the GUI. It seems that the GUI is trying harder
to convert the complete function string components to string values
before giving the values to the Random function.
Thanks for your double checking and insistence.
Felix
Post by Deepak Shetty
regards
deepak
On Thu, Aug 23, 2018 at 1:43 AM Felix Schumacher <
Post by Felix Schumacher
Post by Deepak Shetty
Hi
I initially tried this with a string , but I dont get this issue with
an
Post by Deepak Shetty
Post by Felix Schumacher
Post by Deepak Shetty
integer either - How were you able to replicate
Thread group
+Bean Shell sampler // vars.putObject("numFiles",new Integer(10));
+Http Request
++ParamValue - ${__Random(0,${numFiles},docIndex)}
Try to use the title of a sampler. Parameters seem to be handled
differently.
Felix
Post by Deepak Shetty
which works fine.
On Wed, Aug 22, 2018 at 8:06 AM Felix Schumacher <
Post by David Fertig
Post by David Fertig
I have a variable called numFiles, which I can print and verify
contains
Post by Deepak Shetty
Post by David Fertig
an integer.
Post by David Fertig
Integer numFiles = vars.getObject("numFiles");
I want to make a random number between 0 and that value. But all of
the
Post by Deepak Shetty
Post by David Fertig
following fail
Post by David Fertig
${__Random(0,__ ${numFiles},docIndex)};
Integer docIndex = ${__Random(0,${numFiles})};
${__Random(0,__ numFiles,docIndex)};
Integer docIndex = ${__Random(0,numFiles)};
"${NUMFILES}". See log file for details.
"numFiles". See log file for details.
Post by David Fertig
How do I pass a variable into the random() function?
It seems that this is a bug. At the moment the Strings given to
__Random
Post by Deepak Shetty
Post by Felix Schumacher
Post by Deepak Shetty
Post by David Fertig
will not be evaluated (and therefore the Integer will not be
transformed
Post by Deepak Shetty
Post by Felix Schumacher
Post by Deepak Shetty
Post by David Fertig
into a String).
Till the bug is fixed, you will have to transform the Integer into a
String by yourself.
Regards,
Felix
Post by David Fertig
Thank you
David
This email, including attachments, may contain information that is
privileged, confidential or is exempt from disclosure under applicable
law
Post by Deepak Shetty
Post by David Fertig
(including, but not limited to, protected health information). It is
not
Post by Deepak Shetty
Post by Felix Schumacher
Post by Deepak Shetty
Post by David Fertig
intended for transmission to, or receipt by, any unauthorized persons.
If
Post by Deepak Shetty
Post by David Fertig
the reader of this message is not the intended recipient, or the
employee
Post by Deepak Shetty
Post by David Fertig
or agent responsible for delivering the message to the intended
recipient,
Post by Deepak Shetty
Post by David Fertig
you are hereby notified that any dissemination, distribution or
copying
Post by Deepak Shetty
Post by Felix Schumacher
of
Post by Deepak Shetty
Post by David Fertig
this communication is strictly prohibited. If you believe this email
was
Post by Deepak Shetty
Post by Felix Schumacher
Post by Deepak Shetty
Post by David Fertig
sent to you in error, do not read it. Please notify the sender
immediately
Post by Deepak Shetty
Post by David Fertig
informing them of the error and delete all copies and attachments of
the
Post by Deepak Shetty
Post by Felix Schumacher
Post by Deepak Shetty
Post by David Fertig
message from your system. Thank you.
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
Loading...