In Jmeter , want to provide 100 different files for 100 users I used jp#gc - Directory Listing Data Source for providing different input files. Here we create two requests first request for accessing files and performing operations and the second request for download these output files making 100 output folder.So here 100 users use 100 random files so how to calculate which user uses which input file and where is the output file. how to map these two input and output
You can use __threadNum() function in order to get the number of current virtual use
Input file name you have already as the JMeter Variables coming from the Directory Listing Config
Output file name can be configured using Save Responses to a file using the values from point 1 and 2
More information: Performance Testing: Upload and Download Scenarios with Apache JMeter
Related
Using jMeter to set up a soak / load test that needs to run each request with different data. The structure I currently have is
Thread Group (2 Users, 2 Loops)
- Simple controller
-- Java Sampler (Custom Plugin) to convert CSV Formula data into NewThreadData.csv (as variable)
-- Java Sampler (Custom Plugin) to create directory of files created with NewThreadData.csv merged into a template
-- While Controller Condition - js NewThreadData column not = EOF
--- CSV Data Set Config NewThreadData.csv (Recycle False / Stop of EOF False) - filename passed as variable
--- JMS PUblisher with the FileName a variable using the filename column from within NewThreadData.csv
My problem is the on the second loop, the data is updated in NewThreadData.csv, but the CSV in the while loop never runs again.
Appears that the CSV Data Set Config "knows" it has been run, regardless of the actual CSV data.
Questions
How can I get the CSV Data Set Config to be rerun / re executed in this scenario?
Are there undocumented variables or means of getting the config to reprocess?
Is there a way to spawn a new thread on each iteration rather than reusing the existing thread, as the CSV does execute once for each "User"[thread]. I also tried Stop on EOF : True, but that stopped the second loop.
Aim is to eventually ramp up the user count and the number of loops (changing to forever); with there being about about 100 different combinations of data to be inserted on each loop. The formula I am using has time and thread number to give me data uniqueness along with other data that is dynamically created from a formula. Recycle on EOF is not feasible as I need to regenerate the csv contents on each loop. A super-csv I don't think is feasible to cover the load and soak scenarios.
Thanks in anticipation. Andrew
I don't think it's possible to "reset" the CSV Data Set Config, it's a configuration element hence once it reads the file in its current state it will "stick" to its content.
If you're manipulating file content dynamically I would rather recommend going for __CSVRead() function instead which is evaluated in the runtime just where it's placed therefore it doesn't reserve file and it "rewinds" to the beginning of the file when the last line is read.
More information: How to Pick Different CSV Files at JMeter Runtime
CSV Data Set Config element is executed first and only once even though you have placed it within the while controller. Hence CSV Data Set Config element is not suitable for your requirement.
You could use JSSR223 Pre-processor to work with the dynamic CSV files using a supported programming language/script (Java , Groovy)
In a Http Request, how the values from the CSV file can be shared.
In the Https request I have a variable in 100 places but wanted the different values from CSV to distribute among 100 places having one variable name in the same http request of the thread group.
You cannot achieve this using CSV Data Set Config as it will update the variable value either for each virtual user or for each iteration.
You can consider __CSVRead() function as an alternative, it is pretty easy:
${__CSVRead(test.csv,0)} reads 1st column from test.csv file in "bin" folder of your JMeter installation
${__CSVRead(test.csv,1)} - reads 2nd column
${__CSVRead(test.csv,2)} - reads 3rd column
etc.
${__CSVRead(test.csv,next)} - goes to the next line
Demo:
More information: How to Pick Different CSV Files at JMeter Runtime
I'm setting up a load test for several threads that each one needs a specific token.
How can I outsource it via csv file or other solution?
Screenshot of code:
You can use a csv data set config in jmeter for csv/txt files. Keep data in external csv or text file and use in your jmeter script using csv data set config for your desired threads.
Make sure the number or records in the file should be the same as the number of threads you want to execute.
https://octoperf.com/blog/2018/01/25/jmeter-csv-data-set-config/
We have used let say 500 different data for the same operation and out of which 250 are failed and other 250 is passed.
Do we have any script or method so that i can modify something in property file and segregate that failed data and write that data in some csv or excel file.
You need to create two View Results tree Listeners, with two separate files.
One with Log/Display Only: field mark as Errors and other as Successes.
This way errors and successes will be segregated.
Check out Sample Variables property. You can store JMeter Variables values for each sample result using simple configuration like:
Add the next line to user.properties file (lives in "bin" folder of your JMeter installation)
sample_variables=foo,bar
Next time when you run a JMeter test you will see 2 new extra columns in .jtl results file, foo and bar which will hold the values for the relevant JMeter variables.
This way you will be able to figure out what data presumably causes failure (if it is connected with the input data).
More information:
Configuring JMeter
Apache JMeter Properties Customization Guide
Results File Configuration
I have been using the following BeanShell script in order to delete all output files before each new run of a test plan
import org.apache.commons.io.FileUtils;
FileUtils.cleanDirectory(new File(vars.get("OutPutFolder")));
My test plan consists of a Thread group that is using 100 users (number of threads) with a loop count of 5.
I have tried several ways to incorporate the aforementioned beanshell script but i cannot seem to find the right place to put it in.
Things that i have already tried:
Creating a new "setup thread group" ("Run thread groups consecutively" is checked)
and place script in a beanshell samples > Files do get deleted but outcome files are not persisted to the disk (re-deleted by my script)
and place script in a beanchsell PreProcessor > Files do not get deleted
Placing script in my main Thread group > Files do get deleted but outcome files are not persisted to the disk (re-deleted by my script)
Using an If Controller (${__BeanShell(vars.getIteration() == 1)} && ${__threadNum} == 1)
Not solving your problem, but based on your comment, here's a different simple solution, which provides you with ability to separate current test results from previous test results.
All the listeners in JMeter can accept a dynamic file path, and one of the dynamic values they can use is TESTSTART.MS property (see here), which will be different for each test execution.
So in order to make name of each output file (or report) unique for the run you can use that property in the name of the output file:
your/path/${TESTSTART.MS}_errors.csv
You can even create a sub-folder holding set of the output files for specific execution, like this:
your/path/${TESTSTART.MS}/name1.ext
your/path/${TESTSTART.MS}/name2.ext
That way the names never collide, and they are grouped by execution (all files from the same execution will have the same timestamp, so you can filter them).
On top of that, on linux you could use logrotate to zip old jmeter logs (and since they are just text files, they zip nicely)