tencent cloud

All product documents
Tencent Cloud Observability Platform
gRPC-based Performance Testing
Last updated: 2025-03-10 22:14:18
gRPC-based Performance Testing
Last updated: 2025-03-10 22:14:18
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.
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 avaliable.

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