tencent cloud

All product documents
Tencent Cloud Observability Platform
Use the Request File
Last updated: 2025-03-10 22:20:39
Use the Request File
Last updated: 2025-03-10 22:20:39
A request file mainly refers to the files needed to build your request in a stress test scenario, such as the files to be uploaded in a stress test API. Users can directly operate these request files in the scenario.
For example:
The stress test scenario for Qzone users posting images requires simulating the scenario of users uploading images.
In some bank scenarios, certificates need to be installed on the client, and simulating these scenarios requires opening and loading the certificates on the client.

Use the Request File

1. Upload request file:



2. Use request file in script:
Code for defining global variables (global): It runs once per concurrency.
Code for the main function (default): It runs once per iteration for each concurrency, and each VU will continuously iterate until it reaches the duration limit or iteration limit configured in the current stress test.
Therefore, it is recommended to define some static file read operations in the global scope, as a single concurrency only needs to read the file once. Avoid defining file reads in the main function, as this will result in reading the file in each iteration, leading to performance loss in stress testing.
// send a post request
import http from "pts/http";

const makefile = open("Makefile");

export const options = {};

export default function main() {
let response;

response = http.post("https://httpbin.org/post", makefile, {
headers: {
"Content-Type": "application/octet-stream",
},
});
}
3. The open function provides two modes. If the second parameter is empty, it returns a string; if it is 'b', it returns an ArrayBuffer.
export default function main() {
let data = open('Makefile');
console.log(data); // SHELL := /bin/bash ...
data = open('Makefile', 'b');
console.log(data); // [object ArrayBuffer]
}

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 available.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon