Merge pull request #14769 from yashykt/sslcerttestfix

Use same queue for batch ops and for shutdown in h2_ssl_cert_test
pull/14836/head
Yash Tibrewal 7 years ago committed by GitHub
commit c2a89cbdab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 30
      test/core/end2end/h2_ssl_cert_test.cc

@ -57,8 +57,6 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
f.fixture_data = ffd;
f.cq = grpc_completion_queue_create_for_next(nullptr);
f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
return f;
}
@ -270,27 +268,13 @@ static void drain_cq(grpc_completion_queue* cq) {
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
// Shuts down the server.
// Side effect - Also shuts down and drains the completion queue.
static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
/* Perform a completion queue next, so that any pending operations can be
* finished, and resources can be released. This is so that, shutdown does not
* hang. For example, the server might be stuck in the handshaking code, which
* keeps a ref to a listener. Unless, it is unref'd, shutdown won't be able
* to proceed.
*
* (If shutdown times out, it is probably because 100ms wasn't enough. In that
* case, the deadline can be increased. Or, we could simply have another
* thread for the server to poll the completion queue while the shutdown
* progresses.)
*/
GPR_ASSERT(grpc_completion_queue_next(
f->cq, grpc_timeout_milliseconds_to_deadline(100), nullptr)
.type == GRPC_QUEUE_TIMEOUT);
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
grpc_completion_queue_shutdown(f->cq);
drain_cq(f->cq);
grpc_server_destroy(f->server);
f->server = nullptr;
}
@ -304,11 +288,7 @@ static void shutdown_client(grpc_end2end_test_fixture* f) {
static void end_test(grpc_end2end_test_fixture* f) {
shutdown_client(f);
shutdown_server(f);
grpc_completion_queue_shutdown(f->cq);
drain_cq(f->cq);
grpc_completion_queue_destroy(f->cq);
grpc_completion_queue_destroy(f->shutdown_cq);
}
static void simple_request_body(grpc_end2end_test_fixture f,

Loading…
Cancel
Save