From e2837aa10b1c06e79aca355f5b0ab38f8a8e211b Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Tue, 11 Aug 2020 18:05:57 -0700 Subject: [PATCH] Raise deadline of CancelDuringAresQuery.TestHitDeadlineAndDestroyChannelDuringAresResolutionWithQueryTimeoutIsGraceful test --- test/cpp/naming/cancel_ares_query_test.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/test/cpp/naming/cancel_ares_query_test.cc b/test/cpp/naming/cancel_ares_query_test.cc index 6de84f10a5b..e4c307f0d22 100644 --- a/test/cpp/naming/cancel_ares_query_test.cc +++ b/test/cpp/naming/cancel_ares_query_test.cc @@ -287,10 +287,17 @@ void TestCancelDuringActiveQuery( query_timeout_setting); grpc_channel_args* client_args = nullptr; grpc_status_code expected_status_code = GRPC_STATUS_OK; + gpr_timespec rpc_deadline; if (query_timeout_setting == NONE) { + // The RPC deadline should go off well before the DNS resolution + // timeout fires. expected_status_code = GRPC_STATUS_DEADLINE_EXCEEDED; + // use default DNS resolution timeout (which is over one minute). client_args = nullptr; + rpc_deadline = grpc_timeout_milliseconds_to_deadline(100); } else if (query_timeout_setting == SHORT) { + // The DNS resolution timeout should fire well before the + // RPC's deadline expires. expected_status_code = GRPC_STATUS_UNAVAILABLE; grpc_arg arg; arg.type = GRPC_ARG_INTEGER; @@ -298,13 +305,21 @@ void TestCancelDuringActiveQuery( arg.value.integer = 1; // Set this shorter than the call deadline so that it goes off. client_args = grpc_channel_args_copy_and_add(nullptr, &arg, 1); + // Set the deadline high enough such that if we hit this and get + // a deadline exceeded status code, then we are confident that there's + // a bug causing cancellation of DNS resolutions to not happen in a timely + // manner. + rpc_deadline = grpc_timeout_seconds_to_deadline(10); } else if (query_timeout_setting == ZERO) { + // The RPC deadline should go off well before the DNS resolution + // timeout fires. expected_status_code = GRPC_STATUS_DEADLINE_EXCEEDED; grpc_arg arg; arg.type = GRPC_ARG_INTEGER; arg.key = const_cast(GRPC_ARG_DNS_ARES_QUERY_TIMEOUT_MS); arg.value.integer = 0; // Set this to zero to disable query timeouts. client_args = grpc_channel_args_copy_and_add(nullptr, &arg, 1); + rpc_deadline = grpc_timeout_milliseconds_to_deadline(100); } else { abort(); } @@ -312,10 +327,9 @@ void TestCancelDuringActiveQuery( grpc_insecure_channel_create(client_target.c_str(), client_args, nullptr); grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr); cq_verifier* cqv = cq_verifier_create(cq); - gpr_timespec deadline = grpc_timeout_milliseconds_to_deadline(100); grpc_call* call = grpc_channel_create_call( client, nullptr, GRPC_PROPAGATE_DEFAULTS, cq, - grpc_slice_from_static_string("/foo"), nullptr, deadline, nullptr); + grpc_slice_from_static_string("/foo"), nullptr, rpc_deadline, nullptr); GPR_ASSERT(call); grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv;