This solution will work for the configurations that you shared, 5 concurrent users uploading 10 files each.
First of all, create separate files for each thread (you have 10 files, copy them into 50) and rename them as below
Thread1_file1_0
Thread1_file2_0
Thread1_file3_0
.
.
Thread1_file10_0
Thread2_file1_0
Thread2_file2_0
.
.
Thread5_file10_0
Then create a csv file and add file extensions in column A. Make sure that row 1
reflects the extension of Threadx_file1_0
and row 2
reflects the extension of Threadx_file2_0
file as below and save the csv file in the same folder of your jmx script
Now to the script configurations, add 2 counters before your POST request (which uploads the files) with below configurations
First counter
Start 0
Increment 1
Reference Name originalName
Track counter independently for each user Yes
Reset counter on each Thread Group Iteration No
Second counter
Start 1
Increment 1
Reference Name Iteration
Track counter independently for each user Yes
Reset counter on each Thread Group Iteration No
Now add a loop controller with loop count set to 10
, then add another counter, OS Process Sampler and CSV Data Set Config as children of the loop controller with below configurations
Counter configurations
Start 1
Increment 1
Reference Name fileNumber
Track counter independently for each user Yes
Reset counter on each Thread Group Iteration Yes
CSV Data Set Config
Filename extensionsCSVFile.csv
Variable Names extension
OS Process Sampler configurations
Command cmd
Command parameters
/C
ren {path to your folder}\Thread${__threadNum}_file${fileNumber}_${originalName}.${extension} Thread${__threadNum}_file${fileNumber}_${Iteration}.${extension}
Each line as a separate parameter. Now use file name in your post request as below
{path}\Thread${__threadNum}_file1_${Iteration}.pdf
{path}\Thread${__threadNum}_file2_${Iteration}.pdf
.
.
{path}\Thread${__threadNum}_file10_${Iteration}.docx
This will do the job, but i suggest that you also add a way to revert the names back to Thread1_file1_0
. You can do it by following the below steps
Add a BeanShell PostProcessor as a child of the OS Process Sampler with below code in the code area
props.put("lastIteration", vars.get("Iteration"));
Now add a tearDown Thread Group, then copy the loop controller with all its elements from previous above steps and paste into the tearDown Thread Group (except the BeanShell PostProcessor, remove it after you paste).
Now go the OS Process Sampler within the tearDown Thread Group and adjust the second parameter as below
ren {}\Thread${__threadNum}_file${fileNumber}_${__P(lastIteration)}.${extension} Thread${__threadNum}_file${fileNumber}_0.${extension}
Finally, just make sure that number of threads in both main thread group and tearDown Thread Group is the same, which in this case 5
. The structure will be as below