azurerestjmeterload-testing

How to test file uploads in a REST API using Azure Load Test and JMeter


I'm writing up a series of load tests in JMeter, one of which tests a REST API endpoint that POSTs a form file:

[HttpPost("File")]
public async Task<IActionResult> UploadFile([FromForm] IFormFile file)
{
    // Do stuff.
}

I can do this with JMeter through the File Upload tab of the HTTP Request Sampler:

JMeter snapshot

This works fine, but since C:/my-file.txt is on my local machine, once I upload the .JMX file to Azure Load Test, the file reference becomes invalid, and the tests all fail with an internal File Not Found exception.

I've experimented with both JMeter and Azure, but have had no luck finding a way to provide a file for upload once my load test is imported into Azure. Is this just not possible?


Solution

  • Try removing C:\ from the file path and upload the file.txt along with your test like it's done with CSV files or JMeter Plugins

    If Azure doesn't support feeding data files in this way you can i.e. encode the file contents into Base64 and set it as secret or environment variable. The file can be created from the secret or the environment variable in setUp Thread Group with the help of JSR223 Sampler and Groovy language.