Tristan
Tristan

Reputation: 33

JMeter - How to change File Upload path after X seconds

As the title suggests, I am trying to figure out how to change the File Upload path in JMeter after X amount of seconds. I need this since I am testing an API that uses 60 files and I need to cycle through each file every minute. I already have an idea of using CSV Data Set Config but I'm not sure if that will change the File Path every minute like I need it to. Or maybe even read from the CSV file once per minute?

Upvotes: 0

Views: 203

Answers (1)

Dmitri T
Dmitri T

Reputation: 168157

  1. Use __P() function to read the path to the file from a JMeter Property path

    ${__P(path,)}
    

    enter image description here

  2. Add another Thread Group to your Test Plan and use a Debug Sampler in combination with CSV Data Set Config to read the next filename from the CSV file into path JMeter Variable

    enter image description here

  3. Add a Constant Timer or Flow Control Action sampler to introduce 60 seconds of sleep between iterations

    enter image description here

  4. And finally add a JSR223 PostProcessor to convert path variable into path property:

    props.put('path', vars.get('path'))
    

    enter image description here

    see Top 8 JMeter Java Classes You Should Be Using with Groovy article to learn what do these props and vars shorthands mean

  5. That's it, Debug Sampler will be executed each 60 seconds, the CSV Data Set Config will read next value from the CSV file and the JSR223 PostProcessor will update the path property value with the new filename or file path.

Upvotes: 1

Related Questions