e2e tests: update regex used for connection failure messages (#32325)

* e2e tests: update regex used for connection failure messages

* attempt to tweak regex syntax to work on mac
pull/32331/head
Mark D. Roth 2 years ago committed by GitHub
parent abe50528d0
commit 9dd6a98ed6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      test/cpp/end2end/client_lb_end2end_test.cc
  2. 26
      test/cpp/end2end/xds/xds_cluster_end2end_test.cc
  3. 10
      test/cpp/end2end/xds/xds_end2end_test_lib.cc
  4. 4
      test/cpp/end2end/xds/xds_end2end_test_lib.h
  5. 21
      test/cpp/end2end/xds/xds_ring_hash_end2end_test.cc
  6. 15
      test/cpp/end2end/xds/xds_routing_end2end_test.cc

@ -568,14 +568,12 @@ class ClientLbEnd2endTest : public ::testing::Test {
}
static std::string MakeConnectionFailureRegex(absl::string_view prefix) {
return absl::StrCat(
prefix,
"; last error: (UNKNOWN: (ipv6:%5B::1%5D|ipv4:127.0.0.1):[0-9]+: "
"Failed to connect to remote host: Connection refused|"
"UNAVAILABLE: (ipv6:%5B::1%5D|ipv4:127.0.0.1):[0-9]+: "
"Failed to connect to remote host: FD shutdown|"
"UNAVAILABLE: (ipv6:%5B::1%5D|ipv4:127.0.0.1):[0-9]+: "
"(Socket closed|Connection reset by peer))");
return absl::StrCat(prefix,
"; last error: (UNKNOWN|UNAVAILABLE): "
"(ipv6:%5B::1%5D|ipv4:127.0.0.1):[0-9]+: "
"(Failed to connect to remote host: )?"
"(Connection refused|Connection reset by peer|"
"Socket closed|FD shutdown)");
}
const std::string server_host_;

@ -499,11 +499,8 @@ TEST_P(EdsTest, AllServersUnreachableFailFast) {
// seconds, and we should disocver in that time that the target backend is
// down.
CheckRpcSendFailure(DEBUG_LOCATION, StatusCode::UNAVAILABLE,
"connections to all backends failing; last error: "
"(UNKNOWN: (ipv6:%5B::1%5D|ipv4:127.0.0.1):[0-9]+: "
"Failed to connect to remote host: Connection refused|"
"UNAVAILABLE: (ipv6:%5B::1%5D|ipv4:127.0.0.1):[0-9]+: "
"Failed to connect to remote host: FD shutdown)",
MakeConnectionFailureRegex(
"connections to all backends failing; last error: "),
RpcOptions().set_timeout_ms(kRpcTimeoutMs));
}
@ -526,11 +523,8 @@ TEST_P(EdsTest, BackendsRestart) {
::testing::Eq(GRPC_CHANNEL_CONNECTING)));
// RPCs should fail.
CheckRpcSendFailure(DEBUG_LOCATION, StatusCode::UNAVAILABLE,
"connections to all backends failing; last error: "
"(UNKNOWN: (ipv6:%5B::1%5D|ipv4:127.0.0.1):[0-9]+: "
"Failed to connect to remote host: Connection refused|"
"UNAVAILABLE: (ipv6:%5B::1%5D|ipv4:127.0.0.1):[0-9]+: "
"Failed to connect to remote host: FD shutdown)");
MakeConnectionFailureRegex(
"connections to all backends failing; last error: "));
// Restart all backends. RPCs should start succeeding again.
StartAllBackends();
CheckRpcSendOk(DEBUG_LOCATION, 1,
@ -1176,14 +1170,9 @@ TEST_P(FailoverTest, UpdateInitialUnavailable) {
{"locality1", {MakeNonExistantEndpoint()}, kDefaultLocalityWeight, 1},
});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
constexpr char kErrorMessageRegex[] =
"connections to all backends failing; last error: "
"(UNKNOWN: (ipv6:%5B::1%5D|ipv4:127.0.0.1):[0-9]+: "
"Failed to connect to remote host: Connection refused|"
"UNAVAILABLE: (ipv6:%5B::1%5D|ipv4:127.0.0.1):[0-9]+: "
"Failed to connect to remote host: FD shutdown)";
CheckRpcSendFailure(DEBUG_LOCATION, StatusCode::UNAVAILABLE,
kErrorMessageRegex);
MakeConnectionFailureRegex(
"connections to all backends failing; last error: "));
args = EdsResourceArgs({
{"locality0", CreateEndpointsForBackends(0, 1), kDefaultLocalityWeight,
0},
@ -1195,7 +1184,8 @@ TEST_P(FailoverTest, UpdateInitialUnavailable) {
if (!result.status.ok()) {
EXPECT_EQ(result.status.error_code(), StatusCode::UNAVAILABLE);
EXPECT_THAT(result.status.error_message(),
::testing::MatchesRegex(kErrorMessageRegex));
::testing::MatchesRegex(MakeConnectionFailureRegex(
"connections to all backends failing; last error: ")));
}
});
}

@ -1038,6 +1038,16 @@ void XdsEnd2endTest::SetProtoDuration(
duration_proto->set_nanos(ts.tv_nsec);
}
std::string XdsEnd2endTest::MakeConnectionFailureRegex(
absl::string_view prefix) {
return absl::StrCat(
prefix,
"(UNKNOWN|UNAVAILABLE): (ipv6:%5B::1%5D|ipv4:127.0.0.1):[0-9]+: "
"(Failed to connect to remote host: )?"
"(Connection refused|Connection reset by peer|"
"Socket closed|FD shutdown)");
}
std::string XdsEnd2endTest::ReadFile(const char* file_path) {
grpc_slice slice;
GPR_ASSERT(

@ -1046,6 +1046,10 @@ class XdsEnd2endTest : public ::testing::TestWithParam<XdsTestType> {
return num_rpcs;
}
// Returns a regex that can be matched against an RPC failure status
// message for a connection failure.
static std::string MakeConnectionFailureRegex(absl::string_view prefix);
// Returns the contents of the specified file.
static std::string ReadFile(const char* file_path);

@ -994,11 +994,8 @@ TEST_P(RingHashTest, ReattemptWhenAllEndpointsUnreachable) {
ShutdownBackend(0);
CheckRpcSendFailure(
DEBUG_LOCATION, StatusCode::UNAVAILABLE,
"ring hash cannot find a connected subchannel; first failure: "
"(UNKNOWN: (ipv6:%5B::1%5D|ipv4:127.0.0.1):[0-9]+: "
"Failed to connect to remote host: Connection refused|"
"UNAVAILABLE: (ipv6:%5B::1%5D|ipv4:127.0.0.1):[0-9]+: "
"Failed to connect to remote host: FD shutdown)",
MakeConnectionFailureRegex(
"ring hash cannot find a connected subchannel; first failure: "),
RpcOptions().set_metadata(std::move(metadata)));
StartBackend(0);
// Ensure we are actively connecting without any traffic.
@ -1036,11 +1033,8 @@ TEST_P(RingHashTest, TransientFailureSkipToAvailableReady) {
gpr_log(GPR_INFO, "=== SENDING FIRST RPC ===");
CheckRpcSendFailure(
DEBUG_LOCATION, StatusCode::UNAVAILABLE,
"ring hash cannot find a connected subchannel; first failure: "
"(UNKNOWN: (ipv6:%5B::1%5D|ipv4:127.0.0.1):[0-9]+: "
"Failed to connect to remote host: Connection refused|"
"UNAVAILABLE: (ipv6:%5B::1%5D|ipv4:127.0.0.1):[0-9]+: "
"Failed to connect to remote host: FD shutdown)",
MakeConnectionFailureRegex(
"ring hash cannot find a connected subchannel; first failure: "),
rpc_options);
gpr_log(GPR_INFO, "=== DONE WITH FIRST RPC ===");
EXPECT_EQ(GRPC_CHANNEL_TRANSIENT_FAILURE, channel_->GetState(false));
@ -1075,11 +1069,8 @@ TEST_P(RingHashTest, TransientFailureSkipToAvailableReady) {
gpr_log(GPR_INFO, "=== SENDING SECOND RPC ===");
CheckRpcSendFailure(
DEBUG_LOCATION, StatusCode::UNAVAILABLE,
"ring hash cannot find a connected subchannel; first failure: "
"(UNKNOWN: (ipv6:%5B::1%5D|ipv4:127.0.0.1):[0-9]+: "
"Failed to connect to remote host: Connection refused|"
"UNAVAILABLE: (ipv6:%5B::1%5D|ipv4:127.0.0.1):[0-9]+: "
"Failed to connect to remote host: FD shutdown)",
MakeConnectionFailureRegex(
"ring hash cannot find a connected subchannel; first failure: "),
rpc_options);
gpr_log(GPR_INFO, "=== STARTING BACKEND 1 ===");
StartBackend(1);

@ -1473,14 +1473,9 @@ TEST_P(LdsRdsTest, XdsRoutingClusterUpdateClustersWithPickingDelays) {
RpcOptions().set_wait_for_ready(true).set_timeout_ms(0));
// Send a non-wait_for_ready RPC, which should fail. This tells us
// that the client has received the update and attempted to connect.
constexpr char kErrorMessageRegex[] =
"connections to all backends failing; last error: "
"(UNKNOWN: (ipv6:%5B::1%5D|ipv4:127.0.0.1):[0-9]+: "
"Failed to connect to remote host: Connection refused|"
"UNAVAILABLE: (ipv6:%5B::1%5D|ipv4:127.0.0.1):[0-9]+: "
"Failed to connect to remote host: FD shutdown)";
CheckRpcSendFailure(DEBUG_LOCATION, StatusCode::UNAVAILABLE,
kErrorMessageRegex);
MakeConnectionFailureRegex(
"connections to all backends failing; last error: "));
// Now create a new cluster, pointing to backend 1.
const char* kNewClusterName = "new_cluster";
const char* kNewEdsServiceName = "new_eds_service_name";
@ -1506,8 +1501,10 @@ TEST_P(LdsRdsTest, XdsRoutingClusterUpdateClustersWithPickingDelays) {
[&](const RpcResult& result) {
if (!result.status.ok()) {
EXPECT_EQ(result.status.error_code(), StatusCode::UNAVAILABLE);
EXPECT_THAT(result.status.error_message(),
::testing::MatchesRegex(kErrorMessageRegex));
EXPECT_THAT(
result.status.error_message(),
::testing::MatchesRegex(MakeConnectionFailureRegex(
"connections to all backends failing; last error: ")));
}
},
WaitForBackendOptions().set_reset_counters(false));

Loading…
Cancel
Save