1// Copyright 2017 gRPC authors. 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15// An integration test service that covers all the method signature permutations 16// of unary/streaming requests/responses. 17syntax = "proto3"; 18 19option go_package = "google.golang.org/grpc/interop/grpc_testing"; 20 21package grpc.testing; 22 23message Empty {} 24 25// The type of payload that should be returned. 26enum PayloadType { 27 // Compressable text format. 28 COMPRESSABLE = 0; 29 30 // Uncompressable binary format. 31 UNCOMPRESSABLE = 1; 32 33 // Randomly chosen from all other formats defined in this enum. 34 RANDOM = 2; 35} 36 37// A block of data, to simply increase gRPC message size. 38message Payload { 39 // The type of data in body. 40 PayloadType type = 1; 41 // Primary contents of payload. 42 bytes body = 2; 43} 44 45// A protobuf representation for grpc status. This is used by test 46// clients to specify a status that the server should attempt to return. 47message EchoStatus { 48 int32 code = 1; 49 string message = 2; 50} 51 52// The type of route that a client took to reach a server w.r.t. gRPCLB. 53// The server must fill in "fallback" if it detects that the RPC reached 54// the server via the "gRPCLB fallback" path, and "backend" if it detects 55// that the RPC reached the server via "gRPCLB backend" path (i.e. if it got 56// the address of this server from the gRPCLB server BalanceLoad RPC). Exactly 57// how this detection is done is context and server dependant. 58enum GrpclbRouteType { 59 // Server didn't detect the route that a client took to reach it. 60 GRPCLB_ROUTE_TYPE_UNKNOWN = 0; 61 // Indicates that a client reached a server via gRPCLB fallback. 62 GRPCLB_ROUTE_TYPE_FALLBACK = 1; 63 // Indicates that a client reached a server as a gRPCLB-given backend. 64 GRPCLB_ROUTE_TYPE_BACKEND = 2; 65} 66 67// Unary request. 68message SimpleRequest { 69 // Desired payload type in the response from the server. 70 // If response_type is RANDOM, server randomly chooses one from other formats. 71 PayloadType response_type = 1; 72 73 // Desired payload size in the response from the server. 74 // If response_type is COMPRESSABLE, this denotes the size before compression. 75 int32 response_size = 2; 76 77 // Optional input payload sent along with the request. 78 Payload payload = 3; 79 80 // Whether SimpleResponse should include username. 81 bool fill_username = 4; 82 83 // Whether SimpleResponse should include OAuth scope. 84 bool fill_oauth_scope = 5; 85 86 // Whether server should return a given status 87 EchoStatus response_status = 7; 88 89 // Whether SimpleResponse should include server_id. 90 bool fill_server_id = 9; 91 92 // Whether SimpleResponse should include grpclb_route_type. 93 bool fill_grpclb_route_type = 10; 94} 95 96// Unary response, as configured by the request. 97message SimpleResponse { 98 // Payload to increase message size. 99 Payload payload = 1; 100 101 // The user the request came from, for verifying authentication was 102 // successful when the client expected it. 103 string username = 2; 104 105 // OAuth scope. 106 string oauth_scope = 3; 107 108 // Server ID. This must be unique among different server instances, 109 // but the same across all RPC's made to a particular server instance. 110 string server_id = 4; 111 112 // gRPCLB Path. 113 GrpclbRouteType grpclb_route_type = 5; 114 115 // Server hostname. 116 string hostname = 6; 117} 118 119// Client-streaming request. 120message StreamingInputCallRequest { 121 // Optional input payload sent along with the request. 122 Payload payload = 1; 123 124 // Not expecting any payload from the response. 125} 126 127// Client-streaming response. 128message StreamingInputCallResponse { 129 // Aggregated size of payloads received from the client. 130 int32 aggregated_payload_size = 1; 131} 132 133// Configuration for a particular response. 134message ResponseParameters { 135 // Desired payload sizes in responses from the server. 136 // If response_type is COMPRESSABLE, this denotes the size before compression. 137 int32 size = 1; 138 139 // Desired interval between consecutive responses in the response stream in 140 // microseconds. 141 int32 interval_us = 2; 142} 143 144// Server-streaming request. 145message StreamingOutputCallRequest { 146 // Desired payload type in the response from the server. 147 // If response_type is RANDOM, the payload from each response in the stream 148 // might be of different types. This is to simulate a mixed type of payload 149 // stream. 150 PayloadType response_type = 1; 151 152 // Configuration for each expected response message. 153 repeated ResponseParameters response_parameters = 2; 154 155 // Optional input payload sent along with the request. 156 Payload payload = 3; 157 158 // Whether server should return a given status 159 EchoStatus response_status = 7; 160} 161 162// Server-streaming response, as configured by the request and parameters. 163message StreamingOutputCallResponse { 164 // Payload to increase response size. 165 Payload payload = 1; 166} 167 168// A simple service to test the various types of RPCs and experiment with 169// performance with various types of payload. 170service TestService { 171 // One empty request followed by one empty response. 172 rpc EmptyCall(Empty) returns (Empty); 173 174 // One request followed by one response. 175 // The server returns the client payload as-is. 176 rpc UnaryCall(SimpleRequest) returns (SimpleResponse); 177 178 // One request followed by a sequence of responses (streamed download). 179 // The server returns the payload with client desired type and sizes. 180 rpc StreamingOutputCall(StreamingOutputCallRequest) 181 returns (stream StreamingOutputCallResponse); 182 183 // A sequence of requests followed by one response (streamed upload). 184 // The server returns the aggregated size of client payload as the result. 185 rpc StreamingInputCall(stream StreamingInputCallRequest) 186 returns (StreamingInputCallResponse); 187 188 // A sequence of requests with each request served by the server immediately. 189 // As one request could lead to multiple responses, this interface 190 // demonstrates the idea of full duplexing. 191 rpc FullDuplexCall(stream StreamingOutputCallRequest) 192 returns (stream StreamingOutputCallResponse); 193 194 // A sequence of requests followed by a sequence of responses. 195 // The server buffers all the client requests and then serves them in order. A 196 // stream of responses are returned to the client when the server starts with 197 // first request. 198 rpc HalfDuplexCall(stream StreamingOutputCallRequest) 199 returns (stream StreamingOutputCallResponse); 200} 201 202// A simple service NOT implemented at servers so clients can test for 203// that case. 204service UnimplementedService { 205 // A call that no server should implement 206 rpc UnimplementedCall(grpc.testing.Empty) returns (grpc.testing.Empty); 207} 208 209message LoadBalancerStatsRequest { 210 // Request stats for the next num_rpcs sent by client. 211 int32 num_rpcs = 1; 212 // If num_rpcs have not completed within timeout_sec, return partial results. 213 int32 timeout_sec = 2; 214} 215 216message LoadBalancerStatsResponse { 217 message RpcsByPeer { 218 // The number of completed RPCs for each peer. 219 map<string, int32> rpcs_by_peer = 1; 220 } 221 222 // The number of completed RPCs for each peer. 223 map<string, int32> rpcs_by_peer = 1; 224 // The number of RPCs that failed to record a remote peer. 225 int32 num_failures = 2; 226 // The number of completed RPCs for each method (UnaryCall or EmptyCall). 227 map<string, RpcsByPeer> rpcs_by_method = 3; 228} 229 230// A service used to obtain stats for verifying LB behavior. 231service LoadBalancerStatsService { 232 // Gets the backend distribution for RPCs sent by a test client. 233 rpc GetClientStats(LoadBalancerStatsRequest) 234 returns (LoadBalancerStatsResponse) {} 235} 236