diff options
Diffstat (limited to 'test/cpp/interop/interop_client.h')
-rw-r--r-- | test/cpp/interop/interop_client.h | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/test/cpp/interop/interop_client.h b/test/cpp/interop/interop_client.h index 1f13d5b971..1bfb49d514 100644 --- a/test/cpp/interop/interop_client.h +++ b/test/cpp/interop/interop_client.h @@ -47,9 +47,14 @@ namespace testing { class InteropClient { public: explicit InteropClient(std::shared_ptr<Channel> channel); + explicit InteropClient( + std::shared_ptr<Channel> channel, + bool new_stub_every_test_case); // If new_stub_every_test_case is true, + // a new TestService::Stub object is + // created for every test case below ~InteropClient() {} - void Reset(std::shared_ptr<Channel> channel) { channel_ = channel; } + void Reset(std::shared_ptr<Channel> channel); void DoEmpty(); void DoLargeUnary(); @@ -77,11 +82,26 @@ class InteropClient { void DoPerRpcCreds(const grpc::string& json_key); private: + class ServiceStub { + 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); + + TestService::Stub* Get(); + + void Reset(std::shared_ptr<Channel> channel); + + private: + std::unique_ptr<TestService::Stub> stub_; + std::shared_ptr<Channel> channel_; + bool new_stub_every_call_; // If true, a new stub is returned by every + // Get() call + }; + void PerformLargeUnary(SimpleRequest* request, SimpleResponse* response); void AssertOkOrPrintErrorStatus(const Status& s); - - std::shared_ptr<Channel> channel_; - std::unique_ptr<TestService::Stub> stub_; + ServiceStub serviceStub_; }; } // namespace testing |