diff options
author | Craig Tiller <ctiller@google.com> | 2015-12-17 16:35:00 -0800 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2015-12-17 16:35:00 -0800 |
commit | 1b4e33029efc2dd57036270bd3a73b6841aadbf5 (patch) | |
tree | 1c08b443d17af452ad9cf78320154142a77df757 /test/cpp/util | |
parent | 2dd2e895d9c783f7247bbe70be692118f964532b (diff) |
Consolidate C++ proto files under src/proto
- make the directory structure match the package structure
- sanitize the package structure (test --> testing)
- add auto-detection of proto file dependencies
Diffstat (limited to 'test/cpp/util')
-rw-r--r-- | test/cpp/util/cli_call_test.cc | 12 | ||||
-rw-r--r-- | test/cpp/util/echo.proto | 47 | ||||
-rw-r--r-- | test/cpp/util/echo_duplicate.proto | 42 | ||||
-rw-r--r-- | test/cpp/util/grpc_cli.cc | 9 | ||||
-rw-r--r-- | test/cpp/util/messages.proto | 60 | ||||
-rw-r--r-- | test/cpp/util/metrics_server.cc | 4 | ||||
-rw-r--r-- | test/cpp/util/metrics_server.h | 7 |
7 files changed, 17 insertions, 164 deletions
diff --git a/test/cpp/util/cli_call_test.cc b/test/cpp/util/cli_call_test.cc index 32cd8e4103..2e223ec57e 100644 --- a/test/cpp/util/cli_call_test.cc +++ b/test/cpp/util/cli_call_test.cc @@ -44,16 +44,16 @@ #include "test/core/util/port.h" #include "test/core/util/test_config.h" -#include "test/cpp/util/echo.grpc.pb.h" +#include "src/proto/grpc/testing/echo.grpc.pb.h" #include "test/cpp/util/string_ref_helper.h" -using grpc::cpp::test::util::EchoRequest; -using grpc::cpp::test::util::EchoResponse; +using grpc::testing::EchoRequest; +using grpc::testing::EchoResponse; namespace grpc { namespace testing { -class TestServiceImpl : public ::grpc::cpp::test::util::TestService::Service { +class TestServiceImpl : public ::grpc::testing::TestService::Service { public: Status Echo(ServerContext* context, const EchoRequest* request, EchoResponse* response) GRPC_OVERRIDE { @@ -91,11 +91,11 @@ class CliCallTest : public ::testing::Test { void ResetStub() { channel_ = CreateChannel(server_address_.str(), InsecureChannelCredentials()); - stub_ = grpc::cpp::test::util::TestService::NewStub(channel_); + stub_ = grpc::testing::TestService::NewStub(channel_); } std::shared_ptr<Channel> channel_; - std::unique_ptr<grpc::cpp::test::util::TestService::Stub> stub_; + std::unique_ptr<grpc::testing::TestService::Stub> stub_; std::unique_ptr<Server> server_; std::ostringstream server_address_; TestServiceImpl service_; diff --git a/test/cpp/util/echo.proto b/test/cpp/util/echo.proto deleted file mode 100644 index 8ea2f59897..0000000000 --- a/test/cpp/util/echo.proto +++ /dev/null @@ -1,47 +0,0 @@ - -// Copyright 2015, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -syntax = "proto3"; - -import "test/cpp/util/messages.proto"; - -package grpc.cpp.test.util; - -service TestService { - rpc Echo(EchoRequest) returns (EchoResponse); - rpc RequestStream(stream EchoRequest) returns (EchoResponse); - rpc ResponseStream(EchoRequest) returns (stream EchoResponse); - rpc BidiStream(stream EchoRequest) returns (stream EchoResponse); - rpc Unimplemented(EchoRequest) returns (EchoResponse); -} - -service UnimplementedService { - rpc Unimplemented(EchoRequest) returns (EchoResponse); -} diff --git a/test/cpp/util/echo_duplicate.proto b/test/cpp/util/echo_duplicate.proto deleted file mode 100644 index 9c1d67825a..0000000000 --- a/test/cpp/util/echo_duplicate.proto +++ /dev/null @@ -1,42 +0,0 @@ - -// Copyright 2015, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// This is a partial copy of echo.proto with a different package name. - -syntax = "proto3"; - -import "test/cpp/util/messages.proto"; - -package grpc.cpp.test.util.duplicate; - -service TestService { - rpc Echo(grpc.cpp.test.util.EchoRequest) - returns (grpc.cpp.test.util.EchoResponse); -} diff --git a/test/cpp/util/grpc_cli.cc b/test/cpp/util/grpc_cli.cc index 3f40b242fc..f9b9f0c40a 100644 --- a/test/cpp/util/grpc_cli.cc +++ b/test/cpp/util/grpc_cli.cc @@ -41,8 +41,9 @@ body: "hello world" } b. under grpc/ run - protoc --proto_path=test/proto/ \ - --encode=grpc.testing.SimpleRequest test/proto/messages.proto \ + protoc --proto_path=src/proto/grpc/testing/ \ + --encode=grpc.testing.SimpleRequest + src/proto/grpc/testing/messages.proto \ < input.txt > input.bin 2. Start a server make interop_server && bins/opt/interop_server --port=50051 @@ -51,8 +52,8 @@ /grpc.testing.TestService/UnaryCall --enable_ssl=false \ --input_binary_file=input.bin --output_binary_file=output.bin 4. Decode response - protoc --proto_path=test/proto/ \ - --decode=grpc.testing.SimpleResponse test/proto/messages.proto \ + protoc --proto_path=src/proto/grpc/testing/ \ + --decode=grpc.testing.SimpleResponse src/proto/grpc/testing/messages.proto \ < output.bin > output.txt 5. Now the text form of response should be in output.txt Optionally, metadata can be passed to server via flag --metadata, e.g. diff --git a/test/cpp/util/messages.proto b/test/cpp/util/messages.proto deleted file mode 100644 index a022707be9..0000000000 --- a/test/cpp/util/messages.proto +++ /dev/null @@ -1,60 +0,0 @@ - -// Copyright 2015, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -syntax = "proto3"; - -package grpc.cpp.test.util; - -message RequestParams { - bool echo_deadline = 1; - int32 client_cancel_after_us = 2; - int32 server_cancel_after_us = 3; - bool echo_metadata = 4; - bool check_auth_context = 5; - int32 response_message_length = 6; - bool echo_peer = 7; - string expected_client_identity = 8; // will force check_auth_context. -} - -message EchoRequest { - string message = 1; - RequestParams param = 2; -} - -message ResponseParams { - int64 request_deadline = 1; - string host = 2; - string peer = 3; -} - -message EchoResponse { - string message = 1; - ResponseParams param = 2; -} diff --git a/test/cpp/util/metrics_server.cc b/test/cpp/util/metrics_server.cc index 426295f9b4..40028d3957 100644 --- a/test/cpp/util/metrics_server.cc +++ b/test/cpp/util/metrics_server.cc @@ -35,8 +35,8 @@ #include <grpc++/server_builder.h> -#include "test/proto/metrics.grpc.pb.h" -#include "test/proto/metrics.pb.h" +#include "src/proto/grpc/testing/metrics.grpc.pb.h" +#include "src/proto/grpc/testing/metrics.pb.h" namespace grpc { namespace testing { diff --git a/test/cpp/util/metrics_server.h b/test/cpp/util/metrics_server.h index edde37dc4c..ce05e0be64 100644 --- a/test/cpp/util/metrics_server.h +++ b/test/cpp/util/metrics_server.h @@ -36,11 +36,12 @@ #include <map> #include <mutex> -#include "test/proto/metrics.grpc.pb.h" -#include "test/proto/metrics.pb.h" +#include "src/proto/grpc/testing/metrics.grpc.pb.h" +#include "src/proto/grpc/testing/metrics.pb.h" /* - * This implements a Metrics server defined in test/proto/metrics.proto. Any + * This implements a Metrics server defined in + * src/proto/grpc/testing/metrics.proto. Any * test service can use this to export Metrics (TODO (sreek): Only Gauges for * now). * |