0
votes

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.

1

1 Answers

0
votes

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:

enter image description here

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