Sometimes it is necessary to parameterize dynamic file upload. The recorded request typically will be a multipart post request where one of the fields has a value containing the file content. For example, the request will look like this:
Content-Disposition: form-data; name="submittedfile"; filename="recorded.pdf"
7052 0 obj
The field "submittedfile" here represents the recoded content of the file. In the course of load testing, you want to replace this content with dynamically selected files with the content of the files available locally on the load testing machine. To do so, create a dataset with a field for storing the paths of such files. Then parameterize the multipart request by replacing the field's value with the recoded file content (in this case, "submittedfile" field) with the dataset.
To parameterize the field with file content, the dataset column data must store the file path.
The path of the file can be in one following format:
- The full path of the file (ex. c:\myfolder\Document001.pdf). Use this format for local tests.
- The local path of the file if the file is stored in the local DataFiles directory (ex. \Authorized\Document001.pdf) if the path is in <test directory>\DataFiles\Authorized\Document001.pdf). This is the preferred method for distributed tests (see below)
The files in the DataFiles directory are copied to all agents before the test starts.
The screenshot below shows an example of parameterizing a recorded pdf file upload.
- The recorded file will be parameterized with files inside the <test directory>\DataFiles\Authorized folder. Document001.pdf, Document002.pdf, etc...
- Create a dataset named PDF-Files with a column RelativePath.
- Fill the column with relative paths of the pdf files to upload \Authorized folder. Document001.pdf, \Authorized folder. Document002.pdf, etc...
When parameterizing the multipart file field from a file, the filename and Content-type directives will be parameterized with the filename and content type of that file.
In a distributed test that parameterizes file uploads, the files to upload must be copied to the load agent prior to starting the test. If the dataset uses absolute file paths, then the files to upload must be copied manually to the same path on every load agent before the test starts.
This is a very inefficient method. Instead, it is recommended to copy the files to the local DataFiles directory and use relative paths. Using this approach, StresStimulus will automatically copy the files to upload to every load agent before the test starts.
To create the local DataFiles folder and open it in Windows Explorer, click the Create and open DataFiles folder to parameterize file upload with a relative path button. Copy the files to upload to this folder and reference them by their relative path using "\" + Filename
- No labels