client_lb_end2end_test: fix broken tests (#29938)

* client_lb_end2end_test: fix broken tests

* poll polling engine gives slightly different error messages
pull/29944/head
Mark D. Roth 3 years ago committed by GitHub
parent cb2a92b5bb
commit 27e6a094e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 35
      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<grpc::testing::EchoTestService::Stub>& 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);

Loading…
Cancel
Save