xds_end2end_test_lib: use DEBUG_LOCATION to log where failures originate (#29444)

pull/29449/head
Mark D. Roth 3 years ago committed by GitHub
parent 8ba275291a
commit 6bda57194a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 206
      test/cpp/end2end/xds/xds_cluster_end2end_test.cc
  2. 72
      test/cpp/end2end/xds/xds_cluster_type_end2end_test.cc
  3. 81
      test/cpp/end2end/xds/xds_core_end2end_test.cc
  4. 24
      test/cpp/end2end/xds/xds_csds_end2end_test.cc
  5. 119
      test/cpp/end2end/xds/xds_end2end_test.cc
  6. 49
      test/cpp/end2end/xds/xds_end2end_test_lib.cc
  7. 36
      test/cpp/end2end/xds/xds_end2end_test_lib.h
  8. 22
      test/cpp/end2end/xds/xds_fault_injection_end2end_test.cc
  9. 91
      test/cpp/end2end/xds/xds_ring_hash_end2end_test.cc
  10. 18
      test/cpp/end2end/xds/xds_rls_end2end_test.cc
  11. 330
      test/cpp/end2end/xds/xds_routing_end2end_test.cc

@ -63,7 +63,7 @@ TEST_P(CdsTest, UnsupportedClusterType) {
auto cluster = default_cluster_;
cluster.set_type(Cluster::STATIC);
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("DiscoveryType is not valid."));
@ -76,18 +76,18 @@ TEST_P(CdsTest, InvalidClusterStillExistsIfPreviouslyCached) {
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Check that everything works.
CheckRpcSendOk();
CheckRpcSendOk(DEBUG_LOCATION);
// Now send an update changing the Cluster to be invalid.
auto cluster = default_cluster_;
cluster.set_type(Cluster::STATIC);
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack(StatusCode::OK);
const auto response_state = WaitForCdsNack(DEBUG_LOCATION, StatusCode::OK);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::ContainsRegex(absl::StrCat(
kDefaultClusterName,
": validation error.*DiscoveryType is not valid")));
CheckRpcSendOk();
CheckRpcSendOk(DEBUG_LOCATION);
}
// Tests that CDS client should send a NACK if the eds_config in CDS response
@ -97,7 +97,7 @@ TEST_P(CdsTest, EdsConfigSourceDoesNotSpecifyAdsOrSelf) {
cluster.mutable_eds_cluster_config()->mutable_eds_config()->set_path(
"/foo/bar");
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("EDS ConfigSource is not ADS or SELF."));
@ -111,7 +111,7 @@ TEST_P(CdsTest, AcceptsEdsConfigSourceOfTypeAds) {
balancer_->ads_service()->SetCdsResource(cluster);
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
auto response_state = balancer_->ads_service()->cds_response_state();
ASSERT_TRUE(response_state.has_value());
EXPECT_EQ(response_state->state, AdsServiceImpl::ResponseState::ACKED);
@ -123,7 +123,7 @@ TEST_P(CdsTest, WrongLbPolicy) {
auto cluster = default_cluster_;
cluster.set_lb_policy(Cluster::LEAST_REQUEST);
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("LB policy is not supported."));
@ -135,7 +135,7 @@ TEST_P(CdsTest, WrongLrsServer) {
auto cluster = default_cluster_;
cluster.mutable_lrs_server()->mutable_ads();
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("LRS ConfigSource is not self."));
@ -166,9 +166,9 @@ TEST_P(CdsTest, EndpointWeightDoesNotImpactWeightedRoundRobin) {
});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Wait for both backends to be ready.
WaitForAllBackends(0, 2);
WaitForAllBackends(DEBUG_LOCATION, 0, 2);
// Send kNumRpcs RPCs.
CheckRpcSendOk(kNumRpcs);
CheckRpcSendOk(DEBUG_LOCATION, kNumRpcs);
// The locality picking rates should be roughly equal to the expectation.
const double locality_picked_rate_0 =
static_cast<double>(backends_[0]->backend_service()->request_count()) /
@ -195,7 +195,7 @@ TEST_P(CdsTest, EdsServiceNameDefaultsToClusterName) {
Cluster cluster = default_cluster_;
cluster.mutable_eds_cluster_config()->clear_service_name();
balancer_->ads_service()->SetCdsResource(cluster);
CheckRpcSendOk();
CheckRpcSendOk(DEBUG_LOCATION);
}
// Tests switching over from one cluster to another.
@ -206,7 +206,7 @@ TEST_P(CdsTest, ChangeClusters) {
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends(0, 1)}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// We need to wait for all backends to come online.
WaitForAllBackends(0, 1);
WaitForAllBackends(DEBUG_LOCATION, 0, 1);
// Populate new EDS resource.
args = EdsResourceArgs({{"locality0", CreateEndpointsForBackends(1, 2)}});
balancer_->ads_service()->SetEdsResource(
@ -226,7 +226,7 @@ TEST_P(CdsTest, ChangeClusters) {
SetListenerAndRouteConfiguration(balancer_.get(), default_listener_,
new_route_config);
// Wait for all new backends to be used.
WaitForAllBackends(1, 2);
WaitForAllBackends(DEBUG_LOCATION, 1, 2);
}
// Tests that we go into TRANSIENT_FAILURE if the Cluster disappears.
@ -235,14 +235,15 @@ TEST_P(CdsTest, ClusterRemoved) {
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// We need to wait for all backends to come online.
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
// Unset CDS resource.
balancer_->ads_service()->UnsetResource(kCdsTypeUrl, kDefaultClusterName);
// Wait for RPCs to start failing.
do {
} while (SendRpc(RpcOptions(), nullptr).ok());
// Make sure RPCs are still failing.
CheckRpcSendFailure(CheckRpcSendFailureOptions().set_times(1000));
CheckRpcSendFailure(DEBUG_LOCATION,
CheckRpcSendFailureOptions().set_times(1000));
// Make sure we ACK'ed the update.
auto response_state = balancer_->ads_service()->cds_response_state();
ASSERT_TRUE(response_state.has_value());
@ -335,7 +336,7 @@ TEST_P(CdsTest, ClusterChangeAfterAdsCallFails) {
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends(0, 1)}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Check that the channel is working.
CheckRpcSendOk();
CheckRpcSendOk(DEBUG_LOCATION);
// Stop and restart the balancer.
balancer_->Shutdown();
balancer_->Start();
@ -363,7 +364,8 @@ TEST_P(CdsTest, ClusterChangeAfterAdsCallFails) {
//
// Need to figure out a way to fix this bug, and then change this to
// not allow failures.
WaitForBackend(1, WaitForBackendOptions().set_allow_failures(true));
WaitForBackend(DEBUG_LOCATION, 1,
WaitForBackendOptions().set_allow_failures(true));
}
//
@ -389,9 +391,9 @@ TEST_P(EdsTest, Vanilla) {
// Make sure that trying to connect works without a call.
channel_->GetState(true /* try_to_connect */);
// We need to wait for all backends to come online.
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
// Send kNumRpcsPerAddress RPCs per server.
CheckRpcSendOk(kNumRpcsPerAddress * backends_.size());
CheckRpcSendOk(DEBUG_LOCATION, kNumRpcsPerAddress * backends_.size());
// Each backend should have gotten 100 requests.
for (size_t i = 0; i < backends_.size(); ++i) {
EXPECT_EQ(kNumRpcsPerAddress,
@ -416,9 +418,9 @@ TEST_P(EdsTest, IgnoresUnhealthyEndpoints) {
// Make sure that trying to connect works without a call.
channel_->GetState(true /* try_to_connect */);
// We need to wait for all backends to come online.
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
// Send kNumRpcsPerAddress RPCs per server.
CheckRpcSendOk(kNumRpcsPerAddress * backends_.size());
CheckRpcSendOk(DEBUG_LOCATION, kNumRpcsPerAddress * backends_.size());
// Each backend should have gotten 100 requests.
for (size_t i = 0; i < backends_.size(); ++i) {
EXPECT_EQ(kNumRpcsPerAddress,
@ -436,10 +438,10 @@ TEST_P(EdsTest, SameBackendListedMultipleTimes) {
EdsResourceArgs args({{"locality0", endpoints}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// We need to wait for the backend to come online.
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
// Send kNumRpcsPerAddress RPCs per server.
const size_t kNumRpcsPerAddress = 10;
CheckRpcSendOk(kNumRpcsPerAddress * endpoints.size());
CheckRpcSendOk(DEBUG_LOCATION, kNumRpcsPerAddress * endpoints.size());
// Backend should have gotten 20 requests.
EXPECT_EQ(kNumRpcsPerAddress * endpoints.size(),
backends_[0]->backend_service()->request_count());
@ -453,12 +455,13 @@ TEST_P(EdsTest, InitiallyEmptyServerlist) {
EdsResourceArgs args({std::move(empty_locality)});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// RPCs should fail.
CheckRpcSendFailure();
CheckRpcSendFailure(DEBUG_LOCATION);
// Send non-empty serverlist.
args = EdsResourceArgs({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// RPCs should eventually succeed.
WaitForAllBackends(0, 1, WaitForBackendOptions().set_allow_failures(true));
WaitForAllBackends(DEBUG_LOCATION, 0, 1,
WaitForBackendOptions().set_allow_failures(true));
}
// Tests that RPCs will fail with UNAVAILABLE instead of DEADLINE_EXCEEDED if
@ -487,7 +490,7 @@ TEST_P(EdsTest, BackendsRestart) {
CreateAndStartBackends(3);
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
// Stop backends. RPCs should fail.
ShutdownAllBackends();
// Sending multiple failed requests instead of just one to ensure that the
@ -499,10 +502,12 @@ TEST_P(EdsTest, BackendsRestart) {
// below (which we expect to succeed), if the callbacks happen in the wrong
// order, the same race condition could happen again due to the client not
// yet having noticed that the backends were all down.
CheckRpcSendFailure(CheckRpcSendFailureOptions().set_times(backends_.size()));
CheckRpcSendFailure(DEBUG_LOCATION,
CheckRpcSendFailureOptions().set_times(backends_.size()));
// Restart all backends. RPCs should start succeeding again.
StartAllBackends();
CheckRpcSendOk(1, RpcOptions().set_timeout_ms(2000).set_wait_for_ready(true));
CheckRpcSendOk(DEBUG_LOCATION, 1,
RpcOptions().set_timeout_ms(2000).set_wait_for_ready(true));
}
TEST_P(EdsTest, IgnoresDuplicateUpdates) {
@ -513,15 +518,15 @@ TEST_P(EdsTest, IgnoresDuplicateUpdates) {
});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Wait for all backends to come online.
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
// Send kNumRpcsPerAddress RPCs per server, but send an EDS update in
// between. If the update is not ignored, this will cause the
// round_robin policy to see an update, which will randomly reset its
// position in the address list.
for (size_t i = 0; i < kNumRpcsPerAddress; ++i) {
CheckRpcSendOk(2);
CheckRpcSendOk(DEBUG_LOCATION, 2);
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
CheckRpcSendOk(2);
CheckRpcSendOk(DEBUG_LOCATION, 2);
}
// Each backend should have gotten the right number of requests.
for (size_t i = 1; i < backends_.size(); ++i) {
@ -537,7 +542,7 @@ TEST_P(EdsTest, NacksSparsePriorityList) {
{"locality0", {MakeNonExistantEndpoint()}, kDefaultLocalityWeight, 1},
});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
const auto response_state = WaitForEdsNack();
const auto response_state = WaitForEdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("sparse priority list"));
@ -551,7 +556,7 @@ TEST_P(EdsTest, NacksDuplicateLocalityInSamePriority) {
{"locality0", {MakeNonExistantEndpoint()}, kDefaultLocalityWeight, 0},
});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
const auto response_state = WaitForEdsNack();
const auto response_state = WaitForEdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(
@ -569,12 +574,12 @@ TEST_P(EdsTest, KeepUsingLastDataIfBalancerGoesDown) {
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends(0, 1)}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Start the client and make sure it sees the backend.
WaitForBackend(0);
WaitForBackend(DEBUG_LOCATION, 0);
// Stop the balancer, and verify that RPCs continue to flow to backend 0.
balancer_->Shutdown();
auto deadline = grpc_timeout_seconds_to_deadline(5);
do {
CheckRpcSendOk();
CheckRpcSendOk(DEBUG_LOCATION);
} while (gpr_time_cmp(gpr_now(GPR_CLOCK_MONOTONIC), deadline) < 0);
// Check the EDS resource to point to backend 1 and bring the balancer
// back up.
@ -582,7 +587,7 @@ TEST_P(EdsTest, KeepUsingLastDataIfBalancerGoesDown) {
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
balancer_->Start();
// Wait for client to see backend 1.
WaitForBackend(1);
WaitForBackend(DEBUG_LOCATION, 1);
}
// Tests that the localities in a locality map are picked according to their
@ -606,9 +611,9 @@ TEST_P(EdsTest, WeightedRoundRobin) {
});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Wait for both backends to be ready.
WaitForAllBackends(0, 2);
WaitForAllBackends(DEBUG_LOCATION, 0, 2);
// Send kNumRpcs RPCs.
CheckRpcSendOk(kNumRpcs);
CheckRpcSendOk(DEBUG_LOCATION, kNumRpcs);
// The locality picking rates should be roughly equal to the expectation.
const double locality_picked_rate_0 =
static_cast<double>(backends_[0]->backend_service()->request_count()) /
@ -633,9 +638,9 @@ TEST_P(EdsTest, LocalityContainingNoEndpoints) {
});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Wait for both backends to be ready.
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
// Send kNumRpcs RPCs.
CheckRpcSendOk(kNumRpcs);
CheckRpcSendOk(DEBUG_LOCATION, kNumRpcs);
// All traffic should go to the reachable locality.
EXPECT_EQ(backends_[0]->backend_service()->request_count(),
kNumRpcs / backends_.size());
@ -667,14 +672,15 @@ TEST_P(EdsTest, ManyLocalitiesStressTest) {
}
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Wait until backend 0 is ready.
WaitForBackend(0, WaitForBackendOptions().set_reset_counters(false),
WaitForBackend(DEBUG_LOCATION, 0,
WaitForBackendOptions().set_reset_counters(false),
RpcOptions().set_timeout_ms(kRpcTimeoutMs));
EXPECT_EQ(0U, backends_[1]->backend_service()->request_count());
// The second ADS response contains 1 locality, which contains backend 1.
args = EdsResourceArgs({{"locality0", CreateEndpointsForBackends(1, 2)}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Wait until backend 1 is ready.
WaitForBackend(1);
WaitForBackend(DEBUG_LOCATION, 1);
}
// Tests that the localities in a locality map are picked correctly after
@ -708,10 +714,10 @@ TEST_P(EdsTest, LocalityMapUpdateChurn) {
});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Wait for the first 3 backends to be ready.
WaitForAllBackends(0, 3);
WaitForAllBackends(DEBUG_LOCATION, 0, 3);
gpr_log(GPR_INFO, "========= BEFORE FIRST BATCH ==========");
// Send kNumRpcs RPCs.
CheckRpcSendOk(kNumRpcs);
CheckRpcSendOk(DEBUG_LOCATION, kNumRpcs);
gpr_log(GPR_INFO, "========= DONE WITH FIRST BATCH ==========");
// The picking rates of the first 3 backends should be roughly equal to the
// expectation.
@ -741,10 +747,10 @@ TEST_P(EdsTest, LocalityMapUpdateChurn) {
EXPECT_EQ(0U, backends_[3]->backend_service()->request_count());
// Wait until the locality update has been processed, as signaled by backend
// 3 receiving a request.
WaitForAllBackends(3, 4);
WaitForAllBackends(DEBUG_LOCATION, 3, 4);
gpr_log(GPR_INFO, "========= BEFORE SECOND BATCH ==========");
// Send kNumRpcs RPCs.
CheckRpcSendOk(kNumRpcs);
CheckRpcSendOk(DEBUG_LOCATION, kNumRpcs);
gpr_log(GPR_INFO, "========= DONE WITH SECOND BATCH ==========");
// Backend 0 no longer receives any request.
EXPECT_EQ(0U, backends_[0]->backend_service()->request_count());
@ -775,13 +781,13 @@ TEST_P(EdsTest, ReplaceAllLocalitiesInPriority) {
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends(0, 1)}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Wait for the first backend to be ready.
WaitForBackend(0);
WaitForBackend(DEBUG_LOCATION, 0);
// Send EDS update that replaces the locality and switches to backend 1.
args = EdsResourceArgs({{"locality1", CreateEndpointsForBackends(1, 2)}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// When the client sees the update, RPCs should start going to backend 1.
// No RPCs should fail during this change.
WaitForBackend(1);
WaitForBackend(DEBUG_LOCATION, 1);
}
TEST_P(EdsTest, ConsistentWeightedTargetUpdates) {
@ -792,7 +798,7 @@ TEST_P(EdsTest, ConsistentWeightedTargetUpdates) {
{"locality1", CreateEndpointsForBackends(2, 3)},
});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForAllBackends(1, 3);
WaitForAllBackends(DEBUG_LOCATION, 1, 3);
// Next update removes locality1.
// Also add backend 0 to locality0, so that we can tell when the
// update has been seen.
@ -800,7 +806,7 @@ TEST_P(EdsTest, ConsistentWeightedTargetUpdates) {
{"locality0", CreateEndpointsForBackends(0, 2)},
});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForBackend(0);
WaitForBackend(DEBUG_LOCATION, 0);
// Next update re-adds locality1.
// Also add backend 3 to locality1, so that we can tell when the
// update has been seen.
@ -809,7 +815,7 @@ TEST_P(EdsTest, ConsistentWeightedTargetUpdates) {
{"locality1", CreateEndpointsForBackends(2, 4)},
});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForBackend(3);
WaitForBackend(DEBUG_LOCATION, 3);
}
// Tests that RPCs are dropped according to the drop config.
@ -830,8 +836,8 @@ TEST_P(EdsTest, Drops) {
{kThrottleDropType, kDropPerMillionForThrottle}};
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Send kNumRpcs RPCs and count the drops.
size_t num_drops =
SendRpcsAndCountFailuresWithMessage(kNumRpcs, "EDS-configured drop: ");
size_t num_drops = SendRpcsAndCountFailuresWithMessage(
DEBUG_LOCATION, kNumRpcs, "EDS-configured drop: ");
// The drop rate should be roughly equal to the expectation.
const double seen_drop_rate = static_cast<double>(num_drops) / kNumRpcs;
EXPECT_THAT(seen_drop_rate, ::testing::DoubleNear(kDropRateForLbAndThrottle,
@ -851,8 +857,8 @@ TEST_P(EdsTest, DropPerHundred) {
args.drop_denominator = FractionalPercent::HUNDRED;
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Send kNumRpcs RPCs and count the drops.
size_t num_drops =
SendRpcsAndCountFailuresWithMessage(kNumRpcs, "EDS-configured drop: ");
size_t num_drops = SendRpcsAndCountFailuresWithMessage(
DEBUG_LOCATION, kNumRpcs, "EDS-configured drop: ");
// The drop rate should be roughly equal to the expectation.
const double seen_drop_rate = static_cast<double>(num_drops) / kNumRpcs;
EXPECT_THAT(seen_drop_rate,
@ -872,8 +878,8 @@ TEST_P(EdsTest, DropPerTenThousand) {
args.drop_denominator = FractionalPercent::TEN_THOUSAND;
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Send kNumRpcs RPCs and count the drops.
size_t num_drops =
SendRpcsAndCountFailuresWithMessage(kNumRpcs, "EDS-configured drop: ");
size_t num_drops = SendRpcsAndCountFailuresWithMessage(
DEBUG_LOCATION, kNumRpcs, "EDS-configured drop: ");
// The drop rate should be roughly equal to the expectation.
const double seen_drop_rate = static_cast<double>(num_drops) / kNumRpcs;
EXPECT_THAT(seen_drop_rate,
@ -901,7 +907,7 @@ TEST_P(EdsTest, DropConfigUpdate) {
// Send kNumRpcsLbOnly RPCs and count the drops.
gpr_log(GPR_INFO, "========= BEFORE FIRST BATCH ==========");
size_t num_drops = SendRpcsAndCountFailuresWithMessage(
kNumRpcsLbOnly, "EDS-configured drop: ");
DEBUG_LOCATION, kNumRpcsLbOnly, "EDS-configured drop: ");
gpr_log(GPR_INFO, "========= DONE WITH FIRST BATCH ==========");
// The drop rate should be roughly equal to the expectation.
double seen_drop_rate = static_cast<double>(num_drops) / kNumRpcsLbOnly;
@ -934,7 +940,7 @@ TEST_P(EdsTest, DropConfigUpdate) {
}
// Send kNumRpcsBoth RPCs and count the drops.
gpr_log(GPR_INFO, "========= BEFORE SECOND BATCH ==========");
num_drops = SendRpcsAndCountFailuresWithMessage(kNumRpcsBoth,
num_drops = SendRpcsAndCountFailuresWithMessage(DEBUG_LOCATION, kNumRpcsBoth,
"EDS-configured drop: ");
gpr_log(GPR_INFO, "========= DONE WITH SECOND BATCH ==========");
// The new drop rate should be roughly equal to the expectation.
@ -955,8 +961,8 @@ TEST_P(EdsTest, DropAll) {
{kThrottleDropType, kDropPerMillionForThrottle}};
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Send kNumRpcs RPCs and all of them are dropped.
size_t num_drops =
SendRpcsAndCountFailuresWithMessage(kNumRpcs, "EDS-configured drop: ");
size_t num_drops = SendRpcsAndCountFailuresWithMessage(
DEBUG_LOCATION, kNumRpcs, "EDS-configured drop: ");
EXPECT_EQ(num_drops, kNumRpcs);
}
@ -991,7 +997,8 @@ TEST_P(FailoverTest, ChooseHighestPriority) {
0},
});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForBackend(3, WaitForBackendOptions().set_reset_counters(false));
WaitForBackend(DEBUG_LOCATION, 3,
WaitForBackendOptions().set_reset_counters(false));
for (size_t i = 0; i < 3; ++i) {
EXPECT_EQ(0U, backends_[i]->backend_service()->request_count());
}
@ -1010,7 +1017,8 @@ TEST_P(FailoverTest, DoesNotUsePriorityWithNoEndpoints) {
{"locality3", {}, kDefaultLocalityWeight, 0},
});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForBackend(0, WaitForBackendOptions().set_reset_counters(false));
WaitForBackend(DEBUG_LOCATION, 0,
WaitForBackendOptions().set_reset_counters(false));
for (size_t i = 1; i < 3; ++i) {
EXPECT_EQ(0U, backends_[i]->backend_service()->request_count());
}
@ -1025,7 +1033,7 @@ TEST_P(FailoverTest, DoesNotUseLocalityWithNoEndpoints) {
});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Wait for all backends to be used.
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
}
// If the higher priority localities are not reachable, failover to the
@ -1041,7 +1049,8 @@ TEST_P(FailoverTest, Failover) {
{"locality3", {MakeNonExistantEndpoint()}, kDefaultLocalityWeight, 0},
});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForBackend(0, WaitForBackendOptions().set_reset_counters(false));
WaitForBackend(DEBUG_LOCATION, 0,
WaitForBackendOptions().set_reset_counters(false));
EXPECT_EQ(0U, backends_[1]->backend_service()->request_count());
}
@ -1061,19 +1070,20 @@ TEST_P(FailoverTest, SwitchBackToHigherPriority) {
0},
});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForBackend(3);
WaitForBackend(DEBUG_LOCATION, 3);
ShutdownBackend(3);
ShutdownBackend(0);
WaitForBackend(
1, WaitForBackendOptions().set_reset_counters(false).set_allow_failures(
true));
DEBUG_LOCATION, 1,
WaitForBackendOptions().set_reset_counters(false).set_allow_failures(
true));
for (size_t i = 0; i < backends_.size(); ++i) {
if (i == 1) continue;
EXPECT_EQ(0U, backends_[i]->backend_service()->request_count());
}
StartBackend(0);
WaitForBackend(0);
CheckRpcSendOk(kNumRpcs);
WaitForBackend(DEBUG_LOCATION, 0);
CheckRpcSendOk(DEBUG_LOCATION, kNumRpcs);
EXPECT_EQ(kNumRpcs, backends_[0]->backend_service()->request_count());
}
@ -1086,7 +1096,7 @@ TEST_P(FailoverTest, UpdateInitialUnavailable) {
{"locality1", {MakeNonExistantEndpoint()}, kDefaultLocalityWeight, 1},
});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
CheckRpcSendFailure();
CheckRpcSendFailure(DEBUG_LOCATION);
args = EdsResourceArgs({
{"locality0", CreateEndpointsForBackends(0, 1), kDefaultLocalityWeight,
0},
@ -1094,7 +1104,8 @@ TEST_P(FailoverTest, UpdateInitialUnavailable) {
1},
});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForBackend(0, WaitForBackendOptions().set_allow_failures(true));
WaitForBackend(DEBUG_LOCATION, 0,
WaitForBackendOptions().set_allow_failures(true));
}
// Tests that after the localities' priorities are updated, we still choose
@ -1113,7 +1124,8 @@ TEST_P(FailoverTest, UpdatePriority) {
0},
});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForBackend(3, WaitForBackendOptions().set_reset_counters(false));
WaitForBackend(DEBUG_LOCATION, 3,
WaitForBackendOptions().set_reset_counters(false));
EXPECT_EQ(0U, backends_[0]->backend_service()->request_count());
EXPECT_EQ(0U, backends_[1]->backend_service()->request_count());
EXPECT_EQ(0U, backends_[2]->backend_service()->request_count());
@ -1128,8 +1140,8 @@ TEST_P(FailoverTest, UpdatePriority) {
3},
});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForBackend(1);
CheckRpcSendOk(kNumRpcs);
WaitForBackend(DEBUG_LOCATION, 1);
CheckRpcSendOk(DEBUG_LOCATION, kNumRpcs);
EXPECT_EQ(kNumRpcs, backends_[1]->backend_service()->request_count());
}
@ -1149,7 +1161,8 @@ TEST_P(FailoverTest, MoveAllLocalitiesInCurrentPriorityToHigherPriority) {
// When we get the first update, all backends in priority 0 are down,
// so we will create priority 1. Backends 0 and 1 should have traffic,
// but backend 2 should not.
WaitForAllBackends(0, 2, WaitForBackendOptions().set_reset_counters(false));
WaitForAllBackends(DEBUG_LOCATION, 0, 2,
WaitForBackendOptions().set_reset_counters(false));
EXPECT_EQ(0UL, backends_[2]->backend_service()->request_count());
// Second update:
// - Priority 0 contains both localities 0 and 1.
@ -1163,7 +1176,7 @@ TEST_P(FailoverTest, MoveAllLocalitiesInCurrentPriorityToHigherPriority) {
});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// When backend 2 gets traffic, we know the second update has been seen.
WaitForBackend(2);
WaitForBackend(DEBUG_LOCATION, 2);
// The xDS server got at least 1 response.
EXPECT_TRUE(balancer_->ads_service()->eds_response_state().has_value());
}
@ -1186,7 +1199,7 @@ TEST_P(FailoverTest, PriorityChildNameChurn) {
2},
});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForBackend(0);
WaitForBackend(DEBUG_LOCATION, 0);
// Next update:
// - P0:locality0, child number 0 (still unreachable)
// - P1:locality2, child number 2 (moved from P2 to P1)
@ -1200,7 +1213,7 @@ TEST_P(FailoverTest, PriorityChildNameChurn) {
2},
});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForBackend(1);
WaitForBackend(DEBUG_LOCATION, 1);
// Next update:
// - P0:locality0, child number 0 (still unreachable)
// - P1:locality4, child number 4 (new child number -- should not reuse #1)
@ -1214,7 +1227,8 @@ TEST_P(FailoverTest, PriorityChildNameChurn) {
2},
});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForBackend(3, WaitForBackendOptions().set_reset_counters(false));
WaitForBackend(DEBUG_LOCATION, 3,
WaitForBackendOptions().set_reset_counters(false));
// P2 should not have gotten any traffic in this change.
EXPECT_EQ(0UL, backends_[2]->backend_service()->request_count());
}
@ -1242,10 +1256,11 @@ TEST_P(ClientLoadReportingTest, Vanilla) {
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Wait until all backends are ready.
size_t num_warmup_rpcs = WaitForAllBackends(
0, 4, WaitForBackendOptions().set_reset_counters(false));
DEBUG_LOCATION, 0, 4, WaitForBackendOptions().set_reset_counters(false));
// Send kNumRpcsPerAddress RPCs per server.
CheckRpcSendOk(kNumRpcsPerAddress * backends_.size());
CheckRpcSendFailure(CheckRpcSendFailureOptions()
CheckRpcSendOk(DEBUG_LOCATION, kNumRpcsPerAddress * backends_.size());
CheckRpcSendFailure(DEBUG_LOCATION,
CheckRpcSendFailureOptions()
.set_times(kNumFailuresPerAddress * backends_.size())
.set_rpc_options(RpcOptions().set_server_fail(true)));
const size_t total_successful_rpcs_sent =
@ -1303,10 +1318,11 @@ TEST_P(ClientLoadReportingTest, SendAllClusters) {
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Wait until all backends are ready.
size_t num_warmup_rpcs = WaitForAllBackends();
size_t num_warmup_rpcs = WaitForAllBackends(DEBUG_LOCATION);
// Send kNumRpcsPerAddress RPCs per server.
CheckRpcSendOk(kNumRpcsPerAddress * backends_.size());
CheckRpcSendFailure(CheckRpcSendFailureOptions()
CheckRpcSendOk(DEBUG_LOCATION, kNumRpcsPerAddress * backends_.size());
CheckRpcSendFailure(DEBUG_LOCATION,
CheckRpcSendFailureOptions()
.set_times(kNumFailuresPerAddress * backends_.size())
.set_rpc_options(RpcOptions().set_server_fail(true)));
// Check that each backend got the right number of requests.
@ -1341,7 +1357,7 @@ TEST_P(ClientLoadReportingTest, HonorsClustersRequestedByLrsServer) {
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Wait until all backends are ready.
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
// The load report received at the balancer should be correct.
std::vector<ClientStats> load_report =
balancer_->lrs_service()->WaitForLoadReport();
@ -1358,7 +1374,7 @@ TEST_P(ClientLoadReportingTest, BalancerRestart) {
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends(0, 2)}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Wait until all backends returned by the balancer are ready.
size_t num_rpcs = WaitForAllBackends(0, 2);
size_t num_rpcs = WaitForAllBackends(DEBUG_LOCATION, 0, 2);
std::vector<ClientStats> load_report =
balancer_->lrs_service()->WaitForLoadReport();
ASSERT_EQ(load_report.size(), 1UL);
@ -1380,16 +1396,16 @@ TEST_P(ClientLoadReportingTest, BalancerRestart) {
// subchannel list, which resets the start index randomly. So we need
// to be a little more permissive here to avoid spurious failures.
ResetBackendCounters();
num_rpcs = WaitForAllBackends(0, 2);
num_rpcs = WaitForAllBackends(DEBUG_LOCATION, 0, 2);
// Now restart the balancer, this time pointing to the new backends.
balancer_->Start();
args = EdsResourceArgs({{"locality0", CreateEndpointsForBackends(2, 4)}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Wait for queries to start going to one of the new backends.
// This tells us that we're now using the new serverlist.
num_rpcs += WaitForAllBackends(2, 4);
num_rpcs += WaitForAllBackends(DEBUG_LOCATION, 2, 4);
// Send one RPC per backend.
CheckRpcSendOk(2);
CheckRpcSendOk(DEBUG_LOCATION, 2);
num_rpcs += 2;
// Check client stats.
load_report = balancer_->lrs_service()->WaitForLoadReport();
@ -1426,7 +1442,7 @@ TEST_P(ClientLoadReportingTest, ChangeClusters) {
kNewEdsServiceName);
balancer_->ads_service()->SetCdsResource(new_cluster);
// Wait for all backends to come online.
size_t num_rpcs = WaitForAllBackends(0, 2);
size_t num_rpcs = WaitForAllBackends(DEBUG_LOCATION, 0, 2);
// The load report received at the balancer should be correct.
std::vector<ClientStats> load_report =
balancer_->lrs_service()->WaitForLoadReport();
@ -1463,7 +1479,7 @@ TEST_P(ClientLoadReportingTest, ChangeClusters) {
SetListenerAndRouteConfiguration(balancer_.get(), default_listener_,
new_route_config);
// Wait for all new backends to be used.
num_rpcs = WaitForAllBackends(2, 4);
num_rpcs = WaitForAllBackends(DEBUG_LOCATION, 2, 4);
// The load report received at the balancer should be correct.
load_report = balancer_->lrs_service()->WaitForLoadReport();
EXPECT_THAT(
@ -1543,8 +1559,8 @@ TEST_P(ClientLoadReportingTest, DropStats) {
{kThrottleDropType, kDropPerMillionForThrottle}};
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Send kNumRpcs RPCs and count the drops.
size_t num_drops =
SendRpcsAndCountFailuresWithMessage(kNumRpcs, kStatusMessageDropPrefix);
size_t num_drops = SendRpcsAndCountFailuresWithMessage(
DEBUG_LOCATION, kNumRpcs, kStatusMessageDropPrefix);
// The drop rate should be roughly equal to the expectation.
const double seen_drop_rate = static_cast<double>(num_drops) / kNumRpcs;
EXPECT_THAT(seen_drop_rate, ::testing::DoubleNear(kDropRateForLbAndThrottle,

@ -104,7 +104,7 @@ TEST_P(LogicalDNSClusterTest, Basic) {
std::move(result));
}
// RPCs should succeed.
CheckRpcSendOk();
CheckRpcSendOk(DEBUG_LOCATION);
}
TEST_P(LogicalDNSClusterTest, MissingLoadAssignment) {
@ -114,7 +114,7 @@ TEST_P(LogicalDNSClusterTest, MissingLoadAssignment) {
auto cluster = default_cluster_;
cluster.set_type(Cluster::LOGICAL_DNS);
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(
@ -129,7 +129,7 @@ TEST_P(LogicalDNSClusterTest, MissingLocalities) {
cluster.set_type(Cluster::LOGICAL_DNS);
cluster.mutable_load_assignment();
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -147,7 +147,7 @@ TEST_P(LogicalDNSClusterTest, MultipleLocalities) {
load_assignment->add_endpoints();
load_assignment->add_endpoints();
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -163,7 +163,7 @@ TEST_P(LogicalDNSClusterTest, MissingEndpoints) {
cluster.set_type(Cluster::LOGICAL_DNS);
cluster.mutable_load_assignment()->add_endpoints();
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(
@ -181,7 +181,7 @@ TEST_P(LogicalDNSClusterTest, MultipleEndpoints) {
locality->add_lb_endpoints();
locality->add_lb_endpoints();
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(
@ -197,7 +197,7 @@ TEST_P(LogicalDNSClusterTest, EmptyEndpoint) {
cluster.set_type(Cluster::LOGICAL_DNS);
cluster.mutable_load_assignment()->add_endpoints()->add_lb_endpoints();
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("LbEndpoint endpoint field not set"));
@ -214,7 +214,7 @@ TEST_P(LogicalDNSClusterTest, EndpointMissingAddress) {
->add_lb_endpoints()
->mutable_endpoint();
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("Endpoint address field not set"));
@ -232,7 +232,7 @@ TEST_P(LogicalDNSClusterTest, AddressMissingSocketAddress) {
->mutable_endpoint()
->mutable_address();
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("Address socket_address field not set"));
@ -252,7 +252,7 @@ TEST_P(LogicalDNSClusterTest, SocketAddressHasResolverName) {
->mutable_socket_address()
->set_resolver_name("foo");
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("LOGICAL_DNS clusters must NOT have a "
@ -272,7 +272,7 @@ TEST_P(LogicalDNSClusterTest, SocketAddressMissingAddress) {
->mutable_address()
->mutable_socket_address();
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("SocketAddress address field not set"));
@ -292,7 +292,7 @@ TEST_P(LogicalDNSClusterTest, SocketAddressMissingPort) {
->mutable_socket_address()
->set_address(kServerName);
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("SocketAddress port_value field not set"));
@ -304,7 +304,7 @@ TEST_P(LogicalDNSClusterTest, Disabled) {
auto cluster = default_cluster_;
cluster.set_type(Cluster::LOGICAL_DNS);
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("DiscoveryType is not valid."));
@ -362,16 +362,17 @@ TEST_P(AggregateClusterTest, ) {
custom_cluster->mutable_typed_config()->PackFrom(cluster_config);
balancer_->ads_service()->SetCdsResource(cluster);
// Wait for traffic to go to backend 0.
WaitForBackend(0);
WaitForBackend(DEBUG_LOCATION, 0);
// Shutdown backend 0 and wait for all traffic to go to backend 1.
ShutdownBackend(0);
WaitForBackend(1, WaitForBackendOptions().set_allow_failures(true));
WaitForBackend(DEBUG_LOCATION, 1,
WaitForBackendOptions().set_allow_failures(true));
auto response_state = balancer_->ads_service()->cds_response_state();
ASSERT_TRUE(response_state.has_value());
EXPECT_EQ(response_state->state, AdsServiceImpl::ResponseState::ACKED);
// Bring backend 0 back and ensure all traffic go back to it.
StartBackend(0);
WaitForBackend(0);
WaitForBackend(DEBUG_LOCATION, 0);
}
TEST_P(AggregateClusterTest, DiamondDependency) {
@ -423,16 +424,17 @@ TEST_P(AggregateClusterTest, DiamondDependency) {
custom_cluster->mutable_typed_config()->PackFrom(cluster_config);
balancer_->ads_service()->SetCdsResource(aggregate_cluster2);
// Wait for traffic to go to backend 0.
WaitForBackend(0);
WaitForBackend(DEBUG_LOCATION, 0);
// Shutdown backend 0 and wait for all traffic to go to backend 1.
ShutdownBackend(0);
WaitForBackend(1, WaitForBackendOptions().set_allow_failures(true));
WaitForBackend(DEBUG_LOCATION, 1,
WaitForBackendOptions().set_allow_failures(true));
auto response_state = balancer_->ads_service()->cds_response_state();
ASSERT_TRUE(response_state.has_value());
EXPECT_EQ(response_state->state, AdsServiceImpl::ResponseState::ACKED);
// Bring backend 0 back and ensure all traffic go back to it.
StartBackend(0);
WaitForBackend(0);
WaitForBackend(DEBUG_LOCATION, 0);
}
// This test covers a bug found in the following scenario:
@ -562,13 +564,14 @@ TEST_P(AggregateClusterTest, FallBackWithConnectivityChurn) {
connection_attempt_injector.Start();
// Wait for P0 backend.
// Increase timeout to account for subchannel connection delays.
WaitForBackend(0, WaitForBackendOptions(), RpcOptions().set_timeout_ms(2000));
WaitForBackend(DEBUG_LOCATION, 0, WaitForBackendOptions(),
RpcOptions().set_timeout_ms(2000));
// Bring down the P0 backend.
ShutdownBackend(0);
// Allow the connection attempt to the P1 backend to resume.
connection_attempt_injector.CompletePriority1Connection();
// Wait for P1 backend to start getting traffic.
WaitForBackend(1);
WaitForBackend(DEBUG_LOCATION, 1);
}
TEST_P(AggregateClusterTest, EdsToLogicalDns) {
@ -619,16 +622,17 @@ TEST_P(AggregateClusterTest, EdsToLogicalDns) {
std::move(result));
}
// Wait for traffic to go to backend 0.
WaitForBackend(0);
WaitForBackend(DEBUG_LOCATION, 0);
// Shutdown backend 0 and wait for all traffic to go to backend 1.
ShutdownBackend(0);
WaitForBackend(1, WaitForBackendOptions().set_allow_failures(true));
WaitForBackend(DEBUG_LOCATION, 1,
WaitForBackendOptions().set_allow_failures(true));
auto response_state = balancer_->ads_service()->cds_response_state();
ASSERT_TRUE(response_state.has_value());
EXPECT_EQ(response_state->state, AdsServiceImpl::ResponseState::ACKED);
// Bring backend 0 back and ensure all traffic go back to it.
StartBackend(0);
WaitForBackend(0);
WaitForBackend(DEBUG_LOCATION, 0);
}
TEST_P(AggregateClusterTest, LogicalDnsToEds) {
@ -681,16 +685,17 @@ TEST_P(AggregateClusterTest, LogicalDnsToEds) {
std::move(result));
}
// Wait for traffic to go to backend 0.
WaitForBackend(0);
WaitForBackend(DEBUG_LOCATION, 0);
// Shutdown backend 0 and wait for all traffic to go to backend 1.
ShutdownBackend(0);
WaitForBackend(1, WaitForBackendOptions().set_allow_failures(true));
WaitForBackend(DEBUG_LOCATION, 1,
WaitForBackendOptions().set_allow_failures(true));
auto response_state = balancer_->ads_service()->cds_response_state();
ASSERT_TRUE(response_state.has_value());
EXPECT_EQ(response_state->state, AdsServiceImpl::ResponseState::ACKED);
// Bring backend 0 back and ensure all traffic go back to it.
StartBackend(0);
WaitForBackend(0);
WaitForBackend(DEBUG_LOCATION, 0);
}
// This test covers a bug seen in the wild where the
@ -753,7 +758,7 @@ TEST_P(AggregateClusterTest, ReconfigEdsWhileLogicalDnsChildFails) {
std::move(result));
}
// When an RPC fails, we know the channel has seen the update.
CheckRpcSendFailure();
CheckRpcSendFailure(DEBUG_LOCATION);
// Send an EDS update that moves locality1 to priority 0.
args1 = EdsResourceArgs({
{"locality1", CreateEndpointsForBackends(0, 1), kDefaultLocalityWeight,
@ -763,7 +768,8 @@ TEST_P(AggregateClusterTest, ReconfigEdsWhileLogicalDnsChildFails) {
});
balancer_->ads_service()->SetEdsResource(
BuildEdsResource(args1, kNewEdsService1Name));
WaitForBackend(0, WaitForBackendOptions().set_allow_failures(true));
WaitForBackend(DEBUG_LOCATION, 0,
WaitForBackendOptions().set_allow_failures(true));
}
TEST_P(AggregateClusterTest, MultipleClustersWithSameLocalities) {
@ -804,13 +810,13 @@ TEST_P(AggregateClusterTest, MultipleClustersWithSameLocalities) {
custom_cluster->mutable_typed_config()->PackFrom(cluster_config);
balancer_->ads_service()->SetCdsResource(cluster);
// Wait for channel to get the resources and get connected.
WaitForBackend(0);
WaitForBackend(DEBUG_LOCATION, 0);
// Send an EDS update for cluster 1 that reuses the locality name from
// cluster 1 and points traffic to backend 1.
args1 = EdsResourceArgs({{"locality1", CreateEndpointsForBackends(1, 2)}});
balancer_->ads_service()->SetEdsResource(
BuildEdsResource(args1, kNewEdsServiceName1));
WaitForBackend(1);
WaitForBackend(DEBUG_LOCATION, 1);
}
TEST_P(AggregateClusterTest, RecursionDepthJustBelowMax) {
@ -836,7 +842,7 @@ TEST_P(AggregateClusterTest, RecursionDepthJustBelowMax) {
balancer_->ads_service()->SetCdsResource(cluster);
}
// RPCs should fail with the right status.
CheckRpcSendOk();
CheckRpcSendOk(DEBUG_LOCATION);
}
TEST_P(AggregateClusterTest, RecursionMaxDepth) {
@ -881,7 +887,7 @@ TEST_P(AggregateClusterTest, Disabled) {
custom_cluster->mutable_typed_config()->PackFrom(cluster_config);
cluster.set_type(Cluster::LOGICAL_DNS);
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("DiscoveryType is not valid."));

@ -52,9 +52,9 @@ TEST_P(XdsClientTest, ResourceWrappedInResourceMessage) {
// Make sure that trying to connect works without a call.
channel_->GetState(true /* try_to_connect */);
// We need to wait for all backends to come online.
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
// Send kNumRpcsPerAddress RPCs per server.
CheckRpcSendOk(kNumRpcsPerAddress * backends_.size());
CheckRpcSendOk(DEBUG_LOCATION, kNumRpcsPerAddress * backends_.size());
// Each backend should have gotten 100 requests.
for (size_t i = 0; i < backends_.size(); ++i) {
EXPECT_EQ(kNumRpcsPerAddress,
@ -70,7 +70,7 @@ TEST_P(XdsClientTest, ResourceTypeVersionPersistsAcrossStreamRestarts) {
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends(0, 1)}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Wait for backends to come online.
WaitForAllBackends(0, 1);
WaitForAllBackends(DEBUG_LOCATION, 0, 1);
// Stop balancer.
balancer_->Shutdown();
// Tell balancer to require minimum version 1 for all resource types.
@ -85,7 +85,7 @@ TEST_P(XdsClientTest, ResourceTypeVersionPersistsAcrossStreamRestarts) {
// Restart balancer.
balancer_->Start();
// Make sure client has reconnected.
WaitForAllBackends(1, 2);
WaitForAllBackends(DEBUG_LOCATION, 1, 2);
}
// Tests that we restart all xDS requests when we reestablish the ADS call.
@ -108,14 +108,14 @@ TEST_P(XdsClientTest, RestartsRequestsUponReconnection) {
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends(0, 1)}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// We need to wait for all backends to come online.
WaitForAllBackends(0, 1);
WaitForAllBackends(DEBUG_LOCATION, 0, 1);
// Now shut down and restart the balancer. When the client
// reconnects, it should automatically restart the requests for all
// resource types.
balancer_->Shutdown();
balancer_->Start();
// Make sure things are still working.
CheckRpcSendOk(100);
CheckRpcSendOk(DEBUG_LOCATION, 100);
// Populate new EDS resource.
args = EdsResourceArgs({{"locality0", CreateEndpointsForBackends(1, 2)}});
balancer_->ads_service()->SetEdsResource(
@ -134,7 +134,7 @@ TEST_P(XdsClientTest, RestartsRequestsUponReconnection) {
->set_cluster(kNewClusterName);
balancer_->ads_service()->SetRdsResource(new_route_config);
// Wait for all new backends to be used.
WaitForAllBackends(1, 2);
WaitForAllBackends(DEBUG_LOCATION, 1, 2);
}
// Tests that the NACK for multiple bad resources includes both errors.
@ -176,7 +176,7 @@ TEST_P(XdsClientTest, MultipleBadCdsResources) {
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Send RPC.
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -191,13 +191,16 @@ TEST_P(XdsClientTest, MultipleBadCdsResources) {
{"cluster", kDefaultClusterName},
};
CheckRpcSendOk(
1, RpcOptions().set_metadata(std::move(metadata_default_cluster)));
DEBUG_LOCATION, 1,
RpcOptions().set_metadata(std::move(metadata_default_cluster)));
// RPCs for cluster 2 should fail.
std::vector<std::pair<std::string, std::string>> metadata_cluster_2 = {
{"cluster", kClusterName2},
};
CheckRpcSendFailure(CheckRpcSendFailureOptions().set_rpc_options(
RpcOptions().set_metadata(std::move(metadata_cluster_2))));
CheckRpcSendFailure(
DEBUG_LOCATION,
CheckRpcSendFailureOptions().set_rpc_options(
RpcOptions().set_metadata(std::move(metadata_cluster_2))));
}
TEST_P(XdsClientTest, XdsStreamErrorPropagation) {
@ -236,7 +239,7 @@ TEST_P(GlobalXdsClientTest, MultipleChannelsShareXdsClient) {
default_route_config_);
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
// Create second channel and tell it to connect to kNewServerName.
auto channel2 = CreateChannel(/*failover_timeout_ms=*/0, kNewServerName);
channel2->GetState(/*try_to_connect=*/true);
@ -261,7 +264,7 @@ TEST_P(
balancer_->ads_service()->SetEdsResource(BuildEdsResource(EdsResourceArgs({
{"locality0", CreateEndpointsForBackends(0, 1)},
})));
WaitForBackend(0);
WaitForBackend(DEBUG_LOCATION, 0);
// Create second channel and tell it to connect to kNewServerName.
auto channel2 = CreateChannel(/*failover_timeout_ms=*/0, kNewServerName);
channel2->GetState(/*try_to_connect=*/true);
@ -277,7 +280,7 @@ TEST_P(
balancer_->ads_service()->SetEdsResource(BuildEdsResource(EdsResourceArgs({
{"locality0", CreateEndpointsForBackends(1, 2)},
})));
WaitForBackend(1);
WaitForBackend(DEBUG_LOCATION, 1);
}
// Tests that the NACK for multiple bad LDS resources includes both errors.
@ -299,7 +302,7 @@ TEST_P(GlobalXdsClientTest, MultipleBadLdsResources) {
default_route_config_);
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::ContainsRegex(absl::StrCat(
@ -317,7 +320,7 @@ TEST_P(GlobalXdsClientTest, MultipleBadLdsResources) {
grpc::Status status = stub2->Echo(&context, request, &response);
EXPECT_FALSE(status.ok());
// Wait for second NACK to be reported to xDS server.
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::ContainsRegex(absl::StrCat(
@ -352,19 +355,19 @@ TEST_P(GlobalXdsClientTest, InvalidListenerStillExistsIfPreviouslyCached) {
// Set up valid resources and check that the channel works.
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
CheckRpcSendOk();
CheckRpcSendOk(DEBUG_LOCATION);
// Now send an update changing the Listener to be invalid.
auto listener = default_listener_;
listener.clear_api_listener();
balancer_->ads_service()->SetLdsResource(listener);
const auto response_state = WaitForLdsNack(StatusCode::OK);
const auto response_state = WaitForLdsNack(DEBUG_LOCATION, StatusCode::OK);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::ContainsRegex(absl::StrCat(
kServerName,
": validation error.*"
"Listener has neither address nor ApiListener")));
CheckRpcSendOk();
CheckRpcSendOk(DEBUG_LOCATION);
}
//
@ -391,12 +394,12 @@ INSTANTIATE_TEST_SUITE_P(
TEST_P(TimeoutTest, LdsServerIgnoresRequest) {
balancer_->ads_service()->IgnoreResourceType(kLdsTypeUrl);
CheckRpcSendFailure();
CheckRpcSendFailure(DEBUG_LOCATION);
}
TEST_P(TimeoutTest, LdsResourceNotPresentInRequest) {
balancer_->ads_service()->UnsetResource(kLdsTypeUrl, kServerName);
CheckRpcSendFailure();
CheckRpcSendFailure(DEBUG_LOCATION);
}
TEST_P(TimeoutTest, LdsSecondResourceNotPresentInRequest) {
@ -407,7 +410,7 @@ TEST_P(TimeoutTest, LdsSecondResourceNotPresentInRequest) {
CreateAndStartBackends(1);
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
// Create second channel for a new server name.
// This should fail because there is no LDS resource for this server name.
auto channel2 =
@ -425,13 +428,13 @@ TEST_P(TimeoutTest, LdsSecondResourceNotPresentInRequest) {
TEST_P(TimeoutTest, RdsServerIgnoresRequest) {
balancer_->ads_service()->IgnoreResourceType(kRdsTypeUrl);
CheckRpcSendFailure();
CheckRpcSendFailure(DEBUG_LOCATION);
}
TEST_P(TimeoutTest, RdsResourceNotPresentInRequest) {
balancer_->ads_service()->UnsetResource(kRdsTypeUrl,
kDefaultRouteConfigurationName);
CheckRpcSendFailure();
CheckRpcSendFailure(DEBUG_LOCATION);
}
TEST_P(TimeoutTest, RdsSecondResourceNotPresentInRequest) {
@ -453,7 +456,7 @@ TEST_P(TimeoutTest, RdsSecondResourceNotPresentInRequest) {
rds->mutable_config_source()->mutable_self();
ClientHcmAccessor().Pack(http_connection_manager, &listener);
balancer_->ads_service()->SetLdsResource(listener);
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
// Create second channel for a new server name.
// This should fail because the LDS resource points to a non-existent RDS
// resource.
@ -471,19 +474,19 @@ TEST_P(TimeoutTest, RdsSecondResourceNotPresentInRequest) {
TEST_P(TimeoutTest, CdsServerIgnoresRequest) {
balancer_->ads_service()->IgnoreResourceType(kCdsTypeUrl);
CheckRpcSendFailure();
CheckRpcSendFailure(DEBUG_LOCATION);
}
TEST_P(TimeoutTest, CdsResourceNotPresentInRequest) {
balancer_->ads_service()->UnsetResource(kCdsTypeUrl, kDefaultClusterName);
CheckRpcSendFailure();
CheckRpcSendFailure(DEBUG_LOCATION);
}
TEST_P(TimeoutTest, CdsSecondResourceNotPresentInRequest) {
CreateAndStartBackends(1);
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
// Change route config to point to non-existing cluster.
const char* kNewClusterName = "new_cluster_name";
RouteConfiguration route_config = default_route_config_;
@ -508,20 +511,20 @@ TEST_P(TimeoutTest, CdsSecondResourceNotPresentInRequest) {
TEST_P(TimeoutTest, EdsServerIgnoresRequest) {
balancer_->ads_service()->IgnoreResourceType(kEdsTypeUrl);
CheckRpcSendFailure();
CheckRpcSendFailure(DEBUG_LOCATION);
}
TEST_P(TimeoutTest, EdsResourceNotPresentInRequest) {
// No need to remove EDS resource, since the test suite does not add it
// by default.
CheckRpcSendFailure();
CheckRpcSendFailure(DEBUG_LOCATION);
}
TEST_P(TimeoutTest, EdsSecondResourceNotPresentInRequest) {
CreateAndStartBackends(1);
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
// New cluster that points to a non-existant EDS resource.
const char* kNewClusterName = "new_cluster_name";
Cluster cluster = default_cluster_;
@ -567,7 +570,7 @@ TEST_P(BootstrapSourceTest, Vanilla) {
CreateAndStartBackends(1);
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
}
//
@ -657,7 +660,7 @@ TEST_P(XdsFederationTest, FederationTargetNoAuthorityWithResourceTemplate) {
listener.set_name(kNewListenerName);
SetListenerAndRouteConfiguration(authority_balancer_.get(), listener,
new_route_config);
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
}
// Channel is created with URI "xds://xds.example.com/server.example.com".
@ -710,7 +713,7 @@ TEST_P(XdsFederationTest, FederationTargetAuthorityDefaultResourceTemplate) {
SetListenerAndRouteConfiguration(authority_balancer_.get(), listener,
new_route_config);
// Ensure update has reached and send 10 RPCs to the current stub.
WaitForAllBackends(0, 1);
WaitForAllBackends(DEBUG_LOCATION, 0, 1);
// Create second channel to new target uri and send 1 RPC .
auto channel2 =
CreateChannel(/*failover_timeout_ms=*/0, kNewServerName, kAuthority);
@ -784,7 +787,7 @@ TEST_P(XdsFederationTest, FederationTargetAuthorityWithResourceTemplate) {
SetListenerAndRouteConfiguration(authority_balancer_.get(), listener,
new_route_config);
// Ensure update has reached and send 10 RPCs to the current stub.
WaitForAllBackends(0, 1);
WaitForAllBackends(DEBUG_LOCATION, 0, 1);
// Create second channel to new target uri and send 1 RPC .
auto channel2 =
CreateChannel(/*failover_timeout_ms=*/0, kNewServerName, kAuthority);
@ -873,7 +876,7 @@ TEST_P(XdsFederationTest, FederationServer) {
port);
authority_balancer_->ads_service()->SetLdsResource(server_listener);
}
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
}
//
@ -955,7 +958,7 @@ TEST_P(XdsFederationLoadReportingTest, FederationMultipleLoadReportingTest) {
SetListenerAndRouteConfiguration(authority_balancer_.get(), listener,
new_route_config);
// Ensure update has reached and send 10 RPCs to the current stub.
CheckRpcSendOk(kNumRpcsToDefaultBalancer);
CheckRpcSendOk(DEBUG_LOCATION, kNumRpcsToDefaultBalancer);
// Create second channel to new target uri and send 1 RPC .
auto channel2 =
CreateChannel(/*failover_timeout_ms=*/0, kNewServerName, kAuthority);
@ -1030,7 +1033,7 @@ TEST_P(SecureNamingTest, TargetNameIsExpected) {
{"locality0", CreateEndpointsForBackends()},
});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
CheckRpcSendOk();
CheckRpcSendOk(DEBUG_LOCATION);
}
// Tests that secure naming check fails if target name is unexpected.
@ -1045,7 +1048,7 @@ TEST_P(SecureNamingTest, TargetNameIsUnexpected) {
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Make sure that we blow up (via abort() from the security connector) when
// the name from the balancer doesn't match expectations.
ASSERT_DEATH_IF_SUPPORTED({ CheckRpcSendOk(); }, "");
ASSERT_DEATH_IF_SUPPORTED({ CheckRpcSendOk(DEBUG_LOCATION); }, "");
}
} // namespace

@ -338,7 +338,7 @@ TEST_P(ClientStatusDiscoveryServiceTest, XdsConfigDumpVanilla) {
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends(0, 1)}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Send several RPCs to ensure the xDS setup works
CheckRpcSendOk(kNumRpcs);
CheckRpcSendOk(DEBUG_LOCATION, kNumRpcs);
// Fetches the client config
auto csds_response = FetchCsdsResponse();
gpr_log(GPR_INFO, "xDS config dump: %s", csds_response.DebugString().c_str());
@ -406,13 +406,13 @@ TEST_P(ClientStatusDiscoveryServiceTest, XdsConfigDumpListenerError) {
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends(0, 1)}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Ensure the xDS resolver has working configs.
CheckRpcSendOk();
CheckRpcSendOk(DEBUG_LOCATION);
// Bad Listener should be rejected.
Listener listener;
listener.set_name(kServerName);
balancer_->ads_service()->SetLdsResource(listener);
// The old xDS configs should still be effective.
CheckRpcSendOk();
CheckRpcSendOk(DEBUG_LOCATION);
::testing::Matcher<google::protobuf::Any> api_listener_matcher;
if (GetParam().enable_rds_testing()) {
api_listener_matcher = IsRdsEnabledHCM();
@ -447,14 +447,14 @@ TEST_P(ClientStatusDiscoveryServiceTest, XdsConfigDumpRouteError) {
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends(0, 1)}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Ensure the xDS resolver has working configs.
CheckRpcSendOk();
CheckRpcSendOk(DEBUG_LOCATION);
// Bad route config will be rejected.
RouteConfiguration route_config;
route_config.set_name(kDefaultRouteConfigurationName);
route_config.add_virtual_hosts();
SetRouteConfiguration(balancer_.get(), route_config);
// The old xDS configs should still be effective.
CheckRpcSendOk();
CheckRpcSendOk(DEBUG_LOCATION);
for (int i = 0; i < kFetchConfigRetries; ++i) {
auto csds_response = FetchCsdsResponse();
bool ok = false;
@ -494,13 +494,13 @@ TEST_P(ClientStatusDiscoveryServiceTest, XdsConfigDumpClusterError) {
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends(0, 1)}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Ensure the xDS resolver has working configs.
CheckRpcSendOk();
CheckRpcSendOk(DEBUG_LOCATION);
// Listener without any route, will be rejected.
Cluster cluster;
cluster.set_name(kDefaultClusterName);
balancer_->ads_service()->SetCdsResource(cluster);
// The old xDS configs should still be effective.
CheckRpcSendOk();
CheckRpcSendOk(DEBUG_LOCATION);
for (int i = 0; i < kFetchConfigRetries; ++i) {
auto csds_response = FetchCsdsResponse();
// Check if error state is propagated
@ -526,7 +526,7 @@ TEST_P(ClientStatusDiscoveryServiceTest, XdsConfigDumpEndpointError) {
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends(0, 1)}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// Ensure the xDS resolver has working configs.
CheckRpcSendOk();
CheckRpcSendOk(DEBUG_LOCATION);
// Bad endpoint config will be rejected.
ClusterLoadAssignment cluster_load_assignment;
cluster_load_assignment.set_cluster_name(kDefaultEdsServiceName);
@ -536,7 +536,7 @@ TEST_P(ClientStatusDiscoveryServiceTest, XdsConfigDumpEndpointError) {
endpoint->mutable_address()->mutable_socket_address()->set_port_value(1 << 1);
balancer_->ads_service()->SetEdsResource(cluster_load_assignment);
// The old xDS configs should still be effective.
CheckRpcSendOk();
CheckRpcSendOk(DEBUG_LOCATION);
for (int i = 0; i < kFetchConfigRetries; ++i) {
auto csds_response = FetchCsdsResponse();
// Check if error state is propagated
@ -561,6 +561,7 @@ TEST_P(ClientStatusDiscoveryServiceTest, XdsConfigDumpListenerRequested) {
int kTimeoutMillisecond = 1000;
balancer_->ads_service()->UnsetResource(kLdsTypeUrl, kServerName);
CheckRpcSendFailure(
DEBUG_LOCATION,
CheckRpcSendFailureOptions()
.set_rpc_options(RpcOptions().set_timeout_ms(kTimeoutMillisecond))
.set_expected_error_code(StatusCode::DEADLINE_EXCEEDED));
@ -591,6 +592,7 @@ TEST_P(ClientStatusDiscoveryServiceTest, XdsConfigDumpClusterRequested) {
SetRouteConfiguration(balancer_.get(), route_config);
// Try to get the configs plumb through
CheckRpcSendFailure(
DEBUG_LOCATION,
CheckRpcSendFailureOptions()
.set_rpc_options(RpcOptions().set_timeout_ms(kTimeoutMillisecond))
.set_expected_error_code(StatusCode::DEADLINE_EXCEEDED));
@ -637,6 +639,7 @@ TEST_P(CsdsShortAdsTimeoutTest, XdsConfigDumpListenerDoesNotExist) {
int kTimeoutMillisecond = 1000000; // 1000s wait for the transient failure.
balancer_->ads_service()->UnsetResource(kLdsTypeUrl, kServerName);
CheckRpcSendFailure(
DEBUG_LOCATION,
CheckRpcSendFailureOptions()
.set_rpc_options(RpcOptions().set_timeout_ms(kTimeoutMillisecond))
.set_expected_error_code(grpc::StatusCode::UNAVAILABLE));
@ -653,6 +656,7 @@ TEST_P(CsdsShortAdsTimeoutTest, XdsConfigDumpRouteConfigDoesNotExist) {
balancer_->ads_service()->UnsetResource(kRdsTypeUrl,
kDefaultRouteConfigurationName);
CheckRpcSendFailure(
DEBUG_LOCATION,
CheckRpcSendFailureOptions()
.set_rpc_options(RpcOptions().set_timeout_ms(kTimeoutMillisecond))
.set_expected_error_code(grpc::StatusCode::UNAVAILABLE));
@ -668,6 +672,7 @@ TEST_P(CsdsShortAdsTimeoutTest, XdsConfigDumpClusterDoesNotExist) {
int kTimeoutMillisecond = 1000000; // 1000s wait for the transient failure.
balancer_->ads_service()->UnsetResource(kCdsTypeUrl, kDefaultClusterName);
CheckRpcSendFailure(
DEBUG_LOCATION,
CheckRpcSendFailureOptions()
.set_rpc_options(RpcOptions().set_timeout_ms(kTimeoutMillisecond))
.set_expected_error_code(grpc::StatusCode::UNAVAILABLE));
@ -682,6 +687,7 @@ TEST_P(CsdsShortAdsTimeoutTest, XdsConfigDumpEndpointDoesNotExist) {
int kTimeoutMillisecond = 1000000; // 1000s wait for the transient failure.
balancer_->ads_service()->UnsetResource(kEdsTypeUrl, kDefaultEdsServiceName);
CheckRpcSendFailure(
DEBUG_LOCATION,
CheckRpcSendFailureOptions()
.set_rpc_options(RpcOptions().set_timeout_ms(kTimeoutMillisecond))
.set_expected_error_code(grpc::StatusCode::UNAVAILABLE));

@ -366,7 +366,8 @@ class XdsSecurityTest : public XdsEnd2endTest {
continue;
}
} else {
WaitForBackend(0, WaitForBackendOptions().set_allow_failures(true));
WaitForBackend(DEBUG_LOCATION, 0,
WaitForBackendOptions().set_allow_failures(true));
Status status = SendRpc();
if (!status.ok()) {
gpr_log(GPR_ERROR, "RPC failed. code=%d message=%s Trying again.",
@ -412,7 +413,7 @@ TEST_P(XdsSecurityTest, UnknownTransportSocket) {
auto* transport_socket = cluster.mutable_transport_socket();
transport_socket->set_name("unknown_transport_socket");
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(
@ -425,7 +426,7 @@ TEST_P(XdsSecurityTest,
auto* transport_socket = cluster.mutable_transport_socket();
transport_socket->set_name("envoy.transport_sockets.tls");
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("TLS configuration provided but no "
@ -444,7 +445,7 @@ TEST_P(
*validation_context->add_match_subject_alt_names() = server_san_exact_;
transport_socket->mutable_typed_config()->PackFrom(upstream_tls_context);
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("TLS configuration provided but no "
@ -463,7 +464,7 @@ TEST_P(
->set_instance_name(std::string("fake_plugin1"));
transport_socket->mutable_typed_config()->PackFrom(upstream_tls_context);
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("TLS configuration provided but no "
@ -489,7 +490,7 @@ TEST_P(XdsSecurityTest, RegexSanMatcherDoesNotAllowIgnoreCase) {
*validation_context->add_match_subject_alt_names() = matcher;
transport_socket->mutable_typed_config()->PackFrom(upstream_tls_context);
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(
@ -507,7 +508,7 @@ TEST_P(XdsSecurityTest, UnknownRootCertificateProvider) {
->set_instance_name("unknown");
transport_socket->mutable_typed_config()->PackFrom(upstream_tls_context);
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(
@ -529,7 +530,7 @@ TEST_P(XdsSecurityTest, UnknownIdentityCertificateProvider) {
->set_instance_name("fake_plugin1");
transport_socket->mutable_typed_config()->PackFrom(upstream_tls_context);
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(
@ -552,7 +553,7 @@ TEST_P(XdsSecurityTest,
->add_verify_certificate_spki("spki");
transport_socket->mutable_typed_config()->PackFrom(upstream_tls_context);
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -576,7 +577,7 @@ TEST_P(XdsSecurityTest,
->add_verify_certificate_hash("hash");
transport_socket->mutable_typed_config()->PackFrom(upstream_tls_context);
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -601,7 +602,7 @@ TEST_P(XdsSecurityTest,
->set_value(true);
transport_socket->mutable_typed_config()->PackFrom(upstream_tls_context);
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -624,7 +625,7 @@ TEST_P(XdsSecurityTest, NacksCertificateValidationContextWithCrl) {
->mutable_crl();
transport_socket->mutable_typed_config()->PackFrom(upstream_tls_context);
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -647,7 +648,7 @@ TEST_P(XdsSecurityTest,
->mutable_custom_validator_config();
transport_socket->mutable_typed_config()->PackFrom(upstream_tls_context);
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -665,7 +666,7 @@ TEST_P(XdsSecurityTest, NacksValidationContextSdsSecretConfig) {
->mutable_validation_context_sds_secret_config();
transport_socket->mutable_typed_config()->PackFrom(upstream_tls_context);
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -685,7 +686,7 @@ TEST_P(XdsSecurityTest, NacksTlsParams) {
upstream_tls_context.mutable_common_tls_context()->mutable_tls_params();
transport_socket->mutable_typed_config()->PackFrom(upstream_tls_context);
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("tls_params unsupported"));
@ -705,7 +706,7 @@ TEST_P(XdsSecurityTest, NacksCustomHandshaker) {
->mutable_custom_handshaker();
transport_socket->mutable_typed_config()->PackFrom(upstream_tls_context);
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("custom_handshaker unsupported"));
@ -724,7 +725,7 @@ TEST_P(XdsSecurityTest, NacksTlsCertificates) {
upstream_tls_context.mutable_common_tls_context()->add_tls_certificates();
transport_socket->mutable_typed_config()->PackFrom(upstream_tls_context);
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("tls_certificates unsupported"));
@ -744,7 +745,7 @@ TEST_P(XdsSecurityTest, NacksTlsCertificateSdsSecretConfigs) {
->add_tls_certificate_sds_secret_configs();
transport_socket->mutable_typed_config()->PackFrom(upstream_tls_context);
balancer_->ads_service()->SetCdsResource(cluster);
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -764,7 +765,8 @@ TEST_P(XdsSecurityTest, TestTlsConfigurationInCombinedValidationContext) {
->set_instance_name("fake_plugin1");
transport_socket->mutable_typed_config()->PackFrom(upstream_tls_context);
balancer_->ads_service()->SetCdsResource(cluster);
WaitForBackend(0, WaitForBackendOptions().set_allow_failures(true));
WaitForBackend(DEBUG_LOCATION, 0,
WaitForBackendOptions().set_allow_failures(true));
Status status = SendRpc();
EXPECT_TRUE(status.ok()) << "code=" << status.error_code()
<< " message=" << status.error_message();
@ -784,7 +786,8 @@ TEST_P(XdsSecurityTest,
->set_instance_name("fake_plugin1");
transport_socket->mutable_typed_config()->PackFrom(upstream_tls_context);
balancer_->ads_service()->SetCdsResource(cluster);
WaitForBackend(0, WaitForBackendOptions().set_allow_failures(true));
WaitForBackend(DEBUG_LOCATION, 0,
WaitForBackendOptions().set_allow_failures(true));
Status status = SendRpc();
EXPECT_TRUE(status.ok()) << "code=" << status.error_code()
<< " message=" << status.error_message();
@ -1058,7 +1061,7 @@ class XdsEnabledServerTest : public XdsEnd2endTest {
TEST_P(XdsEnabledServerTest, Basic) {
backends_[0]->Start();
WaitForBackend(0);
WaitForBackend(DEBUG_LOCATION, 0);
}
TEST_P(XdsEnabledServerTest, BadLdsUpdateNoApiListenerNorAddress) {
@ -1069,7 +1072,7 @@ TEST_P(XdsEnabledServerTest, BadLdsUpdateNoApiListenerNorAddress) {
ipv6_only_ ? "[::1]:" : "127.0.0.1:", backends_[0]->port()));
balancer_->ads_service()->SetLdsResource(listener);
backends_[0]->Start();
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -1083,7 +1086,7 @@ TEST_P(XdsEnabledServerTest, BadLdsUpdateBothApiListenerAndAddress) {
backends_[0]->port(),
default_server_route_config_);
backends_[0]->Start();
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -1100,7 +1103,7 @@ TEST_P(XdsEnabledServerTest, NacksNonZeroXffNumTrusterHops) {
backends_[0]->port(),
default_server_route_config_);
backends_[0]->Start();
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("'xff_num_trusted_hops' must be zero"));
@ -1116,7 +1119,7 @@ TEST_P(XdsEnabledServerTest, NacksNonEmptyOriginalIpDetectionExtensions) {
backends_[0]->port(),
default_server_route_config_);
backends_[0]->Start();
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -1130,7 +1133,7 @@ TEST_P(XdsEnabledServerTest, UnsupportedL4Filter) {
balancer_->ads_service()->SetLdsResource(
PopulateServerListenerNameAndPort(listener, backends_[0]->port()));
backends_[0]->Start();
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("Unsupported filter type"));
@ -1146,7 +1149,7 @@ TEST_P(XdsEnabledServerTest, NacksEmptyHttpFilterList) {
backends_[0]->port(),
default_server_route_config_);
backends_[0]->Start();
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("Expected at least one HTTP filter"));
@ -1170,7 +1173,7 @@ TEST_P(XdsEnabledServerTest, UnsupportedHttpFilter) {
backends_[0]->port(),
default_server_route_config_);
backends_[0]->Start();
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("no filter registered for config type "
@ -1195,7 +1198,7 @@ TEST_P(XdsEnabledServerTest, HttpFilterNotSupportedOnServer) {
backends_[0]->port(),
default_server_route_config_);
backends_[0]->Start();
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -1223,7 +1226,7 @@ TEST_P(XdsEnabledServerTest,
backends_[0]->port(),
default_server_route_config_);
backends_[0]->Start();
WaitForBackend(0);
WaitForBackend(DEBUG_LOCATION, 0);
auto response_state = balancer_->ads_service()->lds_response_state();
ASSERT_TRUE(response_state.has_value());
EXPECT_EQ(response_state->state, AdsServiceImpl::ResponseState::ACKED);
@ -1252,7 +1255,7 @@ TEST_P(XdsEnabledServerTest, UseOriginalDstNotSupported) {
backends_[0]->port(),
default_server_route_config_);
backends_[0]->Start();
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -1494,7 +1497,7 @@ TEST_P(XdsServerSecurityTest, UnknownTransportSocket) {
backends_[0]->port(),
default_server_route_config_);
backends_[0]->Start();
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(
@ -1516,7 +1519,7 @@ TEST_P(XdsServerSecurityTest, NacksRequireSNI) {
backends_[0]->port(),
default_server_route_config_);
backends_[0]->Start();
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("require_sni: unsupported"));
@ -1539,7 +1542,7 @@ TEST_P(XdsServerSecurityTest, NacksOcspStaplePolicyOtherThanLenientStapling) {
backends_[0]->port(),
default_server_route_config_);
backends_[0]->Start();
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(
@ -1563,7 +1566,7 @@ TEST_P(
backends_[0]->port(),
default_server_route_config_);
backends_[0]->Start();
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(
@ -1583,7 +1586,7 @@ TEST_P(XdsServerSecurityTest,
backends_[0]->port(),
default_server_route_config_);
backends_[0]->Start();
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("TLS configuration provided but no "
@ -1608,7 +1611,7 @@ TEST_P(XdsServerSecurityTest, NacksMatchSubjectAltNames) {
backends_[0]->port(),
default_server_route_config_);
backends_[0]->Start();
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -1620,7 +1623,7 @@ TEST_P(XdsServerSecurityTest, UnknownIdentityCertificateProvider) {
SendRpc([this]() { return CreateTlsChannel(); }, {}, {},
true /* test_expects_failure */);
backends_[0]->Start();
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(
@ -1631,7 +1634,7 @@ TEST_P(XdsServerSecurityTest, UnknownRootCertificateProvider) {
g_fake1_cert_data_map->Set({{"", {root_cert_, identity_pair_}}});
SetLdsUpdate("unknown", "", "fake_plugin1", "", false);
backends_[0]->Start();
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(
@ -2404,7 +2407,7 @@ TEST_P(XdsServerFilterChainMatchTest, DuplicateMatchNacked) {
backends_[0]->port(),
default_server_route_config_);
backends_[0]->Start();
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -2442,7 +2445,7 @@ TEST_P(XdsServerFilterChainMatchTest, DuplicateMatchOnPrefixRangesNacked) {
backends_[0]->port(),
default_server_route_config_);
backends_[0]->Start();
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
if (ipv6_only_) {
EXPECT_THAT(
@ -2480,7 +2483,7 @@ TEST_P(XdsServerFilterChainMatchTest, DuplicateMatchOnTransportProtocolNacked) {
backends_[0]->port(),
default_server_route_config_);
backends_[0]->Start();
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -2506,7 +2509,7 @@ TEST_P(XdsServerFilterChainMatchTest, DuplicateMatchOnLocalSourceTypeNacked) {
backends_[0]->port(),
default_server_route_config_);
backends_[0]->Start();
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -2533,7 +2536,7 @@ TEST_P(XdsServerFilterChainMatchTest,
backends_[0]->port(),
default_server_route_config_);
backends_[0]->Start();
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -2572,7 +2575,7 @@ TEST_P(XdsServerFilterChainMatchTest,
backends_[0]->port(),
default_server_route_config_);
backends_[0]->Start();
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
if (ipv6_only_) {
EXPECT_THAT(
@ -2608,7 +2611,7 @@ TEST_P(XdsServerFilterChainMatchTest, DuplicateMatchOnSourcePortNacked) {
backends_[0]->port(),
default_server_route_config_);
backends_[0]->Start();
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -2638,7 +2641,7 @@ TEST_P(XdsServerRdsTest, NacksInvalidDomainPattern) {
balancer_.get(), default_server_listener_, backends_[0]->port(),
route_config);
backends_[0]->Start();
const auto response_state = WaitForRouteConfigNack();
const auto response_state = WaitForRouteConfigNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("Invalid domain pattern \"\""));
@ -2651,7 +2654,7 @@ TEST_P(XdsServerRdsTest, NacksEmptyDomainsList) {
balancer_.get(), default_server_listener_, backends_[0]->port(),
route_config);
backends_[0]->Start();
const auto response_state = WaitForRouteConfigNack();
const auto response_state = WaitForRouteConfigNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("VirtualHost has no domains"));
@ -2664,7 +2667,7 @@ TEST_P(XdsServerRdsTest, NacksEmptyRoutesList) {
balancer_.get(), default_server_listener_, backends_[0]->port(),
route_config);
backends_[0]->Start();
const auto response_state = WaitForRouteConfigNack();
const auto response_state = WaitForRouteConfigNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("No route found in the virtual host"));
@ -2681,7 +2684,7 @@ TEST_P(XdsServerRdsTest, NacksEmptyMatch) {
balancer_.get(), default_server_listener_, backends_[0]->port(),
route_config);
backends_[0]->Start();
const auto response_state = WaitForRouteConfigNack();
const auto response_state = WaitForRouteConfigNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("Match can't be null"));
@ -2890,12 +2893,12 @@ TEST_P(XdsRbacNackTest, NacksSchemePrincipalHeader) {
if (GetParam().enable_rds_testing() &&
GetParam().filter_config_setup() ==
XdsTestType::HttpFilterConfigLocation::kHttpFilterConfigInRoute) {
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("':scheme' not allowed in header"));
} else {
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("':scheme' not allowed in header"));
@ -2917,12 +2920,12 @@ TEST_P(XdsRbacNackTest, NacksGrpcPrefixedPrincipalHeaders) {
if (GetParam().enable_rds_testing() &&
GetParam().filter_config_setup() ==
XdsTestType::HttpFilterConfigLocation::kHttpFilterConfigInRoute) {
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("'grpc-' prefixes not allowed in header"));
} else {
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("'grpc-' prefixes not allowed in header"));
@ -2944,12 +2947,12 @@ TEST_P(XdsRbacNackTest, NacksSchemePermissionHeader) {
if (GetParam().enable_rds_testing() &&
GetParam().filter_config_setup() ==
XdsTestType::HttpFilterConfigLocation::kHttpFilterConfigInRoute) {
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("':scheme' not allowed in header"));
} else {
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("':scheme' not allowed in header"));
@ -2971,12 +2974,12 @@ TEST_P(XdsRbacNackTest, NacksGrpcPrefixedPermissionHeaders) {
if (GetParam().enable_rds_testing() &&
GetParam().filter_config_setup() ==
XdsTestType::HttpFilterConfigLocation::kHttpFilterConfigInRoute) {
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("'grpc-' prefixes not allowed in header"));
} else {
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("'grpc-' prefixes not allowed in header"));

@ -822,34 +822,39 @@ Status XdsEnd2endTest::SendRpc(const RpcOptions& rpc_options,
return status;
}
void XdsEnd2endTest::CheckRpcSendOk(const size_t times,
const RpcOptions& rpc_options) {
void XdsEnd2endTest::CheckRpcSendOk(
const grpc_core::DebugLocation& debug_location, const size_t times,
const RpcOptions& rpc_options) {
for (size_t i = 0; i < times; ++i) {
EchoResponse response;
const Status status = SendRpc(rpc_options, &response);
EXPECT_TRUE(status.ok()) << "code=" << status.error_code()
<< " message=" << status.error_message();
EXPECT_TRUE(status.ok())
<< "code=" << status.error_code()
<< " message=" << status.error_message() << " at "
<< debug_location.file() << ":" << debug_location.line();
EXPECT_EQ(response.message(), kRequestMessage);
}
}
void XdsEnd2endTest::CheckRpcSendFailure(
const grpc_core::DebugLocation& debug_location,
const CheckRpcSendFailureOptions& options) {
for (size_t i = 0; options.continue_predicate(i); ++i) {
const Status status = SendRpc(options.rpc_options);
EXPECT_FALSE(status.ok());
EXPECT_FALSE(status.ok())
<< " at " << debug_location.file() << ":" << debug_location.line();
if (options.expected_error_code != StatusCode::OK) {
EXPECT_EQ(options.expected_error_code, status.error_code())
<< "code=" << status.error_code()
<< " message=" << status.error_message();
;
<< " message=" << status.error_message() << " at "
<< debug_location.file() << ":" << debug_location.line();
}
}
}
size_t XdsEnd2endTest::SendRpcsAndCountFailuresWithMessage(
size_t num_rpcs, const char* drop_error_message_prefix,
const RpcOptions& rpc_options) {
const grpc_core::DebugLocation& debug_location, size_t num_rpcs,
const char* drop_error_message_prefix, const RpcOptions& rpc_options) {
size_t num_failed = 0;
for (size_t i = 0; i < num_rpcs; ++i) {
Status status = SendRpc(rpc_options);
@ -857,7 +862,8 @@ size_t XdsEnd2endTest::SendRpcsAndCountFailuresWithMessage(
EXPECT_THAT(status.error_message(),
::testing::StartsWith(drop_error_message_prefix))
<< "code=" << status.error_code()
<< " message=" << status.error_message();
<< " message=" << status.error_message() << " at "
<< debug_location.file() << ":" << debug_location.line();
++num_failed;
}
}
@ -885,6 +891,7 @@ Status XdsEnd2endTest::LongRunningRpc::GetStatus() {
}
std::vector<XdsEnd2endTest::ConcurrentRpc> XdsEnd2endTest::SendConcurrentRpcs(
const grpc_core::DebugLocation& debug_location,
grpc::testing::EchoTestService::Stub* stub, size_t num_rpcs,
const RpcOptions& rpc_options) {
// Variables for RPCs.
@ -915,13 +922,15 @@ std::vector<XdsEnd2endTest::ConcurrentRpc> XdsEnd2endTest::SendConcurrentRpcs(
grpc_core::MutexLock lock(&mu);
cv.Wait(&mu);
}
EXPECT_EQ(completed, num_rpcs);
EXPECT_EQ(completed, num_rpcs)
<< " at " << debug_location.file() << ":" << debug_location.line();
return rpcs;
}
size_t XdsEnd2endTest::WaitForAllBackends(
size_t start_index, size_t stop_index,
const WaitForBackendOptions& wait_options, const RpcOptions& rpc_options) {
const grpc_core::DebugLocation& debug_location, size_t start_index,
size_t stop_index, const WaitForBackendOptions& wait_options,
const RpcOptions& rpc_options) {
size_t num_rpcs = 0;
auto deadline = absl::Now() + (absl::Milliseconds(wait_options.timeout_ms) *
grpc_test_slowdown_factor());
@ -932,10 +941,13 @@ size_t XdsEnd2endTest::WaitForAllBackends(
while (!SeenAllBackends(start_index, stop_index, rpc_options.service)) {
Status status = SendRpc(rpc_options);
if (!wait_options.allow_failures) {
EXPECT_TRUE(status.ok()) << "code=" << status.error_code()
<< " message=" << status.error_message();
EXPECT_TRUE(status.ok())
<< "code=" << status.error_code()
<< " message=" << status.error_message() << " at "
<< debug_location.file() << ":" << debug_location.line();
}
EXPECT_LE(absl::Now(), deadline);
EXPECT_LE(absl::Now(), deadline)
<< " at " << debug_location.file() << ":" << debug_location.line();
if (absl::Now() >= deadline) break;
++num_rpcs;
}
@ -946,6 +958,7 @@ size_t XdsEnd2endTest::WaitForAllBackends(
}
absl::optional<AdsServiceImpl::ResponseState> XdsEnd2endTest::WaitForNack(
const grpc_core::DebugLocation& debug_location,
std::function<absl::optional<AdsServiceImpl::ResponseState>()> get_state,
StatusCode expected_status) {
absl::optional<AdsServiceImpl::ResponseState> response_state;
@ -962,8 +975,8 @@ absl::optional<AdsServiceImpl::ResponseState> XdsEnd2endTest::WaitForNack(
const Status status = SendRpc();
EXPECT_EQ(expected_status, status.error_code())
<< "code=" << status.error_code()
<< " message=" << status.error_message();
;
<< " message=" << status.error_message() << " at "
<< debug_location.file() << ":" << debug_location.line();
} while (continue_predicate());
return response_state;
}

@ -800,7 +800,8 @@ class XdsEnd2endTest : public ::testing::TestWithParam<XdsTestType> {
}
// Sends the specified number of RPCs and fails if the RPC fails.
void CheckRpcSendOk(const size_t times = 1,
void CheckRpcSendOk(const grpc_core::DebugLocation& debug_location,
const size_t times = 1,
const RpcOptions& rpc_options = RpcOptions());
// Options to use with CheckRpcSendFailure().
@ -837,13 +838,15 @@ class XdsEnd2endTest : public ::testing::TestWithParam<XdsTestType> {
// Sends RPCs and expects them to fail.
void CheckRpcSendFailure(
const grpc_core::DebugLocation& debug_location,
const CheckRpcSendFailureOptions& options = CheckRpcSendFailureOptions());
// Sends num_rpcs RPCs, counting how many of them fail with a message
// matching the specfied drop_error_message_prefix.
// Any failure with a non-matching message is a test failure.
size_t SendRpcsAndCountFailuresWithMessage(
size_t num_rpcs, const char* drop_error_message_prefix,
const grpc_core::DebugLocation& debug_location, size_t num_rpcs,
const char* drop_error_message_prefix,
const RpcOptions& rpc_options = RpcOptions());
// A class for running a long-running RPC in its own thread.
@ -878,6 +881,7 @@ class XdsEnd2endTest : public ::testing::TestWithParam<XdsTestType> {
EchoResponse response;
};
std::vector<ConcurrentRpc> SendConcurrentRpcs(
const grpc_core::DebugLocation& debug_location,
grpc::testing::EchoTestService::Stub* stub, size_t num_rpcs,
const RpcOptions& rpc_options);
@ -914,16 +918,18 @@ class XdsEnd2endTest : public ::testing::TestWithParam<XdsTestType> {
// Sends RPCs until all of the backends in the specified range see requests.
// Returns the total number of RPCs sent.
size_t WaitForAllBackends(
size_t start_index = 0, size_t stop_index = 0,
const grpc_core::DebugLocation& debug_location, size_t start_index = 0,
size_t stop_index = 0,
const WaitForBackendOptions& wait_options = WaitForBackendOptions(),
const RpcOptions& rpc_options = RpcOptions());
// Sends RPCs until the backend at index backend_idx sees requests.
void WaitForBackend(
size_t backend_idx,
const grpc_core::DebugLocation& debug_location, size_t backend_idx,
const WaitForBackendOptions& wait_options = WaitForBackendOptions(),
const RpcOptions& rpc_options = RpcOptions()) {
WaitForAllBackends(backend_idx, backend_idx + 1, wait_options, rpc_options);
WaitForAllBackends(debug_location, backend_idx, backend_idx + 1,
wait_options, rpc_options);
}
//
@ -934,47 +940,57 @@ class XdsEnd2endTest : public ::testing::TestWithParam<XdsTestType> {
// Sends RPCs until get_state() returns a response.
absl::optional<AdsServiceImpl::ResponseState> WaitForNack(
const grpc_core::DebugLocation& debug_location,
std::function<absl::optional<AdsServiceImpl::ResponseState>()> get_state,
StatusCode expected_status = StatusCode::UNAVAILABLE);
// Sends RPCs until an LDS NACK is seen.
absl::optional<AdsServiceImpl::ResponseState> WaitForLdsNack(
const grpc_core::DebugLocation& debug_location,
StatusCode expected_status = StatusCode::UNAVAILABLE) {
return WaitForNack(
debug_location,
[&]() { return balancer_->ads_service()->lds_response_state(); },
expected_status);
}
// Sends RPCs until an RDS NACK is seen.
absl::optional<AdsServiceImpl::ResponseState> WaitForRdsNack(
const grpc_core::DebugLocation& debug_location,
StatusCode expected_status = StatusCode::UNAVAILABLE) {
return WaitForNack(
debug_location,
[&]() { return RouteConfigurationResponseState(balancer_.get()); },
expected_status);
}
// Sends RPCs until a CDS NACK is seen.
absl::optional<AdsServiceImpl::ResponseState> WaitForCdsNack(
const grpc_core::DebugLocation& debug_location,
StatusCode expected_status = StatusCode::UNAVAILABLE) {
return WaitForNack(
debug_location,
[&]() { return balancer_->ads_service()->cds_response_state(); },
expected_status);
}
// Sends RPCs until an EDS NACK is seen.
absl::optional<AdsServiceImpl::ResponseState> WaitForEdsNack() {
return WaitForNack(
[&]() { return balancer_->ads_service()->eds_response_state(); });
absl::optional<AdsServiceImpl::ResponseState> WaitForEdsNack(
const grpc_core::DebugLocation& debug_location) {
return WaitForNack(debug_location, [&]() {
return balancer_->ads_service()->eds_response_state();
});
}
// Convenient front-end to wait for RouteConfiguration to be NACKed,
// regardless of whether it's sent in LDS or RDS.
absl::optional<AdsServiceImpl::ResponseState> WaitForRouteConfigNack(
const grpc_core::DebugLocation& debug_location,
StatusCode expected_status = StatusCode::UNAVAILABLE) {
if (GetParam().enable_rds_testing()) {
return WaitForRdsNack(expected_status);
return WaitForRdsNack(debug_location, expected_status);
}
return WaitForLdsNack(expected_status);
return WaitForLdsNack(debug_location, expected_status);
}
// Convenient front-end for accessing xDS response state for a

@ -117,6 +117,7 @@ TEST_P(FaultInjectionTest, XdsFaultInjectionAlwaysAbort) {
SetFilterConfig(http_fault);
// Fire several RPCs, and expect all of them to be aborted.
CheckRpcSendFailure(
DEBUG_LOCATION,
CheckRpcSendFailureOptions()
.set_times(5)
.set_rpc_options(RpcOptions().set_wait_for_ready(true))
@ -142,7 +143,7 @@ TEST_P(FaultInjectionTest, XdsFaultInjectionWithoutListenerFilter) {
BuildRouteConfigurationWithFaultInjection(http_fault);
SetListenerAndRouteConfiguration(balancer_.get(), default_listener_, route);
// Fire several RPCs, and expect all of them to be pass.
CheckRpcSendOk(5, RpcOptions().set_wait_for_ready(true));
CheckRpcSendOk(DEBUG_LOCATION, 5, RpcOptions().set_wait_for_ready(true));
}
TEST_P(FaultInjectionTest, XdsFaultInjectionPercentageAbort) {
@ -164,8 +165,8 @@ TEST_P(FaultInjectionTest, XdsFaultInjectionPercentageAbort) {
// Config fault injection via different setup
SetFilterConfig(http_fault);
// Send kNumRpcs RPCs and count the aborts.
size_t num_aborted =
SendRpcsAndCountFailuresWithMessage(kNumRpcs, "Fault injected");
size_t num_aborted = SendRpcsAndCountFailuresWithMessage(
DEBUG_LOCATION, kNumRpcs, "Fault injected");
// The abort rate should be roughly equal to the expectation.
const double seen_abort_rate = static_cast<double>(num_aborted) / kNumRpcs;
EXPECT_THAT(seen_abort_rate,
@ -195,7 +196,8 @@ TEST_P(FaultInjectionTest, XdsFaultInjectionPercentageAbortViaHeaders) {
{"x-envoy-fault-abort-percentage", std::to_string(kAbortPercentage)},
};
size_t num_aborted = SendRpcsAndCountFailuresWithMessage(
kNumRpcs, "Fault injected", RpcOptions().set_metadata(metadata));
DEBUG_LOCATION, kNumRpcs, "Fault injected",
RpcOptions().set_metadata(metadata));
// The abort rate should be roughly equal to the expectation.
const double seen_abort_rate = static_cast<double>(num_aborted) / kNumRpcs;
EXPECT_THAT(seen_abort_rate,
@ -234,7 +236,7 @@ TEST_P(FaultInjectionTest, XdsFaultInjectionPercentageDelay) {
.set_timeout_ms(kRpcTimeoutMilliseconds)
.set_skip_cancelled_check(true);
std::vector<ConcurrentRpc> rpcs =
SendConcurrentRpcs(stub_.get(), kNumRpcs, rpc_options);
SendConcurrentRpcs(DEBUG_LOCATION, stub_.get(), kNumRpcs, rpc_options);
size_t num_delayed = 0;
for (auto& rpc : rpcs) {
if (rpc.status.error_code() == StatusCode::OK) continue;
@ -284,7 +286,7 @@ TEST_P(FaultInjectionTest, XdsFaultInjectionPercentageDelayViaHeaders) {
.set_timeout_ms(kRpcTimeoutMilliseconds)
.set_skip_cancelled_check(true);
std::vector<ConcurrentRpc> rpcs =
SendConcurrentRpcs(stub_.get(), kNumRpcs, rpc_options);
SendConcurrentRpcs(DEBUG_LOCATION, stub_.get(), kNumRpcs, rpc_options);
size_t num_delayed = 0;
for (auto& rpc : rpcs) {
if (rpc.status.error_code() == StatusCode::OK) continue;
@ -373,7 +375,7 @@ TEST_P(FaultInjectionTest, XdsFaultInjectionAlwaysDelayPercentageAbort) {
int num_aborted = 0;
RpcOptions rpc_options = RpcOptions().set_timeout_ms(kRpcTimeoutMilliseconds);
std::vector<ConcurrentRpc> rpcs =
SendConcurrentRpcs(stub_.get(), kNumRpcs, rpc_options);
SendConcurrentRpcs(DEBUG_LOCATION, stub_.get(), kNumRpcs, rpc_options);
for (auto& rpc : rpcs) {
EXPECT_GE(rpc.elapsed_time,
grpc_core::Duration::Seconds(kFixedDelaySeconds));
@ -434,7 +436,7 @@ TEST_P(FaultInjectionTest,
int num_aborted = 0;
RpcOptions rpc_options = RpcOptions().set_timeout_ms(kRpcTimeoutMilliseconds);
std::vector<ConcurrentRpc> rpcs =
SendConcurrentRpcs(stub_.get(), kNumRpcs, rpc_options);
SendConcurrentRpcs(DEBUG_LOCATION, stub_.get(), kNumRpcs, rpc_options);
for (auto& rpc : rpcs) {
EXPECT_GE(rpc.elapsed_time,
grpc_core::Duration::Seconds(kFixedDelaySeconds));
@ -474,7 +476,7 @@ TEST_P(FaultInjectionTest, XdsFaultInjectionMaxFault) {
int num_delayed = 0;
RpcOptions rpc_options = RpcOptions().set_timeout_ms(kRpcTimeoutMs);
std::vector<ConcurrentRpc> rpcs =
SendConcurrentRpcs(stub_.get(), kNumRpcs, rpc_options);
SendConcurrentRpcs(DEBUG_LOCATION, stub_.get(), kNumRpcs, rpc_options);
for (auto& rpc : rpcs) {
if (rpc.status.error_code() == StatusCode::OK) continue;
EXPECT_EQ(StatusCode::DEADLINE_EXCEEDED, rpc.status.error_code());
@ -485,7 +487,7 @@ TEST_P(FaultInjectionTest, XdsFaultInjectionMaxFault) {
// Conduct one more round of RPCs after previous calls are finished. The goal
// is to validate if the max fault counter is restored to zero.
num_delayed = 0;
rpcs = SendConcurrentRpcs(stub_.get(), kNumRpcs, rpc_options);
rpcs = SendConcurrentRpcs(DEBUG_LOCATION, stub_.get(), kNumRpcs, rpc_options);
for (auto& rpc : rpcs) {
if (rpc.status.error_code() == StatusCode::OK) continue;
EXPECT_EQ(StatusCode::DEADLINE_EXCEEDED, rpc.status.error_code());

@ -135,7 +135,7 @@ TEST_P(RingHashTest, AggregateClusterFallBackFromRingHashAtStartup) {
new_route_config);
// Verifying that we are using ring hash as only 1 endpoint is receiving all
// the traffic.
CheckRpcSendOk(100);
CheckRpcSendOk(DEBUG_LOCATION, 100);
bool found = false;
for (size_t i = 0; i < backends_.size(); ++i) {
if (backends_[i]->backend_service()->request_count() > 0) {
@ -215,7 +215,7 @@ TEST_P(RingHashTest,
delay_injector.Start();
// Send RPC. Need the timeout to be long enough to account for the
// subchannel connection delays.
CheckRpcSendOk(1, RpcOptions().set_timeout_ms(5000));
CheckRpcSendOk(DEBUG_LOCATION, 1, RpcOptions().set_timeout_ms(5000));
}
// Tests that ring hash policy that hashes using channel id ensures all RPCs
@ -233,7 +233,7 @@ TEST_P(RingHashTest, ChannelIdHashing) {
new_route_config);
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
CheckRpcSendOk(100);
CheckRpcSendOk(DEBUG_LOCATION, 100);
bool found = false;
for (size_t i = 0; i < backends_.size(); ++i) {
if (backends_[i]->backend_service()->request_count() > 0) {
@ -276,14 +276,14 @@ TEST_P(RingHashTest, HeaderHashing) {
const auto rpc_options1 = RpcOptions().set_metadata(std::move(metadata1));
const auto rpc_options2 = RpcOptions().set_metadata(std::move(metadata2));
const auto rpc_options3 = RpcOptions().set_metadata(std::move(metadata3));
WaitForBackend(0, WaitForBackendOptions(), rpc_options);
WaitForBackend(1, WaitForBackendOptions(), rpc_options1);
WaitForBackend(2, WaitForBackendOptions(), rpc_options2);
WaitForBackend(3, WaitForBackendOptions(), rpc_options3);
CheckRpcSendOk(100, rpc_options);
CheckRpcSendOk(100, rpc_options1);
CheckRpcSendOk(100, rpc_options2);
CheckRpcSendOk(100, rpc_options3);
WaitForBackend(DEBUG_LOCATION, 0, WaitForBackendOptions(), rpc_options);
WaitForBackend(DEBUG_LOCATION, 1, WaitForBackendOptions(), rpc_options1);
WaitForBackend(DEBUG_LOCATION, 2, WaitForBackendOptions(), rpc_options2);
WaitForBackend(DEBUG_LOCATION, 3, WaitForBackendOptions(), rpc_options3);
CheckRpcSendOk(DEBUG_LOCATION, 100, rpc_options);
CheckRpcSendOk(DEBUG_LOCATION, 100, rpc_options1);
CheckRpcSendOk(DEBUG_LOCATION, 100, rpc_options2);
CheckRpcSendOk(DEBUG_LOCATION, 100, rpc_options3);
for (size_t i = 0; i < backends_.size(); ++i) {
EXPECT_EQ(100, backends_[i]->backend_service()->request_count());
}
@ -322,10 +322,10 @@ TEST_P(RingHashTest, HeaderHashingWithRegexRewrite) {
const auto rpc_options1 = RpcOptions().set_metadata(std::move(metadata1));
const auto rpc_options2 = RpcOptions().set_metadata(std::move(metadata2));
const auto rpc_options3 = RpcOptions().set_metadata(std::move(metadata3));
CheckRpcSendOk(100, rpc_options);
CheckRpcSendOk(100, rpc_options1);
CheckRpcSendOk(100, rpc_options2);
CheckRpcSendOk(100, rpc_options3);
CheckRpcSendOk(DEBUG_LOCATION, 100, rpc_options);
CheckRpcSendOk(DEBUG_LOCATION, 100, rpc_options1);
CheckRpcSendOk(DEBUG_LOCATION, 100, rpc_options2);
CheckRpcSendOk(DEBUG_LOCATION, 100, rpc_options3);
bool found = false;
for (size_t i = 0; i < backends_.size(); ++i) {
if (backends_[i]->backend_service()->request_count() > 0) {
@ -356,9 +356,9 @@ TEST_P(RingHashTest, NoHashPolicy) {
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// TODO(donnadionne): remove extended timeout after ring creation
// optimization.
WaitForAllBackends(0, 2, WaitForBackendOptions(),
WaitForAllBackends(DEBUG_LOCATION, 0, 2, WaitForBackendOptions(),
RpcOptions().set_timeout_ms(kRpcTimeoutMs));
CheckRpcSendOk(kNumRpcs);
CheckRpcSendOk(DEBUG_LOCATION, kNumRpcs);
const int request_count_1 = backends_[0]->backend_service()->request_count();
const int request_count_2 = backends_[1]->backend_service()->request_count();
EXPECT_THAT(static_cast<double>(request_count_1) / kNumRpcs,
@ -388,7 +388,7 @@ TEST_P(RingHashTest, ContinuesPastTerminalPolicyThatDoesNotProduceResult) {
std::vector<std::pair<std::string, std::string>> metadata = {
{"address_hash", CreateMetadataValueThatHashesToBackend(0)}};
const auto rpc_options = RpcOptions().set_metadata(std::move(metadata));
CheckRpcSendOk(100, rpc_options);
CheckRpcSendOk(DEBUG_LOCATION, 100, rpc_options);
EXPECT_EQ(backends_[0]->backend_service()->request_count(), 100);
EXPECT_EQ(backends_[1]->backend_service()->request_count(), 0);
}
@ -422,9 +422,9 @@ TEST_P(RingHashTest, HashOnHeaderThatIsNotPresent) {
const auto rpc_options = RpcOptions().set_metadata(std::move(metadata));
// TODO(donnadionne): remove extended timeout after ring creation
// optimization.
WaitForAllBackends(0, 2, WaitForBackendOptions(),
WaitForAllBackends(DEBUG_LOCATION, 0, 2, WaitForBackendOptions(),
RpcOptions().set_timeout_ms(kRpcTimeoutMs));
CheckRpcSendOk(kNumRpcs, rpc_options);
CheckRpcSendOk(DEBUG_LOCATION, kNumRpcs, rpc_options);
const int request_count_1 = backends_[0]->backend_service()->request_count();
const int request_count_2 = backends_[1]->backend_service()->request_count();
EXPECT_THAT(static_cast<double>(request_count_1) / kNumRpcs,
@ -464,9 +464,9 @@ TEST_P(RingHashTest, UnsupportedHashPolicyDefaultToRandomHashing) {
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// TODO(donnadionne): remove extended timeout after ring creation
// optimization.
WaitForAllBackends(0, 2, WaitForBackendOptions(),
WaitForAllBackends(DEBUG_LOCATION, 0, 2, WaitForBackendOptions(),
RpcOptions().set_timeout_ms(kRpcTimeoutMs));
CheckRpcSendOk(kNumRpcs);
CheckRpcSendOk(DEBUG_LOCATION, kNumRpcs);
const int request_count_1 = backends_[0]->backend_service()->request_count();
const int request_count_2 = backends_[1]->backend_service()->request_count();
EXPECT_THAT(static_cast<double>(request_count_1) / kNumRpcs,
@ -500,9 +500,9 @@ TEST_P(RingHashTest, RandomHashingDistributionAccordingToEndpointWeight) {
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// TODO(donnadionne): remove extended timeout after ring creation
// optimization.
WaitForAllBackends(0, 2, WaitForBackendOptions(),
WaitForAllBackends(DEBUG_LOCATION, 0, 2, WaitForBackendOptions(),
RpcOptions().set_timeout_ms(kRpcTimeoutMs));
CheckRpcSendOk(kNumRpcs);
CheckRpcSendOk(DEBUG_LOCATION, kNumRpcs);
const int weight_33_request_count =
backends_[0]->backend_service()->request_count();
const int weight_66_request_count =
@ -539,9 +539,9 @@ TEST_P(RingHashTest,
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// TODO(donnadionne): remove extended timeout after ring creation
// optimization.
WaitForAllBackends(0, 2, WaitForBackendOptions(),
WaitForAllBackends(DEBUG_LOCATION, 0, 2, WaitForBackendOptions(),
RpcOptions().set_timeout_ms(kRpcTimeoutMs));
CheckRpcSendOk(kNumRpcs);
CheckRpcSendOk(DEBUG_LOCATION, kNumRpcs);
const int weight_20_request_count =
backends_[0]->backend_service()->request_count();
const int weight_80_request_count =
@ -576,7 +576,7 @@ TEST_P(RingHashTest, FixedHashingTerminalPolicy) {
{"random_string", absl::StrFormat("%" PRIu32, rand())},
};
const auto rpc_options = RpcOptions().set_metadata(std::move(metadata));
CheckRpcSendOk(100, rpc_options);
CheckRpcSendOk(DEBUG_LOCATION, 100, rpc_options);
bool found = false;
for (size_t i = 0; i < backends_.size(); ++i) {
if (backends_[i]->backend_service()->request_count() > 0) {
@ -606,7 +606,7 @@ TEST_P(RingHashTest, IdleToReady) {
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
EXPECT_EQ(GRPC_CHANNEL_IDLE, channel_->GetState(false));
CheckRpcSendOk();
CheckRpcSendOk(DEBUG_LOCATION);
EXPECT_EQ(GRPC_CHANNEL_READY, channel_->GetState(false));
}
@ -899,8 +899,8 @@ TEST_P(RingHashTest, TransientFailureCheckNextOne) {
{"address_hash",
CreateMetadataValueThatHashesToBackendPort(unused_port)}};
const auto rpc_options = RpcOptions().set_metadata(std::move(metadata));
WaitForBackend(0, WaitForBackendOptions(), rpc_options);
CheckRpcSendOk(100, rpc_options);
WaitForBackend(DEBUG_LOCATION, 0, WaitForBackendOptions(), rpc_options);
CheckRpcSendOk(DEBUG_LOCATION, 100, rpc_options);
}
// Test that when a backend goes down, we will move on to the next subchannel
@ -927,13 +927,13 @@ TEST_P(RingHashTest, SwitchToLowerPrioirtyAndThenBack) {
std::vector<std::pair<std::string, std::string>> metadata = {
{"address_hash", CreateMetadataValueThatHashesToBackend(0)}};
const auto rpc_options = RpcOptions().set_metadata(std::move(metadata));
WaitForBackend(0, WaitForBackendOptions(), rpc_options);
WaitForBackend(DEBUG_LOCATION, 0, WaitForBackendOptions(), rpc_options);
ShutdownBackend(0);
WaitForBackend(1, WaitForBackendOptions().set_allow_failures(true),
rpc_options);
WaitForBackend(DEBUG_LOCATION, 1,
WaitForBackendOptions().set_allow_failures(true), rpc_options);
StartBackend(0);
WaitForBackend(0, WaitForBackendOptions(), rpc_options);
CheckRpcSendOk(100, rpc_options);
WaitForBackend(DEBUG_LOCATION, 0, WaitForBackendOptions(), rpc_options);
CheckRpcSendOk(DEBUG_LOCATION, 100, rpc_options);
EXPECT_EQ(100, backends_[0]->backend_service()->request_count());
EXPECT_EQ(0, backends_[1]->backend_service()->request_count());
}
@ -958,8 +958,9 @@ TEST_P(RingHashTest, ReattemptWhenAllEndpointsUnreachable) {
{"address_hash", CreateMetadataValueThatHashesToBackend(0)}};
EXPECT_EQ(GRPC_CHANNEL_IDLE, channel_->GetState(false));
ShutdownBackend(0);
CheckRpcSendFailure(CheckRpcSendFailureOptions().set_rpc_options(
RpcOptions().set_metadata(std::move(metadata))));
CheckRpcSendFailure(DEBUG_LOCATION,
CheckRpcSendFailureOptions().set_rpc_options(
RpcOptions().set_metadata(std::move(metadata))));
StartBackend(0);
// Ensure we are actively connecting without any traffic.
EXPECT_TRUE(channel_->WaitForConnected(
@ -994,13 +995,14 @@ TEST_P(RingHashTest, TransientFailureSkipToAvailableReady) {
ShutdownBackend(0);
ShutdownBackend(1);
CheckRpcSendFailure(
DEBUG_LOCATION,
CheckRpcSendFailureOptions().set_rpc_options(rpc_options));
EXPECT_EQ(GRPC_CHANNEL_TRANSIENT_FAILURE, channel_->GetState(false));
// Bring up 0, should be picked as the RPC is hashed to it.
StartBackend(0);
EXPECT_TRUE(channel_->WaitForConnected(
grpc_timeout_milliseconds_to_deadline(kConnectionTimeoutMilliseconds)));
WaitForBackend(0, WaitForBackendOptions(), rpc_options);
WaitForBackend(DEBUG_LOCATION, 0, WaitForBackendOptions(), rpc_options);
// Bring down 0 and bring up 1.
// Note the RPC contains a header value that will always be hashed to
// backend 0. So by purposely bring down backend 0 and bring up another
@ -1013,11 +1015,12 @@ TEST_P(RingHashTest, TransientFailureSkipToAvailableReady) {
// will go through some non-READY entries and skip them as per design.
ShutdownBackend(0);
CheckRpcSendFailure(
DEBUG_LOCATION,
CheckRpcSendFailureOptions().set_rpc_options(rpc_options));
StartBackend(1);
EXPECT_TRUE(channel_->WaitForConnected(
grpc_timeout_milliseconds_to_deadline(kConnectionTimeoutMilliseconds)));
WaitForBackend(1, WaitForBackendOptions(), rpc_options);
WaitForBackend(DEBUG_LOCATION, 1, WaitForBackendOptions(), rpc_options);
}
// Test unspported hash policy types are all ignored before a supported
@ -1043,7 +1046,7 @@ TEST_P(RingHashTest, UnsupportedHashPolicyUntilChannelIdHashing) {
new_route_config);
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
CheckRpcSendOk(100);
CheckRpcSendOk(DEBUG_LOCATION, 100);
bool found = false;
for (size_t i = 0; i < backends_.size(); ++i) {
if (backends_[i]->backend_service()->request_count() > 0) {
@ -1073,7 +1076,7 @@ TEST_P(RingHashTest, InvalidHashFunction) {
new_route_config);
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -1096,7 +1099,7 @@ TEST_P(RingHashTest, InvalidMinimumRingSize) {
new_route_config);
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(
@ -1119,7 +1122,7 @@ TEST_P(RingHashTest, InvalidMaxmumRingSize) {
new_route_config);
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(
@ -1144,7 +1147,7 @@ TEST_P(RingHashTest, InvalidRingSizeMinGreaterThanMax) {
new_route_config);
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
const auto response_state = WaitForCdsNack();
const auto response_state = WaitForCdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(

@ -153,8 +153,9 @@ TEST_P(RlsTest, XdsRoutingClusterSpecifierPlugin) {
kRlsClusterSpecifierPluginInstanceName);
SetRouteConfiguration(balancer_.get(), new_route_config);
auto rpc_options = RpcOptions().set_metadata({{kRlsTestKey1, kRlsTestValue}});
WaitForAllBackends(1, 2, WaitForBackendOptions(), rpc_options);
CheckRpcSendOk(kNumEchoRpcs, rpc_options);
WaitForAllBackends(DEBUG_LOCATION, 1, 2, WaitForBackendOptions(),
rpc_options);
CheckRpcSendOk(DEBUG_LOCATION, kNumEchoRpcs, rpc_options);
// Make sure RPCs all go to the correct backend.
EXPECT_EQ(kNumEchoRpcs, backends_[1]->backend_service()->request_count());
}
@ -168,7 +169,7 @@ TEST_P(RlsTest, XdsRoutingClusterSpecifierPluginNacksUndefinedSpecifier) {
default_route->mutable_route()->set_cluster_specifier_plugin(
kRlsClusterSpecifierPluginInstanceName);
SetRouteConfiguration(balancer_.get(), new_route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(absl::StrCat(
@ -207,7 +208,7 @@ TEST_P(RlsTest, XdsRoutingClusterSpecifierPluginNacksDuplicateSpecifier) {
default_route->mutable_route()->set_cluster_specifier_plugin(
kRlsClusterSpecifierPluginInstanceName);
SetRouteConfiguration(balancer_.get(), new_route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(absl::StrCat(
@ -233,7 +234,7 @@ TEST_P(RlsTest,
default_route->mutable_route()->set_cluster_specifier_plugin(
kRlsClusterSpecifierPluginInstanceName);
SetRouteConfiguration(balancer_.get(), new_route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("Unknown ClusterSpecifierPlugin type "
@ -266,7 +267,7 @@ TEST_P(RlsTest,
SetRouteConfiguration(balancer_.get(), new_route_config);
// Ensure we ignore the cluster specifier plugin and send traffic according to
// the default route.
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
}
TEST_P(RlsTest, XdsRoutingRlsClusterSpecifierPluginNacksRequiredMatch) {
@ -296,7 +297,7 @@ TEST_P(RlsTest, XdsRoutingRlsClusterSpecifierPluginNacksRequiredMatch) {
default_route->mutable_route()->set_cluster_specifier_plugin(
kRlsClusterSpecifierPluginInstanceName);
SetRouteConfiguration(balancer_.get(), new_route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -337,7 +338,8 @@ TEST_P(RlsTest, XdsRoutingClusterSpecifierPluginDisabled) {
// Ensure we ignore the cluster specifier plugin and send traffic according to
// the default route.
auto rpc_options = RpcOptions().set_metadata({{kRlsTestKey1, kRlsTestValue}});
WaitForAllBackends(0, 1, WaitForBackendOptions(), rpc_options);
WaitForAllBackends(DEBUG_LOCATION, 0, 1, WaitForBackendOptions(),
rpc_options);
}
} // namespace

@ -44,7 +44,7 @@ TEST_P(LdsTest, NoApiListener) {
auto listener = default_listener_;
listener.clear_api_listener();
balancer_->ads_service()->SetLdsResource(listener);
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -62,7 +62,7 @@ TEST_P(LdsTest, WrongRouteSpecifier) {
listener.mutable_api_listener()->mutable_api_listener()->PackFrom(
http_connection_manager);
balancer_->ads_service()->SetLdsResource(listener);
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -82,7 +82,7 @@ TEST_P(LdsTest, RdsMissingConfigSource) {
listener.mutable_api_listener()->mutable_api_listener()->PackFrom(
http_connection_manager);
balancer_->ads_service()->SetLdsResource(listener);
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(
@ -103,7 +103,7 @@ TEST_P(LdsTest, RdsConfigSourceDoesNotSpecifyAdsOrSelf) {
listener.mutable_api_listener()->mutable_api_listener()->PackFrom(
http_connection_manager);
balancer_->ads_service()->SetLdsResource(listener);
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("HttpConnectionManager ConfigSource for "
@ -127,7 +127,7 @@ TEST_P(LdsTest, AcceptsRdsConfigSourceOfTypeAds) {
default_route_config_);
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
auto response_state = balancer_->ads_service()->lds_response_state();
ASSERT_TRUE(response_state.has_value());
EXPECT_EQ(response_state->state, AdsServiceImpl::ResponseState::ACKED);
@ -147,7 +147,7 @@ TEST_P(LdsTest, NacksNonTerminalHttpFilterAtEndOfList) {
http_connection_manager);
SetListenerAndRouteConfiguration(balancer_.get(), listener,
default_route_config_);
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(
@ -171,7 +171,7 @@ TEST_P(LdsTest, NacksTerminalFilterBeforeEndOfList) {
http_connection_manager);
SetListenerAndRouteConfiguration(balancer_.get(), listener,
default_route_config_);
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -195,7 +195,7 @@ TEST_P(LdsTest, RejectsEmptyHttpFilterName) {
http_connection_manager);
SetListenerAndRouteConfiguration(balancer_.get(), listener,
default_route_config_);
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("empty filter name at index 0"));
@ -216,7 +216,7 @@ TEST_P(LdsTest, RejectsDuplicateHttpFilterName) {
http_connection_manager);
SetListenerAndRouteConfiguration(balancer_.get(), listener,
default_route_config_);
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("duplicate HTTP filter name: router"));
@ -237,7 +237,7 @@ TEST_P(LdsTest, RejectsUnknownHttpFilterType) {
http_connection_manager);
SetListenerAndRouteConfiguration(balancer_.get(), listener,
default_route_config_);
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("no filter registered for config type "
@ -263,7 +263,7 @@ TEST_P(LdsTest, IgnoresOptionalUnknownHttpFilterType) {
default_route_config_);
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
auto response_state = balancer_->ads_service()->lds_response_state();
ASSERT_TRUE(response_state.has_value());
EXPECT_EQ(response_state->state, AdsServiceImpl::ResponseState::ACKED);
@ -284,7 +284,7 @@ TEST_P(LdsTest, RejectsHttpFilterWithoutConfig) {
http_connection_manager);
SetListenerAndRouteConfiguration(balancer_.get(), listener,
default_route_config_);
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(
@ -310,7 +310,7 @@ TEST_P(LdsTest, IgnoresOptionalHttpFilterWithoutConfig) {
default_route_config_);
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
auto response_state = balancer_->ads_service()->lds_response_state();
ASSERT_TRUE(response_state.has_value());
EXPECT_EQ(response_state->state, AdsServiceImpl::ResponseState::ACKED);
@ -333,7 +333,7 @@ TEST_P(LdsTest, RejectsUnparseableHttpFilterType) {
http_connection_manager);
SetListenerAndRouteConfiguration(balancer_.get(), listener,
default_route_config_);
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -358,7 +358,7 @@ TEST_P(LdsTest, RejectsHttpFiltersNotSupportedOnClients) {
http_connection_manager);
SetListenerAndRouteConfiguration(balancer_.get(), listener,
default_route_config_);
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -386,7 +386,7 @@ TEST_P(LdsTest, IgnoresOptionalHttpFiltersNotSupportedOnClients) {
default_route_config_);
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
auto response_state = balancer_->ads_service()->lds_response_state();
ASSERT_TRUE(response_state.has_value());
EXPECT_EQ(response_state->state, AdsServiceImpl::ResponseState::ACKED);
@ -403,7 +403,7 @@ TEST_P(LdsTest, RejectsNonZeroXffNumTrusterHops) {
http_connection_manager);
SetListenerAndRouteConfiguration(balancer_.get(), listener,
default_route_config_);
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("'xff_num_trusted_hops' must be zero"));
@ -420,7 +420,7 @@ TEST_P(LdsTest, RejectsNonEmptyOriginalIpDetectionExtensions) {
http_connection_manager);
SetListenerAndRouteConfiguration(balancer_.get(), listener,
default_route_config_);
const auto response_state = WaitForLdsNack();
const auto response_state = WaitForLdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -452,7 +452,7 @@ TEST_P(LdsV2Test, IgnoresHttpFilters) {
default_route_config_);
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
CheckRpcSendOk();
CheckRpcSendOk(DEBUG_LOCATION);
}
using LdsRdsTest = XdsEnd2endTest;
@ -502,7 +502,7 @@ TEST_P(LdsRdsTest, DefaultRouteSpecifiesSlashPrefix) {
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// We need to wait for all backends to come online.
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
}
// Tests that we go into TRANSIENT_FAILURE if the Listener is removed.
@ -511,14 +511,15 @@ TEST_P(LdsRdsTest, ListenerRemoved) {
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
// We need to wait for all backends to come online.
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
// Unset LDS resource.
balancer_->ads_service()->UnsetResource(kLdsTypeUrl, kServerName);
// Wait for RPCs to start failing.
do {
} while (SendRpc(RpcOptions(), nullptr).ok());
// Make sure RPCs are still failing.
CheckRpcSendFailure(CheckRpcSendFailureOptions().set_times(1000));
CheckRpcSendFailure(DEBUG_LOCATION,
CheckRpcSendFailureOptions().set_times(1000));
// Make sure we ACK'ed the update.
auto response_state = balancer_->ads_service()->lds_response_state();
ASSERT_TRUE(response_state.has_value());
@ -532,7 +533,7 @@ TEST_P(LdsRdsTest, NoMatchedDomain) {
route_config.mutable_virtual_hosts(0)->clear_domains();
route_config.mutable_virtual_hosts(0)->add_domains("unmatched_domain");
SetRouteConfiguration(balancer_.get(), route_config);
CheckRpcSendFailure();
CheckRpcSendFailure(DEBUG_LOCATION);
// Do a bit of polling, to allow the ACK to get to the ADS server.
channel_->WaitForConnected(grpc_timeout_milliseconds_to_deadline(100));
auto response_state = RouteConfigurationResponseState(balancer_.get());
@ -578,7 +579,7 @@ TEST_P(LdsRdsTest, RouteMatchHasQueryParameters) {
route1->mutable_match()->set_prefix("/grpc.testing.EchoTest1Service/");
route1->mutable_match()->add_query_parameters();
SetRouteConfiguration(balancer_.get(), route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("No valid routes specified."));
@ -607,7 +608,7 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPrefixNoLeadingSlash) {
auto* route1 = route_config.mutable_virtual_hosts(0)->mutable_routes(0);
route1->mutable_match()->set_prefix("grpc.testing.EchoTest1Service/");
SetRouteConfiguration(balancer_.get(), route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("No valid routes specified."));
@ -620,7 +621,7 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPrefixExtraContent) {
auto* route1 = route_config.mutable_virtual_hosts(0)->mutable_routes(0);
route1->mutable_match()->set_prefix("/grpc.testing.EchoTest1Service/Echo1/");
SetRouteConfiguration(balancer_.get(), route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("No valid routes specified."));
@ -633,7 +634,7 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPrefixDoubleSlash) {
auto* route1 = route_config.mutable_virtual_hosts(0)->mutable_routes(0);
route1->mutable_match()->set_prefix("//");
SetRouteConfiguration(balancer_.get(), route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("No valid routes specified."));
@ -646,7 +647,7 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPathEmptyPath) {
auto* route1 = route_config.mutable_virtual_hosts(0)->mutable_routes(0);
route1->mutable_match()->set_path("");
SetRouteConfiguration(balancer_.get(), route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("No valid routes specified."));
@ -659,7 +660,7 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPathNoLeadingSlash) {
auto* route1 = route_config.mutable_virtual_hosts(0)->mutable_routes(0);
route1->mutable_match()->set_path("grpc.testing.EchoTest1Service/Echo1");
SetRouteConfiguration(balancer_.get(), route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("No valid routes specified."));
@ -672,7 +673,7 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPathTooManySlashes) {
auto* route1 = route_config.mutable_virtual_hosts(0)->mutable_routes(0);
route1->mutable_match()->set_path("/grpc.testing.EchoTest1Service/Echo1/");
SetRouteConfiguration(balancer_.get(), route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("No valid routes specified."));
@ -685,7 +686,7 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPathOnlyOneSlash) {
auto* route1 = route_config.mutable_virtual_hosts(0)->mutable_routes(0);
route1->mutable_match()->set_path("/grpc.testing.EchoTest1Service.Echo1");
SetRouteConfiguration(balancer_.get(), route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("No valid routes specified."));
@ -698,7 +699,7 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPathMissingService) {
auto* route1 = route_config.mutable_virtual_hosts(0)->mutable_routes(0);
route1->mutable_match()->set_path("//Echo1");
SetRouteConfiguration(balancer_.get(), route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("No valid routes specified."));
@ -711,7 +712,7 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPathMissingMethod) {
auto* route1 = route_config.mutable_virtual_hosts(0)->mutable_routes(0);
route1->mutable_match()->set_path("/grpc.testing.EchoTest1Service/");
SetRouteConfiguration(balancer_.get(), route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("No valid routes specified."));
@ -725,7 +726,7 @@ TEST_P(LdsRdsTest, RouteMatchHasInvalidPathRegex) {
route1->mutable_match()->mutable_safe_regex()->set_regex("a[z-a]");
route1->mutable_route()->set_cluster(kNewCluster1Name);
SetRouteConfiguration(balancer_.get(), route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(
@ -745,8 +746,9 @@ TEST_P(LdsRdsTest, MatchingRouteHasNoRouteAction) {
route->mutable_match()->set_prefix("");
route->mutable_route()->set_cluster(kDefaultClusterName);
SetRouteConfiguration(balancer_.get(), route_config);
CheckRpcSendFailure(CheckRpcSendFailureOptions().set_expected_error_code(
StatusCode::UNAVAILABLE));
CheckRpcSendFailure(DEBUG_LOCATION,
CheckRpcSendFailureOptions().set_expected_error_code(
StatusCode::UNAVAILABLE));
}
TEST_P(LdsRdsTest, RouteActionClusterHasEmptyClusterName) {
@ -758,7 +760,7 @@ TEST_P(LdsRdsTest, RouteActionClusterHasEmptyClusterName) {
default_route->mutable_match()->set_prefix("");
default_route->mutable_route()->set_cluster(kDefaultClusterName);
SetRouteConfiguration(balancer_.get(), route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -783,7 +785,7 @@ TEST_P(LdsRdsTest, RouteActionWeightedTargetHasIncorrectTotalWeightSet) {
default_route->mutable_match()->set_prefix("");
default_route->mutable_route()->set_cluster(kDefaultClusterName);
SetRouteConfiguration(balancer_.get(), route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(
@ -807,7 +809,7 @@ TEST_P(LdsRdsTest, RouteActionWeightedClusterHasZeroTotalWeight) {
default_route->mutable_match()->set_prefix("");
default_route->mutable_route()->set_cluster(kDefaultClusterName);
SetRouteConfiguration(balancer_.get(), route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -832,7 +834,7 @@ TEST_P(LdsRdsTest, RouteActionWeightedTargetClusterHasEmptyClusterName) {
default_route->mutable_match()->set_prefix("");
default_route->mutable_route()->set_cluster(kDefaultClusterName);
SetRouteConfiguration(balancer_.get(), route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("RouteAction weighted_cluster cluster "
@ -856,7 +858,7 @@ TEST_P(LdsRdsTest, RouteActionWeightedTargetClusterHasNoWeight) {
default_route->mutable_match()->set_prefix("");
default_route->mutable_route()->set_cluster(kDefaultClusterName);
SetRouteConfiguration(balancer_.get(), route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(
@ -873,7 +875,7 @@ TEST_P(LdsRdsTest, RouteHeaderMatchInvalidRegex) {
header_matcher1->mutable_safe_regex_match()->set_regex("a[z-a]");
route1->mutable_route()->set_cluster(kNewCluster1Name);
SetRouteConfiguration(balancer_.get(), route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -892,7 +894,7 @@ TEST_P(LdsRdsTest, RouteHeaderMatchInvalidRange) {
header_matcher1->mutable_range_match()->set_end(1000);
route1->mutable_route()->set_cluster(kNewCluster1Name);
SetRouteConfiguration(balancer_.get(), route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -953,16 +955,19 @@ TEST_P(LdsRdsTest, XdsRoutingPathMatching) {
default_route->mutable_match()->set_prefix("");
default_route->mutable_route()->set_cluster(kDefaultClusterName);
SetRouteConfiguration(balancer_.get(), new_route_config);
WaitForAllBackends(0, 2);
CheckRpcSendOk(kNumEchoRpcs, RpcOptions().set_wait_for_ready(true));
CheckRpcSendOk(kNumEcho1Rpcs, RpcOptions()
.set_rpc_service(SERVICE_ECHO1)
.set_rpc_method(METHOD_ECHO1)
.set_wait_for_ready(true));
CheckRpcSendOk(kNumEcho2Rpcs, RpcOptions()
.set_rpc_service(SERVICE_ECHO2)
.set_rpc_method(METHOD_ECHO2)
.set_wait_for_ready(true));
WaitForAllBackends(DEBUG_LOCATION, 0, 2);
CheckRpcSendOk(DEBUG_LOCATION, kNumEchoRpcs,
RpcOptions().set_wait_for_ready(true));
CheckRpcSendOk(DEBUG_LOCATION, kNumEcho1Rpcs,
RpcOptions()
.set_rpc_service(SERVICE_ECHO1)
.set_rpc_method(METHOD_ECHO1)
.set_wait_for_ready(true));
CheckRpcSendOk(DEBUG_LOCATION, kNumEcho2Rpcs,
RpcOptions()
.set_rpc_service(SERVICE_ECHO2)
.set_rpc_method(METHOD_ECHO2)
.set_wait_for_ready(true));
// Make sure RPCs all go to the correct backend.
for (size_t i = 0; i < 2; ++i) {
EXPECT_EQ(kNumEchoRpcs / 2,
@ -1027,11 +1032,13 @@ TEST_P(LdsRdsTest, XdsRoutingPathMatchingCaseInsensitive) {
default_route->mutable_match()->set_prefix("");
default_route->mutable_route()->set_cluster(kDefaultClusterName);
SetRouteConfiguration(balancer_.get(), new_route_config);
CheckRpcSendOk(kNumEchoRpcs, RpcOptions().set_wait_for_ready(true));
CheckRpcSendOk(kNumEcho1Rpcs, RpcOptions()
.set_rpc_service(SERVICE_ECHO1)
.set_rpc_method(METHOD_ECHO1)
.set_wait_for_ready(true));
CheckRpcSendOk(DEBUG_LOCATION, kNumEchoRpcs,
RpcOptions().set_wait_for_ready(true));
CheckRpcSendOk(DEBUG_LOCATION, kNumEcho1Rpcs,
RpcOptions()
.set_rpc_service(SERVICE_ECHO1)
.set_rpc_method(METHOD_ECHO1)
.set_wait_for_ready(true));
// Make sure RPCs all go to the correct backend.
EXPECT_EQ(kNumEchoRpcs, backends_[0]->backend_service()->request_count());
EXPECT_EQ(0, backends_[0]->backend_service1()->request_count());
@ -1088,13 +1095,14 @@ TEST_P(LdsRdsTest, XdsRoutingPrefixMatching) {
default_route->mutable_match()->set_prefix("");
default_route->mutable_route()->set_cluster(kDefaultClusterName);
SetRouteConfiguration(balancer_.get(), new_route_config);
WaitForAllBackends(0, 2);
CheckRpcSendOk(kNumEchoRpcs, RpcOptions().set_wait_for_ready(true));
WaitForAllBackends(DEBUG_LOCATION, 0, 2);
CheckRpcSendOk(DEBUG_LOCATION, kNumEchoRpcs,
RpcOptions().set_wait_for_ready(true));
CheckRpcSendOk(
kNumEcho1Rpcs,
DEBUG_LOCATION, kNumEcho1Rpcs,
RpcOptions().set_rpc_service(SERVICE_ECHO1).set_wait_for_ready(true));
CheckRpcSendOk(
kNumEcho2Rpcs,
DEBUG_LOCATION, kNumEcho2Rpcs,
RpcOptions().set_rpc_service(SERVICE_ECHO2).set_wait_for_ready(true));
// Make sure RPCs all go to the correct backend.
for (size_t i = 0; i < 2; ++i) {
@ -1160,11 +1168,13 @@ TEST_P(LdsRdsTest, XdsRoutingPrefixMatchingCaseInsensitive) {
default_route->mutable_match()->set_prefix("");
default_route->mutable_route()->set_cluster(kDefaultClusterName);
SetRouteConfiguration(balancer_.get(), new_route_config);
CheckRpcSendOk(kNumEchoRpcs, RpcOptions().set_wait_for_ready(true));
CheckRpcSendOk(kNumEcho1Rpcs, RpcOptions()
.set_rpc_service(SERVICE_ECHO1)
.set_rpc_method(METHOD_ECHO1)
.set_wait_for_ready(true));
CheckRpcSendOk(DEBUG_LOCATION, kNumEchoRpcs,
RpcOptions().set_wait_for_ready(true));
CheckRpcSendOk(DEBUG_LOCATION, kNumEcho1Rpcs,
RpcOptions()
.set_rpc_service(SERVICE_ECHO1)
.set_rpc_method(METHOD_ECHO1)
.set_wait_for_ready(true));
// Make sure RPCs all go to the correct backend.
EXPECT_EQ(kNumEchoRpcs, backends_[0]->backend_service()->request_count());
EXPECT_EQ(0, backends_[0]->backend_service1()->request_count());
@ -1223,13 +1233,14 @@ TEST_P(LdsRdsTest, XdsRoutingPathRegexMatching) {
default_route->mutable_match()->set_prefix("");
default_route->mutable_route()->set_cluster(kDefaultClusterName);
SetRouteConfiguration(balancer_.get(), new_route_config);
WaitForAllBackends(0, 2);
CheckRpcSendOk(kNumEchoRpcs, RpcOptions().set_wait_for_ready(true));
WaitForAllBackends(DEBUG_LOCATION, 0, 2);
CheckRpcSendOk(DEBUG_LOCATION, kNumEchoRpcs,
RpcOptions().set_wait_for_ready(true));
CheckRpcSendOk(
kNumEcho1Rpcs,
DEBUG_LOCATION, kNumEcho1Rpcs,
RpcOptions().set_rpc_service(SERVICE_ECHO1).set_wait_for_ready(true));
CheckRpcSendOk(
kNumEcho2Rpcs,
DEBUG_LOCATION, kNumEcho2Rpcs,
RpcOptions().set_rpc_service(SERVICE_ECHO2).set_wait_for_ready(true));
// Make sure RPCs all go to the correct backend.
for (size_t i = 0; i < 2; ++i) {
@ -1312,11 +1323,12 @@ TEST_P(LdsRdsTest, XdsRoutingWeightedCluster) {
default_route->mutable_match()->set_prefix("");
default_route->mutable_route()->set_cluster(kDefaultClusterName);
SetRouteConfiguration(balancer_.get(), new_route_config);
WaitForAllBackends(0, 1);
WaitForAllBackends(1, 3, WaitForBackendOptions(),
WaitForAllBackends(DEBUG_LOCATION, 0, 1);
WaitForAllBackends(DEBUG_LOCATION, 1, 3, WaitForBackendOptions(),
RpcOptions().set_rpc_service(SERVICE_ECHO1));
CheckRpcSendOk(kNumEchoRpcs);
CheckRpcSendOk(kNumEcho1Rpcs, RpcOptions().set_rpc_service(SERVICE_ECHO1));
CheckRpcSendOk(DEBUG_LOCATION, kNumEchoRpcs);
CheckRpcSendOk(DEBUG_LOCATION, kNumEcho1Rpcs,
RpcOptions().set_rpc_service(SERVICE_ECHO1));
// Make sure RPCs all go to the correct backend.
EXPECT_EQ(kNumEchoRpcs, backends_[0]->backend_service()->request_count());
EXPECT_EQ(0, backends_[0]->backend_service1()->request_count());
@ -1390,8 +1402,8 @@ TEST_P(LdsRdsTest, RouteActionWeightedTargetDefaultRoute) {
->mutable_total_weight()
->set_value(kWeight75 + kWeight25);
SetRouteConfiguration(balancer_.get(), new_route_config);
WaitForAllBackends(1, 3);
CheckRpcSendOk(kNumEchoRpcs);
WaitForAllBackends(DEBUG_LOCATION, 1, 3);
CheckRpcSendOk(DEBUG_LOCATION, kNumEchoRpcs);
// Make sure RPCs all go to the correct backend.
EXPECT_EQ(0, backends_[0]->backend_service()->request_count());
const int weight_75_request_count =
@ -1482,11 +1494,11 @@ TEST_P(LdsRdsTest, XdsRoutingWeightedClusterUpdateWeights) {
default_route->mutable_match()->set_prefix("");
default_route->mutable_route()->set_cluster(kDefaultClusterName);
SetRouteConfiguration(balancer_.get(), new_route_config);
WaitForAllBackends(0, 1);
WaitForAllBackends(1, 3, WaitForBackendOptions(),
WaitForAllBackends(DEBUG_LOCATION, 0, 1);
WaitForAllBackends(DEBUG_LOCATION, 1, 3, WaitForBackendOptions(),
RpcOptions().set_rpc_service(SERVICE_ECHO1));
CheckRpcSendOk(kNumEchoRpcs);
CheckRpcSendOk(kNumEcho1Rpcs7525,
CheckRpcSendOk(DEBUG_LOCATION, kNumEchoRpcs);
CheckRpcSendOk(DEBUG_LOCATION, kNumEcho1Rpcs7525,
RpcOptions().set_rpc_service(SERVICE_ECHO1));
// Make sure RPCs all go to the correct backend.
EXPECT_EQ(kNumEchoRpcs, backends_[0]->backend_service()->request_count());
@ -1514,9 +1526,9 @@ TEST_P(LdsRdsTest, XdsRoutingWeightedClusterUpdateWeights) {
default_route->mutable_route()->set_cluster(kNewCluster3Name);
SetRouteConfiguration(balancer_.get(), new_route_config);
ResetBackendCounters();
WaitForAllBackends(3, 4);
CheckRpcSendOk(kNumEchoRpcs);
CheckRpcSendOk(kNumEcho1Rpcs5050,
WaitForAllBackends(DEBUG_LOCATION, 3, 4);
CheckRpcSendOk(DEBUG_LOCATION, kNumEchoRpcs);
CheckRpcSendOk(DEBUG_LOCATION, kNumEcho1Rpcs5050,
RpcOptions().set_rpc_service(SERVICE_ECHO1));
// Make sure RPCs all go to the correct backend.
EXPECT_EQ(0, backends_[0]->backend_service()->request_count());
@ -1613,11 +1625,11 @@ TEST_P(LdsRdsTest, XdsRoutingWeightedClusterUpdateClusters) {
default_route->mutable_match()->set_prefix("");
default_route->mutable_route()->set_cluster(kDefaultClusterName);
SetRouteConfiguration(balancer_.get(), new_route_config);
WaitForBackend(0);
WaitForBackend(1, WaitForBackendOptions(),
WaitForBackend(DEBUG_LOCATION, 0);
WaitForBackend(DEBUG_LOCATION, 1, WaitForBackendOptions(),
RpcOptions().set_rpc_service(SERVICE_ECHO1));
CheckRpcSendOk(kNumEchoRpcs);
CheckRpcSendOk(kNumEcho1Rpcs7525,
CheckRpcSendOk(DEBUG_LOCATION, kNumEchoRpcs);
CheckRpcSendOk(DEBUG_LOCATION, kNumEcho1Rpcs7525,
RpcOptions().set_rpc_service(SERVICE_ECHO1));
// Make sure RPCs all go to the correct backend.
EXPECT_EQ(kNumEchoRpcs, backends_[0]->backend_service()->request_count());
@ -1642,10 +1654,10 @@ TEST_P(LdsRdsTest, XdsRoutingWeightedClusterUpdateClusters) {
weighted_cluster2->mutable_weight()->set_value(kWeight50);
SetRouteConfiguration(balancer_.get(), new_route_config);
ResetBackendCounters();
WaitForBackend(2, WaitForBackendOptions(),
WaitForBackend(DEBUG_LOCATION, 2, WaitForBackendOptions(),
RpcOptions().set_rpc_service(SERVICE_ECHO1));
CheckRpcSendOk(kNumEchoRpcs);
CheckRpcSendOk(kNumEcho1Rpcs5050,
CheckRpcSendOk(DEBUG_LOCATION, kNumEchoRpcs);
CheckRpcSendOk(DEBUG_LOCATION, kNumEcho1Rpcs5050,
RpcOptions().set_rpc_service(SERVICE_ECHO1));
// Make sure RPCs all go to the correct backend.
EXPECT_EQ(kNumEchoRpcs, backends_[0]->backend_service()->request_count());
@ -1670,10 +1682,10 @@ TEST_P(LdsRdsTest, XdsRoutingWeightedClusterUpdateClusters) {
weighted_cluster2->mutable_weight()->set_value(kWeight25);
SetRouteConfiguration(balancer_.get(), new_route_config);
ResetBackendCounters();
WaitForBackend(3, WaitForBackendOptions(),
WaitForBackend(DEBUG_LOCATION, 3, WaitForBackendOptions(),
RpcOptions().set_rpc_service(SERVICE_ECHO1));
CheckRpcSendOk(kNumEchoRpcs);
CheckRpcSendOk(kNumEcho1Rpcs7525,
CheckRpcSendOk(DEBUG_LOCATION, kNumEchoRpcs);
CheckRpcSendOk(DEBUG_LOCATION, kNumEcho1Rpcs7525,
RpcOptions().set_rpc_service(SERVICE_ECHO1));
// Make sure RPCs all go to the correct backend.
EXPECT_EQ(kNumEchoRpcs, backends_[0]->backend_service()->request_count());
@ -1716,8 +1728,8 @@ TEST_P(LdsRdsTest, XdsRoutingClusterUpdateClusters) {
// Send Route Configuration.
RouteConfiguration new_route_config = default_route_config_;
SetRouteConfiguration(balancer_.get(), new_route_config);
WaitForAllBackends(0, 1);
CheckRpcSendOk(kNumEchoRpcs);
WaitForAllBackends(DEBUG_LOCATION, 0, 1);
CheckRpcSendOk(DEBUG_LOCATION, kNumEchoRpcs);
// Make sure RPCs all go to the correct backend.
EXPECT_EQ(kNumEchoRpcs, backends_[0]->backend_service()->request_count());
// Change Route Configurations: new default cluster.
@ -1725,8 +1737,8 @@ TEST_P(LdsRdsTest, XdsRoutingClusterUpdateClusters) {
new_route_config.mutable_virtual_hosts(0)->mutable_routes(0);
default_route->mutable_route()->set_cluster(kNewClusterName);
SetRouteConfiguration(balancer_.get(), new_route_config);
WaitForAllBackends(1, 2);
CheckRpcSendOk(kNumEchoRpcs);
WaitForAllBackends(DEBUG_LOCATION, 1, 2);
CheckRpcSendOk(DEBUG_LOCATION, kNumEchoRpcs);
// Make sure RPCs all go to the correct backend.
EXPECT_EQ(kNumEchoRpcs, backends_[1]->backend_service()->request_count());
}
@ -1761,7 +1773,8 @@ TEST_P(LdsRdsTest, XdsRoutingClusterUpdateClustersWithPickingDelays) {
// Send exactly one RPC with no deadline and with wait_for_ready=true.
// This RPC will not complete until after backend 0 is started.
std::thread sending_rpc([this]() {
CheckRpcSendOk(1, RpcOptions().set_wait_for_ready(true).set_timeout_ms(0));
CheckRpcSendOk(DEBUG_LOCATION, 1,
RpcOptions().set_wait_for_ready(true).set_timeout_ms(0));
});
// Send a non-wait_for_ready RPC which should fail, this will tell us
// that the client has received the update and attempted to connect.
@ -1775,8 +1788,9 @@ TEST_P(LdsRdsTest, XdsRoutingClusterUpdateClustersWithPickingDelays) {
// Wait for RPCs to go to the new backend: 1, this ensures that the client
// has processed the update.
WaitForBackend(
1, WaitForBackendOptions().set_reset_counters(false).set_allow_failures(
true));
DEBUG_LOCATION, 1,
WaitForBackendOptions().set_reset_counters(false).set_allow_failures(
true));
// Bring up the previous backend: 0, this will allow the delayed RPC to
// finally call on_call_committed upon completion.
StartBackend(0);
@ -1879,6 +1893,7 @@ TEST_P(LdsRdsTest, XdsRoutingApplyXdsTimeout) {
t0 + grpc_core::Duration::Seconds(kTimeoutMaxStreamDurationSecond) +
grpc_core::Duration::Milliseconds(kTimeoutMillis);
CheckRpcSendFailure(
DEBUG_LOCATION,
CheckRpcSendFailureOptions()
.set_rpc_options(RpcOptions()
.set_rpc_service(SERVICE_ECHO1)
@ -1896,6 +1911,7 @@ TEST_P(LdsRdsTest, XdsRoutingApplyXdsTimeout) {
t2 = t0 + grpc_core::Duration::Seconds(kTimeoutHttpMaxStreamDurationSecond) +
grpc_core::Duration::Milliseconds(kTimeoutMillis);
CheckRpcSendFailure(
DEBUG_LOCATION,
CheckRpcSendFailureOptions()
.set_rpc_options(RpcOptions()
.set_rpc_service(SERVICE_ECHO2)
@ -1913,6 +1929,7 @@ TEST_P(LdsRdsTest, XdsRoutingApplyXdsTimeout) {
t2 = t0 + grpc_core::Duration::Seconds(kTimeoutApplicationSecond) +
grpc_core::Duration::Milliseconds(kTimeoutMillis);
CheckRpcSendFailure(
DEBUG_LOCATION,
CheckRpcSendFailureOptions()
.set_rpc_options(RpcOptions().set_wait_for_ready(true).set_timeout_ms(
grpc_core::Duration::Seconds(kTimeoutApplicationSecond).millis()))
@ -1991,6 +2008,7 @@ TEST_P(LdsRdsTest, XdsRoutingApplyApplicationTimeoutWhenXdsTimeoutExplicit0) {
// Test application timeout is applied for route 1
auto t0 = system_clock::now();
CheckRpcSendFailure(
DEBUG_LOCATION,
CheckRpcSendFailureOptions()
.set_rpc_options(
RpcOptions()
@ -2007,6 +2025,7 @@ TEST_P(LdsRdsTest, XdsRoutingApplyApplicationTimeoutWhenXdsTimeoutExplicit0) {
// Test application timeout is applied for route 2
t0 = system_clock::now();
CheckRpcSendFailure(
DEBUG_LOCATION,
CheckRpcSendFailureOptions()
.set_rpc_options(
RpcOptions()
@ -2044,6 +2063,7 @@ TEST_P(LdsRdsTest, XdsRoutingApplyApplicationTimeoutWhenHttpTimeoutExplicit0) {
// Test application timeout is applied for route 1
auto t0 = system_clock::now();
CheckRpcSendFailure(
DEBUG_LOCATION,
CheckRpcSendFailureOptions()
.set_rpc_options(RpcOptions().set_wait_for_ready(true).set_timeout_ms(
grpc_core::Duration::Seconds(kTimeoutApplicationSecond).millis()))
@ -2064,6 +2084,7 @@ TEST_P(LdsRdsTest, XdsRoutingWithOnlyApplicationTimeout) {
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
auto t0 = system_clock::now();
CheckRpcSendFailure(
DEBUG_LOCATION,
CheckRpcSendFailureOptions()
.set_rpc_options(RpcOptions().set_wait_for_ready(true).set_timeout_ms(
grpc_core::Duration::Seconds(kTimeoutApplicationSecond).millis()))
@ -2094,6 +2115,7 @@ TEST_P(LdsRdsTest, XdsRetryPolicyNumRetries) {
SetRouteConfiguration(balancer_.get(), new_route_config);
// Ensure we retried the correct number of times on all supported status.
CheckRpcSendFailure(
DEBUG_LOCATION,
CheckRpcSendFailureOptions()
.set_rpc_options(
RpcOptions().set_server_expected_error(StatusCode::CANCELLED))
@ -2101,6 +2123,7 @@ TEST_P(LdsRdsTest, XdsRetryPolicyNumRetries) {
EXPECT_EQ(kNumRetries + 1, backends_[0]->backend_service()->request_count());
ResetBackendCounters();
CheckRpcSendFailure(
DEBUG_LOCATION,
CheckRpcSendFailureOptions()
.set_rpc_options(RpcOptions().set_server_expected_error(
StatusCode::DEADLINE_EXCEEDED))
@ -2108,6 +2131,7 @@ TEST_P(LdsRdsTest, XdsRetryPolicyNumRetries) {
EXPECT_EQ(kNumRetries + 1, backends_[0]->backend_service()->request_count());
ResetBackendCounters();
CheckRpcSendFailure(
DEBUG_LOCATION,
CheckRpcSendFailureOptions()
.set_rpc_options(
RpcOptions().set_server_expected_error(StatusCode::INTERNAL))
@ -2115,6 +2139,7 @@ TEST_P(LdsRdsTest, XdsRetryPolicyNumRetries) {
EXPECT_EQ(kNumRetries + 1, backends_[0]->backend_service()->request_count());
ResetBackendCounters();
CheckRpcSendFailure(
DEBUG_LOCATION,
CheckRpcSendFailureOptions()
.set_rpc_options(RpcOptions().set_server_expected_error(
StatusCode::RESOURCE_EXHAUSTED))
@ -2122,6 +2147,7 @@ TEST_P(LdsRdsTest, XdsRetryPolicyNumRetries) {
EXPECT_EQ(kNumRetries + 1, backends_[0]->backend_service()->request_count());
ResetBackendCounters();
CheckRpcSendFailure(
DEBUG_LOCATION,
CheckRpcSendFailureOptions()
.set_rpc_options(
RpcOptions().set_server_expected_error(StatusCode::UNAVAILABLE))
@ -2130,6 +2156,7 @@ TEST_P(LdsRdsTest, XdsRetryPolicyNumRetries) {
ResetBackendCounters();
// Ensure we don't retry on an unsupported status.
CheckRpcSendFailure(
DEBUG_LOCATION,
CheckRpcSendFailureOptions()
.set_rpc_options(RpcOptions().set_server_expected_error(
StatusCode::UNAUTHENTICATED))
@ -2155,6 +2182,7 @@ TEST_P(LdsRdsTest, XdsRetryPolicyAtVirtualHostLevel) {
SetRouteConfiguration(balancer_.get(), new_route_config);
// Ensure we retried the correct number of times on a supported status.
CheckRpcSendFailure(
DEBUG_LOCATION,
CheckRpcSendFailureOptions()
.set_rpc_options(RpcOptions().set_server_expected_error(
StatusCode::DEADLINE_EXCEEDED))
@ -2189,6 +2217,7 @@ TEST_P(LdsRdsTest, XdsRetryPolicyLongBackOff) {
// No need to set max interval and just let it be the default of 10x of base.
// We expect 1 retry before the RPC times out with DEADLINE_EXCEEDED.
CheckRpcSendFailure(
DEBUG_LOCATION,
CheckRpcSendFailureOptions()
.set_rpc_options(
RpcOptions().set_timeout_ms(2500).set_server_expected_error(
@ -2231,6 +2260,7 @@ TEST_P(LdsRdsTest, XdsRetryPolicyMaxBackOff) {
SetRouteConfiguration(balancer_.get(), new_route_config);
// We expect 2 retry before the RPC times out with DEADLINE_EXCEEDED.
CheckRpcSendFailure(
DEBUG_LOCATION,
CheckRpcSendFailureOptions()
.set_rpc_options(
RpcOptions().set_timeout_ms(2500).set_server_expected_error(
@ -2256,6 +2286,7 @@ TEST_P(LdsRdsTest, XdsRetryPolicyUnsupportedStatusCode) {
SetRouteConfiguration(balancer_.get(), new_route_config);
// We expect no retry.
CheckRpcSendFailure(
DEBUG_LOCATION,
CheckRpcSendFailureOptions()
.set_rpc_options(RpcOptions().set_server_expected_error(
StatusCode::DEADLINE_EXCEEDED))
@ -2288,6 +2319,7 @@ TEST_P(LdsRdsTest,
SetRouteConfiguration(balancer_.get(), new_route_config);
// We expect no retry.
CheckRpcSendFailure(
DEBUG_LOCATION,
CheckRpcSendFailureOptions()
.set_rpc_options(RpcOptions().set_server_expected_error(
StatusCode::DEADLINE_EXCEEDED))
@ -2310,7 +2342,7 @@ TEST_P(LdsRdsTest, XdsRetryPolicyInvalidNumRetriesZero) {
// Setting num_retries to zero is not valid.
retry_policy->mutable_num_retries()->set_value(0);
SetRouteConfiguration(balancer_.get(), new_route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -2337,7 +2369,7 @@ TEST_P(LdsRdsTest, XdsRetryPolicyRetryBackOffMissingBaseInterval) {
max_interval->set_seconds(0);
max_interval->set_nanos(250000000);
SetRouteConfiguration(balancer_.get(), new_route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -2414,11 +2446,12 @@ TEST_P(LdsRdsTest, XdsRoutingHeadersMatching) {
.set_rpc_method(METHOD_ECHO1)
.set_metadata(std::move(metadata));
// Make sure all backends are up.
WaitForBackend(0);
WaitForBackend(1, WaitForBackendOptions(), header_match_rpc_options);
WaitForBackend(DEBUG_LOCATION, 0);
WaitForBackend(DEBUG_LOCATION, 1, WaitForBackendOptions(),
header_match_rpc_options);
// Send RPCs.
CheckRpcSendOk(kNumEchoRpcs);
CheckRpcSendOk(kNumEcho1Rpcs, header_match_rpc_options);
CheckRpcSendOk(DEBUG_LOCATION, kNumEchoRpcs);
CheckRpcSendOk(DEBUG_LOCATION, kNumEcho1Rpcs, header_match_rpc_options);
EXPECT_EQ(kNumEchoRpcs, backends_[0]->backend_service()->request_count());
EXPECT_EQ(0, backends_[0]->backend_service1()->request_count());
EXPECT_EQ(0, backends_[0]->backend_service2()->request_count());
@ -2467,9 +2500,9 @@ TEST_P(LdsRdsTest, XdsRoutingHeadersMatchingSpecialHeaderContentType) {
default_route->mutable_route()->set_cluster(kDefaultClusterName);
SetRouteConfiguration(balancer_.get(), route_config);
// Make sure the backend is up.
WaitForAllBackends(0, 1);
WaitForAllBackends(DEBUG_LOCATION, 0, 1);
// Send RPCs.
CheckRpcSendOk(kNumEchoRpcs);
CheckRpcSendOk(DEBUG_LOCATION, kNumEchoRpcs);
EXPECT_EQ(kNumEchoRpcs, backends_[0]->backend_service()->request_count());
EXPECT_EQ(0, backends_[1]->backend_service()->request_count());
auto response_state = RouteConfigurationResponseState(balancer_.get());
@ -2514,8 +2547,9 @@ TEST_P(LdsRdsTest, XdsRoutingHeadersMatchingSpecialCasesToIgnore) {
std::vector<std::pair<std::string, std::string>> metadata = {
{"grpc-foo-bin", "grpc-foo-bin"},
};
WaitForAllBackends(0, 1);
CheckRpcSendOk(kNumEchoRpcs, RpcOptions().set_metadata(metadata));
WaitForAllBackends(DEBUG_LOCATION, 0, 1);
CheckRpcSendOk(DEBUG_LOCATION, kNumEchoRpcs,
RpcOptions().set_metadata(metadata));
// Verify that only the default backend got RPCs since all previous routes
// were mismatched.
EXPECT_EQ(kNumEchoRpcs, backends_[0]->backend_service()->request_count());
@ -2563,8 +2597,8 @@ TEST_P(LdsRdsTest, XdsRoutingRuntimeFractionMatching) {
default_route->mutable_match()->set_prefix("");
default_route->mutable_route()->set_cluster(kDefaultClusterName);
SetRouteConfiguration(balancer_.get(), route_config);
WaitForAllBackends(0, 2);
CheckRpcSendOk(kNumRpcs);
WaitForAllBackends(DEBUG_LOCATION, 0, 2);
CheckRpcSendOk(DEBUG_LOCATION, kNumRpcs);
const int default_backend_count =
backends_[0]->backend_service()->request_count();
const int matched_backend_count =
@ -2656,12 +2690,14 @@ TEST_P(LdsRdsTest, XdsRoutingHeadersMatchingUnmatchCases) {
{"header3", "123"},
{"header1", "GET"},
};
WaitForAllBackends(0, 1);
CheckRpcSendOk(kNumEchoRpcs, RpcOptions().set_metadata(metadata));
CheckRpcSendOk(kNumEcho1Rpcs, RpcOptions()
.set_rpc_service(SERVICE_ECHO1)
.set_rpc_method(METHOD_ECHO1)
.set_metadata(metadata));
WaitForAllBackends(DEBUG_LOCATION, 0, 1);
CheckRpcSendOk(DEBUG_LOCATION, kNumEchoRpcs,
RpcOptions().set_metadata(metadata));
CheckRpcSendOk(DEBUG_LOCATION, kNumEcho1Rpcs,
RpcOptions()
.set_rpc_service(SERVICE_ECHO1)
.set_rpc_method(METHOD_ECHO1)
.set_metadata(metadata));
// Verify that only the default backend got RPCs since all previous routes
// were mismatched.
for (size_t i = 1; i < 4; ++i) {
@ -2708,10 +2744,13 @@ TEST_P(LdsRdsTest, XdsRoutingChangeRoutesWithoutChangingClusters) {
SetRouteConfiguration(balancer_.get(), route_config);
// Make sure all backends are up and that requests for each RPC
// service go to the right backends.
WaitForBackend(0, WaitForBackendOptions().set_reset_counters(false));
WaitForBackend(1, WaitForBackendOptions().set_reset_counters(false),
WaitForBackend(DEBUG_LOCATION, 0,
WaitForBackendOptions().set_reset_counters(false));
WaitForBackend(DEBUG_LOCATION, 1,
WaitForBackendOptions().set_reset_counters(false),
RpcOptions().set_rpc_service(SERVICE_ECHO1));
WaitForBackend(0, WaitForBackendOptions().set_reset_counters(false),
WaitForBackend(DEBUG_LOCATION, 0,
WaitForBackendOptions().set_reset_counters(false),
RpcOptions().set_rpc_service(SERVICE_ECHO2));
// Requests for services Echo and Echo2 should have gone to backend 0.
EXPECT_EQ(1, backends_[0]->backend_service()->request_count());
@ -2725,14 +2764,17 @@ TEST_P(LdsRdsTest, XdsRoutingChangeRoutesWithoutChangingClusters) {
// different RPC service, and wait for the client to make the change.
route1->mutable_match()->set_prefix("/grpc.testing.EchoTest2Service/");
SetRouteConfiguration(balancer_.get(), route_config);
WaitForBackend(1, WaitForBackendOptions(),
WaitForBackend(DEBUG_LOCATION, 1, WaitForBackendOptions(),
RpcOptions().set_rpc_service(SERVICE_ECHO2));
// Now repeat the earlier test, making sure all traffic goes to the
// right place.
WaitForBackend(0, WaitForBackendOptions().set_reset_counters(false));
WaitForBackend(0, WaitForBackendOptions().set_reset_counters(false),
WaitForBackend(DEBUG_LOCATION, 0,
WaitForBackendOptions().set_reset_counters(false));
WaitForBackend(DEBUG_LOCATION, 0,
WaitForBackendOptions().set_reset_counters(false),
RpcOptions().set_rpc_service(SERVICE_ECHO1));
WaitForBackend(1, WaitForBackendOptions().set_reset_counters(false),
WaitForBackend(DEBUG_LOCATION, 1,
WaitForBackendOptions().set_reset_counters(false),
RpcOptions().set_rpc_service(SERVICE_ECHO2));
// Requests for services Echo and Echo1 should have gone to backend 0.
EXPECT_EQ(1, backends_[0]->backend_service()->request_count());
@ -2753,7 +2795,7 @@ TEST_P(LdsRdsTest, RejectsUnknownHttpFilterTypeInVirtualHost) {
(*per_filter_config)["unknown"].PackFrom(Listener());
SetListenerAndRouteConfiguration(balancer_.get(), default_listener_,
route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("no filter registered for config type "
@ -2775,7 +2817,7 @@ TEST_P(LdsRdsTest, IgnoresOptionalUnknownHttpFilterTypeInVirtualHost) {
route_config);
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
auto response_state = RouteConfigurationResponseState(balancer_.get());
ASSERT_TRUE(response_state.has_value());
EXPECT_EQ(response_state->state, AdsServiceImpl::ResponseState::ACKED);
@ -2790,7 +2832,7 @@ TEST_P(LdsRdsTest, RejectsHttpFilterWithoutConfigInVirtualHost) {
(*per_filter_config)["unknown"];
SetListenerAndRouteConfiguration(balancer_.get(), default_listener_,
route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(
@ -2807,7 +2849,7 @@ TEST_P(LdsRdsTest, RejectsHttpFilterWithoutConfigInFilterConfigInVirtualHost) {
::envoy::config::route::v3::FilterConfig());
SetListenerAndRouteConfiguration(balancer_.get(), default_listener_,
route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(
@ -2830,7 +2872,7 @@ TEST_P(LdsRdsTest, IgnoresOptionalHttpFilterWithoutConfigInVirtualHost) {
{"locality0", CreateEndpointsForBackends()},
});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
auto response_state = RouteConfigurationResponseState(balancer_.get());
ASSERT_TRUE(response_state.has_value());
EXPECT_EQ(response_state->state, AdsServiceImpl::ResponseState::ACKED);
@ -2846,7 +2888,7 @@ TEST_P(LdsRdsTest, RejectsUnparseableHttpFilterTypeInVirtualHost) {
envoy::extensions::filters::http::router::v3::Router());
SetListenerAndRouteConfiguration(balancer_.get(), default_listener_,
route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -2863,7 +2905,7 @@ TEST_P(LdsRdsTest, RejectsUnknownHttpFilterTypeInRoute) {
(*per_filter_config)["unknown"].PackFrom(Listener());
SetListenerAndRouteConfiguration(balancer_.get(), default_listener_,
route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("no filter registered for config type "
@ -2886,7 +2928,7 @@ TEST_P(LdsRdsTest, IgnoresOptionalUnknownHttpFilterTypeInRoute) {
route_config);
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
auto response_state = RouteConfigurationResponseState(balancer_.get());
ASSERT_TRUE(response_state.has_value());
EXPECT_EQ(response_state->state, AdsServiceImpl::ResponseState::ACKED);
@ -2902,7 +2944,7 @@ TEST_P(LdsRdsTest, RejectsHttpFilterWithoutConfigInRoute) {
(*per_filter_config)["unknown"];
SetListenerAndRouteConfiguration(balancer_.get(), default_listener_,
route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(
@ -2920,7 +2962,7 @@ TEST_P(LdsRdsTest, RejectsHttpFilterWithoutConfigInFilterConfigInRoute) {
::envoy::config::route::v3::FilterConfig());
SetListenerAndRouteConfiguration(balancer_.get(), default_listener_,
route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(
@ -2942,7 +2984,7 @@ TEST_P(LdsRdsTest, IgnoresOptionalHttpFilterWithoutConfigInRoute) {
route_config);
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
auto response_state = RouteConfigurationResponseState(balancer_.get());
ASSERT_TRUE(response_state.has_value());
EXPECT_EQ(response_state->state, AdsServiceImpl::ResponseState::ACKED);
@ -2959,7 +3001,7 @@ TEST_P(LdsRdsTest, RejectsUnparseableHttpFilterTypeInRoute) {
envoy::extensions::filters::http::router::v3::Router());
SetListenerAndRouteConfiguration(balancer_.get(), default_listener_,
route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,
@ -2981,7 +3023,7 @@ TEST_P(LdsRdsTest, RejectsUnknownHttpFilterTypeInClusterWeight) {
(*per_filter_config)["unknown"].PackFrom(Listener());
SetListenerAndRouteConfiguration(balancer_.get(), default_listener_,
route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr("no filter registered for config type "
@ -3009,7 +3051,7 @@ TEST_P(LdsRdsTest, IgnoresOptionalUnknownHttpFilterTypeInClusterWeight) {
route_config);
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
auto response_state = RouteConfigurationResponseState(balancer_.get());
ASSERT_TRUE(response_state.has_value());
EXPECT_EQ(response_state->state, AdsServiceImpl::ResponseState::ACKED);
@ -3030,7 +3072,7 @@ TEST_P(LdsRdsTest, RejectsHttpFilterWithoutConfigInClusterWeight) {
(*per_filter_config)["unknown"];
SetListenerAndRouteConfiguration(balancer_.get(), default_listener_,
route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(
@ -3054,7 +3096,7 @@ TEST_P(LdsRdsTest,
::envoy::config::route::v3::FilterConfig());
SetListenerAndRouteConfiguration(balancer_.get(), default_listener_,
route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(response_state->error_message,
::testing::HasSubstr(
@ -3081,7 +3123,7 @@ TEST_P(LdsRdsTest, IgnoresOptionalHttpFilterWithoutConfigInClusterWeight) {
route_config);
EdsResourceArgs args({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
WaitForAllBackends();
WaitForAllBackends(DEBUG_LOCATION);
auto response_state = RouteConfigurationResponseState(balancer_.get());
ASSERT_TRUE(response_state.has_value());
EXPECT_EQ(response_state->state, AdsServiceImpl::ResponseState::ACKED);
@ -3103,7 +3145,7 @@ TEST_P(LdsRdsTest, RejectsUnparseableHttpFilterTypeInClusterWeight) {
envoy::extensions::filters::http::router::v3::Router());
SetListenerAndRouteConfiguration(balancer_.get(), default_listener_,
route_config);
const auto response_state = WaitForRdsNack();
const auto response_state = WaitForRdsNack(DEBUG_LOCATION);
ASSERT_TRUE(response_state.has_value()) << "timed out waiting for NACK";
EXPECT_THAT(
response_state->error_message,

Loading…
Cancel
Save