diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc index 31f4521a57c..81538417fa1 100644 --- a/test/cpp/end2end/client_lb_end2end_test.cc +++ b/test/cpp/end2end/client_lb_end2end_test.cc @@ -352,12 +352,13 @@ class ClientLbEnd2endTest : public ::testing::Test { void CheckRpcSendFailure( const grpc_core::DebugLocation& location, const std::unique_ptr& stub, - StatusCode expected_status, absl::string_view expected_message) { + StatusCode expected_status, absl::string_view expected_message_regex) { Status status = SendRpc(stub); EXPECT_FALSE(status.ok()); EXPECT_EQ(expected_status, status.error_code()) << location.file() << ":" << location.line(); - EXPECT_EQ(expected_message, status.error_message()) + EXPECT_THAT(status.error_message(), + ::testing::ContainsRegex(expected_message_regex)) << location.file() << ":" << location.line(); } @@ -1221,8 +1222,11 @@ TEST_F(PickFirstTest, ReresolutionNoSelected) { response_generator.SetNextResolution(dead_ports); gpr_log(GPR_INFO, "****** INITIAL RESOLUTION SET *******"); for (size_t i = 0; i < 10; ++i) { - CheckRpcSendFailure(DEBUG_LOCATION, stub, StatusCode::UNAVAILABLE, - "failed to connect to all addresses"); + CheckRpcSendFailure( + DEBUG_LOCATION, stub, StatusCode::UNAVAILABLE, + "failed to connect to all addresses; last error: " + "(UNKNOWN: Failed to connect to remote host: Connection refused|" + "UNAVAILABLE: Failed to connect to remote host: FD shutdown)"); } // Set a re-resolution result that contains reachable ports, so that the // pick_first LB policy can recover soon. @@ -1230,7 +1234,12 @@ TEST_F(PickFirstTest, ReresolutionNoSelected) { gpr_log(GPR_INFO, "****** RE-RESOLUTION SET *******"); WaitForServer(DEBUG_LOCATION, stub, 0, [](const Status& status) { EXPECT_EQ(StatusCode::UNAVAILABLE, status.error_code()); - EXPECT_EQ("failed to connect to all addresses", status.error_message()); + EXPECT_THAT( + status.error_message(), + ::testing::ContainsRegex( + "failed to connect to all addresses; last error: " + "(UNKNOWN: Failed to connect to remote host: Connection refused|" + "UNAVAILABLE: Failed to connect to remote host: FD shutdown)")); }); CheckRpcSendOk(DEBUG_LOCATION, stub); EXPECT_EQ(servers_[0]->service_.request_count(), 1); @@ -1432,8 +1441,11 @@ TEST_F(PickFirstTest, response_generator.SetNextResolution(ports); EXPECT_EQ(GRPC_CHANNEL_IDLE, channel->GetState(false)); // Send an RPC, which should fail. - CheckRpcSendFailure(DEBUG_LOCATION, stub, StatusCode::UNAVAILABLE, - "failed to connect to all addresses"); + CheckRpcSendFailure( + DEBUG_LOCATION, stub, StatusCode::UNAVAILABLE, + "failed to connect to all addresses; last error: " + "(UNKNOWN: Failed to connect to remote host: Connection refused|" + "UNAVAILABLE: Failed to connect to remote host: FD shutdown)"); // Channel should be in TRANSIENT_FAILURE. EXPECT_EQ(GRPC_CHANNEL_TRANSIENT_FAILURE, channel->GetState(false)); // Now start a server on the last port. @@ -1986,7 +1998,8 @@ TEST_F(RoundRobinTest, HealthChecking) { servers_[2]->SetServingStatus("health_check_service_name", false); EXPECT_TRUE(WaitForChannelNotReady(channel.get())); CheckRpcSendFailure(DEBUG_LOCATION, stub, StatusCode::UNAVAILABLE, - "connections to all backends failing"); + "connections to all backends failing; last error: " + "UNAVAILABLE: backend unhealthy"); // Clean up. EnableDefaultHealthCheckService(false); } @@ -2043,7 +2056,8 @@ TEST_F(RoundRobinTest, WithHealthCheckingInhibitPerChannel) { // failing. EXPECT_FALSE(WaitForChannelReady(channel1.get(), 1)); CheckRpcSendFailure(DEBUG_LOCATION, stub1, StatusCode::UNAVAILABLE, - "connections to all backends failing"); + "connections to all backends failing; last error: " + "UNAVAILABLE: backend unhealthy"); // Second channel should be READY. EXPECT_TRUE(WaitForChannelReady(channel2.get(), 1)); CheckRpcSendOk(DEBUG_LOCATION, stub2); @@ -2087,7 +2101,8 @@ TEST_F(RoundRobinTest, HealthCheckingServiceNamePerChannel) { // failing. EXPECT_FALSE(WaitForChannelReady(channel1.get(), 1)); CheckRpcSendFailure(DEBUG_LOCATION, stub1, StatusCode::UNAVAILABLE, - "connections to all backends failing"); + "connections to all backends failing; last error: " + "UNAVAILABLE: backend unhealthy"); // Second channel should be READY. EXPECT_TRUE(WaitForChannelReady(channel2.get(), 1)); CheckRpcSendOk(DEBUG_LOCATION, stub2);