aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/end2end/server_builder_plugin_test.cc
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2016-06-21 09:15:57 -0700
committerGravatar Craig Tiller <ctiller@google.com>2016-06-21 09:15:57 -0700
commitd263b925e8b8ce36042f34eda34715696b6eef3e (patch)
tree8bd69ce6ad66ab7de48a507c4d753f1920c174f1 /test/cpp/end2end/server_builder_plugin_test.cc
parente63246d1007516ca5c74043139304a371c0ce672 (diff)
Make sure to poll cq
Diffstat (limited to 'test/cpp/end2end/server_builder_plugin_test.cc')
-rw-r--r--test/cpp/end2end/server_builder_plugin_test.cc15
1 files changed, 11 insertions, 4 deletions
diff --git a/test/cpp/end2end/server_builder_plugin_test.cc b/test/cpp/end2end/server_builder_plugin_test.cc
index 75f23b64a7..7d0b467d81 100644
--- a/test/cpp/end2end/server_builder_plugin_test.cc
+++ b/test/cpp/end2end/server_builder_plugin_test.cc
@@ -37,6 +37,7 @@
#include <grpc++/impl/server_builder_option.h>
#include <grpc++/impl/server_builder_plugin.h>
#include <grpc++/impl/server_initializer.h>
+#include <grpc++/impl/thd.h>
#include <grpc++/security/credentials.h>
#include <grpc++/security/server_credentials.h>
#include <grpc++/server.h>
@@ -188,6 +189,7 @@ class ServerBuilderPluginTest : public ::testing::TestWithParam<bool> {
grpc::string server_address = "localhost:" + to_string(port_);
builder_->AddListeningPort(server_address, InsecureServerCredentials());
cq_ = builder_->AddCompletionQueue();
+ cq_thread_ = grpc::thread(std::bind(&ServerBuilderPluginTest::RunCQ, this));
server_ = builder_->BuildAndStart();
EXPECT_TRUE(CheckPresent());
}
@@ -204,11 +206,8 @@ class ServerBuilderPluginTest : public ::testing::TestWithParam<bool> {
EXPECT_TRUE(plugin->init_server_is_called());
EXPECT_TRUE(plugin->finish_is_called());
server_->Shutdown();
- void* tag;
- bool ok;
cq_->Shutdown();
- while (cq_->Next(&tag, &ok))
- ;
+ cq_thread_.join();
}
string to_string(const int number) {
@@ -223,6 +222,7 @@ class ServerBuilderPluginTest : public ::testing::TestWithParam<bool> {
std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_;
std::unique_ptr<ServerCompletionQueue> cq_;
std::unique_ptr<Server> server_;
+ grpc::thread cq_thread_;
TestServiceImpl service_;
int port_;
@@ -238,6 +238,13 @@ class ServerBuilderPluginTest : public ::testing::TestWithParam<bool> {
return nullptr;
}
}
+
+ void RunCQ() {
+ void* tag;
+ bool ok;
+ while (cq_->Next(&tag, &ok))
+ ;
+ }
};
TEST_P(ServerBuilderPluginTest, PluginWithoutServiceTest) {