From 25dba29540b2421affea885664bf801f1e930066 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 28 Nov 2016 09:24:01 -0800 Subject: Move test block, refine conditions --- test/core/end2end/tests/filter_latency.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'test/core/end2end/tests/filter_latency.c') diff --git a/test/core/end2end/tests/filter_latency.c b/test/core/end2end/tests/filter_latency.c index 37ce3b1222..e43d584f73 100644 --- a/test/core/end2end/tests/filter_latency.c +++ b/test/core/end2end/tests/filter_latency.c @@ -226,18 +226,6 @@ static void test_request(grpc_end2end_test_config config) { grpc_call_destroy(s); grpc_call_destroy(c); - const gpr_timespec end_time = gpr_now(GPR_CLOCK_MONOTONIC); - const gpr_timespec max_latency = gpr_time_sub(end_time, start_time); - - gpr_mu_lock(&g_mu); - GPR_ASSERT(gpr_time_cmp(max_latency, g_client_latency) >= 0); - GPR_ASSERT(gpr_time_cmp(gpr_time_0(GPR_TIMESPAN), g_client_latency) < 0); - GPR_ASSERT(gpr_time_cmp(max_latency, g_server_latency) >= 0); - GPR_ASSERT(gpr_time_cmp(gpr_time_0(GPR_TIMESPAN), g_server_latency) < 0); - // Server latency should always be smaller than client latency. - GPR_ASSERT(gpr_time_cmp(g_server_latency, g_client_latency) < 0); - gpr_mu_unlock(&g_mu); - cq_verifier_destroy(cqv); grpc_byte_buffer_destroy(request_payload); @@ -245,6 +233,23 @@ static void test_request(grpc_end2end_test_config config) { end_test(&f); config.tear_down_data(&f); + + const gpr_timespec end_time = gpr_now(GPR_CLOCK_MONOTONIC); + const gpr_timespec max_latency = gpr_time_sub(end_time, start_time); + + // Perform checks after test tear-down + // Guards against the case that there's outstanding channel-related work on a + // call prior to verification + gpr_mu_lock(&g_mu); + GPR_ASSERT(gpr_time_cmp(max_latency, g_client_latency) >= 0); + GPR_ASSERT(gpr_time_cmp(gpr_time_0(GPR_TIMESPAN), g_client_latency) <= 0); + GPR_ASSERT(gpr_time_cmp(max_latency, g_server_latency) >= 0); + GPR_ASSERT(gpr_time_cmp(gpr_time_0(GPR_TIMESPAN), g_server_latency) <= 0); + // Server latency should always be smaller than client latency, however since + // we only calculate latency at destruction time, and that might mean that we + // need to wait for an outstanding write, this isn't verifiable right now. + // GPR_ASSERT(gpr_time_cmp(g_server_latency, g_client_latency) < 0); + gpr_mu_unlock(&g_mu); } /******************************************************************************* -- cgit v1.2.3 From a45a5e46117ab6dd921a0dae4fc80c3cba8422b0 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 28 Nov 2016 09:45:06 -0800 Subject: Rephrase comment --- test/core/end2end/tests/filter_latency.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test/core/end2end/tests/filter_latency.c') diff --git a/test/core/end2end/tests/filter_latency.c b/test/core/end2end/tests/filter_latency.c index e43d584f73..19e1d808de 100644 --- a/test/core/end2end/tests/filter_latency.c +++ b/test/core/end2end/tests/filter_latency.c @@ -247,7 +247,8 @@ static void test_request(grpc_end2end_test_config config) { GPR_ASSERT(gpr_time_cmp(gpr_time_0(GPR_TIMESPAN), g_server_latency) <= 0); // Server latency should always be smaller than client latency, however since // we only calculate latency at destruction time, and that might mean that we - // need to wait for an outstanding write, this isn't verifiable right now. + // need to wait for an outstanding channel-related work, this isn't verifiable + // right now (the server MAY hold on to the call for longer than the client). // GPR_ASSERT(gpr_time_cmp(g_server_latency, g_client_latency) < 0); gpr_mu_unlock(&g_mu); } -- cgit v1.2.3 From 797bc83311026e197fcbe435bc11595127d5453e Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 28 Nov 2016 09:52:31 -0800 Subject: Fix comment --- test/core/end2end/tests/filter_latency.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/core/end2end/tests/filter_latency.c') diff --git a/test/core/end2end/tests/filter_latency.c b/test/core/end2end/tests/filter_latency.c index 19e1d808de..ea63d45420 100644 --- a/test/core/end2end/tests/filter_latency.c +++ b/test/core/end2end/tests/filter_latency.c @@ -247,7 +247,7 @@ static void test_request(grpc_end2end_test_config config) { GPR_ASSERT(gpr_time_cmp(gpr_time_0(GPR_TIMESPAN), g_server_latency) <= 0); // Server latency should always be smaller than client latency, however since // we only calculate latency at destruction time, and that might mean that we - // need to wait for an outstanding channel-related work, this isn't verifiable + // need to wait for outstanding channel-related work, this isn't verifiable // right now (the server MAY hold on to the call for longer than the client). // GPR_ASSERT(gpr_time_cmp(g_server_latency, g_client_latency) < 0); gpr_mu_unlock(&g_mu); -- cgit v1.2.3