0

I have created a test plan using JMeter in which I have just moved the files from source folder to destination folder and in that, I have successfully succeeded.

Now the main problem is after moving files from source to the destination folder, The files are automatically deleted by the server after 5 or 6 seconds where I have sent the files. That's the functionality of the internal server. I just have to check the files that I have sent are present or not in the destination folder before the files get deleted by the server and also want to measures the time after how much time the files will be deleted from the destination folder.

How can I do this, Can Anyone please help me with this?

My Test Plan is:

enter image description here

Example: values Inputs

source = /home/example/sourcefile.csv
destination = /main/destination/destinationFOlder/destinationFile.csv
4
  • Whether file can be accessed using public url?. For example, file is in the path /img/home.jpg in your server and it should be accessible by link your_base_url/img/home.jpg May 18, 2020 at 6:04
  • I don't know about how the functioning is happening on the server-side. My requirement is just to check the files are moved to the destination folder or not before it gets deleted by the server.
    – Rajan
    May 18, 2020 at 6:19
  • Sorry i am still not clear. Where you are running your Jmeter test if it is in server you can use this script since you can access your server directories but your testing it from your local machine and you cannot access the directories in the server so you need to access the file from the server using its external link May 18, 2020 at 6:27
  • I have run my JMeter script on the server using putty. I have updated my question with an example for more clarification. Please see that also.
    – Rajan
    May 18, 2020 at 6:30

1 Answer 1

2

If you're running JMeter at the same machine (server) - just call File.exists() function which returns true if the file is present and false otherwise

enter image description here

also don't inline JMeter Functions or Variables into Groovy scripts like {destination}, use vars.get('destination') expression instead where vars stands for JMeterVariables class instance.

As per JSR223 Sampler documentation:

When using this feature, ensure your script code does not use JMeter variables or JMeter function calls directly in script code as caching would only cache first replacement. Instead use script parameters.

More information: Top 8 JMeter Java Classes You Should Be Using with Groovy

3
  • Thanks a lot !! Actually, destination comes from the CSV config data set. So, Is it okay to use vars.get('destination') instead of ${destination}?
    – Rajan
    May 18, 2020 at 14:53
  • And, I want to run the script until the file gets deleted by the server automatically. I want to measure the time when the file gets deleted by the server from the destination folder after sent to the destination folder. How can I do this? Please let me know?
    – Rajan
    May 18, 2020 at 15:02
  • There's no good way to measure file existence time (you'd basically need to write a loop and keep polling till the file disappears). You're likely better off checking for a downstream artifact of processing.
    – ernie
    May 19, 2020 at 17:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.