I have the following Test Plan:
Test Plan
Thread Group
Java Request
CSV Data Config Set
My Thread Group has 1 thread looping forever. To my understanding, the thread should go down the CSV file line by line, 1 line per loop. However, it stays on the same first line. If I have two threads, then the first thread will stay on the first line, second thread on the second line, and so on.
I have tried all the different options in CSV Data Config Set (even if it doesn't make sense to try those options) including:
Checked path to file is correct
Tried file encoding as empty, UTF-8, UTF-16
Checked delimiter was correct in CSV
Checked variable names were correct
Allow quoted data true and false
Recycle on EOF true and false
Stop thread on EOF true and false
Tried all sharing modes
I also ensured the CSV file had no empty lines. I am using JMeter 2.13 and the line break character in the CSV is CR LF if that helps.
I've looked at tutorials and other JMeter questions on here, it seems that by default the threads should go down the CSV file. I remember it was behaving properly awhile back, unsure when it started behaving this way.
It is hard to say anything without seeing the code of the Java Request sampler to read the variable from the CSV and your CSV Data Set configuration.
If you want each thread to read the next line from the CSV file each iteration you need to set the Sharing Mode to All Threads
Try using other sampler, i.e. Debug Sampler as it might be the case your approach to reading the variable from the CSV file is not valid
According to JMeter Best Practices you should always be using the latest version of JMeter and you're sitting on a 4-years-old version, it might be the case you're suffering from an issue which has been already fixed so consider migrating to JMeter 5.1.1 or whatever is the latest stable JMeter version available at JMeter Downloads page
Related
I've been scratching my head on this issue. It seems that Jmeter wont write on one of my empty CSV file and throws this error. But one of my CSV file in the same thread doesn't replicate the error and writes properly.
These is how I called my CSV and how I printed it.
I don't see anything which could cause the error in your partial screenshot, if you need further assistance consider:
Adding Debug Sampler to visualize all your variables which are being used in the script
Adding the full code as text, not as the screenshot so the issue could be reproduced.
Going forward it might be a better idea to use i.e. Flexible File Writer instead of Groovy for writing the variables into the file as if you run your script with 2+ threads you might run into a race condition with several threads concurrently writing into the file which most probably will result in data corruption/loss
Currently, i have a requirement where I need to make sure that the data once read is not read again. Earlier I used to use HttpSimpleTableServer when I had to run only one loop with keep=false. However now I need to run 2 loops and for which the above option doesn’t work as the same csv is read from the start agin for the second loop. So I was thinking if there is a way to read data from different csv files per loop. If not how can I make sure that different data is read from the csv for every loop and no data is ever repeated. My Jmeter version is 5.3.
You can use CSV Data Set Config component to read the data from CSV files.
Set the `` flag to false to read the data only once.
You may set the remaining flags based on your need.
You may add two different CSV Data Set Config elements to work with different CSV files.
If you want to handle this programmatically API documentation will be useful. API documenation
If you need to read 2 different files in 2 different loops you should consider going for __CSVRead() function instead
Create 2 files like file0.csv and file1.csv
Once done you will be able to:
${__CSVRead(file${__jm__Thread Group__idx}.csv,0)} - read first column
${__CSVRead(file${__jm__Thread Group__idx}.csv,1)} - read second column
${__CSVRead(file${__jm__Thread Group__idx}.csv,next)} - proceed to next row
etc.
The __CSVRead() function will proceed to the next file on next Thread Group iteration
More information: How to Pick Different CSV Files at JMeter Runtime
I try to remove result files from a listener but it won't work. It seems JMeter lock the result files in runtime.
The screenshot below shows that I save the result to a csv file 'raw-result-table.csv'.
In Setup Thread, I add an OS Sampler to remove the result files. See screenshot below.
It cannot remove the files. I think it is because JMeter lock the file in runtime.
Please note that the OS Sampler is correct. It can remove the files when I disable the thread 'AD'. I've tried BeanShell script and result is the same.
Actually you won't be able to delete the file which is being used for storing results of the current session. Also there are some issues with your test design:
You should not be using any Listeners, especially View Results in Table / Tree, they consume a lot of resources and may ruin your test.
You should be running your test in command-line non-GUI mode. You can combine it with deleting the previous results file like:
del *result*.csv && jmeter -n -t test.jmx -l result.csv
Upon test completion you can open result.csv file in JMeter GUI and perform the analysis.
You should be using JSR223 Test Elements and Groovy language instead of Beanshell (same applies to the functions, you should substitute __Beanshell() function with __groovy() function) as Groovy has much better performance
I am running jmeter through the command line, and generating a jtl log file. The last couple of runs, it seems that it has created a couple of different .jtl files, with one of them starting in the middle of the run. Is there a Maximum Length of a Log File, or has anyone seen anything like this before?
Thanks
The JTL files can grow as large as they need to be. In some cases my tests yield JTL files over 25 gigs in size.
However, if you do not change the JTL name between runs it will append to the file, not overwrite. Is it possible you are looking at two test runs in a single JTL file? You would see a big chunk where it looks like there are no results.
If you are running from command line, my suggestion would be to build a shell or batch script that auto timestamps the jtl parameter and starts the test. This way you are guaranteed, without any thinking, to have new files for each run.
Also, just so you are aware: There is a nice plugin jar that will allow you to generate awesome graphs from a raw JTL file!
http://jmeter-plugins.org/wiki/JMeterPluginsCMD/
I want to run 5 threads and each thread pulls in data from different .csv file. For example, thread 1 maps to data_1.csv... I do NOT want to create 5 Thread Groups.
Please help. Thank you!
To be able to open different csv files in the same test plan execution, you have to build a file name with the threadNum function.
According to your example you would have to set the filename to "data_${__threadNum}.csv" in the csv reader so the 5 threads will load your 5 files.
The files are shared upon their filenames so the sharing mode is not an issue.
According to usermanual By default, the file is only opened once, and each thread will use a different line from the file. You can change sharing mode but not open several different CSV files, i.e. one file for each thread.
Upd: on the other hand, if you don't have a lot of threads you can try this