aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/core/iomgr/tcp_server_posix_test.c10
-rw-r--r--test/core/surface/concurrent_connectivity_test.c2
-rw-r--r--test/core/surface/server_chttp2_test.c8
-rw-r--r--test/core/surface/server_test.c10
-rw-r--r--test/core/util/test_tcp_server.c4
-rw-r--r--test/cpp/end2end/server_builder_plugin_test.cc17
6 files changed, 36 insertions, 15 deletions
diff --git a/test/core/iomgr/tcp_server_posix_test.c b/test/core/iomgr/tcp_server_posix_test.c
index eda774fca5..6e2d1d0fc9 100644
--- a/test/core/iomgr/tcp_server_posix_test.c
+++ b/test/core/iomgr/tcp_server_posix_test.c
@@ -129,7 +129,7 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp,
static void test_no_op(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_tcp_server *s;
- GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, &s));
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, NULL, &s));
grpc_tcp_server_unref(&exec_ctx, s);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -137,7 +137,7 @@ static void test_no_op(void) {
static void test_no_op_with_start(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_tcp_server *s;
- GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, &s));
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, NULL, &s));
LOG_TEST("test_no_op_with_start");
grpc_tcp_server_start(&exec_ctx, s, NULL, 0, on_connect, NULL);
grpc_tcp_server_unref(&exec_ctx, s);
@@ -148,7 +148,7 @@ static void test_no_op_with_port(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
struct sockaddr_in addr;
grpc_tcp_server *s;
- GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, &s));
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, NULL, &s));
LOG_TEST("test_no_op_with_port");
memset(&addr, 0, sizeof(addr));
@@ -166,7 +166,7 @@ static void test_no_op_with_port_and_start(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
struct sockaddr_in addr;
grpc_tcp_server *s;
- GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, &s));
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, NULL, &s));
LOG_TEST("test_no_op_with_port_and_start");
int port;
@@ -226,7 +226,7 @@ static void test_connect(unsigned n) {
unsigned svr1_fd_count;
int svr1_port;
grpc_tcp_server *s;
- GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, &s));
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, NULL, &s));
unsigned i;
server_weak_ref weak_ref;
server_weak_ref_init(&weak_ref);
diff --git a/test/core/surface/concurrent_connectivity_test.c b/test/core/surface/concurrent_connectivity_test.c
index f447a68887..f7567f350d 100644
--- a/test/core/surface/concurrent_connectivity_test.c
+++ b/test/core/surface/concurrent_connectivity_test.c
@@ -113,7 +113,7 @@ void bad_server_thread(void *vargs) {
socklen_t addr_len = sizeof(addr);
int port;
grpc_tcp_server *s;
- grpc_error *error = grpc_tcp_server_create(NULL, &s);
+ grpc_error *error = grpc_tcp_server_create(NULL, NULL, &s);
GPR_ASSERT(error == GRPC_ERROR_NONE);
memset(&addr, 0, sizeof(addr));
addr.ss_family = AF_INET;
diff --git a/test/core/surface/server_chttp2_test.c b/test/core/surface/server_chttp2_test.c
index f42ca9f9cd..6310b6f00b 100644
--- a/test/core/surface/server_chttp2_test.c
+++ b/test/core/surface/server_chttp2_test.c
@@ -49,10 +49,16 @@ void test_unparsable_target(void) {
}
void test_add_same_port_twice() {
+ grpc_arg a;
+ a.type = GRPC_ARG_INTEGER;
+ a.key = GRPC_ARG_ALLOW_REUSEPORT;
+ a.value.integer = 0;
+ grpc_channel_args args = {1, &a};
+
int port = grpc_pick_unused_port_or_die();
char *addr = NULL;
grpc_completion_queue *cq = grpc_completion_queue_create(NULL);
- grpc_server *server = grpc_server_create(NULL, NULL);
+ grpc_server *server = grpc_server_create(&args, NULL);
grpc_server_credentials *fake_creds =
grpc_fake_transport_security_server_credentials_create();
gpr_join_host_port(&addr, "localhost", port);
diff --git a/test/core/surface/server_test.c b/test/core/surface/server_test.c
index 02eb432e2d..6dd8a435aa 100644
--- a/test/core/surface/server_test.c
+++ b/test/core/surface/server_test.c
@@ -82,9 +82,15 @@ void test_request_call_on_no_server_cq(void) {
}
void test_bind_server_twice(void) {
+ grpc_arg a;
+ a.type = GRPC_ARG_INTEGER;
+ a.key = GRPC_ARG_ALLOW_REUSEPORT;
+ a.value.integer = 0;
+ grpc_channel_args args = {1, &a};
+
char *addr;
- grpc_server *server1 = grpc_server_create(NULL, NULL);
- grpc_server *server2 = grpc_server_create(NULL, NULL);
+ grpc_server *server1 = grpc_server_create(&args, NULL);
+ grpc_server *server2 = grpc_server_create(&args, NULL);
grpc_completion_queue *cq = grpc_completion_queue_create(NULL);
int port = grpc_pick_unused_port_or_die();
gpr_asprintf(&addr, "[::]:%d", port);
diff --git a/test/core/util/test_tcp_server.c b/test/core/util/test_tcp_server.c
index 27c16fc764..8a0b3932d8 100644
--- a/test/core/util/test_tcp_server.c
+++ b/test/core/util/test_tcp_server.c
@@ -72,8 +72,8 @@ void test_tcp_server_start(test_tcp_server *server, int port) {
addr.sin_port = htons((uint16_t)port);
memset(&addr.sin_addr, 0, sizeof(addr.sin_addr));
- grpc_error *error =
- grpc_tcp_server_create(&server->shutdown_complete, &server->tcp_server);
+ grpc_error *error = grpc_tcp_server_create(&server->shutdown_complete, NULL,
+ &server->tcp_server);
GPR_ASSERT(error == GRPC_ERROR_NONE);
error = grpc_tcp_server_add_port(server->tcp_server, &addr, sizeof(addr),
&port_added);
diff --git a/test/cpp/end2end/server_builder_plugin_test.cc b/test/cpp/end2end/server_builder_plugin_test.cc
index 75f23b64a7..778a2be573 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>
@@ -187,7 +188,10 @@ class ServerBuilderPluginTest : public ::testing::TestWithParam<bool> {
void StartServer() {
grpc::string server_address = "localhost:" + to_string(port_);
builder_->AddListeningPort(server_address, InsecureServerCredentials());
+ // we run some tests without a service, and for those we need to supply a
+ // frequently polled completion queue
cq_ = builder_->AddCompletionQueue();
+ cq_thread_ = grpc::thread(std::bind(&ServerBuilderPluginTest::RunCQ, this));
server_ = builder_->BuildAndStart();
EXPECT_TRUE(CheckPresent());
}
@@ -204,11 +208,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 +224,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 +240,13 @@ class ServerBuilderPluginTest : public ::testing::TestWithParam<bool> {
return nullptr;
}
}
+
+ void RunCQ() {
+ void* tag;
+ bool ok;
+ while (cq_->Next(&tag, &ok))
+ ;
+ }
};
TEST_P(ServerBuilderPluginTest, PluginWithoutServiceTest) {