diff options
author | 2018-06-15 11:13:46 -0400 | |
---|---|---|
committer | 2018-06-15 11:13:46 -0400 | |
commit | c14e95fc63302421b71f0939a71d3a2b32c8ab1f (patch) | |
tree | 7a5a865423be974130cd24d3e70067052d6b9d8e /test/cpp/interop | |
parent | c7166ae67dd554d41b4d26286da2888aebc0153b (diff) | |
parent | bd6ac0f9d57dda96797bbd5b1bd27815342e7ee5 (diff) |
Merge branch 'master' of https://github.com/grpc/grpc into channelz
Diffstat (limited to 'test/cpp/interop')
-rw-r--r-- | test/cpp/interop/http2_client.cc | 11 | ||||
-rw-r--r-- | test/cpp/interop/http2_client.h | 6 | ||||
-rw-r--r-- | test/cpp/interop/interop_client.cc | 16 | ||||
-rw-r--r-- | test/cpp/interop/interop_client.h | 11 | ||||
-rw-r--r-- | test/cpp/interop/interop_server.cc | 8 | ||||
-rw-r--r-- | test/cpp/interop/server_helper.h | 8 | ||||
-rw-r--r-- | test/cpp/interop/stress_interop_client.cc | 5 | ||||
-rw-r--r-- | test/cpp/interop/stress_interop_client.h | 4 |
8 files changed, 37 insertions, 32 deletions
diff --git a/test/cpp/interop/http2_client.cc b/test/cpp/interop/http2_client.cc index 543f159265..bc7f0f5edb 100644 --- a/test/cpp/interop/http2_client.cc +++ b/test/cpp/interop/http2_client.cc @@ -42,16 +42,16 @@ const int kLargeRequestSize = 271828; const int kLargeResponseSize = 314159; } // namespace -Http2Client::ServiceStub::ServiceStub(std::shared_ptr<Channel> channel) - : channel_(channel) { +Http2Client::ServiceStub::ServiceStub(const std::shared_ptr<Channel>& channel) + : channel_(std::move(channel)) { stub_ = TestService::NewStub(channel); } TestService::Stub* Http2Client::ServiceStub::Get() { return stub_.get(); } -Http2Client::Http2Client(std::shared_ptr<Channel> channel) +Http2Client::Http2Client(const std::shared_ptr<Channel>& channel) : serviceStub_(channel), - channel_(channel), + channel_(std::move(channel)), defaultRequest_(BuildDefaultRequest()) {} bool Http2Client::AssertStatusCode(const Status& s, StatusCode expected_code) { @@ -140,7 +140,8 @@ bool Http2Client::DoPing() { return true; } -void Http2Client::MaxStreamsWorker(std::shared_ptr<grpc::Channel> channel) { +void Http2Client::MaxStreamsWorker( + const std::shared_ptr<grpc::Channel>& channel) { SimpleResponse response; AssertStatusCode(SendUnaryCall(&response), grpc::StatusCode::OK); GPR_ASSERT(response.payload().body() == diff --git a/test/cpp/interop/http2_client.h b/test/cpp/interop/http2_client.h index 2bcfdd69db..269d3b32e2 100644 --- a/test/cpp/interop/http2_client.h +++ b/test/cpp/interop/http2_client.h @@ -31,7 +31,7 @@ namespace testing { class Http2Client { public: - explicit Http2Client(std::shared_ptr<Channel> channel); + explicit Http2Client(const std::shared_ptr<Channel>& channel); ~Http2Client() {} bool DoRstAfterHeader(); @@ -44,7 +44,7 @@ class Http2Client { private: class ServiceStub { public: - ServiceStub(std::shared_ptr<Channel> channel); + ServiceStub(const std::shared_ptr<Channel>& channel); TestService::Stub* Get(); @@ -53,7 +53,7 @@ class Http2Client { std::shared_ptr<Channel> channel_; }; - void MaxStreamsWorker(std::shared_ptr<grpc::Channel> channel); + void MaxStreamsWorker(const std::shared_ptr<grpc::Channel>& channel); bool AssertStatusCode(const Status& s, StatusCode expected_code); Status SendUnaryCall(SimpleResponse* response); SimpleRequest BuildDefaultRequest(); diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc index 68bf1e6dc7..fce99a1697 100644 --- a/test/cpp/interop/interop_client.cc +++ b/test/cpp/interop/interop_client.cc @@ -19,6 +19,7 @@ #include <cinttypes> #include <fstream> #include <memory> +#include <utility> #include <grpc/grpc.h> #include <grpc/support/alloc.h> @@ -73,7 +74,7 @@ void UnaryCompressionChecks(const InteropClientContextInspector& inspector, } } // namespace -InteropClient::ServiceStub::ServiceStub(std::shared_ptr<Channel> channel, +InteropClient::ServiceStub::ServiceStub(const std::shared_ptr<Channel>& channel, bool new_stub_every_call) : channel_(channel), new_stub_every_call_(new_stub_every_call) { // If new_stub_every_call is false, then this is our chance to initialize @@ -99,7 +100,8 @@ InteropClient::ServiceStub::GetUnimplementedServiceStub() { return unimplemented_service_stub_.get(); } -void InteropClient::ServiceStub::Reset(std::shared_ptr<Channel> channel) { +void InteropClient::ServiceStub::Reset( + const std::shared_ptr<Channel>& channel) { channel_ = channel; // Update stub_ as well. Note: If new_stub_every_call_ is true, we can reset @@ -111,14 +113,14 @@ void InteropClient::ServiceStub::Reset(std::shared_ptr<Channel> channel) { } } -void InteropClient::Reset(std::shared_ptr<Channel> channel) { - serviceStub_.Reset(channel); +void InteropClient::Reset(const std::shared_ptr<Channel>& channel) { + serviceStub_.Reset(std::move(channel)); } -InteropClient::InteropClient(std::shared_ptr<Channel> channel, +InteropClient::InteropClient(const std::shared_ptr<Channel>& channel, bool new_stub_every_test_case, bool do_not_abort_on_transient_failures) - : serviceStub_(channel, new_stub_every_test_case), + : serviceStub_(std::move(channel), new_stub_every_test_case), do_not_abort_on_transient_failures_(do_not_abort_on_transient_failures) {} bool InteropClient::AssertStatusOk(const Status& s, @@ -180,7 +182,7 @@ bool InteropClient::PerformLargeUnary(SimpleRequest* request, bool InteropClient::PerformLargeUnary(SimpleRequest* request, SimpleResponse* response, - CheckerFn custom_checks_fn) { + const CheckerFn& custom_checks_fn) { ClientContext context; InteropClientContextInspector inspector(context); request->set_response_size(kLargeResponseSize); diff --git a/test/cpp/interop/interop_client.h b/test/cpp/interop/interop_client.h index 79ff24fc47..480eb3f4b6 100644 --- a/test/cpp/interop/interop_client.h +++ b/test/cpp/interop/interop_client.h @@ -40,12 +40,12 @@ class InteropClient { /// created for every test case /// If do_not_abort_on_transient_failures is true, abort() is not called in /// case of transient failures (like connection failures) - explicit InteropClient(std::shared_ptr<Channel> channel, + explicit InteropClient(const std::shared_ptr<Channel>& channel, bool new_stub_every_test_case, bool do_not_abort_on_transient_failures); ~InteropClient() {} - void Reset(std::shared_ptr<Channel> channel); + void Reset(const std::shared_ptr<Channel>& channel); bool DoEmpty(); bool DoLargeUnary(); @@ -83,12 +83,13 @@ class InteropClient { public: // If new_stub_every_call = true, pointer to a new instance of // TestServce::Stub is returned by Get() everytime it is called - ServiceStub(std::shared_ptr<Channel> channel, bool new_stub_every_call); + ServiceStub(const std::shared_ptr<Channel>& channel, + bool new_stub_every_call); TestService::Stub* Get(); UnimplementedService::Stub* GetUnimplementedServiceStub(); - void Reset(std::shared_ptr<Channel> channel); + void Reset(const std::shared_ptr<Channel>& channel); private: std::unique_ptr<TestService::Stub> stub_; @@ -102,7 +103,7 @@ class InteropClient { /// Run \a custom_check_fn as an additional check. bool PerformLargeUnary(SimpleRequest* request, SimpleResponse* response, - CheckerFn custom_checks_fn); + const CheckerFn& custom_checks_fn); bool AssertStatusOk(const Status& s, const grpc::string& optional_debug_string); bool AssertStatusCode(const Status& s, StatusCode expected_code, diff --git a/test/cpp/interop/interop_server.cc b/test/cpp/interop/interop_server.cc index f55d624b21..6570bbf969 100644 --- a/test/cpp/interop/interop_server.cc +++ b/test/cpp/interop/interop_server.cc @@ -317,25 +317,25 @@ class TestServiceImpl : public TestService::Service { }; void grpc::testing::interop::RunServer( - std::shared_ptr<ServerCredentials> creds) { + const std::shared_ptr<ServerCredentials>& creds) { RunServer(creds, FLAGS_port, nullptr, nullptr); } void grpc::testing::interop::RunServer( - std::shared_ptr<ServerCredentials> creds, + const std::shared_ptr<ServerCredentials>& creds, std::unique_ptr<std::vector<std::unique_ptr<ServerBuilderOption>>> server_options) { RunServer(creds, FLAGS_port, nullptr, std::move(server_options)); } void grpc::testing::interop::RunServer( - std::shared_ptr<ServerCredentials> creds, const int port, + const std::shared_ptr<ServerCredentials>& creds, const int port, ServerStartedCondition* server_started_condition) { RunServer(creds, port, server_started_condition, nullptr); } void grpc::testing::interop::RunServer( - std::shared_ptr<ServerCredentials> creds, const int port, + const std::shared_ptr<ServerCredentials>& creds, const int port, ServerStartedCondition* server_started_condition, std::unique_ptr<std::vector<std::unique_ptr<ServerBuilderOption>>> server_options) { diff --git a/test/cpp/interop/server_helper.h b/test/cpp/interop/server_helper.h index 265874df70..1bfbf8e474 100644 --- a/test/cpp/interop/server_helper.h +++ b/test/cpp/interop/server_helper.h @@ -63,7 +63,7 @@ struct ServerStartedCondition { /// Run gRPC interop server using port FLAGS_port. /// /// \param creds The credentials associated with the server. -void RunServer(std::shared_ptr<ServerCredentials> creds); +void RunServer(const std::shared_ptr<ServerCredentials>& creds); /// Run gRPC interop server. /// @@ -71,7 +71,7 @@ void RunServer(std::shared_ptr<ServerCredentials> creds); /// \param port Port to use for the server. /// \param server_started_condition (optional) Struct holding mutex, condition /// variable, and condition used to notify when the server has started. -void RunServer(std::shared_ptr<ServerCredentials> creds, int port, +void RunServer(const std::shared_ptr<ServerCredentials>& creds, int port, ServerStartedCondition* server_started_condition); /// Run gRPC interop server. @@ -79,7 +79,7 @@ void RunServer(std::shared_ptr<ServerCredentials> creds, int port, /// \param creds The credentials associated with the server. /// \param server_options List of options to set when building the server. void RunServer( - std::shared_ptr<ServerCredentials> creds, + const std::shared_ptr<ServerCredentials>& creds, std::unique_ptr<std::vector<std::unique_ptr<ServerBuilderOption>>> server_options); @@ -91,7 +91,7 @@ void RunServer( /// \param server_started_condition (optional) Struct holding mutex, condition // variable, and condition used to notify when the server has started. void RunServer( - std::shared_ptr<ServerCredentials> creds, const int port, + const std::shared_ptr<ServerCredentials>& creds, const int port, ServerStartedCondition* server_started_condition, std::unique_ptr<std::vector<std::unique_ptr<grpc::ServerBuilderOption>>> server_options); diff --git a/test/cpp/interop/stress_interop_client.cc b/test/cpp/interop/stress_interop_client.cc index 30a8351cfe..9d373c3cd9 100644 --- a/test/cpp/interop/stress_interop_client.cc +++ b/test/cpp/interop/stress_interop_client.cc @@ -68,7 +68,7 @@ TestCaseType WeightedRandomTestSelector::GetNextTest() const { StressTestInteropClient::StressTestInteropClient( int test_id, const grpc::string& server_address, - std::shared_ptr<Channel> channel, + const std::shared_ptr<Channel>& channel, const WeightedRandomTestSelector& test_selector, long test_duration_secs, long sleep_duration_ms, bool do_not_abort_on_transient_failures) : test_id_(test_id), @@ -80,7 +80,8 @@ StressTestInteropClient::StressTestInteropClient( test_duration_secs_(test_duration_secs), sleep_duration_ms_(sleep_duration_ms) {} -void StressTestInteropClient::MainLoop(std::shared_ptr<QpsGauge> qps_gauge) { +void StressTestInteropClient::MainLoop( + const std::shared_ptr<QpsGauge>& qps_gauge) { gpr_log(GPR_INFO, "Running test %d. ServerAddr: %s", test_id_, server_address_.c_str()); diff --git a/test/cpp/interop/stress_interop_client.h b/test/cpp/interop/stress_interop_client.h index a306dc3565..e4fa7d0973 100644 --- a/test/cpp/interop/stress_interop_client.h +++ b/test/cpp/interop/stress_interop_client.h @@ -91,14 +91,14 @@ class WeightedRandomTestSelector { class StressTestInteropClient { public: StressTestInteropClient(int test_id, const grpc::string& server_address, - std::shared_ptr<Channel> channel, + const std::shared_ptr<Channel>& channel, const WeightedRandomTestSelector& test_selector, long test_duration_secs, long sleep_duration_ms, bool do_not_abort_on_transient_failures); // The main function. Use this as the thread entry point. // qps_gauge is the QpsGauge to record the requests per second metric - void MainLoop(std::shared_ptr<QpsGauge> qps_gauge); + void MainLoop(const std::shared_ptr<QpsGauge>& qps_gauge); private: bool RunTest(TestCaseType test_case); |