Random Variable in Jmeter

Viewed 23

Can we use a variable in the minimum value in the Random Variable like:enter image description here

It always give only 0. MIN and MAX are defined in a .csv data file. I am trying to get a random number between 1-15 from load generator-1 and 16-30 from load generator-2

Thanks, N

2 Answers

What do you use for reading the values from CSV? If it's CSV Data Set Config - it won't work because according to the JMeter Test Element Execution Order:

  1. Random Variable is executed before any Sampler
  2. CSV Data Set Config reads next line from the CSV file on each Sampler iteration

If you have CSV file which looks like:

1,15

You can amend your Random Variable configuration to use __CSVRead() function, something like:

enter image description here

Textual representation just in case:

${__CSVRead(test.csv,0)}
${__CSVRead(test.csv,1)}

you will get the result you're looking for as JMeter Functions are being evaluated just at where they're found.

You surely can use variables to provide Minimum and Maximum values for Random Variable element.

As to why it always returns '0':

I assume that MIN and MAX variables are not initialized. You could check that by adding Debug Sampler before Random Variable and viewing the actual values in View Result Tree element. If they are indeed not initialized I suggest you should check that .csv data file is correctly read by CSV Data Set Config.

Related