How to simulate users in .csv files as thread counts in jmeter - jmeter

I have a .csv file which has 100 users. Is there a way where i can simulate thread group and thread count to read each user and from .csv file and do the http request operation and loop and pick the second user?

If you want to configure JMeter to generate as many threads as you have rows in your CSV file you can use __groovy() function for this like:
${__groovy(new File('/path/to/your/file.csv').readLines().size(),)}
The function can be placed directly in "Number of Threads" section of the Thread Group

Related

Can I use the same CSV file for multiples Thread groups?

could find a precise answer to my question.
I have multiple Threads groups on my Test Plan, in all of them I created a CSV file to read a list of cars, for example:
Thread group 1 cars_thread_1.csv
Thread group 2 cars_thread_2.csv
Thread group 3 cars_thread_3.csv
But the list of cars didn't change inside the CSV files.
What's the recommended approach? Keep it like that or I can create a single CSV cars.csv and all of the threads read it?
Sure you can, just place it at the same level as Thread Groups so all of them would be in the CSV Data Set Config's scope
By default each thread will read next line from the file on each iteration, if this behaviour is not something you're looking for - you can amend Sharing Mode setting of the CSV Data Set Config.

JMeter - execute 100K requests (CSV driven) in parallel

I have a task to execute 100K requests using CSV data driven
CSV holds ids
100,
101,
102,
...
In JMeter CSV Data Set Config is saving id variable and call API with ${id}
This is working fine, but I want to execute requests in parallel to reduce time of execution.
It seems that parallel sampler/controller can't be used in this case,
How can this be done using CSV driven test?
In the CSV Data Set Config set "Sharing Mode" parameter to All threads.
In the Thread Group set "Number of Threads" to the desired value
That's it, JMeter will run your requests in parallel and each thread (virtual user) will pick up new line from the CSV file on each iteration as it can be seen using i.e. View Results in Table listener

JMeter CSV data set split into threads (users)

What I want to do:
I would like to test behavior of the system for 50 users. Each user has to do the same action X times,
with different input ( X - depends on how many records I have in the CSV file, so if the file contains 1000 records, each user will do the action 20 times).
What I actually did to do that:
I set up CSV Data Set Config (with CSV file with 1000 lines) and ofc set up Number of Threads to 50
What is my problem:
Now I'm quite not sure how to share the CSV file so that all user will have unique poll of the lines from the file. (so each user will have his unique lines from the CSV)
What can I do to workaround:
I can copy thread groups to make 50 thread groups, and add them separated CSV files, but it sounds ridiculous...
Given you set the following values in the CSV Data Set Config
Recycle on EOF: False
Stop thread on EOF: True
Sharing mode: All threads
then each thread (virtual user) will fetch new value(s) from the CSV file which will guarantee uniqueness of the test data
You can check this yourself by using __threadNum() function and ${__jm__Thread Group__idx}; variable
More information: CSV Data Set Config in Sharing Mode - Made Easy
In thread group under thread properties, we can set
number of threads = 50
ramp up period = 1
loop count = 20
So, here each thread after a sec will take next line from csv file and execute it.
This way the same csv file will be shared among different threads.
I would recommend to create multiple CSV files for your test plan and assign the variables accordingly for smooth execution of the script. Using same CSV file can not solve the problem as there are times when few threads executing much faster and others are slow in that case action will start replicating between different threads.

How to use data from .csv file for Ultimate thread group

I have a use case where 10000 users are hitting the API sequentially.
first 1000 users/sec are hitting an API then they hold for 10-15 seconds and again another 2000 users are going to access the api.
Issue is i have an api <path>/user_id/${userId} and i have 10000 user ids stored in a .csv file
how fetch the file for every 1000 users at first set and 2000 users in the next?
I have added CSV Data set Config and i have the .csv file path
Below screenshot is my .csv set config.
Beanshell error
GetUserID API
Ashu
To pick first 1000 userIds for first 1000 threads and and next 2000 userids for next 2000 threads and so on follow this steps
Create a csv file with only userIds(Do not mention the column name in csv).
To the JMeter test plan add a simple thread group and bean shell sampler to the thread group.
Add the following code to the beanshell sampler
above code will add UserIds to JMeter properties.
now to pick userIds use
${__P(user_id_${__longSum(${__threadNum},-1,)})}
I have created a sample test plan to pick only first 10 values from csv for the first minute and pick next 10 for the next minute you can see the screenshot here
I would recommend run the tests in cloud.
Please follow this link to know more

JMeter CSV file does not loop through sequentially

My Jmeter script is taking all the values from CSV but when I see it in the HTTP request output, they are not been displayed sequentially. For e,g- 50th row in CSV does not correspond to 50th HTTP request.
Thank you!
This should be fine when you have more than 1 thread and all threads are sharing the same CSV file.
Each thread executes the test plan independently - but share the same csv file. these threads do not wait for each other. Ex: Thread 3 does not have to wait for thread 2 to pick the second row. It is like first come and first serve! Whichever thread is ready to pick the data - it gets the data from csv. Rest assured all the csv rows will be read sequentially ie..not random rows.

Resources