aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/end2end/health_service_end2end_test.cc
diff options
context:
space:
mode:
authorGravatar yang-g <yangg@google.com>2016-12-29 10:00:27 -0800
committerGravatar yang-g <yangg@google.com>2016-12-29 10:00:27 -0800
commit50993b7a4c083b8b202010aca1bb95cf9902cf74 (patch)
tree8bb902e5ff20d44903d8488de9aa8641de8fafb6 /test/cpp/end2end/health_service_end2end_test.cc
parent1accb12408d89160055e687d49b3b346e57ad14a (diff)
async first take
Diffstat (limited to 'test/cpp/end2end/health_service_end2end_test.cc')
-rw-r--r--test/cpp/end2end/health_service_end2end_test.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/cpp/end2end/health_service_end2end_test.cc b/test/cpp/end2end/health_service_end2end_test.cc
index 969aea1318..c41a75ec37 100644
--- a/test/cpp/end2end/health_service_end2end_test.cc
+++ b/test/cpp/end2end/health_service_end2end_test.cc
@@ -45,6 +45,7 @@
#include <grpc++/server_builder.h>
#include <grpc++/server_context.h>
#include <grpc/grpc.h>
+#include <grpc/support/log.h>
#include <gtest/gtest.h>
#include "src/proto/grpc/health/v1/health.grpc.pb.h"
@@ -148,12 +149,17 @@ class HealthServiceEnd2endTest : public ::testing::Test {
if (register_sync_health_service_impl) {
builder.RegisterService(&health_check_service_impl_);
}
+ cq_ = builder.AddCompletionQueue();
server_ = builder.BuildAndStart();
}
void TearDown() override {
if (server_) {
server_->Shutdown();
+ cq_->Shutdown();
+ if (cq_thread_.joinable()) {
+ cq_thread_.join();
+ }
}
}
@@ -219,6 +225,8 @@ class HealthServiceEnd2endTest : public ::testing::Test {
std::unique_ptr<Health::Stub> hc_stub_;
std::unique_ptr<Server> server_;
std::ostringstream server_address_;
+ std::unique_ptr<ServerCompletionQueue> cq_;
+ std::thread cq_thread_;
};
TEST_F(HealthServiceEnd2endTest, DefaultHealthServiceDisabled) {
@@ -246,6 +254,28 @@ TEST_F(HealthServiceEnd2endTest, DefaultHealthService) {
Status(StatusCode::INVALID_ARGUMENT, ""));
}
+void LoopCompletionQueue(ServerCompletionQueue* cq) {
+ void* tag;
+ bool ok;
+ while (cq->Next(&tag, &ok)) {
+ gpr_log(GPR_ERROR, "next %p %d", tag, ok);
+ }
+ gpr_log(GPR_ERROR, "returning from thread");
+}
+
+TEST_F(HealthServiceEnd2endTest, DefaultHealthServiceAsync) {
+ EnableDefaultHealthCheckService(true);
+ EXPECT_TRUE(DefaultHealthCheckServiceEnabled());
+ SetUpServer(false, false, nullptr);
+ cq_thread_ = std::thread(LoopCompletionQueue, cq_.get());
+ VerifyHealthCheckService();
+
+ // The default service has a size limit of the service name.
+ const grpc::string kTooLongServiceName(201, 'x');
+ SendHealthCheckRpc(kTooLongServiceName,
+ Status(StatusCode::INVALID_ARGUMENT, ""));
+}
+
// Provide an empty service to disable the default service.
TEST_F(HealthServiceEnd2endTest, ExplicitlyDisableViaOverride) {
EnableDefaultHealthCheckService(true);