1
2// Copyright 2015-2016 gRPC authors.
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//     http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16// Message definitions to be used by integration test service definitions.
17
18syntax = "proto3";
19
20package grpc.testing;
21
22// TODO(dgq): Go back to using well-known types once
23// https://github.com/grpc/grpc/issues/6980 has been fixed.
24// import "google/protobuf/wrappers.proto";
25message BoolValue {
26  // The bool value.
27  bool value = 1;
28}
29
30// The type of payload that should be returned.
31enum PayloadType {
32  // Compressable text format.
33  COMPRESSABLE = 0;
34}
35
36// A block of data, to simply increase gRPC message size.
37message Payload {
38  // The type of data in body.
39  PayloadType type = 1;
40  // Primary contents of payload.
41  bytes body = 2;
42}
43
44// A protobuf representation for grpc status. This is used by test
45// clients to specify a status that the server should attempt to return.
46message EchoStatus {
47  int32 code = 1;
48  string message = 2;
49}
50
51// The type of route that a client took to reach a server w.r.t. gRPCLB.
52// The server must fill in "fallback" if it detects that the RPC reached
53// the server via the "gRPCLB fallback" path, and "backend" if it detects
54// that the RPC reached the server via "gRPCLB backend" path (i.e. if it got
55// the address of this server from the gRPCLB server BalanceLoad RPC). Exactly
56// how this detection is done is context and server dependent.
57enum GrpclbRouteType {
58  // Server didn't detect the route that a client took to reach it.
59  GRPCLB_ROUTE_TYPE_UNKNOWN = 0;
60  // Indicates that a client reached a server via gRPCLB fallback.
61  GRPCLB_ROUTE_TYPE_FALLBACK = 1;
62  // Indicates that a client reached a server as a gRPCLB-given backend.
63  GRPCLB_ROUTE_TYPE_BACKEND = 2;
64}
65
66// Unary request.
67message SimpleRequest {
68  // Desired payload type in the response from the server.
69  // If response_type is RANDOM, server randomly chooses one from other formats.
70  PayloadType response_type = 1;
71
72  // Desired payload size in the response from the server.
73  int32 response_size = 2;
74
75  // Optional input payload sent along with the request.
76  Payload payload = 3;
77
78  // Whether SimpleResponse should include username.
79  bool fill_username = 4;
80
81  // Whether SimpleResponse should include OAuth scope.
82  bool fill_oauth_scope = 5;
83
84  // Whether to request the server to compress the response. This field is
85  // "nullable" in order to interoperate seamlessly with clients not able to
86  // implement the full compression tests by introspecting the call to verify
87  // the response's compression status.
88  BoolValue response_compressed = 6;
89
90  // Whether server should return a given status
91  EchoStatus response_status = 7;
92
93  // Whether the server should expect this request to be compressed.
94  BoolValue expect_compressed = 8;
95
96  // Whether SimpleResponse should include server_id.
97  bool fill_server_id = 9;
98
99  // Whether SimpleResponse should include grpclb_route_type.
100  bool fill_grpclb_route_type = 10;
101}
102
103// Unary response, as configured by the request.
104message SimpleResponse {
105  // Payload to increase message size.
106  Payload payload = 1;
107  // The user the request came from, for verifying authentication was
108  // successful when the client expected it.
109  string username = 2;
110  // OAuth scope.
111  string oauth_scope = 3;
112
113  // Server ID. This must be unique among different server instances,
114  // but the same across all RPC's made to a particular server instance.
115  string server_id = 4;
116  // gRPCLB Path.
117  GrpclbRouteType grpclb_route_type = 5;
118
119  // Server hostname.
120  string hostname = 6;
121}
122
123// Client-streaming request.
124message StreamingInputCallRequest {
125  // Optional input payload sent along with the request.
126  Payload payload = 1;
127
128  // Whether the server should expect this request to be compressed. This field
129  // is "nullable" in order to interoperate seamlessly with servers not able to
130  // implement the full compression tests by introspecting the call to verify
131  // the request's compression status.
132  BoolValue expect_compressed = 2;
133
134  // Not expecting any payload from the response.
135}
136
137// Client-streaming response.
138message StreamingInputCallResponse {
139  // Aggregated size of payloads received from the client.
140  int32 aggregated_payload_size = 1;
141}
142
143// Configuration for a particular response.
144message ResponseParameters {
145  // Desired payload sizes in responses from the server.
146  int32 size = 1;
147
148  // Desired interval between consecutive responses in the response stream in
149  // microseconds.
150  int32 interval_us = 2;
151
152  // Whether to request the server to compress the response. This field is
153  // "nullable" in order to interoperate seamlessly with clients not able to
154  // implement the full compression tests by introspecting the call to verify
155  // the response's compression status.
156  BoolValue compressed = 3;
157}
158
159// Server-streaming request.
160message StreamingOutputCallRequest {
161  // Desired payload type in the response from the server.
162  // If response_type is RANDOM, the payload from each response in the stream
163  // might be of different types. This is to simulate a mixed type of payload
164  // stream.
165  PayloadType response_type = 1;
166
167  // Configuration for each expected response message.
168  repeated ResponseParameters response_parameters = 2;
169
170  // Optional input payload sent along with the request.
171  Payload payload = 3;
172
173  // Whether server should return a given status
174  EchoStatus response_status = 7;
175}
176
177// Server-streaming response, as configured by the request and parameters.
178message StreamingOutputCallResponse {
179  // Payload to increase response size.
180  Payload payload = 1;
181}
182
183// For reconnect interop test only.
184// Client tells server what reconnection parameters it used.
185message ReconnectParams {
186  int32 max_reconnect_backoff_ms = 1;
187}
188
189// For reconnect interop test only.
190// Server tells client whether its reconnects are following the spec and the
191// reconnect backoffs it saw.
192message ReconnectInfo {
193  bool passed = 1;
194  repeated int32 backoff_ms = 2;
195}
196
197message LoadBalancerStatsRequest {
198  // Request stats for the next num_rpcs sent by client.
199  int32 num_rpcs = 1;
200  // If num_rpcs have not completed within timeout_sec, return partial results.
201  int32 timeout_sec = 2;
202}
203
204message LoadBalancerStatsResponse {
205  message RpcsByPeer {
206    // The number of completed RPCs for each peer.
207    map<string, int32> rpcs_by_peer = 1;
208  }
209  // The number of completed RPCs for each peer.
210  map<string, int32> rpcs_by_peer = 1;
211  // The number of RPCs that failed to record a remote peer.
212  int32 num_failures = 2;
213  map<string, RpcsByPeer> rpcs_by_method = 3;
214}
215
216// Request for retrieving a test client's accumulated stats.
217message LoadBalancerAccumulatedStatsRequest {}
218
219// Accumulated stats for RPCs sent by a test client.
220message LoadBalancerAccumulatedStatsResponse {
221  // The total number of RPCs have ever issued for each type.
222  map<string, int32> num_rpcs_started_by_method = 1;
223  // The total number of RPCs have ever completed successfully for each type.
224  map<string, int32> num_rpcs_succeeded_by_method = 2;
225  // The total number of RPCs have ever failed for each type.
226  map<string, int32> num_rpcs_failed_by_method = 3;
227}
228
229// Configurations for a test client.
230message ClientConfigureRequest {
231  // Type of RPCs to send.
232  enum RpcType {
233    EMPTY_CALL = 0;
234    UNARY_CALL = 1;
235  }
236
237  // Metadata to be attached for the given type of RPCs.
238  message Metadata {
239    RpcType type = 1;
240    string key = 2;
241    string value = 3;
242  }
243
244  // The types of RPCs the client sends.
245  repeated RpcType types = 1;
246  // The collection of custom metadata to be attached to RPCs sent by the client.
247  repeated Metadata metadata = 2;
248}
249
250// Response for updating a test client's configuration.
251message ClientConfigureResponse {}
252