diff options
author | ncteisen <ncteisen@gmail.com> | 2018-07-17 16:36:59 -0700 |
---|---|---|
committer | ncteisen <ncteisen@gmail.com> | 2018-07-17 17:12:26 -0700 |
commit | b6597b4fbde40b61200d363a195239e19e0b599c (patch) | |
tree | 98377751da4b5183e8685d50d1993b747a475c64 /test/cpp/interop/interop_client.cc | |
parent | 3904de99b8539acd0957d5e5f65e1d5531fefdaf (diff) |
Add two new soak interop tests
Diffstat (limited to 'test/cpp/interop/interop_client.cc')
-rw-r--r-- | test/cpp/interop/interop_client.cc | 60 |
1 files changed, 41 insertions, 19 deletions
diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc index fce99a1697..a023e8776b 100644 --- a/test/cpp/interop/interop_client.cc +++ b/test/cpp/interop/interop_client.cc @@ -74,13 +74,15 @@ void UnaryCompressionChecks(const InteropClientContextInspector& inspector, } } // namespace -InteropClient::ServiceStub::ServiceStub(const std::shared_ptr<Channel>& channel, - bool new_stub_every_call) - : channel_(channel), new_stub_every_call_(new_stub_every_call) { +InteropClient::ServiceStub::ServiceStub( + ChannelCreationFunc channel_creation_func, bool new_stub_every_call) + : channel_creation_func_(channel_creation_func), + channel_(channel_creation_func_()), + new_stub_every_call_(new_stub_every_call) { // If new_stub_every_call is false, then this is our chance to initialize // stub_. (see Get()) if (!new_stub_every_call) { - stub_ = TestService::NewStub(channel); + stub_ = TestService::NewStub(channel_); } } @@ -100,27 +102,19 @@ InteropClient::ServiceStub::GetUnimplementedServiceStub() { return unimplemented_service_stub_.get(); } -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 - // the stub_ since the next call to Get() will create a new stub - if (new_stub_every_call_) { - stub_.reset(); +void InteropClient::ServiceStub::ResetChannel() { + channel_ = channel_creation_func_(); + if (!new_stub_every_call_) { + stub_ = TestService::NewStub(channel_); } else { - stub_ = TestService::NewStub(channel); + stub_.reset(); } } -void InteropClient::Reset(const std::shared_ptr<Channel>& channel) { - serviceStub_.Reset(std::move(channel)); -} - -InteropClient::InteropClient(const std::shared_ptr<Channel>& channel, +InteropClient::InteropClient(ChannelCreationFunc channel_creation_func, bool new_stub_every_test_case, bool do_not_abort_on_transient_failures) - : serviceStub_(std::move(channel), new_stub_every_test_case), + : serviceStub_(channel_creation_func, new_stub_every_test_case), do_not_abort_on_transient_failures_(do_not_abort_on_transient_failures) {} bool InteropClient::AssertStatusOk(const Status& s, @@ -1028,6 +1022,34 @@ bool InteropClient::DoCustomMetadata() { return true; } +bool InteropClient::DoRpcSoakTest() { + gpr_log(GPR_DEBUG, "Sending 1000 RPCs..."); + SimpleRequest request; + SimpleResponse response; + for (int i = 0; i < 1000; ++i) { + if (!PerformLargeUnary(&request, &response)) { + return false; + } + } + gpr_log(GPR_DEBUG, "rpc_soak test done."); + return true; +} + +bool InteropClient::DoChannelSoakTest() { + gpr_log(GPR_DEBUG, + "Sending 1000 RPCs, tearing down the channel each time..."); + SimpleRequest request; + SimpleResponse response; + for (int i = 0; i < 1000; ++i) { + serviceStub_.ResetChannel(); + if (!PerformLargeUnary(&request, &response)) { + return false; + } + } + gpr_log(GPR_DEBUG, "channel_soak test done."); + return true; +} + bool InteropClient::DoUnimplementedService() { gpr_log(GPR_DEBUG, "Sending a request for an unimplemented service..."); |