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#@#%^&*,)}"}
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:
Pass Variables Between Thread Groups in JMeter The first thread group makes a GET request to a web service. We then use the JSON Extractor plugin to parse the JSON response. Using JSONPath, we extract the value for a particular key and save it as a JMeter variable.
1) Create excel and insert data in excel column wise i.e. horizontally insert all the data. 2) Use below code in place of your unique parameter. So it will pick unique data for each thread. Show activity on this post.
Step to implement the logic for passing the variable value to another Thread Group: Add a 'Regular Expression Extractor' post-processor as a child element of 1.1 HTTP Request (Fetcher) and fetch the value in a variable (say employeeID) Add a 'BeanShell Assertion' and write ${__setProperty(valueToPass,${employeeID})}
Though I am too late for the question, I thought someone might find it useful.
Hope it helps.
Refer to http://blog.developer.bazaarvoice.com/2016/05/19/quick-and-easy-web-service-load-testing-with-jmeter/
Beside all the suggestion from Ubik and DmitrT, I would put the CSV configuration element OUTSIDE the thread group. Let me know.
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
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:
Also ib fileName path field replace \ by \ or /
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!
The easiest way to put csv data set config outside thread group and keep shared mode as "ALL THREADS", it will solve your purpose. Even in case of multiple thread groups, you can use this csv data in shared mode and each thread will pick unique data automatically.
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