From 5f9445792e90824c6a68d6110dfc3340eb9b500e Mon Sep 17 00:00:00 2001 From: Jihun Cho Date: Tue, 11 Sep 2018 19:19:03 -0700 Subject: [PATCH 1/3] Add test.proto which is used in interops test in various gRPC projects. The test.proto is adapted from grpc-java. --- BUILD.bazel | 11 +++++ grpc/testing/messages.proto | 28 ++++++++----- grpc/testing/test.proto | 81 +++++++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+), 11 deletions(-) create mode 100644 grpc/testing/test.proto diff --git a/BUILD.bazel b/BUILD.bazel index db8511db..3cd612bc 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -24,6 +24,7 @@ proto_library( proto_library( name = "messages_proto", srcs = ["grpc/testing/messages.proto"], + deps = ["@com_google_protobuf//:wrappers_proto"], ) proto_library( @@ -111,6 +112,16 @@ proto_library( visibility = ["//visibility:public"], ) +proto_library( + name = "test_proto", + srcs = ["grpc/testing/test.proto"], + visibility = ["//visibility:public"], + deps = [ + ":messages_proto", + "@com_google_protobuf//:empty_proto", + ], +) + # Deprecated: do not use proto_library( name = "reflection_proto_deprecated", diff --git a/grpc/testing/messages.proto b/grpc/testing/messages.proto index 7b1b7286..6def66f3 100644 --- a/grpc/testing/messages.proto +++ b/grpc/testing/messages.proto @@ -19,18 +19,20 @@ syntax = "proto3"; package grpc.testing; -// TODO(dgq): Go back to using well-known types once -// https://github.com/grpc/grpc/issues/6980 has been fixed. -// import "google/protobuf/wrappers.proto"; -message BoolValue { - // The bool value. - bool value = 1; -} +option java_package = "io.grpc.testing.integration"; + +import "google/protobuf/wrappers.proto"; // The type of payload that should be returned. enum PayloadType { // Compressable text format. COMPRESSABLE = 0; + + // Uncompressable binary format. + UNCOMPRESSABLE = 1; + + // Randomly chosen from all other formats defined in this enum. + RANDOM = 2; } // A block of data, to simply increase gRPC message size. @@ -70,13 +72,13 @@ message SimpleRequest { // "nullable" in order to interoperate seamlessly with clients not able to // implement the full compression tests by introspecting the call to verify // the response's compression status. - BoolValue response_compressed = 6; + google.protobuf.BoolValue response_compressed = 6; // Whether server should return a given status EchoStatus response_status = 7; // Whether the server should expect this request to be compressed. - BoolValue expect_compressed = 8; + google.protobuf.BoolValue expect_compressed = 8; } // Unary response, as configured by the request. @@ -90,6 +92,10 @@ message SimpleResponse { string oauth_scope = 3; } +message SimpleContext { + string value = 1; +} + // Client-streaming request. message StreamingInputCallRequest { // Optional input payload sent along with the request. @@ -99,7 +105,7 @@ message StreamingInputCallRequest { // is "nullable" in order to interoperate seamlessly with servers not able to // implement the full compression tests by introspecting the call to verify // the request's compression status. - BoolValue expect_compressed = 2; + google.protobuf.BoolValue expect_compressed = 2; // Not expecting any payload from the response. } @@ -123,7 +129,7 @@ message ResponseParameters { // "nullable" in order to interoperate seamlessly with clients not able to // implement the full compression tests by introspecting the call to verify // the response's compression status. - BoolValue compressed = 3; + google.protobuf.BoolValue compressed = 3; } // Server-streaming request. diff --git a/grpc/testing/test.proto b/grpc/testing/test.proto new file mode 100644 index 00000000..a50bcc37 --- /dev/null +++ b/grpc/testing/test.proto @@ -0,0 +1,81 @@ +// Copyright 2018 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// An integration test service that covers all the method signature permutations +// of unary/streaming requests/responses. +syntax = "proto3"; + +import "google/protobuf/empty.proto"; +import "grpc/testing/messages.proto"; + +package grpc.testing; + +option java_package = "io.grpc.testing.integration"; + +// A simple service to test the various types of RPCs and experiment with +// performance with various types of payload. +service TestService { + // One empty request followed by one empty response. + rpc EmptyCall(google.protobuf.Empty) returns (google.protobuf.Empty); + + // One request followed by one response. + rpc UnaryCall(SimpleRequest) returns (SimpleResponse); + + // One request followed by one response. Response has cache control + // headers set such that a caching HTTP proxy (such as GFE) can + // satisfy subsequent requests. + rpc CacheableUnaryCall(SimpleRequest) returns (SimpleResponse); + + // One request followed by a sequence of responses (streamed download). + // The server returns the payload with client desired type and sizes. + rpc StreamingOutputCall(StreamingOutputCallRequest) + returns (stream StreamingOutputCallResponse); + + // A sequence of requests followed by one response (streamed upload). + // The server returns the aggregated size of client payload as the result. + rpc StreamingInputCall(stream StreamingInputCallRequest) + returns (StreamingInputCallResponse); + + // A sequence of requests with each request served by the server immediately. + // As one request could lead to multiple responses, this interface + // demonstrates the idea of full duplexing. + rpc FullDuplexCall(stream StreamingOutputCallRequest) + returns (stream StreamingOutputCallResponse); + + // A sequence of requests followed by a sequence of responses. + // The server buffers all the client requests and then serves them in order. A + // stream of responses are returned to the client when the server starts with + // first request. + rpc HalfDuplexCall(stream StreamingOutputCallRequest) + returns (stream StreamingOutputCallResponse); + + // The test server will not implement this method. It will be used + // to test the behavior when clients call unimplemented methods. + rpc UnimplementedCall(google.protobuf.Empty) returns (google.protobuf.Empty); +} + +// A simple service NOT implemented at servers so clients can test for +// that case. +service UnimplementedService { + // A call that no server should implement + rpc UnimplementedCall(google.protobuf.Empty) returns (google.protobuf.Empty); +} + +// A service used to control reconnect server. +service ReconnectService { + // Starts ReconnectService + rpc Start(google.protobuf.Empty) returns (google.protobuf.Empty); + + // Stops ReconnectService + rpc Stop(google.protobuf.Empty) returns (grpc.testing.ReconnectInfo); +} From 3eb2d09a80766bf56f70ee52aaa5e57b4ab03f9d Mon Sep 17 00:00:00 2001 From: Jihun Cho Date: Fri, 26 Oct 2018 09:33:49 -0700 Subject: [PATCH 2/3] change back to use custom Empty, BoolValue. --- BUILD.bazel | 8 ++++++-- grpc/testing/empty.proto | 29 +++++++++++++++++++++++++++++ grpc/testing/messages.proto | 16 +++++++++++----- grpc/testing/test.proto | 12 ++++++------ 4 files changed, 52 insertions(+), 13 deletions(-) create mode 100644 grpc/testing/empty.proto diff --git a/BUILD.bazel b/BUILD.bazel index 3cd612bc..d95497f2 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -24,7 +24,6 @@ proto_library( proto_library( name = "messages_proto", srcs = ["grpc/testing/messages.proto"], - deps = ["@com_google_protobuf//:wrappers_proto"], ) proto_library( @@ -117,11 +116,16 @@ proto_library( srcs = ["grpc/testing/test.proto"], visibility = ["//visibility:public"], deps = [ + ":empty_proto", ":messages_proto", - "@com_google_protobuf//:empty_proto", ], ) +proto_library( + name = "empty_proto", + srcs = ["grpc/testing/empty.proto"], +) + # Deprecated: do not use proto_library( name = "reflection_proto_deprecated", diff --git a/grpc/testing/empty.proto b/grpc/testing/empty.proto new file mode 100644 index 00000000..bd626abe --- /dev/null +++ b/grpc/testing/empty.proto @@ -0,0 +1,29 @@ +// Copyright 2015 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +syntax = "proto2"; + +package grpc.testing; + +option java_package = "io.grpc.testing.integration"; +option java_outer_classname = "EmptyProtos"; + +// An empty message that you can re-use to avoid defining duplicated empty +// messages in your project. A typical example is to use it as argument or the +// return value of a service API. For instance: +// +// service Foo { +// rpc Bar (grpc.testing.Empty) returns (grpc.testing.Empty) { }; +// }; +// +message Empty {} diff --git a/grpc/testing/messages.proto b/grpc/testing/messages.proto index 6def66f3..d0ebdcc8 100644 --- a/grpc/testing/messages.proto +++ b/grpc/testing/messages.proto @@ -21,7 +21,13 @@ package grpc.testing; option java_package = "io.grpc.testing.integration"; -import "google/protobuf/wrappers.proto"; +// TODO(dgq): Go back to using well-known types once +// https://github.com/grpc/grpc/issues/6980 has been fixed. +// import "google/protobuf/wrappers.proto"; +message BoolValue { + // The bool value. + bool value = 1; +} // The type of payload that should be returned. enum PayloadType { @@ -72,13 +78,13 @@ message SimpleRequest { // "nullable" in order to interoperate seamlessly with clients not able to // implement the full compression tests by introspecting the call to verify // the response's compression status. - google.protobuf.BoolValue response_compressed = 6; + BoolValue response_compressed = 6; // Whether server should return a given status EchoStatus response_status = 7; // Whether the server should expect this request to be compressed. - google.protobuf.BoolValue expect_compressed = 8; + BoolValue expect_compressed = 8; } // Unary response, as configured by the request. @@ -105,7 +111,7 @@ message StreamingInputCallRequest { // is "nullable" in order to interoperate seamlessly with servers not able to // implement the full compression tests by introspecting the call to verify // the request's compression status. - google.protobuf.BoolValue expect_compressed = 2; + BoolValue expect_compressed = 2; // Not expecting any payload from the response. } @@ -129,7 +135,7 @@ message ResponseParameters { // "nullable" in order to interoperate seamlessly with clients not able to // implement the full compression tests by introspecting the call to verify // the response's compression status. - google.protobuf.BoolValue compressed = 3; + BoolValue compressed = 3; } // Server-streaming request. diff --git a/grpc/testing/test.proto b/grpc/testing/test.proto index a50bcc37..053efa00 100644 --- a/grpc/testing/test.proto +++ b/grpc/testing/test.proto @@ -15,7 +15,7 @@ // of unary/streaming requests/responses. syntax = "proto3"; -import "google/protobuf/empty.proto"; +import "grpc/testing/empty.proto"; import "grpc/testing/messages.proto"; package grpc.testing; @@ -26,7 +26,7 @@ option java_package = "io.grpc.testing.integration"; // performance with various types of payload. service TestService { // One empty request followed by one empty response. - rpc EmptyCall(google.protobuf.Empty) returns (google.protobuf.Empty); + rpc EmptyCall(grpc.testing.Empty) returns (grpc.testing.Empty); // One request followed by one response. rpc UnaryCall(SimpleRequest) returns (SimpleResponse); @@ -61,21 +61,21 @@ service TestService { // The test server will not implement this method. It will be used // to test the behavior when clients call unimplemented methods. - rpc UnimplementedCall(google.protobuf.Empty) returns (google.protobuf.Empty); + rpc UnimplementedCall(grpc.testing.Empty) returns (grpc.testing.Empty); } // A simple service NOT implemented at servers so clients can test for // that case. service UnimplementedService { // A call that no server should implement - rpc UnimplementedCall(google.protobuf.Empty) returns (google.protobuf.Empty); + rpc UnimplementedCall(grpc.testing.Empty) returns (grpc.testing.Empty); } // A service used to control reconnect server. service ReconnectService { // Starts ReconnectService - rpc Start(google.protobuf.Empty) returns (google.protobuf.Empty); + rpc Start(grpc.testing.Empty) returns (grpc.testing.Empty); // Stops ReconnectService - rpc Stop(google.protobuf.Empty) returns (grpc.testing.ReconnectInfo); + rpc Stop(grpc.testing.Empty) returns (grpc.testing.ReconnectInfo); } From c47d7bcd71397f038e1c0cbce59109bffa2427d2 Mon Sep 17 00:00:00 2001 From: Jihun Cho Date: Mon, 29 Oct 2018 10:29:54 -0700 Subject: [PATCH 3/3] deprecates PayloadType since it has only 1 option. --- BUILD.bazel | 1 + grpc/testing/messages.proto | 26 ++++---------------------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index d95497f2..3a040752 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -124,6 +124,7 @@ proto_library( proto_library( name = "empty_proto", srcs = ["grpc/testing/empty.proto"], + visibility = ["//visibility:public"], ) # Deprecated: do not use diff --git a/grpc/testing/messages.proto b/grpc/testing/messages.proto index d0ebdcc8..9db2d36f 100644 --- a/grpc/testing/messages.proto +++ b/grpc/testing/messages.proto @@ -29,22 +29,10 @@ message BoolValue { bool value = 1; } -// The type of payload that should be returned. -enum PayloadType { - // Compressable text format. - COMPRESSABLE = 0; - - // Uncompressable binary format. - UNCOMPRESSABLE = 1; - - // Randomly chosen from all other formats defined in this enum. - RANDOM = 2; -} - // A block of data, to simply increase gRPC message size. message Payload { - // The type of data in body. - PayloadType type = 1; + reserved 1; + // Primary contents of payload. bytes body = 2; } @@ -58,9 +46,7 @@ message EchoStatus { // Unary request. message SimpleRequest { - // Desired payload type in the response from the server. - // If response_type is RANDOM, server randomly chooses one from other formats. - PayloadType response_type = 1; + reserved 1; // Desired payload size in the response from the server. int32 response_size = 2; @@ -140,11 +126,7 @@ message ResponseParameters { // Server-streaming request. message StreamingOutputCallRequest { - // Desired payload type in the response from the server. - // If response_type is RANDOM, the payload from each response in the stream - // might be of different types. This is to simulate a mixed type of payload - // stream. - PayloadType response_type = 1; + reserved 1; // Configuration for each expected response message. repeated ResponseParameters response_parameters = 2;