Skip to content
Snippets Groups Projects
Commit d263b925 authored by Craig Tiller's avatar Craig Tiller
Browse files

Make sure to poll cq

parent e63246d1
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <grpc++/impl/server_builder_option.h> #include <grpc++/impl/server_builder_option.h>
#include <grpc++/impl/server_builder_plugin.h> #include <grpc++/impl/server_builder_plugin.h>
#include <grpc++/impl/server_initializer.h> #include <grpc++/impl/server_initializer.h>
#include <grpc++/impl/thd.h>
#include <grpc++/security/credentials.h> #include <grpc++/security/credentials.h>
#include <grpc++/security/server_credentials.h> #include <grpc++/security/server_credentials.h>
#include <grpc++/server.h> #include <grpc++/server.h>
...@@ -188,6 +189,7 @@ class ServerBuilderPluginTest : public ::testing::TestWithParam<bool> { ...@@ -188,6 +189,7 @@ class ServerBuilderPluginTest : public ::testing::TestWithParam<bool> {
grpc::string server_address = "localhost:" + to_string(port_); grpc::string server_address = "localhost:" + to_string(port_);
builder_->AddListeningPort(server_address, InsecureServerCredentials()); builder_->AddListeningPort(server_address, InsecureServerCredentials());
cq_ = builder_->AddCompletionQueue(); cq_ = builder_->AddCompletionQueue();
cq_thread_ = grpc::thread(std::bind(&ServerBuilderPluginTest::RunCQ, this));
server_ = builder_->BuildAndStart(); server_ = builder_->BuildAndStart();
EXPECT_TRUE(CheckPresent()); EXPECT_TRUE(CheckPresent());
} }
...@@ -204,11 +206,8 @@ class ServerBuilderPluginTest : public ::testing::TestWithParam<bool> { ...@@ -204,11 +206,8 @@ class ServerBuilderPluginTest : public ::testing::TestWithParam<bool> {
EXPECT_TRUE(plugin->init_server_is_called()); EXPECT_TRUE(plugin->init_server_is_called());
EXPECT_TRUE(plugin->finish_is_called()); EXPECT_TRUE(plugin->finish_is_called());
server_->Shutdown(); server_->Shutdown();
void* tag;
bool ok;
cq_->Shutdown(); cq_->Shutdown();
while (cq_->Next(&tag, &ok)) cq_thread_.join();
;
} }
string to_string(const int number) { string to_string(const int number) {
...@@ -223,6 +222,7 @@ class ServerBuilderPluginTest : public ::testing::TestWithParam<bool> { ...@@ -223,6 +222,7 @@ class ServerBuilderPluginTest : public ::testing::TestWithParam<bool> {
std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_;
std::unique_ptr<ServerCompletionQueue> cq_; std::unique_ptr<ServerCompletionQueue> cq_;
std::unique_ptr<Server> server_; std::unique_ptr<Server> server_;
grpc::thread cq_thread_;
TestServiceImpl service_; TestServiceImpl service_;
int port_; int port_;
...@@ -238,6 +238,13 @@ class ServerBuilderPluginTest : public ::testing::TestWithParam<bool> { ...@@ -238,6 +238,13 @@ class ServerBuilderPluginTest : public ::testing::TestWithParam<bool> {
return nullptr; return nullptr;
} }
} }
void RunCQ() {
void* tag;
bool ok;
while (cq_->Next(&tag, &ok))
;
}
}; };
TEST_P(ServerBuilderPluginTest, PluginWithoutServiceTest) { TEST_P(ServerBuilderPluginTest, PluginWithoutServiceTest) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment