Use next CSV file when all values used - jmeter

I have 10 CSV files with usernames with 1 million records each. Ideally I want to use an unique value for every thread and when all values from the first CSV file have been used, it should start using the values from the second CSV file, and so on.
Adding multiple CSV Data Set Config elements is no problem and it is easy to add them to a If or While controller. But what can be the trigger to go to the next file?
As an alternative, I use multiple If controller with e.g. ${__eval(${__threadNum})} < 1000 and ${__eval(${__threadNum})} > 1000 and ${__eval(${__threadNum})} < 2000 to make sure the users read from different CSV files, but this is a bit cumbersome when the number of users change often, because you need to change the if conditions accordingly.

Perhaps you should consider switching to __CSVRead() function which is capable of fetching data from multiple CSV files. Optionally in conjunction with __counter() function if you need to switch files based on certain condition
See How to Use JMeter Functions post series for advanced information on aforementioned and more useful JMeter Functions.

Related

How Can i avoid repeated/duplicate test data or to avoid already executed data without deleting in CSV file?

We have a constrain in our application, For test data providing in JMeter execution (using CSV Data Set Config element) we are not supposed to provide duplicate test data and it won't accept in all the fields. So we kept unique test data (upto 8K data for 8k concurrent users) for all the fields in CSV format.
Here I have a manual intervention, After each test execution (i.e) 100 users, 1000 users up to 8000 users) we need to delete each row (WRT to users in thread group) in CSV file else the duplicate data will be fetching for next execution and result will be failed.
Here my questions is,
1. How Can i avoid repeated/duplicate test data or to avoid already executed data without deleting in CSV file.
2. During JMeter test execution with CSV files, How can we specify to take the data from the respective rows. For example 101th row, 1001th row & 7999th row (which contains 8000 rows of data)?
The easiest option will be using HTTP Simple Table Server, its READ command has KEEP=FALSE attribute so you will be able to feed your test with the unique data without having to physically remove it from the original CSV file.
You can install HTTP Simple Table Server plugin using JMeter Plugins Manager:
In general if your test doesn't need to be repeatable instead of keeping the data in the CSV file you can consider generating it on the fly using such JMeter Functions as:
__Random()
__RandomString()
__RandomDate()
__UUID()
etc.

JMeter- Reading One row of CSV file to Multiple rows of another csv file

How can I loop one csv file to another csv file in JMeter, where the first csv file contains all the login data and the other csv file contains the transaction data. I am supposed to run where 1 teller should process 30 transaction.
Go for __CSVRead() function.
You will not be able to use CSV Data Set Config as it is a Configuration Element and according to the JMeter Test Elements Execution Order all the configuration elements are being initialised at the very beginning of the test while your requirement is to read data based on user dynamically.
Check out How to Pick Different CSV Files at JMeter Runtime article for comprehensive information on using __CSVRead() function

writing multiple files (different content) using spring batch

I have a requirement to write multiple files using Spring Batch. The first file will be written based on the data from the database table. The second file will contain just the number of records written to the first file. How can I create the second file? I am not sure whether org.springframework.batch.item.file.MultiResourceItemWriter is an option for me as I think it will write multiple files based on the data it will write chunks of data in the multiple files. Correct me if I am wrong here.
Please do suggest some options with sample code if possible.
You have couple of options:
You can use CompositeItemWriter which calls collection of item writers in defined order so you can define one item writer which will write records based on data from DB and second will count records and write that to another file.
You can write data to a file in first step, finish whole file and save it somewhere, you can save counter of records if that is all you need to StepContext (common batch patterns and scroll to 11.8 Passing Data to Future Steps) and read in new Taskletcounter and save to new file.
If you want to go with option 1 which I think is right choice you can check this example of batch job configuration with CompositeItemWriter

how to login multiple users with different input in different threads in Jmeter using CSV data set config

How to login multiple users with different input in different threads in Jmeter using CSV data set config?
I have added CSV data set config but the thread is picking only the first entry and i m not able to see the responses for other user login
If you use CSV data set config which contains parameterized values which users(threads) will use while running script.
below is snapshot of jmeter of csv data set config which contain emp.csv file which contains values like,
nachiket,101,test
nikhil,102,test
harish,103,test
which are empname,empid,passwd respectively for 3 users.
if you run test with 3 users then thread1 will pick first and 2nd thread will pick 2nd val so on and you can repeat the file if it has less values than no of threads.
You need to provide enough loops/iterations as given one iteration only CSV Data Set Config will read only the first entry.
Try putting the request you want to parametrize under a Loop Controller, set enough loops and see whether it resolves your issue.
See Using CSV DATA SET CONFIG guide for more details.

JMeter export graph to CSV exports to multiple columns, write results to file exports to one column

I was annoyed with JMeter writing data results to CSV as one column. So when the CSV file was opened in Excel all values would be added to one single column (which requires annoying manual copy/paste work to get to graphs). I then noticed that if I choose Export to CSV on a Listener graph, it actually exports the CSV file as separate columns in Excel, which is great.
Is it possible to have the "Write results to file" write data into separate columns by default as it does with the graph "Export to CSV"? Thanks!
Suppose you have at least 2 options:
Simple Data Writer, which one you are using at the moment, as you understand.
In jmeter.properties file (JMETER_HOME\bin\jmeter.properties) uncomment and set jmeter.save.saveservice.default_delimiter=; to use ';' instead of ',' (used by default) as separator in csv-files (which one you are creating using "Write results to file") - this will separate values in different columns if opened in Excel.
# For use with Comma-separated value (CSV) files or other formats
# where the fields' values are separated by specified delimiters.
jmeter.save.saveservice.default_delimiter=;
Flexible File Writer from jmeter-plugins pack implments the same functionality and looks to be more customizable.
Idea is the same as above - use ";" to separate values written into file:
Write file header: endTimeMillis;responseTime;latency;sentBytes;receivedBytes;isSuccessful;responseCode
Record each sample as: endTimeMillis|;|responseTime|;|latency|;|sentBytes|;|receivedBytes|;|isSuccessful|;|responseCode|\r\n
Hope this helps.

Resources