tencent cloud

Performance Testing Service

Related Agreements
Service Level Agreement
Use Limits
Privacy Policy
Data Processing And Security Agreement
문서Performance Testing Service

gRPC-based Performance Testing

포커스 모드
폰트 크기
마지막 업데이트 시간: 2025-03-10 16:46:54
This document introduces how to orchestrate a gRPC protocol request.

Basic Usage

By using the APIs provided by the pts/grpc module, you can create a gRPC client and send gRPC requests.

Protocol File Upload

Upload your defined .proto file by choosing PTS > Test Scenarios > Create Scenario > File Management > Protocol File.
Note:
For the types of protocols supported by PTS and how to use them, see Using Protocol Files.

Script Writing

Create a gRPC client, and then use the following methods provided by the client to write your logic:
load: Loads and parses the .proto file you uploaded.
connect: Establishes a connection with the gRPC server.
invoke: Initiates an RPC call and obtains the response.
close: Closes a connection.
Examples of the .proto file and scenario script are as follows:
// based on https://github.com/go-kit/kit/blob/master/examples/addsvc/pb/addsvc.proto

syntax = "proto3";

package addsvc;

// The Add service definition.
service Add {
// Sums two integers.
rpc Sum (SumRequest) returns (SumReply) {}
}

// The sum request contains two parameters.
message SumRequest {
int64 a = 1;
int64 b = 2;
}

// The sum response contains the result of the calculation.
message SumReply {
int64 v = 1;
string err = 2;
}
Scenario script:
// GRPC API
import grpc from 'pts/grpc';

const client = new grpc.Client();

// Load the addsvc.proto file from the root directory of the protocol file.
client.load([], 'addsvc.proto');

export default () => {
client.connect('grpcb.in:9000', { insecure: true });

const rsp = client.invoke('addsvc.Add/Sum', {
a: 1,
b: 2,
});
console.log(rsp.data.v); // 3

client.close();
};

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.

도움말 및 지원

문제 해결에 도움이 되었나요?

피드백