From a7aa9cf9acf894771d46948b4a5cc52105526a41 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Fri, 11 Oct 2019 11:29:01 -0400 Subject: [PATCH 1/2] Consider "Socket closed" to be a good status Issue #20509 --- test/cpp/qps/driver.cc | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index db0b81fdeed..a5d913ca911 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -118,6 +118,20 @@ static double ServerIdleCpuTime(const ServerStats& s) { } static int Cores(int n) { return n; } +static bool IsSuccess(Status s) { + if (s.ok()) return true; + // Since we shutdown servers and clients at the same time, they both can + // observe cancellation. Thus, we consider CANCELLED as good status. + if (static_cast(s.error_code()) == StatusCode::CANCELLED) { + return true; + } + // Since we shutdown servers and clients at the same time, server can close + // the socket before the client attempts to do that, and vice versa. Thus + // receiving a "Socket closed" error is fine. + if (s.error_message() == "Socket closed") return true; + return false; +} + // Postprocess ScenarioResult and populate result summary. static void postprocess_scenario_result(ScenarioResult* result) { Histogram histogram; @@ -498,8 +512,7 @@ std::unique_ptr RunScenario( // Since we shutdown servers and clients at the same time, clients can // observe cancellation. Thus, we consider both OK and CANCELLED as good // status. - const bool success = s.ok() || static_cast(s.error_code()) == - StatusCode::CANCELLED; + const bool success = IsSuccess(s); result->add_client_success(success); if (!success) { gpr_log(GPR_ERROR, "Client %zu had an error %s", i, @@ -534,8 +547,7 @@ std::unique_ptr RunScenario( // Since we shutdown servers and clients at the same time, servers can // observe cancellation. Thus, we consider both OK and CANCELLED as good // status. - const bool success = s.ok() || static_cast(s.error_code()) == - StatusCode::CANCELLED; + const bool success = IsSuccess(s); result->add_server_success(success); if (!success) { gpr_log(GPR_ERROR, "Server %zu had an error %s", i, From 5340111aa6650e685f5f4ef156271f0731834674 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Fri, 11 Oct 2019 13:20:18 -0400 Subject: [PATCH 2/2] Fix sanity check. --- test/cpp/qps/driver.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index a5d913ca911..c37529ea274 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -118,7 +118,7 @@ static double ServerIdleCpuTime(const ServerStats& s) { } static int Cores(int n) { return n; } -static bool IsSuccess(Status s) { +static bool IsSuccess(const Status& s) { if (s.ok()) return true; // Since we shutdown servers and clients at the same time, they both can // observe cancellation. Thus, we consider CANCELLED as good status.