I have a very large CSV file (8000+ items) of URLs that I'm reading with a CSV Data Set Config element. It is populating the path of an HTTP Request sampler and iterating through with a while controller.
This is fine except what I want is have each user (thread) to pick a random URL from the CSV URL list. What I don't want is each thread using CSV items sequentially.
I was able to achieve this with a Random Order Controller with multiple HTTP Request samplers , however 8000+ HTTP Samplers really bogged down jmeter to an unusable state. So this is why I put the HTTP Sampler URLs in the CSV file. It doesn't appear that I can use the Random Order Controller with the CSV file data however. So how can I achieve random CSV data item selection per thread?
Using the Random function In this method, you need to define JMeter's random function and pass min, max and variable name (optional) as a value of Match No. field. The random function generates a random value within the specified range and passes into the Match No.
The __Random function will give you an index for your interval. To obtain values from 1 to 5, you have to call __Random(1,6,) , as it will never reach the MAX value. The __V function, will obtain the value of the variable with the given name.
There are several ways to generate a random string in JMeter. Examples: ${__RandomString(5)} This will generate a random string, which may or may not be readable. ${__RandomString(5,ABCD123)} This will generate a random string using only the alphanumeric values you supply.
There is another way to achieve this:
It's not really random, the file is still read sequentially, but your work thread makes jumps in the file. It worked for me ;-)
There's no random selection function when reading csv data. The reason is you would need to read the whole file into memory first to do this and that's a bad idea with a load test tool (any load test tool).
Other commercial tools solve this problem by automatically re-processing the data. In JMeter you can achieve the same manually by simply sorting the data using an arbitrary field. If you sort by, say Surname, then the result is effectively random distribution.
Note. If you ensure the default All Threads
is set for the CSV Data Set Config then the data will be unique in the scope of the JMeter process.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With