how to send unique data for each thread in jmeter
Solution 1
Though I am too late for the question, I thought someone might find it useful.
- Create a Random Variable for the thread group
- Assign min and max value for that variable. Please make sure the difference between the min and max is big so that there will be less collisions.
- Mark Per Thread(User) as TRUE
Hope it helps.
Solution 2
Beside all the suggestion from Ubik and DmitrT, I would put the CSV configuration element OUTSIDE the thread group. Let me know.
Solution 3
The CSV approach is Ok, but how did you configure csv dataset and put it in plan ?
Ensure you set "Recycle on EOF" to false to ensure no data is reused.
Can you show this ?
Can you also show HTTP Request content ?
Edit 01 september 2015:
- your csv config does not declare variableNames which should contain tenantName
Also ib fileName path field replace \ by \ or /
Solution 4
I have also had the same issue with a User Defined Variables element. In it, I created a UUID and assign it to a variable. I was expecting each thread to generate a different UUID, but this was not the case.
Solution (which worked for me) Add a Beanshell Sampler. In it, generate the unique value such with a UUID and use the put method to store the value in "vars". Each thread will execute the code and have its own unique value.
Example: To generate and store a unique accountId for each thread to use
String uniqueId = "${__UUID()}";
vars.put("accountId", uniqueId);
I hope this helps!
Solution 5
If you need to send unique data which can be random I believe that __UUID() function can help.
It generates random exclusive GUID structures each time when being called and seems to be exactly what you're looking for.
For explanation and demo of this and more JMeter Functions see How to Use JMeter Functions posts series
bagui
Updated on June 16, 2022Comments
-
bagui almost 2 years
I'm using jmeter to test my REST API for 10000 hit for which each http hit will store some data in DB. I have followed the below test plan
I'm running 10 threads in parallel with ramp up time 20 sec each and loop 1000 to achieve the same.
But the issue here is my threads are not taking unique data set. Whereas my backend HTTP URL expecting unique string for each http hit.
Now I have tried with the below approaches.
Single CSV data set config with 10000 unique values and all threads in thread groups are reading the same data.
Different CSV Data set for each threads and allocate the csv file with thread using filename${__threadNum}.csv
Using jmeter _RandomString method to generate random strings on runtime for each http hit, in http post body I'm passing like
{"tenantName":"${__RandomString(15,abcdefghijklmnofqrst1234567#@#%^&*,)}"}
- Using BeanShell preprocessor to call a java method and generate unique pattern all the time win HTTP Request sampler.
Now none of the above approaches works for me. While running the test plan after some point of time 2 threads are trying to use the same data and hit my HTTP url. And I'm getting conflict error from http response. My error count keeps increasing.
Now I really don't understand how these 2 treads trying to hit http with same data?
Can some one please explain the issue and help me to set the correct test plan configuration.
EDIT:
CSV data set config for all thread:
HTTP Request :
Adding test plan with CSV dataset:
-
bagui over 8 yearsHi, edited the question with csv dataset and http request. Please check.
-
bagui over 8 yearsHi, I tried with __uuid in my request param. But some times 2 threads are passing me same data while hit http request
-
bagui over 8 yearsadded the test plan with CSV dataset. Please check.
-
bagui over 8 yearsI've defined the variable in http request, and the same variable name is the csv header, so it's replacing. Also I don't think it's an issue with the file path separator as the file contents are getting processed.