JMeter Query - Different User use different file locations for same HTTP Request - jmeter

Suppose a total of 50 users and one HTTP request/sampler were created so in that case we provide one input file when run Api then all 50 users use the same input files (same input file location )and some requests failed.
We want to make ideas or scripts for users to use different file locations so not chance to fail request or file not found exception.

You can parameterize the file name/location just like any other request parameter, username, etc.
The configuration element which is most frequently user for parameterization is CSV Data Set Config.
However if you don't want to manually manage the file content and protect yourself from "file not founds" it makes sense to consider going for Directory Listing Config plugin which reads the files in the given folder and stores them into a JMeter Variable so each thread/iteration will pick the next file from the pool.
You can install Directory Listing Config plugin using JMeter Plugins Manager

Related

Uploading unique files at concurrent load using JMeter

We have usecase where we need to call an API that uploads its respective category of unique file.
For every API call we need to use a unique FileName. I mean File once used in an API call should not be used again.
For Example
CarAPI will be called by uploading a file-name from list of files (CarAP_1.xml to CarAP_1000.xml files)
File CarAP_1.xml once used in an API call should not be used again in next call
BikeAPI will be called by uploading a file-name from list of files (BikeAP_1.xml to BikeAP_1000.xml files)
File once used in an API call should not be used again.
Any thoughts or inputs on how we can achieve this using JMeter.
You can put these filenames
either to a CSV file and use HTTP Simple Table Server, its READ endpoint has KEEP=false mode so once the data is used it will be removed from memory hence you can avoid duplicate requests
or to Redis and use Redis Data Set Config which also provides possibility to remove the data from the list once it has been utilized
Both plugins can be installed using JMeter Plugins Manager

delete uploaded file from folder using JMeter

I am sending a HTTP request to upload a file. And the request is setup like this:
uploadFile
And, the Directory Listing plugin pointing to a directory with all files and the request picks one file at a time. It works fine when run with one thread but, when i run in multiple threads, i see that already uploaded file is picked again to upload which leads to error.
I have added regular expression extrator to get the filename from the request body like this:
extract-filename-from-requestbody
And then, I am trying to use a post processor beanshell script to either delete the file from the folder or move to a different folder. But, not been successful. Need some help on this.
The first issue is i am not sure if i am extracting the value the right way. The value is to be got from request body and not request header. But, i dont see that option in the extractor.
Second, i am unable to use/retrieve the value from the extractor. Tried vars.get, vars.getObject and simply "${fileName}". Nothing works.
I don't think that deleting the file will help because Directory Listing Config reads the folder at the beginning of the test (see Execution Order chapter) so no matter whether the file is physically present or not JMeter will try to upload it
If you want to get unique files without repetitions just untick "Rewind on end of list" box:
This way each virtual user will read the next value so there will be no duplicates. When the last file will be used - the test will stop.
More information: Introducing the Directory Listing Config Plugin on JMeter
Also going forward consider using JSR223 Test Elements and Groovy language instead of Beanshell, it's the recommended option since JMeter 3.1

Jmeter is downloading a 67Mb file but only saving 10,240 KB

Bit of Background, I am using Jmeter to search for a download url from a rest API with an Oauth authorisation token set from the rest API. Once I have this URL I am doing a HTTP request, GET with redirect automatically, keepAlive and browser-compatible headers all checked.
Hanging of this I have then attached a "Save response to a file" with the file name prefix set to "blob" (this will be a filename set by a parameter later) and Add timestamp to the file name checked.
The url in question points to a zip file that needs OAuth header token (which is set successfully) the whole test plan succeeds.
This is great and you can see looking at the results
You can see that there are 67821343 bytes downloaded by the HTTP Request this is what we are expecting to see as this is the size of the file around 67Mb
This is were it starts to go wrong however as the save file only has 10,240 KB is an OCTET-Stream File and renaming this file to a zip just does not work as it is not a complete zip file.
This is my issue the Save file is not saving all the information and only save 10,240KB, every single time.
What am i doing wrong?
Is there a better way to get this zip file?
Please help it is driving me mad.
As once I have downloaded it I then need to assess the contents of the zip file to prove that the download URL that we are being directed to contains the correct ZIP.
here's the RUB if i do it manually through a browser i get the file downloaded successfully and it is exactly the same size (67821343 Bytes) but it just doesn't save in Jmeter.
Add the following property to user.properties file:
httpsampler.max_bytes_to_store_per_request=73400320
This will allow JMeter to save files up to 70MB
You can also set this property to 0 - in this case JMeter will not truncate data (make sure you amend JVM heap so responses could fit in memory)
References:
Configuring JMeter
Apache JMeter Properties Customization Guide

Trying to upload more than one file gets an error Jmeter

I have the following request:
this will return the following error:
but, if i remove the second file, leaving only one file, the request performs ok
please advice.
My expectation that this is due to missing Parameter Name value as it correlates with Name is blank error.
Can you try the following:
Copy files you want to upload to the "bin" folder of your JMeter installation
Record your file upload event using HTTP(S) Test Script Recorder
Compare recorded script with the one you are currently have.
Another assumption is that your endpoint doesn't support multiple file uploads so you will have to either to it sequentially or use multiple threads and Synchronizing Timer to do it at the same moment but using different threads (virtual users)

Need to test upload multiple file (CSV) with the multiple Vuser in the Jmeter script

I have scenario
Step#1 Login to the Application
Step#2 Search the Submission Number
Step#3 Go to the Account Detail
Step#4 Browse the file from the your system
Step#5 Click on the Submit button
I am able to do the same by the single user.
Need to do the same task through the multiple user.
Thanks in Advance
For parametrisation using single CSV file - use CSV Data Set Config
For parametrisation using multiple CSV files - use __CSVRead() function
If you need to simulate file upload with JMeter - use "Send Files With the Request" section of the HTTP Request sampler
See Performance testing: Upload and Download Scenarios with Apache JMeter guide for detailed information on how to perform file upload and download with JMeter

Resources