Make sure to poll cq

pull/6644/head
Craig Tiller 9 years ago
parent e63246d100
commit d263b925e8
  1. 15
      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) {

Loading…
Cancel
Save