From b0f275e4af3a18882110994713368eb288594b66 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 27 Jan 2016 10:45:50 -0800 Subject: [PATCH 1/3] Small testing fixes - end2end test deadlines may complete before checking IsCancelled => don't expect it to be false in these cases - add exponential backoff to port_posix - ensure run_tests rebuilds targets with a regex I commonly use --- src/proto/grpc/testing/echo_messages.proto | 1 + test/core/util/port_posix.c | 3 ++- test/cpp/end2end/end2end_test.cc | 3 ++- tools/run_tests/run_tests.py | 4 ++-- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/proto/grpc/testing/echo_messages.proto b/src/proto/grpc/testing/echo_messages.proto index f01d645af73..b9f1eec2e27 100644 --- a/src/proto/grpc/testing/echo_messages.proto +++ b/src/proto/grpc/testing/echo_messages.proto @@ -41,6 +41,7 @@ message RequestParams { int32 response_message_length = 6; bool echo_peer = 7; string expected_client_identity = 8; // will force check_auth_context. + bool skip_cancelled_check = 9; } message EchoRequest { diff --git a/test/core/util/port_posix.c b/test/core/util/port_posix.c index 732a51c5cbd..1b574f4399d 100644 --- a/test/core/util/port_posix.c +++ b/test/core/util/port_posix.c @@ -37,6 +37,7 @@ #include "test/core/util/port.h" +#include #include #include #include @@ -229,10 +230,10 @@ static void got_port_from_server(grpc_exec_ctx *exec_ctx, void *arg, grpc_httpcli_request req; memset(&req, 0, sizeof(req)); GPR_ASSERT(pr->retries < 10); + sleep(1 + (unsigned)(pow(1.3, pr->retries) * rand() / RAND_MAX)); pr->retries++; req.host = pr->server; req.path = "/get"; - sleep(1); grpc_httpcli_get(exec_ctx, pr->ctx, &pr->pollset, &req, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10), got_port_from_server, pr); diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index f8027bcf0b5..6303d2cc13f 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -244,7 +244,7 @@ class TestServiceImpl : public ::grpc::testing::EchoTestService::Service { gpr_time_from_micros(request->param().server_cancel_after_us(), GPR_TIMESPAN))); return Status::CANCELLED; - } else { + } else if (!request->has_param() || !request->param().skip_cancelled_check()) { EXPECT_FALSE(context->IsCancelled()); } @@ -823,6 +823,7 @@ TEST_P(ProxyEnd2endTest, RpcDeadlineExpires) { EchoRequest request; EchoResponse response; request.set_message("Hello"); + request.mutable_param()->set_skip_cancelled_check(true); ClientContext context; std::chrono::system_clock::time_point deadline = diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index f8b01021c88..3180e6bc3a4 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -151,9 +151,9 @@ class CLanguage(object): def make_targets(self, test_regex): if platform_string() != 'windows' and test_regex != '.*': # use the regex to minimize the number of things to build - return [target['name'] + return [os.path.basename(target['name']) for target in get_c_tests(False, self.test_lang) - if re.search(test_regex, target['name'])] + if re.search(test_regex, '/' + target['name'])] if platform_string() == 'windows': # don't build tools on windows just yet return ['buildtests_%s' % self.make_target] From 2c1c7d54733baadd68b0272b08d3a34a6bb9bf59 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 27 Jan 2016 13:54:56 -0800 Subject: [PATCH 2/3] Fix copyrights --- src/proto/grpc/testing/echo_messages.proto | 2 +- test/core/util/port_posix.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/proto/grpc/testing/echo_messages.proto b/src/proto/grpc/testing/echo_messages.proto index b9f1eec2e27..d05a35548d1 100644 --- a/src/proto/grpc/testing/echo_messages.proto +++ b/src/proto/grpc/testing/echo_messages.proto @@ -1,5 +1,5 @@ -// Copyright 2015, Google Inc. +// Copyright 2015-2016, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without diff --git a/test/core/util/port_posix.c b/test/core/util/port_posix.c index 1b574f4399d..11cefbf01c2 100644 --- a/test/core/util/port_posix.c +++ b/test/core/util/port_posix.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without From a0fef1478436881247828893b6179157acac6678 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 27 Jan 2016 15:10:39 -0800 Subject: [PATCH 3/3] clang-format code --- test/cpp/end2end/end2end_test.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 6303d2cc13f..5a414ebc86c 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -244,7 +244,8 @@ class TestServiceImpl : public ::grpc::testing::EchoTestService::Service { gpr_time_from_micros(request->param().server_cancel_after_us(), GPR_TIMESPAN))); return Status::CANCELLED; - } else if (!request->has_param() || !request->param().skip_cancelled_check()) { + } else if (!request->has_param() || + !request->param().skip_cancelled_check()) { EXPECT_FALSE(context->IsCancelled()); }