tencent cloud

Tencent Cloud Observability Platform

Release Notes and Announcements
Release Notes
Product Introduction
Overview
Strengths
Basic Features
Basic Concepts
Use Cases
Use Limits
Purchase Guide
Tencent Cloud Product Monitoring
Application Performance Management
Mobile App Performance Monitoring
Real User Monitoring
Cloud Automated Testing
Prometheus Monitoring
Grafana
EventBridge
PTS
Quick Start
Monitoring Overview
Instance Group
Tencent Cloud Product Monitoring
Application Performance Management
Real User Monitoring
Cloud Automated Testing
Performance Testing Service
Prometheus Getting Started
Grafana
Dashboard Creation
EventBridge
Alarm Service
Cloud Product Monitoring
Tencent Cloud Service Metrics
Operation Guide
CVM Agents
Cloud Product Monitoring Integration with Grafana
Troubleshooting
Practical Tutorial
Application Performance Management
Product Introduction
Access Guide
Operation Guide
Practical Tutorial
Parameter Information
FAQs
Mobile App Performance Monitoring
Overview
Operation Guide
Access Guide
Practical Tutorial
Tencent Cloud Real User Monitoring
Product Introduction
Operation Guide
Connection Guide
FAQs
Cloud Automated Testing
Product Introduction
Operation Guide
FAQs
Performance Testing Service
Overview
Operation Guide
Practice Tutorial
JavaScript API List
FAQs
Prometheus Monitoring
Product Introduction
Access Guide
Operation Guide
Practical Tutorial
Terraform
FAQs
Grafana
Product Introduction
Operation Guide
Guide on Grafana Common Features
FAQs
Dashboard
Overview
Operation Guide
Alarm Management
Console Operation Guide
Troubleshooting
FAQs
EventBridge
Product Introduction
Operation Guide
Practical Tutorial
FAQs
Report Management
FAQs
General
Alarm Service
Concepts
Monitoring Charts
CVM Agents
Dynamic Alarm Threshold
CM Connection to Grafana
Documentation Guide
Related Agreements
Application Performance Management Service Level Agreement
APM Privacy Policy
APM Data Processing And Security Agreement
RUM Service Level Agreement
Mobile Performance Monitoring Service Level Agreement
Cloud Automated Testing Service Level Agreement
Prometheus Service Level Agreement
TCMG Service Level Agreements
PTS Service Level Agreement
PTS Use Limits
Cloud Monitor Service Level Agreement
API Documentation
History
Introduction
API Category
Making API Requests
Monitoring Data Query APIs
Alarm APIs
Legacy Alert APIs
Notification Template APIs
TMP APIs
Grafana Service APIs
Event Center APIs
TencentCloud Managed Service for Prometheus APIs
Monitoring APIs
Data Types
Error Codes
Glossary

Basic Usage

PDF
フォーカスモード
フォントサイズ
最終更新日: 2025-03-10 22:14:18
PTS supports the GET, POST, PUT, PATCH, OPTIONS, DELETE, and HEAD requests of the HTTP protocol.

Script Writing

HTTP GET Request

// Send a http get request
import http from 'pts/http';
import { check, sleep } from 'pts';

export default function () {
// simple get request
const resp1 = http.get('http://httpbin.org/get');
console.log(resp1.body);
// if resp1.body is a json string, resp1.json() transfer json format body to a json object
console.log(resp1.json());
check('status is 200', () => resp1.statusCode === 200);

// sleep 1 second
sleep(1);

// get request with headers and parameters
const resp2 = http.get('http://httpbin.org/get', {
headers: {
'Connection': 'keep-alive',
'User-Agent': 'pts-engine'
},
query: {
'name1': 'value1',
'name2': 'value2',
}
});
console.log(resp2.json().args.name1); // 'value1'
check('body.args.name1 equals value1', () => resp2.json().args.name1 === 'value1');
};

HTTP POST Request

// Send a post request
import http from 'pts/http';
import { check } from 'pts';

export default function () {
const resp = http.post(
'http://httpbin.org/post',
{
user_id: '12345',
},
{
headers: {
'Content-Type': 'application/json',
},
}
);

console.log(resp.json().json.user_id); // 12345
check('body.json.user_id equals 12345', () => resp.json().json.user_id === '12345');
}

File Dependency

In the performance testing scenario, you can upload the following types of files to provide status data during the execution of the performance testing task:
Parameter file: It dynamically provides test data in CSV format. That is, when the scenario is executed by each concurrent user (VU), each line of data will be obtained from the parameter file as the test data values for reference by variables in the script. For specific usage, see Using Parameter Files.
Request file: It is required for constructing your request, for example, the file that needs to be uploaded. For specific usage, see Using Request Files.
Protocol file: It is required for request serialization. For specific usage, see Using Protocol Files.

ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック