diff options
author | Vijay Pai <vpai@google.com> | 2017-10-10 23:20:09 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-10 23:20:09 -0700 |
commit | ca46ce10b02417c17f30b9785e5986ee38e3f7d5 (patch) | |
tree | 10f8a238902cd8eab856b6bce9d15397f16d8e1d /test | |
parent | 441a14fd43f6033714a5022667e1591967947bb5 (diff) | |
parent | ac8921be5e8b843be4465baacf2414c949c71f0d (diff) |
Merge pull request #12939 from vjpai/proxy_e2e
Add a little sleep in end2end_test service to make short deadlines actually expire
Diffstat (limited to 'test')
-rw-r--r-- | test/cpp/end2end/end2end_test.cc | 15 | ||||
-rw-r--r-- | test/cpp/end2end/test_service_impl.cc | 8 |
2 files changed, 18 insertions, 5 deletions
diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 810ee303f2..c5178526f8 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -1280,6 +1280,8 @@ TEST_P(ProxyEnd2endTest, RpcDeadlineExpires) { EchoResponse response; request.set_message("Hello"); request.mutable_param()->set_skip_cancelled_check(true); + // Let server sleep for 2 ms first to guarantee expiry + request.mutable_param()->set_server_sleep_us(2 * 1000); ClientContext context; std::chrono::system_clock::time_point deadline = @@ -1407,6 +1409,10 @@ TEST_P(ProxyEnd2endTest, HugeResponse) { } TEST_P(ProxyEnd2endTest, Peer) { + // Peer is not meaningful for inproc + if (GetParam().inproc) { + return; + } ResetStub(); EchoRequest request; EchoResponse response; @@ -1775,11 +1781,10 @@ std::vector<TestScenario> CreateTestScenarios(bool use_proxy, credentials_types.push_back(kInsecureCredentialsType); } GPR_ASSERT(!credentials_types.empty()); - for (auto it = credentials_types.begin(); it != credentials_types.end(); - ++it) { - scenarios.emplace_back(false, false, *it); + for (const auto& cred : credentials_types) { + scenarios.emplace_back(false, false, cred); if (use_proxy) { - scenarios.emplace_back(true, false, *it); + scenarios.emplace_back(true, false, cred); } } if (test_inproc && insec_ok()) { @@ -1798,7 +1803,7 @@ INSTANTIATE_TEST_CASE_P(End2endServerTryCancel, End2endServerTryCancelTest, INSTANTIATE_TEST_CASE_P(ProxyEnd2end, ProxyEnd2endTest, ::testing::ValuesIn(CreateTestScenarios(true, true, - true, false))); + true, true))); INSTANTIATE_TEST_CASE_P(SecureEnd2end, SecureEnd2endTest, ::testing::ValuesIn(CreateTestScenarios(false, false, diff --git a/test/cpp/end2end/test_service_impl.cc b/test/cpp/end2end/test_service_impl.cc index 4fa98c24f5..e4f7c08f25 100644 --- a/test/cpp/end2end/test_service_impl.cc +++ b/test/cpp/end2end/test_service_impl.cc @@ -73,6 +73,14 @@ void CheckServerAuthContext( Status TestServiceImpl::Echo(ServerContext* context, const EchoRequest* request, EchoResponse* response) { + // A bit of sleep to make sure that short deadline tests fail + if (request->has_param() && request->param().server_sleep_us() > 0) { + gpr_sleep_until( + gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), + gpr_time_from_micros(request->param().server_sleep_us(), + GPR_TIMESPAN))); + } + if (request->has_param() && request->param().server_die()) { gpr_log(GPR_ERROR, "The request should not reach application handler."); GPR_ASSERT(0); |