diff options
author | kpayson64 <kpayson@google.com> | 2016-07-14 18:26:25 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-14 18:26:25 -0700 |
commit | 27a02b5d9d79f5f8eae09315b13d61595e16c1a6 (patch) | |
tree | 85b2755bae817ee8e376075dd057d07ba36d3cda /test/cpp | |
parent | 7f6c7798b08afcbf77e675e0bc4e8ce5b6ba580d (diff) | |
parent | 6ec11f2acd1311384cd17ea933e7bb9140ef75d7 (diff) |
Merge pull request #7319 from yang-g/wait_async
Make Server::Wait work for async only server.
Diffstat (limited to 'test/cpp')
-rw-r--r-- | test/cpp/end2end/async_end2end_test.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 6c7eae53a4..4a8936d281 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -345,6 +345,31 @@ TEST_P(AsyncEnd2endTest, SequentialRpcs) { SendRpc(10); } +// We do not need to protect notify because the use is synchronized. +void ServerWait(Server* server, int* notify) { + server->Wait(); + *notify = 1; +} +TEST_P(AsyncEnd2endTest, WaitAndShutdownTest) { + int notify = 0; + std::thread* wait_thread = + new std::thread(&ServerWait, server_.get(), ¬ify); + ResetStub(); + SendRpc(1); + EXPECT_EQ(0, notify); + server_->Shutdown(); + wait_thread->join(); + EXPECT_EQ(1, notify); + delete wait_thread; +} + +TEST_P(AsyncEnd2endTest, ShutdownThenWait) { + ResetStub(); + SendRpc(1); + server_->Shutdown(); + server_->Wait(); +} + // Test a simple RPC using the async version of Next TEST_P(AsyncEnd2endTest, AsyncNextRpc) { ResetStub(); |