how to take data from CSV file without retaking, using multiple threads in jMeter? - performance

I have a CSV file with data, that is dynamic and is changed every test run (it could be 3k or 80+k lines). This data - is uuid, that I extract from CSV and set as a variables to my http requests. HTTP request has DELETE method, so after getting each uuid from CSV file - I can't use it again cause I would have a 404 status code. I've already set up CSV Data Set Config and there is no problems when I do it in 1 thread (Number of Threads (users): 1). But, for proper performance testing I need to run test in multiple threads, i.e. 30 or 50. And the point is - that I don't know how to set up logic to be agile and if I have a CSV file with 50k+ uuids that should be used in one Thread Group that has 30 threads - each thread will take only assigned to him uuids, won't retake them and won't take not assigned to him uuids.
Thanks in advance!

If you're using CSV Data Set Config (and this is what you should be using for 80+k lines file) with default Sharing Mode setting of "All Threads"
each JMeter thread (virtual user) will be taking next line on each iteration which means that each UUID will be used only once no matter how many users are there.
If you additionally set Recycle on EOF to "False" and Stop thread on EOF to "True" your test will be stopped when JMeter reaches the end of the CSV file so no duplicate requests will be sent.

Related

While loop in Jmeter

I am trying to create a jmeter test in which I am taking the http requests and their bodies from the csv file.
I want to run it for 2 users which will fire the http requests mentioned in the csv file 2 times. Which means 2 users will simultaneously start the test, they will fire the http requests mentioned in the csv file once and then will do the same with 2nd iteration. I tried doing it with different settings for Recycle EOF to TRUE/FALSE and Stop thread on EOF to TRUE/FALSE but either it is going in infinite loop or it is firing the requests as . I am definitely missing something here. Any help is appreciated. I am using Jmeter version 5.3
The easiest would be just replacing your While Controller with the Loop Controller with the number of loops equal to the number of lines in the CSV file.
You can determine the number of lines using the following __groovy() function:
${__groovy(new File('c:/full.csv').readLines().size(),)}
In the CSV Data Set Config set "Recycle on EOF" and "Stop thread on EOF" to false

Is it possible to read data from a csv file sequentially in jmeter while performing concurrent requests?

I have created a CSV file with 200 data. While performing concurrent requests (i.e ramp-up period 0 secs), I want the requests to be performed in the same sequential order as present in the file because an ID from the response data of the current API has to be used in sequential order in the request body of another API.
Details in my thread group:
No of threads(users) - 200
Ramp-up period - 0
Loop count - 1
I want the data in csv file to be read sequentially i.e row1, row2, row3... and so on
Your requirements are mutually exclusive because you want concurrency and sequential execution at the same time.
Actually threads are reading data sequentially, the reason you're seeing "randomness" is due to your application response time distribution, if application response time will be 1 ms - the process of reading test data will be sequential.
In general it shouldn't have any impact because as per documentation JMeter Variables are local to a thread so if you have 2 samplers one after another each thread will execute the sampler on top first and the sampler on bottom second and all the context (variables, cookies, cache, etc.) will remain.
Whatever, if despite all above points you still looking for a way of sequential reading data by multiple concurrent threads you will have to switch to __CSVRead() function, something like:
${__CSVRead(test.csv,0)} ${__CSVRead(test.csv,next)}
Demo:
More information (and another feature): How to Pick Different CSV Files at JMeter Runtime

Reuse parameters from single CSV Dataset for multiple users

I am using "CSV Dataset config" to read a parameter from the specified CSV file. I have set the "Sharing Mode" as all threads. For that Thread Group, I have specified "Number of Threads" as four (for four users). I have set "Recycle on EOF" as "True" (I tried with "False" too, but no difference).
When I start the test, It ran for just one user, read all the data from the CSV file, completed the test and stopped. For the other three users, it did not run at all. My guess is - because the CSV file was closed once the testing for user 1 completed.
I tried using multiple Thread Groups in the same Test Plan and each Test Group had just one user. Even then it did not work.
The expectation is- the same CSV file can be used for multiple users and across different Test Groups. There must be a way to rewind the CSV file either by JSR223 Post Processor or otherwise.
I cannot reproduce your issue using JMeter 5.2 and it is quite hard to tell anything comprehensive without seeing your Test Plan.
My expectation is that you violated JMeter Scoping Rules somewhere somehow, i.e. you placed CSV Data Set Config inside one Thread Group while it should live at the same level as all Thread Groups
Given
The following CSV file stored as test.csv in JMeter's "bin" folder:
line1
line2
line3
And the following CSV Data Set Config:
2 Thread Groups set up like:
You should see that each virtual user in each Thread Group is reading next line from CSV file on each iteration:

How can I get Number of Threads and Duration from CSV in Jmeter

I can easily get username and password from CSV using CSV config control in Jmeter but I can't do same for Number of Threads & Duration for Thread Group.
I tried and provided Number of Threads and duration in CSV but seems not working. Getting Number of Threads always Zero.
Is there any way to get it? Just want to make my JMX dynamic so no need to open JMX if I only want to change number of threads and duration and can be easily update.
Your requirement is to parameterize the number of threads and duration. But should it be from CSV file by using CSV config element? Because We can not do that way!
One suggestion is to keep a properties file for thread numbers and duration for each Thread Group and pass the properties file as parameter.
This is exactly explained here with more additional information as well.
http://www.testautomationguru.com/jmeter-manage-test-plan/

Proper way to save Jmeter Results to csv - how to finalize results file

I do the same scenario that was already described in other topics not at once: I'm trying to save Jmeter results to database from csv file.
I have an Aggregate Report listener that saves results to csv file, and everything is OK here.
I also added TearDown Thread Group to my scenario that gets strings from this csv file (by CSV DataSet config) and processes it to database. This part also works fine with static CSV.
Two problems here:
Aggregate Report listener is added on the top level of scenario. So, it adds all samplers from TearDown group to results file as well. So, it's like a recursion: if I do teardown until end of result file, I'll never reach the end, as every new iteration adds some new rows.
At the moment when CSV dataset config takes csv file, it's still in memory only and not finalized to disk. So, file is just empty. How to tell Jmeter that it should write the content from memory to a file and close input stream?
Any ideas how to solve it?
I know that I can move Listener into threads, but in this case I have to duplicate it for every thread group. It's always better to have one listener in one place as I can potentially change its settings.
Thanks in advance.
There is a JMeter Property jmeter.save.saveservice.autoflush defaulting to false
# AutoFlush on each line written in XML or CSV output
# Setting this to true will result in less test results data loss in case of Crash
# but with impact on performances, particularly for intensive tests (low or no pauses)
# Since JMeter 2.10, this is false by default
#jmeter.save.saveservice.autoflush=false
You can amend its value by setting it to true so JMeter will write down each single line of results into the file and closing the file once done. It can be done in 2 ways:
Permanent: add the following line to user.properties file (located in JMeter's "bin" folder)
jmeter.save.saveservice.autoflush=true
You will need to restart JMeter to pick the change up
Ad-hoc: pass the property via -J command-line argument
jmeter -Jjmeter.save.saveservice.autoflush=true -n -t .....

Resources