diff --git a/src/core/ext/xds/xds_client.cc b/src/core/ext/xds/xds_client.cc index 9d7d940bc76..7a027a2cf57 100644 --- a/src/core/ext/xds/xds_client.cc +++ b/src/core/ext/xds/xds_client.cc @@ -969,7 +969,7 @@ void XdsClient::ChannelState::AdsCallState::AcceptRdsUpdate( " resources", xds_client(), rds_update_map.size()); } - auto& rds_state = state_map_[XdsApi::kLdsTypeUrl]; + auto& rds_state = state_map_[XdsApi::kRdsTypeUrl]; for (auto& p : rds_update_map) { const std::string& route_config_name = p.first; XdsApi::RdsUpdate& rds_update = p.second; diff --git a/test/cpp/end2end/xds_end2end_test.cc b/test/cpp/end2end/xds_end2end_test.cc index e36a1445fbf..e8797ceb527 100644 --- a/test/cpp/end2end/xds_end2end_test.cc +++ b/test/cpp/end2end/xds_end2end_test.cc @@ -114,10 +114,34 @@ constexpr char kDefaultLocalityRegion[] = "xds_default_locality_region"; constexpr char kDefaultLocalityZone[] = "xds_default_locality_zone"; constexpr char kLbDropType[] = "lb"; constexpr char kThrottleDropType[] = "throttle"; -constexpr char kDefaultResourceName[] = "application_target_name"; +constexpr char kServerName[] = "server.example.com"; +constexpr char kDefaultRouteConfigurationName[] = "route_config_name"; +constexpr char kDefaultClusterName[] = "cluster_name"; +constexpr char kDefaultEdsServiceName[] = "eds_service_name"; constexpr int kDefaultLocalityWeight = 3; constexpr int kDefaultLocalityPriority = 0; +constexpr char kRequestMessage[] = "Live long and prosper."; +constexpr char kDefaultServiceConfig[] = + "{\n" + " \"loadBalancingConfig\":[\n" + " { \"does_not_exist\":{} },\n" + " { \"eds_experimental\":{\n" + " \"clusterName\": \"application_target_name\",\n" + " \"lrsLoadReportingServerName\": \"\"\n" + " } }\n" + " ]\n" + "}"; +constexpr char kDefaultServiceConfigWithoutLoadReporting[] = + "{\n" + " \"loadBalancingConfig\":[\n" + " { \"does_not_exist\":{} },\n" + " { \"eds_experimental\":{\n" + " \"clusterName\": \"application_target_name\"\n" + " } }\n" + " ]\n" + "}"; + constexpr char kBootstrapFileV3[] = "{\n" " \"xds_servers\": [\n" @@ -465,22 +489,22 @@ class AdsServiceImpl : public std::enable_shared_from_this { : v2_rpc_service_(this, /*is_v2=*/true), v3_rpc_service_(this, /*is_v2=*/false) { // Construct RDS response data. - default_route_config_.set_name(kDefaultResourceName); + default_route_config_.set_name(kDefaultRouteConfigurationName); auto* virtual_host = default_route_config_.add_virtual_hosts(); virtual_host->add_domains("*"); auto* route = virtual_host->add_routes(); route->mutable_match()->set_prefix(""); - route->mutable_route()->set_cluster(kDefaultResourceName); + route->mutable_route()->set_cluster(kDefaultClusterName); SetRdsResource(default_route_config_); // Construct LDS response data (with inlined RDS result). default_listener_ = BuildListener(default_route_config_); SetLdsResource(default_listener_); // Construct CDS response data. - default_cluster_.set_name(kDefaultResourceName); + default_cluster_.set_name(kDefaultClusterName); default_cluster_.set_type(Cluster::EDS); - default_cluster_.mutable_eds_cluster_config() - ->mutable_eds_config() - ->mutable_ads(); + auto* eds_config = default_cluster_.mutable_eds_cluster_config(); + eds_config->mutable_eds_config()->mutable_ads(); + eds_config->set_service_name(kDefaultEdsServiceName); default_cluster_.set_lb_policy(Cluster::ROUND_ROBIN); if (enable_load_reporting) { default_cluster_.mutable_lrs_server()->mutable_self(); @@ -585,7 +609,7 @@ class AdsServiceImpl : public std::enable_shared_from_this { auto listener = default_listener_; HttpConnectionManager http_connection_manager; auto* rds = http_connection_manager.mutable_rds(); - rds->set_route_config_name(kDefaultResourceName); + rds->set_route_config_name(kDefaultRouteConfigurationName); rds->mutable_config_source()->mutable_ads(); listener.mutable_api_listener()->mutable_api_listener()->PackFrom( http_connection_manager); @@ -596,31 +620,17 @@ class AdsServiceImpl : public std::enable_shared_from_this { HttpConnectionManager http_connection_manager; *(http_connection_manager.mutable_route_config()) = route_config; Listener listener; - listener.set_name(kDefaultResourceName); + listener.set_name(kServerName); listener.mutable_api_listener()->mutable_api_listener()->PackFrom( http_connection_manager); return listener; } - void Start() { - grpc_core::MutexLock lock(&ads_mu_); - ads_done_ = false; - } - - void Shutdown() { - { - grpc_core::MutexLock lock(&ads_mu_); - NotifyDoneWithAdsCallLocked(); - resource_type_response_state_.clear(); - } - gpr_log(GPR_INFO, "ADS[%p]: shut down", this); - } - static ClusterLoadAssignment BuildEdsResource( const EdsResourceArgs& args, - const char* cluster_name = kDefaultResourceName) { + const char* eds_service_name = kDefaultEdsServiceName) { ClusterLoadAssignment assignment; - assignment.set_cluster_name(cluster_name); + assignment.set_cluster_name(eds_service_name); for (const auto& locality : args.locality_list) { auto* endpoints = assignment.add_endpoints(); endpoints->mutable_load_balancing_weight()->set_value(locality.lb_weight); @@ -657,6 +667,20 @@ class AdsServiceImpl : public std::enable_shared_from_this { return assignment; } + void Start() { + grpc_core::MutexLock lock(&ads_mu_); + ads_done_ = false; + } + + void Shutdown() { + { + grpc_core::MutexLock lock(&ads_mu_); + NotifyDoneWithAdsCallLocked(); + resource_type_response_state_.clear(); + } + gpr_log(GPR_INFO, "ADS[%p]: shut down", this); + } + void NotifyDoneWithAdsCall() { grpc_core::MutexLock lock(&ads_mu_); NotifyDoneWithAdsCallLocked(); @@ -1116,7 +1140,7 @@ class LrsServiceImpl : public std::enable_shared_from_this { v3_rpc_service_(this), client_load_reporting_interval_seconds_( client_load_reporting_interval_seconds), - cluster_names_({kDefaultResourceName}) {} + cluster_names_({kDefaultClusterName}) {} ::envoy::service::load_stats::v2::LoadReportingService::Service* v2_rpc_service() { @@ -1349,6 +1373,10 @@ class XdsEnd2endTest : public ::testing::TestWithParam { ResetStub(); } + const char* DefaultEdsServiceName() const { + return GetParam().use_xds_resolver() ? kDefaultEdsServiceName : kServerName; + } + void TearDown() override { ShutdownAllBackends(); for (auto& balancer : balancers_) balancer->Shutdown(); @@ -1392,9 +1420,8 @@ class XdsEnd2endTest : public ::testing::TestWithParam { if (!expected_targets.empty()) { args.SetString(GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS, expected_targets); } - std::string scheme = GetParam().use_xds_resolver() ? "xds" : "fake"; - std::ostringstream uri; - uri << scheme << ":///" << kApplicationTargetName_; + std::string uri = absl::StrCat( + GetParam().use_xds_resolver() ? "xds" : "fake", ":///", kServerName); // TODO(dgq): templatize tests to run everything using both secure and // insecure channel credentials. grpc_channel_credentials* channel_creds = @@ -1406,7 +1433,7 @@ class XdsEnd2endTest : public ::testing::TestWithParam { channel_creds, call_creds, nullptr))); call_creds->Unref(); channel_creds->Unref(); - channel_ = ::grpc::CreateCustomChannel(uri.str(), creds, args); + channel_ = ::grpc::CreateCustomChannel(uri, creds, args); stub_ = grpc::testing::EchoTestService::NewStub(channel_); stub1_ = grpc::testing::EchoTest1Service::NewStub(channel_); stub2_ = grpc::testing::EchoTest2Service::NewStub(channel_); @@ -1589,8 +1616,8 @@ class XdsEnd2endTest : public ::testing::TestWithParam { grpc_error* error = GRPC_ERROR_NONE; const char* service_config_json = GetParam().enable_load_reporting() - ? kDefaultServiceConfig_ - : kDefaultServiceConfigWithoutLoadReporting_; + ? kDefaultServiceConfig + : kDefaultServiceConfigWithoutLoadReporting; result.service_config = grpc_core::ServiceConfig::Create(service_config_json, &error); ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); @@ -1666,7 +1693,7 @@ class XdsEnd2endTest : public ::testing::TestWithParam { grpc_timeout_milliseconds_to_deadline(rpc_options.timeout_ms)); } if (rpc_options.wait_for_ready) context.set_wait_for_ready(true); - request.set_message(kRequestMessage_); + request.set_message(kRequestMessage); if (rpc_options.server_fail) { request.mutable_param()->mutable_expected_error()->set_code( GRPC_STATUS_FAILED_PRECONDITION); @@ -1697,7 +1724,7 @@ class XdsEnd2endTest : public ::testing::TestWithParam { const Status status = SendRpc(rpc_options, &response); EXPECT_TRUE(status.ok()) << "code=" << status.error_code() << " message=" << status.error_message(); - EXPECT_EQ(response.message(), kRequestMessage_); + EXPECT_EQ(response.message(), kRequestMessage); } } @@ -1888,27 +1915,6 @@ class XdsEnd2endTest : public ::testing::TestWithParam { response_generator_; grpc_core::RefCountedPtr lb_channel_response_generator_; - const std::string kRequestMessage_ = "Live long and prosper."; - const std::string kApplicationTargetName_ = kDefaultResourceName; - const char* kDefaultServiceConfig_ = - "{\n" - " \"loadBalancingConfig\":[\n" - " { \"does_not_exist\":{} },\n" - " { \"eds_experimental\":{\n" - " \"clusterName\": \"application_target_name\",\n" - " \"lrsLoadReportingServerName\": \"\"\n" - " } }\n" - " ]\n" - "}"; - const char* kDefaultServiceConfigWithoutLoadReporting_ = - "{\n" - " \"loadBalancingConfig\":[\n" - " { \"does_not_exist\":{} },\n" - " { \"eds_experimental\":{\n" - " \"clusterName\": \"application_target_name\"\n" - " } }\n" - " ]\n" - "}"; }; class BasicTest : public XdsEnd2endTest { @@ -1926,7 +1932,7 @@ TEST_P(BasicTest, Vanilla) { {"locality0", GetBackendPorts()}, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); // 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. @@ -1956,7 +1962,7 @@ TEST_P(BasicTest, IgnoresUnhealthyEndpoints) { {HealthStatus::DRAINING}}, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); // 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. @@ -1982,7 +1988,7 @@ TEST_P(BasicTest, SameBackendListedMultipleTimes) { }); const size_t kNumRpcsPerAddress = 10; balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); // We need to wait for the backend to come online. WaitForBackend(0); // Send kNumRpcsPerAddress RPCs per server. @@ -2007,14 +2013,15 @@ TEST_P(BasicTest, InitiallyEmptyServerlist) { empty_locality, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); // Send non-empty serverlist only after kServerlistDelayMs. args = AdsServiceImpl::EdsResourceArgs({ {"locality0", GetBackendPorts()}, }); std::thread delayed_resource_setter( std::bind(&BasicTest::SetEdsResourceWithDelay, this, 0, - AdsServiceImpl::BuildEdsResource(args), kServerlistDelayMs)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName()), + kServerlistDelayMs)); const auto t0 = system_clock::now(); // Client will block: LB will initially send empty serverlist. CheckRpcSendOk( @@ -2044,7 +2051,7 @@ TEST_P(BasicTest, AllServersUnreachableFailFast) { {"locality0", ports}, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); const Status status = SendRpc(); // The error shouldn't be DEADLINE_EXCEEDED. EXPECT_EQ(StatusCode::UNAVAILABLE, status.error_code()); @@ -2059,7 +2066,7 @@ TEST_P(BasicTest, BackendsRestart) { {"locality0", GetBackendPorts()}, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); WaitForAllBackends(); // Stop backends. RPCs should fail. ShutdownAllBackends(); @@ -2086,7 +2093,7 @@ TEST_P(BasicTest, IgnoresDuplicateUpdates) { {"locality0", GetBackendPorts()}, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); // Wait for all backends to come online. WaitForAllBackends(); // Send kNumRpcsPerAddress RPCs per server, but send an EDS update in @@ -2096,7 +2103,7 @@ TEST_P(BasicTest, IgnoresDuplicateUpdates) { for (size_t i = 0; i < kNumRpcsPerAddress; ++i) { CheckRpcSendOk(2); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); CheckRpcSendOk(2); } // Each backend should have gotten the right number of requests. @@ -2111,6 +2118,7 @@ using XdsResolverOnlyTest = BasicTest; // Tests switching over from one cluster to another. TEST_P(XdsResolverOnlyTest, ChangeClusters) { const char* kNewClusterName = "new_cluster_name"; + const char* kNewEdsServiceName = "new_eds_service_name"; SetNextResolution({}); SetNextResolutionForLbChannelAllBalancers(); AdsServiceImpl::EdsResourceArgs args({ @@ -2125,10 +2133,12 @@ TEST_P(XdsResolverOnlyTest, ChangeClusters) { {"locality0", GetBackendPorts(2, 4)}, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args2, kNewClusterName)); + AdsServiceImpl::BuildEdsResource(args2, kNewEdsServiceName)); // Populate new CDS resource. Cluster new_cluster = balancers_[0]->ads_service()->default_cluster(); new_cluster.set_name(kNewClusterName); + new_cluster.mutable_eds_cluster_config()->set_service_name( + kNewEdsServiceName); balancers_[0]->ads_service()->SetCdsResource(new_cluster); // Change RDS resource to point to new cluster. RouteConfiguration new_route_config = @@ -2158,8 +2168,7 @@ TEST_P(XdsResolverOnlyTest, ClusterRemoved) { // We need to wait for all backends to come online. WaitForAllBackends(); // Unset CDS resource. - balancers_[0]->ads_service()->UnsetResource(kCdsTypeUrl, - kDefaultResourceName); + balancers_[0]->ads_service()->UnsetResource(kCdsTypeUrl, kDefaultClusterName); // Wait for RPCs to start failing. do { } while (SendRpc(RpcOptions(), nullptr).ok()); @@ -2174,6 +2183,7 @@ TEST_P(XdsResolverOnlyTest, ClusterRemoved) { TEST_P(XdsResolverOnlyTest, RestartsRequestsUponReconnection) { balancers_[0]->ads_service()->SetLdsToUseDynamicRds(); const char* kNewClusterName = "new_cluster_name"; + const char* kNewEdsServiceName = "new_eds_service_name"; SetNextResolution({}); SetNextResolutionForLbChannelAllBalancers(); AdsServiceImpl::EdsResourceArgs args({ @@ -2195,10 +2205,12 @@ TEST_P(XdsResolverOnlyTest, RestartsRequestsUponReconnection) { {"locality0", GetBackendPorts(2, 4)}, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args2, kNewClusterName)); + AdsServiceImpl::BuildEdsResource(args2, kNewEdsServiceName)); // Populate new CDS resource. Cluster new_cluster = balancers_[0]->ads_service()->default_cluster(); new_cluster.set_name(kNewClusterName); + new_cluster.mutable_eds_cluster_config()->set_service_name( + kNewEdsServiceName); balancers_[0]->ads_service()->SetCdsResource(new_cluster); // Change RDS resource to point to new cluster. RouteConfiguration new_route_config = @@ -2242,11 +2254,12 @@ class XdsResolverLoadReportingOnlyTest : public XdsEnd2endTest { // Tests load reporting when switching over from one cluster to another. TEST_P(XdsResolverLoadReportingOnlyTest, ChangeClusters) { const char* kNewClusterName = "new_cluster_name"; + const char* kNewEdsServiceName = "new_eds_service_name"; balancers_[0]->lrs_service()->set_cluster_names( - {kDefaultResourceName, kNewClusterName}); + {kDefaultClusterName, kNewClusterName}); SetNextResolution({}); SetNextResolutionForLbChannelAllBalancers(); - // cluster kDefaultResourceName -> locality0 -> backends 0 and 1 + // cluster kDefaultClusterName -> locality0 -> backends 0 and 1 AdsServiceImpl::EdsResourceArgs args({ {"locality0", GetBackendPorts(0, 2)}, }); @@ -2257,10 +2270,12 @@ TEST_P(XdsResolverLoadReportingOnlyTest, ChangeClusters) { {"locality1", GetBackendPorts(2, 4)}, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args2, kNewClusterName)); + AdsServiceImpl::BuildEdsResource(args2, kNewEdsServiceName)); // CDS resource for kNewClusterName. Cluster new_cluster = balancers_[0]->ads_service()->default_cluster(); new_cluster.set_name(kNewClusterName); + new_cluster.mutable_eds_cluster_config()->set_service_name( + kNewEdsServiceName); balancers_[0]->ads_service()->SetCdsResource(new_cluster); // Wait for all backends to come online. int num_ok = 0; @@ -2273,7 +2288,7 @@ TEST_P(XdsResolverLoadReportingOnlyTest, ChangeClusters) { EXPECT_THAT( load_report, ::testing::ElementsAre(::testing::AllOf( - ::testing::Property(&ClientStats::cluster_name, kDefaultResourceName), + ::testing::Property(&ClientStats::cluster_name, kDefaultClusterName), ::testing::Property( &ClientStats::locality_stats, ::testing::ElementsAre(::testing::Pair( @@ -2312,7 +2327,7 @@ TEST_P(XdsResolverLoadReportingOnlyTest, ChangeClusters) { ::testing::ElementsAre( ::testing::AllOf( ::testing::Property(&ClientStats::cluster_name, - kDefaultResourceName), + kDefaultClusterName), ::testing::Property( &ClientStats::locality_stats, ::testing::ElementsAre(::testing::Pair( @@ -2373,7 +2388,7 @@ using SecureNamingTest = BasicTest; // Tests that secure naming check passes if target name is expected. TEST_P(SecureNamingTest, TargetNameIsExpected) { // TODO(juanlishen): Use separate fake creds for the balancer channel. - ResetStub(0, kApplicationTargetName_ + ";lb"); + ResetStub(0, absl::StrCat(kServerName, ";lb")); SetNextResolution({}); SetNextResolutionForLbChannel({balancers_[0]->port()}); const size_t kNumRpcsPerAddress = 100; @@ -2381,7 +2396,7 @@ TEST_P(SecureNamingTest, TargetNameIsExpected) { {"locality0", GetBackendPorts()}, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); // 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. @@ -2403,7 +2418,7 @@ TEST_P(SecureNamingTest, TargetNameIsUnexpected) { // the name from the balancer doesn't match expectations. ASSERT_DEATH_IF_SUPPORTED( { - ResetStub(0, kApplicationTargetName_ + ";lb"); + ResetStub(0, absl::StrCat(kServerName, ";lb")); SetNextResolution({}); SetNextResolutionForLbChannel({balancers_[0]->port()}); channel_->WaitForConnected(grpc_timeout_seconds_to_deadline(1)); @@ -2453,7 +2468,7 @@ TEST_P(LdsTest, RdsMissingConfigSource) { auto listener = balancers_[0]->ads_service()->default_listener(); HttpConnectionManager http_connection_manager; http_connection_manager.mutable_rds()->set_route_config_name( - kDefaultResourceName); + kDefaultRouteConfigurationName); listener.mutable_api_listener()->mutable_api_listener()->PackFrom( http_connection_manager); balancers_[0]->ads_service()->SetLdsResource(listener); @@ -2473,7 +2488,7 @@ TEST_P(LdsTest, RdsConfigSourceDoesNotSpecifyAds) { auto listener = balancers_[0]->ads_service()->default_listener(); HttpConnectionManager http_connection_manager; auto* rds = http_connection_manager.mutable_rds(); - rds->set_route_config_name(kDefaultResourceName); + rds->set_route_config_name(kDefaultRouteConfigurationName); rds->mutable_config_source()->mutable_self(); listener.mutable_api_listener()->mutable_api_listener()->PackFrom( http_connection_manager); @@ -2517,8 +2532,7 @@ TEST_P(LdsRdsTest, ListenerRemoved) { // We need to wait for all backends to come online. WaitForAllBackends(); // Unset LDS resource. - balancers_[0]->ads_service()->UnsetResource(kLdsTypeUrl, - kDefaultResourceName); + balancers_[0]->ads_service()->UnsetResource(kLdsTypeUrl, kServerName); // Wait for RPCs to start failing. do { } while (SendRpc(RpcOptions(), nullptr).ok()); @@ -2623,7 +2637,7 @@ TEST_P(LdsRdsTest, RouteMatchHasValidPrefixEmptyOrSingleSlash) { route1->mutable_match()->set_prefix(""); auto* default_route = route_config.mutable_virtual_hosts(0)->add_routes(); default_route->mutable_match()->set_prefix("/"); - default_route->mutable_route()->set_cluster(kDefaultResourceName); + default_route->mutable_route()->set_cluster(kDefaultClusterName); SetRouteConfiguration(0, route_config); SetNextResolution({}); SetNextResolutionForLbChannelAllBalancers(); @@ -2817,7 +2831,7 @@ TEST_P(LdsRdsTest, RouteActionClusterHasEmptyClusterName) { route1->mutable_route()->set_cluster(""); auto* default_route = route_config.mutable_virtual_hosts(0)->add_routes(); default_route->mutable_match()->set_prefix(""); - default_route->mutable_route()->set_cluster(kDefaultResourceName); + default_route->mutable_route()->set_cluster(kDefaultClusterName); SetRouteConfiguration(0, route_config); SetNextResolution({}); SetNextResolutionForLbChannelAllBalancers(); @@ -2845,7 +2859,7 @@ TEST_P(LdsRdsTest, RouteActionWeightedTargetHasIncorrectTotalWeightSet) { ->set_value(kWeight75 + 1); auto* default_route = route_config.mutable_virtual_hosts(0)->add_routes(); default_route->mutable_match()->set_prefix(""); - default_route->mutable_route()->set_cluster(kDefaultResourceName); + default_route->mutable_route()->set_cluster(kDefaultClusterName); SetRouteConfiguration(0, route_config); SetNextResolution({}); SetNextResolutionForLbChannelAllBalancers(); @@ -2872,7 +2886,7 @@ TEST_P(LdsRdsTest, RouteActionWeightedTargetClusterHasEmptyClusterName) { ->set_value(kWeight75); auto* default_route = route_config.mutable_virtual_hosts(0)->add_routes(); default_route->mutable_match()->set_prefix(""); - default_route->mutable_route()->set_cluster(kDefaultResourceName); + default_route->mutable_route()->set_cluster(kDefaultClusterName); SetRouteConfiguration(0, route_config); SetNextResolution({}); SetNextResolutionForLbChannelAllBalancers(); @@ -2900,7 +2914,7 @@ TEST_P(LdsRdsTest, RouteActionWeightedTargetClusterHasNoWeight) { ->set_value(kWeight75); auto* default_route = route_config.mutable_virtual_hosts(0)->add_routes(); default_route->mutable_match()->set_prefix(""); - default_route->mutable_route()->set_cluster(kDefaultResourceName); + default_route->mutable_route()->set_cluster(kDefaultClusterName); SetRouteConfiguration(0, route_config); SetNextResolution({}); SetNextResolutionForLbChannelAllBalancers(); @@ -2970,7 +2984,9 @@ TEST_P(LdsRdsTest, Timeout) { // specified) after unable to find a match with previous routes. TEST_P(LdsRdsTest, XdsRoutingPathMatching) { const char* kNewCluster1Name = "new_cluster_1"; + const char* kNewEdsService1Name = "new_eds_service_name_1"; const char* kNewCluster2Name = "new_cluster_2"; + const char* kNewEdsService2Name = "new_eds_service_name_2"; const size_t kNumEcho1Rpcs = 10; const size_t kNumEcho2Rpcs = 20; const size_t kNumEchoRpcs = 30; @@ -2989,15 +3005,19 @@ TEST_P(LdsRdsTest, XdsRoutingPathMatching) { balancers_[0]->ads_service()->SetEdsResource( AdsServiceImpl::BuildEdsResource(args)); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args1, kNewCluster1Name)); + AdsServiceImpl::BuildEdsResource(args1, kNewEdsService1Name)); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args2, kNewCluster2Name)); + AdsServiceImpl::BuildEdsResource(args2, kNewEdsService2Name)); // Populate new CDS resources. Cluster new_cluster1 = balancers_[0]->ads_service()->default_cluster(); new_cluster1.set_name(kNewCluster1Name); + new_cluster1.mutable_eds_cluster_config()->set_service_name( + kNewEdsService1Name); balancers_[0]->ads_service()->SetCdsResource(new_cluster1); Cluster new_cluster2 = balancers_[0]->ads_service()->default_cluster(); new_cluster2.set_name(kNewCluster2Name); + new_cluster2.mutable_eds_cluster_config()->set_service_name( + kNewEdsService2Name); balancers_[0]->ads_service()->SetCdsResource(new_cluster2); // Populating Route Configurations for LDS. RouteConfiguration new_route_config = @@ -3010,10 +3030,10 @@ TEST_P(LdsRdsTest, XdsRoutingPathMatching) { route2->mutable_route()->set_cluster(kNewCluster2Name); auto* route3 = new_route_config.mutable_virtual_hosts(0)->add_routes(); route3->mutable_match()->set_path("/grpc.testing.EchoTest3Service/Echo3"); - route3->mutable_route()->set_cluster(kDefaultResourceName); + route3->mutable_route()->set_cluster(kDefaultClusterName); auto* default_route = new_route_config.mutable_virtual_hosts(0)->add_routes(); default_route->mutable_match()->set_prefix(""); - default_route->mutable_route()->set_cluster(kDefaultResourceName); + default_route->mutable_route()->set_cluster(kDefaultClusterName); SetRouteConfiguration(0, new_route_config); WaitForAllBackends(0, 2); CheckRpcSendOk(kNumEchoRpcs, RpcOptions().set_wait_for_ready(true)); @@ -3042,7 +3062,9 @@ TEST_P(LdsRdsTest, XdsRoutingPathMatching) { TEST_P(LdsRdsTest, XdsRoutingPrefixMatching) { const char* kNewCluster1Name = "new_cluster_1"; + const char* kNewEdsService1Name = "new_eds_service_name_1"; const char* kNewCluster2Name = "new_cluster_2"; + const char* kNewEdsService2Name = "new_eds_service_name_2"; const size_t kNumEcho1Rpcs = 10; const size_t kNumEcho2Rpcs = 20; const size_t kNumEchoRpcs = 30; @@ -3061,15 +3083,19 @@ TEST_P(LdsRdsTest, XdsRoutingPrefixMatching) { balancers_[0]->ads_service()->SetEdsResource( AdsServiceImpl::BuildEdsResource(args)); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args1, kNewCluster1Name)); + AdsServiceImpl::BuildEdsResource(args1, kNewEdsService1Name)); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args2, kNewCluster2Name)); + AdsServiceImpl::BuildEdsResource(args2, kNewEdsService2Name)); // Populate new CDS resources. Cluster new_cluster1 = balancers_[0]->ads_service()->default_cluster(); new_cluster1.set_name(kNewCluster1Name); + new_cluster1.mutable_eds_cluster_config()->set_service_name( + kNewEdsService1Name); balancers_[0]->ads_service()->SetCdsResource(new_cluster1); Cluster new_cluster2 = balancers_[0]->ads_service()->default_cluster(); new_cluster2.set_name(kNewCluster2Name); + new_cluster2.mutable_eds_cluster_config()->set_service_name( + kNewEdsService2Name); balancers_[0]->ads_service()->SetCdsResource(new_cluster2); // Populating Route Configurations for LDS. RouteConfiguration new_route_config = @@ -3082,7 +3108,7 @@ TEST_P(LdsRdsTest, XdsRoutingPrefixMatching) { route2->mutable_route()->set_cluster(kNewCluster2Name); auto* default_route = new_route_config.mutable_virtual_hosts(0)->add_routes(); default_route->mutable_match()->set_prefix(""); - default_route->mutable_route()->set_cluster(kDefaultResourceName); + default_route->mutable_route()->set_cluster(kDefaultClusterName); SetRouteConfiguration(0, new_route_config); WaitForAllBackends(0, 2); CheckRpcSendOk(kNumEchoRpcs, RpcOptions().set_wait_for_ready(true)); @@ -3109,7 +3135,9 @@ TEST_P(LdsRdsTest, XdsRoutingPrefixMatching) { TEST_P(LdsRdsTest, XdsRoutingPathRegexMatching) { const char* kNewCluster1Name = "new_cluster_1"; + const char* kNewEdsService1Name = "new_eds_service_name_1"; const char* kNewCluster2Name = "new_cluster_2"; + const char* kNewEdsService2Name = "new_eds_service_name_2"; const size_t kNumEcho1Rpcs = 10; const size_t kNumEcho2Rpcs = 20; const size_t kNumEchoRpcs = 30; @@ -3128,15 +3156,19 @@ TEST_P(LdsRdsTest, XdsRoutingPathRegexMatching) { balancers_[0]->ads_service()->SetEdsResource( AdsServiceImpl::BuildEdsResource(args)); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args1, kNewCluster1Name)); + AdsServiceImpl::BuildEdsResource(args1, kNewEdsService1Name)); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args2, kNewCluster2Name)); + AdsServiceImpl::BuildEdsResource(args2, kNewEdsService2Name)); // Populate new CDS resources. Cluster new_cluster1 = balancers_[0]->ads_service()->default_cluster(); new_cluster1.set_name(kNewCluster1Name); + new_cluster1.mutable_eds_cluster_config()->set_service_name( + kNewEdsService1Name); balancers_[0]->ads_service()->SetCdsResource(new_cluster1); Cluster new_cluster2 = balancers_[0]->ads_service()->default_cluster(); new_cluster2.set_name(kNewCluster2Name); + new_cluster2.mutable_eds_cluster_config()->set_service_name( + kNewEdsService2Name); balancers_[0]->ads_service()->SetCdsResource(new_cluster2); // Populating Route Configurations for LDS. RouteConfiguration new_route_config = @@ -3151,7 +3183,7 @@ TEST_P(LdsRdsTest, XdsRoutingPathRegexMatching) { route2->mutable_route()->set_cluster(kNewCluster2Name); auto* default_route = new_route_config.mutable_virtual_hosts(0)->add_routes(); default_route->mutable_match()->set_prefix(""); - default_route->mutable_route()->set_cluster(kDefaultResourceName); + default_route->mutable_route()->set_cluster(kDefaultClusterName); SetRouteConfiguration(0, new_route_config); WaitForAllBackends(0, 2); CheckRpcSendOk(kNumEchoRpcs, RpcOptions().set_wait_for_ready(true)); @@ -3178,7 +3210,9 @@ TEST_P(LdsRdsTest, XdsRoutingPathRegexMatching) { TEST_P(LdsRdsTest, XdsRoutingWeightedCluster) { const char* kNewCluster1Name = "new_cluster_1"; + const char* kNewEdsService1Name = "new_eds_service_name_1"; const char* kNewCluster2Name = "new_cluster_2"; + const char* kNewEdsService2Name = "new_eds_service_name_2"; const size_t kNumEcho1Rpcs = 1000; const size_t kNumEchoRpcs = 10; const size_t kWeight75 = 75; @@ -3198,15 +3232,19 @@ TEST_P(LdsRdsTest, XdsRoutingWeightedCluster) { balancers_[0]->ads_service()->SetEdsResource( AdsServiceImpl::BuildEdsResource(args)); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args1, kNewCluster1Name)); + AdsServiceImpl::BuildEdsResource(args1, kNewEdsService1Name)); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args2, kNewCluster2Name)); + AdsServiceImpl::BuildEdsResource(args2, kNewEdsService2Name)); // Populate new CDS resources. Cluster new_cluster1 = balancers_[0]->ads_service()->default_cluster(); new_cluster1.set_name(kNewCluster1Name); + new_cluster1.mutable_eds_cluster_config()->set_service_name( + kNewEdsService1Name); balancers_[0]->ads_service()->SetCdsResource(new_cluster1); Cluster new_cluster2 = balancers_[0]->ads_service()->default_cluster(); new_cluster2.set_name(kNewCluster2Name); + new_cluster2.mutable_eds_cluster_config()->set_service_name( + kNewEdsService2Name); balancers_[0]->ads_service()->SetCdsResource(new_cluster2); // Populating Route Configurations for LDS. RouteConfiguration new_route_config = @@ -3227,7 +3265,7 @@ TEST_P(LdsRdsTest, XdsRoutingWeightedCluster) { ->set_value(kWeight75 + kWeight25); auto* default_route = new_route_config.mutable_virtual_hosts(0)->add_routes(); default_route->mutable_match()->set_prefix(""); - default_route->mutable_route()->set_cluster(kDefaultResourceName); + default_route->mutable_route()->set_cluster(kDefaultClusterName); SetRouteConfiguration(0, new_route_config); WaitForAllBackends(0, 1); WaitForAllBackends(1, 3, true, RpcOptions().set_rpc_service(SERVICE_ECHO1)); @@ -3262,7 +3300,9 @@ TEST_P(LdsRdsTest, XdsRoutingWeightedCluster) { TEST_P(LdsRdsTest, RouteActionWeightedTargetDefaultRoute) { const char* kNewCluster1Name = "new_cluster_1"; + const char* kNewEdsService1Name = "new_eds_service_name_1"; const char* kNewCluster2Name = "new_cluster_2"; + const char* kNewEdsService2Name = "new_eds_service_name_2"; const size_t kNumEchoRpcs = 1000; const size_t kWeight75 = 75; const size_t kWeight25 = 25; @@ -3281,15 +3321,19 @@ TEST_P(LdsRdsTest, RouteActionWeightedTargetDefaultRoute) { balancers_[0]->ads_service()->SetEdsResource( AdsServiceImpl::BuildEdsResource(args)); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args1, kNewCluster1Name)); + AdsServiceImpl::BuildEdsResource(args1, kNewEdsService1Name)); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args2, kNewCluster2Name)); + AdsServiceImpl::BuildEdsResource(args2, kNewEdsService2Name)); // Populate new CDS resources. Cluster new_cluster1 = balancers_[0]->ads_service()->default_cluster(); new_cluster1.set_name(kNewCluster1Name); + new_cluster1.mutable_eds_cluster_config()->set_service_name( + kNewEdsService1Name); balancers_[0]->ads_service()->SetCdsResource(new_cluster1); Cluster new_cluster2 = balancers_[0]->ads_service()->default_cluster(); new_cluster2.set_name(kNewCluster2Name); + new_cluster2.mutable_eds_cluster_config()->set_service_name( + kNewEdsService2Name); balancers_[0]->ads_service()->SetCdsResource(new_cluster2); // Populating Route Configurations for LDS. RouteConfiguration new_route_config = @@ -3337,8 +3381,11 @@ TEST_P(LdsRdsTest, RouteActionWeightedTargetDefaultRoute) { TEST_P(LdsRdsTest, XdsRoutingWeightedClusterUpdateWeights) { const char* kNewCluster1Name = "new_cluster_1"; - const char* kNewCluster2Name = "anew_cluster_2"; + const char* kNewEdsService1Name = "new_eds_service_name_1"; + const char* kNewCluster2Name = "new_cluster_2"; + const char* kNewEdsService2Name = "new_eds_service_name_2"; const char* kNewCluster3Name = "new_cluster_3"; + const char* kNewEdsService3Name = "new_eds_service_name_3"; const size_t kNumEcho1Rpcs = 1000; const size_t kNumEchoRpcs = 10; const size_t kWeight75 = 75; @@ -3362,20 +3409,26 @@ TEST_P(LdsRdsTest, XdsRoutingWeightedClusterUpdateWeights) { balancers_[0]->ads_service()->SetEdsResource( AdsServiceImpl::BuildEdsResource(args)); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args1, kNewCluster1Name)); + AdsServiceImpl::BuildEdsResource(args1, kNewEdsService1Name)); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args2, kNewCluster2Name)); + AdsServiceImpl::BuildEdsResource(args2, kNewEdsService2Name)); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args3, kNewCluster3Name)); + AdsServiceImpl::BuildEdsResource(args3, kNewEdsService3Name)); // Populate new CDS resources. Cluster new_cluster1 = balancers_[0]->ads_service()->default_cluster(); new_cluster1.set_name(kNewCluster1Name); + new_cluster1.mutable_eds_cluster_config()->set_service_name( + kNewEdsService1Name); balancers_[0]->ads_service()->SetCdsResource(new_cluster1); Cluster new_cluster2 = balancers_[0]->ads_service()->default_cluster(); new_cluster2.set_name(kNewCluster2Name); + new_cluster2.mutable_eds_cluster_config()->set_service_name( + kNewEdsService2Name); balancers_[0]->ads_service()->SetCdsResource(new_cluster2); Cluster new_cluster3 = balancers_[0]->ads_service()->default_cluster(); new_cluster3.set_name(kNewCluster3Name); + new_cluster3.mutable_eds_cluster_config()->set_service_name( + kNewEdsService3Name); balancers_[0]->ads_service()->SetCdsResource(new_cluster3); // Populating Route Configurations. RouteConfiguration new_route_config = @@ -3396,7 +3449,7 @@ TEST_P(LdsRdsTest, XdsRoutingWeightedClusterUpdateWeights) { ->set_value(kWeight75 + kWeight25); auto* default_route = new_route_config.mutable_virtual_hosts(0)->add_routes(); default_route->mutable_match()->set_prefix(""); - default_route->mutable_route()->set_cluster(kDefaultResourceName); + default_route->mutable_route()->set_cluster(kDefaultClusterName); SetRouteConfiguration(0, new_route_config); WaitForAllBackends(0, 1); WaitForAllBackends(1, 3, true, RpcOptions().set_rpc_service(SERVICE_ECHO1)); @@ -3466,8 +3519,11 @@ TEST_P(LdsRdsTest, XdsRoutingWeightedClusterUpdateWeights) { TEST_P(LdsRdsTest, XdsRoutingWeightedClusterUpdateClusters) { const char* kNewCluster1Name = "new_cluster_1"; - const char* kNewCluster2Name = "anew_cluster_2"; + const char* kNewEdsService1Name = "new_eds_service_name_1"; + const char* kNewCluster2Name = "new_cluster_2"; + const char* kNewEdsService2Name = "new_eds_service_name_2"; const char* kNewCluster3Name = "new_cluster_3"; + const char* kNewEdsService3Name = "new_eds_service_name_3"; const size_t kNumEcho1Rpcs = 1000; const size_t kNumEchoRpcs = 10; const size_t kWeight75 = 75; @@ -3491,20 +3547,26 @@ TEST_P(LdsRdsTest, XdsRoutingWeightedClusterUpdateClusters) { balancers_[0]->ads_service()->SetEdsResource( AdsServiceImpl::BuildEdsResource(args)); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args1, kNewCluster1Name)); + AdsServiceImpl::BuildEdsResource(args1, kNewEdsService1Name)); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args2, kNewCluster2Name)); + AdsServiceImpl::BuildEdsResource(args2, kNewEdsService2Name)); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args3, kNewCluster3Name)); + AdsServiceImpl::BuildEdsResource(args3, kNewEdsService3Name)); // Populate new CDS resources. Cluster new_cluster1 = balancers_[0]->ads_service()->default_cluster(); new_cluster1.set_name(kNewCluster1Name); + new_cluster1.mutable_eds_cluster_config()->set_service_name( + kNewEdsService1Name); balancers_[0]->ads_service()->SetCdsResource(new_cluster1); Cluster new_cluster2 = balancers_[0]->ads_service()->default_cluster(); new_cluster2.set_name(kNewCluster2Name); + new_cluster2.mutable_eds_cluster_config()->set_service_name( + kNewEdsService2Name); balancers_[0]->ads_service()->SetCdsResource(new_cluster2); Cluster new_cluster3 = balancers_[0]->ads_service()->default_cluster(); new_cluster3.set_name(kNewCluster3Name); + new_cluster3.mutable_eds_cluster_config()->set_service_name( + kNewEdsService3Name); balancers_[0]->ads_service()->SetCdsResource(new_cluster3); // Populating Route Configurations. RouteConfiguration new_route_config = @@ -3517,7 +3579,7 @@ TEST_P(LdsRdsTest, XdsRoutingWeightedClusterUpdateClusters) { weighted_cluster1->mutable_weight()->set_value(kWeight75); auto* weighted_cluster2 = route1->mutable_route()->mutable_weighted_clusters()->add_clusters(); - weighted_cluster2->set_name(kDefaultResourceName); + weighted_cluster2->set_name(kDefaultClusterName); weighted_cluster2->mutable_weight()->set_value(kWeight25); route1->mutable_route() ->mutable_weighted_clusters() @@ -3525,7 +3587,7 @@ TEST_P(LdsRdsTest, XdsRoutingWeightedClusterUpdateClusters) { ->set_value(kWeight75 + kWeight25); auto* default_route = new_route_config.mutable_virtual_hosts(0)->add_routes(); default_route->mutable_match()->set_prefix(""); - default_route->mutable_route()->set_cluster(kDefaultResourceName); + default_route->mutable_route()->set_cluster(kDefaultClusterName); SetRouteConfiguration(0, new_route_config); WaitForAllBackends(0, 1); WaitForAllBackends(1, 2, true, RpcOptions().set_rpc_service(SERVICE_ECHO1)); @@ -3623,7 +3685,8 @@ TEST_P(LdsRdsTest, XdsRoutingWeightedClusterUpdateClusters) { } TEST_P(LdsRdsTest, XdsRoutingClusterUpdateClusters) { - const char* kNewCluster1Name = "new_cluster_1"; + const char* kNewClusterName = "new_cluster"; + const char* kNewEdsServiceName = "new_eds_service_name"; const size_t kNumEchoRpcs = 5; SetNextResolution({}); SetNextResolutionForLbChannelAllBalancers(); @@ -3637,11 +3700,13 @@ TEST_P(LdsRdsTest, XdsRoutingClusterUpdateClusters) { balancers_[0]->ads_service()->SetEdsResource( AdsServiceImpl::BuildEdsResource(args)); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args1, kNewCluster1Name)); + AdsServiceImpl::BuildEdsResource(args1, kNewEdsServiceName)); // Populate new CDS resources. - Cluster new_cluster1 = balancers_[0]->ads_service()->default_cluster(); - new_cluster1.set_name(kNewCluster1Name); - balancers_[0]->ads_service()->SetCdsResource(new_cluster1); + Cluster new_cluster = balancers_[0]->ads_service()->default_cluster(); + new_cluster.set_name(kNewClusterName); + new_cluster.mutable_eds_cluster_config()->set_service_name( + kNewEdsServiceName); + balancers_[0]->ads_service()->SetCdsResource(new_cluster); // Send Route Configuration. RouteConfiguration new_route_config = balancers_[0]->ads_service()->default_route_config(); @@ -3653,7 +3718,7 @@ TEST_P(LdsRdsTest, XdsRoutingClusterUpdateClusters) { // Change Route Configurations: new default cluster. auto* default_route = new_route_config.mutable_virtual_hosts(0)->mutable_routes(0); - default_route->mutable_route()->set_cluster(kNewCluster1Name); + default_route->mutable_route()->set_cluster(kNewClusterName); SetRouteConfiguration(0, new_route_config); WaitForAllBackends(1, 2); CheckRpcSendOk(kNumEchoRpcs); @@ -3662,7 +3727,8 @@ TEST_P(LdsRdsTest, XdsRoutingClusterUpdateClusters) { } TEST_P(LdsRdsTest, XdsRoutingClusterUpdateClustersWithPickingDelays) { - const char* kNewCluster1Name = "new_cluster_1"; + const char* kNewClusterName = "new_cluster"; + const char* kNewEdsServiceName = "new_eds_service_name"; SetNextResolution({}); SetNextResolutionForLbChannelAllBalancers(); // Populate new EDS resources. @@ -3675,11 +3741,13 @@ TEST_P(LdsRdsTest, XdsRoutingClusterUpdateClustersWithPickingDelays) { balancers_[0]->ads_service()->SetEdsResource( AdsServiceImpl::BuildEdsResource(args)); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args1, kNewCluster1Name)); + AdsServiceImpl::BuildEdsResource(args1, kNewEdsServiceName)); // Populate new CDS resources. - Cluster new_cluster1 = balancers_[0]->ads_service()->default_cluster(); - new_cluster1.set_name(kNewCluster1Name); - balancers_[0]->ads_service()->SetCdsResource(new_cluster1); + Cluster new_cluster = balancers_[0]->ads_service()->default_cluster(); + new_cluster.set_name(kNewClusterName); + new_cluster.mutable_eds_cluster_config()->set_service_name( + kNewEdsServiceName); + balancers_[0]->ads_service()->SetCdsResource(new_cluster); // Bring down the current backend: 0, this will delay route picking time, // resulting in un-committed RPCs. ShutdownBackend(0); @@ -3700,7 +3768,7 @@ TEST_P(LdsRdsTest, XdsRoutingClusterUpdateClustersWithPickingDelays) { // Send a update RouteConfiguration to use backend 1. auto* default_route = new_route_config.mutable_virtual_hosts(0)->mutable_routes(0); - default_route->mutable_route()->set_cluster(kNewCluster1Name); + default_route->mutable_route()->set_cluster(kNewClusterName); SetRouteConfiguration(0, new_route_config); // Wait for RPCs to go to the new backend: 1, this ensures that the client has // processed the update. @@ -3715,7 +3783,8 @@ TEST_P(LdsRdsTest, XdsRoutingClusterUpdateClustersWithPickingDelays) { } TEST_P(LdsRdsTest, XdsRoutingHeadersMatching) { - const char* kNewCluster1Name = "new_cluster_1"; + const char* kNewClusterName = "new_cluster"; + const char* kNewEdsServiceName = "new_eds_service_name"; const size_t kNumEcho1Rpcs = 100; const size_t kNumEchoRpcs = 5; SetNextResolution({}); @@ -3730,11 +3799,13 @@ TEST_P(LdsRdsTest, XdsRoutingHeadersMatching) { balancers_[0]->ads_service()->SetEdsResource( AdsServiceImpl::BuildEdsResource(args)); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args1, kNewCluster1Name)); + AdsServiceImpl::BuildEdsResource(args1, kNewEdsServiceName)); // Populate new CDS resources. - Cluster new_cluster1 = balancers_[0]->ads_service()->default_cluster(); - new_cluster1.set_name(kNewCluster1Name); - balancers_[0]->ads_service()->SetCdsResource(new_cluster1); + Cluster new_cluster = balancers_[0]->ads_service()->default_cluster(); + new_cluster.set_name(kNewClusterName); + new_cluster.mutable_eds_cluster_config()->set_service_name( + kNewEdsServiceName); + balancers_[0]->ads_service()->SetCdsResource(new_cluster); // Populating Route Configurations for LDS. RouteConfiguration route_config = balancers_[0]->ads_service()->default_route_config(); @@ -3760,10 +3831,10 @@ TEST_P(LdsRdsTest, XdsRoutingHeadersMatching) { header_matcher6->set_name("header6"); header_matcher6->set_suffix_match(".cc"); header_matcher6->set_invert_match(true); - route1->mutable_route()->set_cluster(kNewCluster1Name); + route1->mutable_route()->set_cluster(kNewClusterName); auto* default_route = route_config.mutable_virtual_hosts(0)->add_routes(); default_route->mutable_match()->set_prefix(""); - default_route->mutable_route()->set_cluster(kDefaultResourceName); + default_route->mutable_route()->set_cluster(kDefaultClusterName); SetRouteConfiguration(0, route_config); std::vector> metadata = { {"header1", "POST"}, {"header2", "blah"}, @@ -3792,7 +3863,8 @@ TEST_P(LdsRdsTest, XdsRoutingHeadersMatching) { } TEST_P(LdsRdsTest, XdsRoutingHeadersMatchingSpecialHeaderContentType) { - const char* kNewCluster1Name = "new_cluster_1"; + const char* kNewClusterName = "new_cluster"; + const char* kNewEdsServiceName = "new_eds_service_name"; const size_t kNumEchoRpcs = 100; SetNextResolution({}); SetNextResolutionForLbChannelAllBalancers(); @@ -3806,11 +3878,13 @@ TEST_P(LdsRdsTest, XdsRoutingHeadersMatchingSpecialHeaderContentType) { balancers_[0]->ads_service()->SetEdsResource( AdsServiceImpl::BuildEdsResource(args)); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args1, kNewCluster1Name)); + AdsServiceImpl::BuildEdsResource(args1, kNewEdsServiceName)); // Populate new CDS resources. - Cluster new_cluster1 = balancers_[0]->ads_service()->default_cluster(); - new_cluster1.set_name(kNewCluster1Name); - balancers_[0]->ads_service()->SetCdsResource(new_cluster1); + Cluster new_cluster = balancers_[0]->ads_service()->default_cluster(); + new_cluster.set_name(kNewClusterName); + new_cluster.mutable_eds_cluster_config()->set_service_name( + kNewEdsServiceName); + balancers_[0]->ads_service()->SetCdsResource(new_cluster); // Populating Route Configurations for LDS. RouteConfiguration route_config = balancers_[0]->ads_service()->default_route_config(); @@ -3819,13 +3893,13 @@ TEST_P(LdsRdsTest, XdsRoutingHeadersMatchingSpecialHeaderContentType) { auto* header_matcher1 = route1->mutable_match()->add_headers(); header_matcher1->set_name("content-type"); header_matcher1->set_exact_match("notapplication/grpc"); - route1->mutable_route()->set_cluster(kNewCluster1Name); + route1->mutable_route()->set_cluster(kNewClusterName); auto* default_route = route_config.mutable_virtual_hosts(0)->add_routes(); default_route->mutable_match()->set_prefix(""); auto* header_matcher2 = default_route->mutable_match()->add_headers(); header_matcher2->set_name("content-type"); header_matcher2->set_exact_match("application/grpc"); - default_route->mutable_route()->set_cluster(kDefaultResourceName); + default_route->mutable_route()->set_cluster(kDefaultClusterName); SetRouteConfiguration(0, route_config); // Make sure the backend is up. WaitForAllBackends(0, 1); @@ -3839,7 +3913,9 @@ TEST_P(LdsRdsTest, XdsRoutingHeadersMatchingSpecialHeaderContentType) { TEST_P(LdsRdsTest, XdsRoutingHeadersMatchingSpecialCasesToIgnore) { const char* kNewCluster1Name = "new_cluster_1"; + const char* kNewEdsService1Name = "new_eds_service_name_1"; const char* kNewCluster2Name = "new_cluster_2"; + const char* kNewEdsService2Name = "new_eds_service_name_2"; const size_t kNumEchoRpcs = 100; SetNextResolution({}); SetNextResolutionForLbChannelAllBalancers(); @@ -3856,15 +3932,19 @@ TEST_P(LdsRdsTest, XdsRoutingHeadersMatchingSpecialCasesToIgnore) { balancers_[0]->ads_service()->SetEdsResource( AdsServiceImpl::BuildEdsResource(args)); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args1, kNewCluster1Name)); + AdsServiceImpl::BuildEdsResource(args1, kNewEdsService1Name)); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args2, kNewCluster2Name)); + AdsServiceImpl::BuildEdsResource(args2, kNewEdsService2Name)); // Populate new CDS resources. Cluster new_cluster1 = balancers_[0]->ads_service()->default_cluster(); new_cluster1.set_name(kNewCluster1Name); + new_cluster1.mutable_eds_cluster_config()->set_service_name( + kNewEdsService1Name); balancers_[0]->ads_service()->SetCdsResource(new_cluster1); Cluster new_cluster2 = balancers_[0]->ads_service()->default_cluster(); new_cluster2.set_name(kNewCluster2Name); + new_cluster2.mutable_eds_cluster_config()->set_service_name( + kNewEdsService2Name); balancers_[0]->ads_service()->SetCdsResource(new_cluster2); // Populating Route Configurations for LDS. RouteConfiguration route_config = @@ -3883,7 +3963,7 @@ TEST_P(LdsRdsTest, XdsRoutingHeadersMatchingSpecialCasesToIgnore) { route2->mutable_route()->set_cluster(kNewCluster2Name); auto* default_route = route_config.mutable_virtual_hosts(0)->add_routes(); default_route->mutable_match()->set_prefix(""); - default_route->mutable_route()->set_cluster(kDefaultResourceName); + default_route->mutable_route()->set_cluster(kDefaultClusterName); SetRouteConfiguration(0, route_config); // Send headers which will mismatch each route std::vector> metadata = { @@ -3902,7 +3982,8 @@ TEST_P(LdsRdsTest, XdsRoutingHeadersMatchingSpecialCasesToIgnore) { } TEST_P(LdsRdsTest, XdsRoutingRuntimeFractionMatching) { - const char* kNewCluster1Name = "new_cluster_1"; + const char* kNewClusterName = "new_cluster"; + const char* kNewEdsServiceName = "new_eds_service_name"; const size_t kNumRpcs = 1000; SetNextResolution({}); SetNextResolutionForLbChannelAllBalancers(); @@ -3916,11 +3997,13 @@ TEST_P(LdsRdsTest, XdsRoutingRuntimeFractionMatching) { balancers_[0]->ads_service()->SetEdsResource( AdsServiceImpl::BuildEdsResource(args)); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args1, kNewCluster1Name)); + AdsServiceImpl::BuildEdsResource(args1, kNewEdsServiceName)); // Populate new CDS resources. - Cluster new_cluster1 = balancers_[0]->ads_service()->default_cluster(); - new_cluster1.set_name(kNewCluster1Name); - balancers_[0]->ads_service()->SetCdsResource(new_cluster1); + Cluster new_cluster = balancers_[0]->ads_service()->default_cluster(); + new_cluster.set_name(kNewClusterName); + new_cluster.mutable_eds_cluster_config()->set_service_name( + kNewEdsServiceName); + balancers_[0]->ads_service()->SetCdsResource(new_cluster); // Populating Route Configurations for LDS. RouteConfiguration route_config = balancers_[0]->ads_service()->default_route_config(); @@ -3929,10 +4012,10 @@ TEST_P(LdsRdsTest, XdsRoutingRuntimeFractionMatching) { ->mutable_runtime_fraction() ->mutable_default_value() ->set_numerator(25); - route1->mutable_route()->set_cluster(kNewCluster1Name); + route1->mutable_route()->set_cluster(kNewClusterName); auto* default_route = route_config.mutable_virtual_hosts(0)->add_routes(); default_route->mutable_match()->set_prefix(""); - default_route->mutable_route()->set_cluster(kDefaultResourceName); + default_route->mutable_route()->set_cluster(kDefaultClusterName); SetRouteConfiguration(0, route_config); WaitForAllBackends(0, 2); CheckRpcSendOk(kNumRpcs); @@ -3955,8 +4038,11 @@ TEST_P(LdsRdsTest, XdsRoutingRuntimeFractionMatching) { TEST_P(LdsRdsTest, XdsRoutingHeadersMatchingUnmatchCases) { const char* kNewCluster1Name = "new_cluster_1"; + const char* kNewEdsService1Name = "new_eds_service_name_1"; const char* kNewCluster2Name = "new_cluster_2"; + const char* kNewEdsService2Name = "new_eds_service_name_2"; const char* kNewCluster3Name = "new_cluster_3"; + const char* kNewEdsService3Name = "new_eds_service_name_3"; const size_t kNumEcho1Rpcs = 100; const size_t kNumEchoRpcs = 5; SetNextResolution({}); @@ -3977,20 +4063,26 @@ TEST_P(LdsRdsTest, XdsRoutingHeadersMatchingUnmatchCases) { balancers_[0]->ads_service()->SetEdsResource( AdsServiceImpl::BuildEdsResource(args)); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args1, kNewCluster1Name)); + AdsServiceImpl::BuildEdsResource(args1, kNewEdsService1Name)); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args2, kNewCluster2Name)); + AdsServiceImpl::BuildEdsResource(args2, kNewEdsService2Name)); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args3, kNewCluster3Name)); + AdsServiceImpl::BuildEdsResource(args3, kNewEdsService3Name)); // Populate new CDS resources. Cluster new_cluster1 = balancers_[0]->ads_service()->default_cluster(); new_cluster1.set_name(kNewCluster1Name); + new_cluster1.mutable_eds_cluster_config()->set_service_name( + kNewEdsService1Name); balancers_[0]->ads_service()->SetCdsResource(new_cluster1); Cluster new_cluster2 = balancers_[0]->ads_service()->default_cluster(); new_cluster2.set_name(kNewCluster2Name); + new_cluster2.mutable_eds_cluster_config()->set_service_name( + kNewEdsService2Name); balancers_[0]->ads_service()->SetCdsResource(new_cluster2); Cluster new_cluster3 = balancers_[0]->ads_service()->default_cluster(); - new_cluster1.set_name(kNewCluster3Name); + new_cluster3.set_name(kNewCluster3Name); + new_cluster3.mutable_eds_cluster_config()->set_service_name( + kNewEdsService3Name); balancers_[0]->ads_service()->SetCdsResource(new_cluster3); // Populating Route Configurations for LDS. RouteConfiguration route_config = @@ -4016,7 +4108,7 @@ TEST_P(LdsRdsTest, XdsRoutingHeadersMatchingUnmatchCases) { route3->mutable_route()->set_cluster(kNewCluster3Name); auto* default_route = route_config.mutable_virtual_hosts(0)->add_routes(); default_route->mutable_match()->set_prefix(""); - default_route->mutable_route()->set_cluster(kDefaultResourceName); + default_route->mutable_route()->set_cluster(kDefaultClusterName); SetRouteConfiguration(0, route_config); // Send headers which will mismatch each route std::vector> metadata = { @@ -4153,6 +4245,25 @@ TEST_P(EdsTest, NacksSparsePriorityList) { "EDS update includes sparse priority list"); } +// In most of our tests, we use different names for different resource +// types, to make sure that there are no cut-and-paste errors in the code +// that cause us to look at data for the wrong resource type. So we add +// this test to make sure that the EDS resource name defaults to the +// cluster name if not specified in the CDS resource. +TEST_P(EdsTest, EdsServiceNameDefaultsToClusterName) { + AdsServiceImpl::EdsResourceArgs args({ + {"locality0", GetBackendPorts()}, + }); + balancers_[0]->ads_service()->SetEdsResource( + AdsServiceImpl::BuildEdsResource(args, kDefaultClusterName)); + Cluster cluster = balancers_[0]->ads_service()->default_cluster(); + cluster.mutable_eds_cluster_config()->clear_service_name(); + balancers_[0]->ads_service()->SetCdsResource(cluster); + SetNextResolution({}); + SetNextResolutionForLbChannelAllBalancers(); + CheckRpcSendOk(); +} + using LocalityMapTest = BasicTest; // Tests that the localities in a locality map are picked according to their @@ -4174,7 +4285,7 @@ TEST_P(LocalityMapTest, WeightedRoundRobin) { {"locality1", GetBackendPorts(1, 2), kLocalityWeight1}, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); // Wait for both backends to be ready. WaitForAllBackends(0, 2); // Send kNumRpcs RPCs. @@ -4208,7 +4319,7 @@ TEST_P(LocalityMapTest, LocalityContainingNoEndpoints) { {"locality1", {}}, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); // Wait for both backends to be ready. WaitForAllBackends(); // Send kNumRpcs RPCs. @@ -4228,9 +4339,8 @@ TEST_P(LocalityMapTest, LocalityContainingNoEndpoints) { TEST_P(LocalityMapTest, NoLocalities) { SetNextResolution({}); SetNextResolutionForLbChannelAllBalancers(); - // EDS response contains 2 localities, one with no endpoints. balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource({})); + AdsServiceImpl::BuildEdsResource({}, DefaultEdsServiceName())); Status status = SendRpc(); EXPECT_FALSE(status.ok()); EXPECT_EQ(status.error_code(), StatusCode::UNAVAILABLE); @@ -4252,14 +4362,15 @@ TEST_P(LocalityMapTest, StressTest) { args.locality_list.emplace_back(std::move(locality)); } balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); // The second ADS response contains 1 locality, which contains backend 1. args = AdsServiceImpl::EdsResourceArgs({ {"locality0", GetBackendPorts(1, 2)}, }); std::thread delayed_resource_setter( std::bind(&BasicTest::SetEdsResourceWithDelay, this, 0, - AdsServiceImpl::BuildEdsResource(args), 60 * 1000)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName()), + 60 * 1000)); // Wait until backend 0 is ready, before which kNumLocalities localities are // received and handled by the xds policy. WaitForBackend(0, /*reset_counters=*/false); @@ -4300,7 +4411,7 @@ TEST_P(LocalityMapTest, UpdateMap) { {"locality2", GetBackendPorts(2, 3), 4}, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); // Wait for the first 3 backends to be ready. WaitForAllBackends(0, 3); gpr_log(GPR_INFO, "========= BEFORE FIRST BATCH =========="); @@ -4331,7 +4442,7 @@ TEST_P(LocalityMapTest, UpdateMap) { {"locality3", GetBackendPorts(3, 4), 6}, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); // Backend 3 hasn't received any request. EXPECT_EQ(0U, backends_[3]->backend_service()->request_count()); // Wait until the locality update has been processed, as signaled by backend 3 @@ -4371,13 +4482,13 @@ TEST_P(LocalityMapTest, ReplaceAllLocalitiesInPriority) { {"locality0", GetBackendPorts(0, 1)}, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); args = AdsServiceImpl::EdsResourceArgs({ {"locality1", GetBackendPorts(1, 2)}, }); - std::thread delayed_resource_setter( - std::bind(&BasicTest::SetEdsResourceWithDelay, this, 0, - AdsServiceImpl::BuildEdsResource(args), 5000)); + std::thread delayed_resource_setter(std::bind( + &BasicTest::SetEdsResourceWithDelay, this, 0, + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName()), 5000)); // Wait for the first backend to be ready. WaitForBackend(0); // Keep sending RPCs until we switch over to backend 1, which tells us @@ -4406,7 +4517,7 @@ TEST_P(FailoverTest, ChooseHighestPriority) { {"locality3", GetBackendPorts(3, 4), kDefaultLocalityWeight, 0}, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); WaitForBackend(3, false); for (size_t i = 0; i < 3; ++i) { EXPECT_EQ(0U, backends_[i]->backend_service()->request_count()); @@ -4424,7 +4535,7 @@ TEST_P(FailoverTest, DoesNotUsePriorityWithNoEndpoints) { {"locality3", {}, kDefaultLocalityWeight, 0}, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); WaitForBackend(0, false); for (size_t i = 1; i < 3; ++i) { EXPECT_EQ(0U, backends_[i]->backend_service()->request_count()); @@ -4440,7 +4551,7 @@ TEST_P(FailoverTest, DoesNotUseLocalityWithNoEndpoints) { {"locality1", GetBackendPorts(), kDefaultLocalityWeight, 0}, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); // Wait for all backends to be used. std::tuple counts = WaitForAllBackends(); // Make sure no RPCs failed in the transition. @@ -4461,7 +4572,7 @@ TEST_P(FailoverTest, Failover) { ShutdownBackend(3); ShutdownBackend(0); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); WaitForBackend(1, false); for (size_t i = 0; i < 4; ++i) { if (i == 1) continue; @@ -4484,7 +4595,7 @@ TEST_P(FailoverTest, SwitchBackToHigherPriority) { ShutdownBackend(3); ShutdownBackend(0); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); WaitForBackend(1, false); for (size_t i = 0; i < 4; ++i) { if (i == 1) continue; @@ -4506,7 +4617,7 @@ TEST_P(FailoverTest, UpdateInitialUnavailable) { {"locality1", GetBackendPorts(1, 2), kDefaultLocalityWeight, 1}, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); args = AdsServiceImpl::EdsResourceArgs({ {"locality0", GetBackendPorts(0, 1), kDefaultLocalityWeight, 0}, {"locality1", GetBackendPorts(1, 2), kDefaultLocalityWeight, 1}, @@ -4515,9 +4626,9 @@ TEST_P(FailoverTest, UpdateInitialUnavailable) { }); ShutdownBackend(0); ShutdownBackend(1); - std::thread delayed_resource_setter( - std::bind(&BasicTest::SetEdsResourceWithDelay, this, 0, - AdsServiceImpl::BuildEdsResource(args), 1000)); + std::thread delayed_resource_setter(std::bind( + &BasicTest::SetEdsResourceWithDelay, this, 0, + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName()), 1000)); gpr_timespec deadline = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(500, GPR_TIMESPAN)); // Send 0.5 second worth of RPCs. @@ -4545,16 +4656,16 @@ TEST_P(FailoverTest, UpdatePriority) { {"locality3", GetBackendPorts(3, 4), kDefaultLocalityWeight, 0}, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); args = AdsServiceImpl::EdsResourceArgs({ {"locality0", GetBackendPorts(0, 1), kDefaultLocalityWeight, 2}, {"locality1", GetBackendPorts(1, 2), kDefaultLocalityWeight, 0}, {"locality2", GetBackendPorts(2, 3), kDefaultLocalityWeight, 1}, {"locality3", GetBackendPorts(3, 4), kDefaultLocalityWeight, 3}, }); - std::thread delayed_resource_setter( - std::bind(&BasicTest::SetEdsResourceWithDelay, this, 0, - AdsServiceImpl::BuildEdsResource(args), 1000)); + std::thread delayed_resource_setter(std::bind( + &BasicTest::SetEdsResourceWithDelay, this, 0, + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName()), 1000)); WaitForBackend(3, false); for (size_t i = 0; i < 3; ++i) { EXPECT_EQ(0U, backends_[i]->backend_service()->request_count()); @@ -4578,7 +4689,7 @@ TEST_P(FailoverTest, MoveAllLocalitiesInCurrentPriorityToHigherPriority) { {"locality1", GetBackendPorts(1, 3), kDefaultLocalityWeight, 1}, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); // Second update: // - Priority 0 contains both localities 0 and 1. // - Priority 1 is not present. @@ -4588,9 +4699,9 @@ TEST_P(FailoverTest, MoveAllLocalitiesInCurrentPriorityToHigherPriority) { {"locality0", GetBackendPorts(0, 1), kDefaultLocalityWeight, 0}, {"locality1", GetBackendPorts(1, 4), kDefaultLocalityWeight, 0}, }); - std::thread delayed_resource_setter( - std::bind(&BasicTest::SetEdsResourceWithDelay, this, 0, - AdsServiceImpl::BuildEdsResource(args), 1000)); + std::thread delayed_resource_setter(std::bind( + &BasicTest::SetEdsResourceWithDelay, this, 0, + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName()), 1000)); // When we get the first update, all backends in priority 0 are down, // so we will create priority 1. Backends 1 and 2 should have traffic, // but backend 3 should not. @@ -4624,7 +4735,7 @@ TEST_P(DropTest, Vanilla) { args.drop_categories = {{kLbDropType, kDropPerMillionForLb}, {kThrottleDropType, kDropPerMillionForThrottle}}; balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); WaitForAllBackends(); // Send kNumRpcs RPCs and count the drops. size_t num_drops = 0; @@ -4637,7 +4748,7 @@ TEST_P(DropTest, Vanilla) { } else { EXPECT_TRUE(status.ok()) << "code=" << status.error_code() << " message=" << status.error_message(); - EXPECT_EQ(response.message(), kRequestMessage_); + EXPECT_EQ(response.message(), kRequestMessage); } } // The drop rate should be roughly equal to the expectation. @@ -4664,7 +4775,7 @@ TEST_P(DropTest, DropPerHundred) { args.drop_categories = {{kLbDropType, kDropPerHundredForLb}}; args.drop_denominator = FractionalPercent::HUNDRED; balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); WaitForAllBackends(); // Send kNumRpcs RPCs and count the drops. size_t num_drops = 0; @@ -4677,7 +4788,7 @@ TEST_P(DropTest, DropPerHundred) { } else { EXPECT_TRUE(status.ok()) << "code=" << status.error_code() << " message=" << status.error_message(); - EXPECT_EQ(response.message(), kRequestMessage_); + EXPECT_EQ(response.message(), kRequestMessage); } } // The drop rate should be roughly equal to the expectation. @@ -4703,7 +4814,7 @@ TEST_P(DropTest, DropPerTenThousand) { args.drop_categories = {{kLbDropType, kDropPerTenThousandForLb}}; args.drop_denominator = FractionalPercent::TEN_THOUSAND; balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); WaitForAllBackends(); // Send kNumRpcs RPCs and count the drops. size_t num_drops = 0; @@ -4716,7 +4827,7 @@ TEST_P(DropTest, DropPerTenThousand) { } else { EXPECT_TRUE(status.ok()) << "code=" << status.error_code() << " message=" << status.error_message(); - EXPECT_EQ(response.message(), kRequestMessage_); + EXPECT_EQ(response.message(), kRequestMessage); } } // The drop rate should be roughly equal to the expectation. @@ -4745,7 +4856,7 @@ TEST_P(DropTest, Update) { }); args.drop_categories = {{kLbDropType, kDropPerMillionForLb}}; balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); WaitForAllBackends(); // Send kNumRpcs RPCs and count the drops. size_t num_drops = 0; @@ -4759,7 +4870,7 @@ TEST_P(DropTest, Update) { } else { EXPECT_TRUE(status.ok()) << "code=" << status.error_code() << " message=" << status.error_message(); - EXPECT_EQ(response.message(), kRequestMessage_); + EXPECT_EQ(response.message(), kRequestMessage); } } gpr_log(GPR_INFO, "========= DONE WITH FIRST BATCH =========="); @@ -4776,7 +4887,7 @@ TEST_P(DropTest, Update) { args.drop_categories = {{kLbDropType, kDropPerMillionForLb}, {kThrottleDropType, kDropPerMillionForThrottle}}; balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); // Wait until the drop rate increases to the middle of the two configs, which // implies that the update has been in effect. const double kDropRateThreshold = @@ -4792,7 +4903,7 @@ TEST_P(DropTest, Update) { } else { EXPECT_TRUE(status.ok()) << "code=" << status.error_code() << " message=" << status.error_message(); - EXPECT_EQ(response.message(), kRequestMessage_); + EXPECT_EQ(response.message(), kRequestMessage); } seen_drop_rate = static_cast(num_drops) / num_rpcs; } @@ -4808,7 +4919,7 @@ TEST_P(DropTest, Update) { } else { EXPECT_TRUE(status.ok()) << "code=" << status.error_code() << " message=" << status.error_message(); - EXPECT_EQ(response.message(), kRequestMessage_); + EXPECT_EQ(response.message(), kRequestMessage); } } gpr_log(GPR_INFO, "========= DONE WITH SECOND BATCH =========="); @@ -4834,7 +4945,7 @@ TEST_P(DropTest, DropAll) { args.drop_categories = {{kLbDropType, kDropPerMillionForLb}, {kThrottleDropType, kDropPerMillionForThrottle}}; balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); // Send kNumRpcs RPCs and all of them are dropped. for (size_t i = 0; i < kNumRpcs; ++i) { EchoResponse response; @@ -4858,12 +4969,12 @@ TEST_P(BalancerUpdateTest, UpdateBalancersButKeepUsingOriginalBalancer) { {"locality0", {backends_[0]->port()}}, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); args = AdsServiceImpl::EdsResourceArgs({ {"locality0", {backends_[1]->port()}}, }); balancers_[1]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); // Wait until the first backend is ready. WaitForBackend(0); // Send 10 requests. @@ -4921,12 +5032,12 @@ TEST_P(BalancerUpdateTest, Repeated) { {"locality0", {backends_[0]->port()}}, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); args = AdsServiceImpl::EdsResourceArgs({ {"locality0", {backends_[1]->port()}}, }); balancers_[1]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); // Wait until the first backend is ready. WaitForBackend(0); // Send 10 requests. @@ -4991,12 +5102,12 @@ TEST_P(BalancerUpdateTest, DeadUpdate) { {"locality0", {backends_[0]->port()}}, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); args = AdsServiceImpl::EdsResourceArgs({ {"locality0", {backends_[1]->port()}}, }); balancers_[1]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); // Start servers and send 10 RPCs per server. gpr_log(GPR_INFO, "========= BEFORE FIRST BATCH =========="); CheckRpcSendOk(10); @@ -5081,6 +5192,9 @@ class ClientLoadReportingTest : public XdsEnd2endTest { // Tests that the load report received at the balancer is correct. TEST_P(ClientLoadReportingTest, Vanilla) { + if (!GetParam().use_xds_resolver()) { + balancers_[0]->lrs_service()->set_cluster_names({kServerName}); + } SetNextResolution({}); SetNextResolutionForLbChannel({balancers_[0]->port()}); const size_t kNumRpcsPerAddress = 10; @@ -5091,7 +5205,7 @@ TEST_P(ClientLoadReportingTest, Vanilla) { {"locality0", GetBackendPorts()}, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); // Wait until all backends are ready. int num_ok = 0; int num_failure = 0; @@ -5138,7 +5252,7 @@ TEST_P(ClientLoadReportingTest, SendAllClusters) { {"locality0", GetBackendPorts()}, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); // Wait until all backends are ready. int num_ok = 0; int num_failure = 0; @@ -5183,7 +5297,7 @@ TEST_P(ClientLoadReportingTest, HonorsClustersRequestedByLrsServer) { {"locality0", GetBackendPorts()}, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); // Wait until all backends are ready. int num_ok = 0; int num_failure = 0; @@ -5208,6 +5322,9 @@ TEST_P(ClientLoadReportingTest, HonorsClustersRequestedByLrsServer) { // Tests that if the balancer restarts, the client load report contains the // stats before and after the restart correctly. TEST_P(ClientLoadReportingTest, BalancerRestart) { + if (!GetParam().use_xds_resolver()) { + balancers_[0]->lrs_service()->set_cluster_names({kServerName}); + } SetNextResolution({}); SetNextResolutionForLbChannel({balancers_[0]->port()}); const size_t kNumBackendsFirstPass = backends_.size() / 2; @@ -5217,7 +5334,7 @@ TEST_P(ClientLoadReportingTest, BalancerRestart) { {"locality0", GetBackendPorts(0, kNumBackendsFirstPass)}, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); // Wait until all backends returned by the balancer are ready. int num_ok = 0; int num_failure = 0; @@ -5255,7 +5372,7 @@ TEST_P(ClientLoadReportingTest, BalancerRestart) { {"locality0", GetBackendPorts(kNumBackendsFirstPass)}, }); balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); // Wait for queries to start going to one of the new backends. // This tells us that we're now using the new serverlist. std::tie(num_ok, num_failure, num_drops) = @@ -5281,6 +5398,9 @@ class ClientLoadReportingWithDropTest : public XdsEnd2endTest { // Tests that the drop stats are correctly reported by client load reporting. TEST_P(ClientLoadReportingWithDropTest, Vanilla) { + if (!GetParam().use_xds_resolver()) { + balancers_[0]->lrs_service()->set_cluster_names({kServerName}); + } SetNextResolution({}); SetNextResolutionForLbChannelAllBalancers(); const size_t kNumRpcs = 3000; @@ -5297,7 +5417,7 @@ TEST_P(ClientLoadReportingWithDropTest, Vanilla) { args.drop_categories = {{kLbDropType, kDropPerMillionForLb}, {kThrottleDropType, kDropPerMillionForThrottle}}; balancers_[0]->ads_service()->SetEdsResource( - AdsServiceImpl::BuildEdsResource(args)); + AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); int num_ok = 0; int num_failure = 0; int num_drops = 0; @@ -5313,7 +5433,7 @@ TEST_P(ClientLoadReportingWithDropTest, Vanilla) { } else { EXPECT_TRUE(status.ok()) << "code=" << status.error_code() << " message=" << status.error_message(); - EXPECT_EQ(response.message(), kRequestMessage_); + EXPECT_EQ(response.message(), kRequestMessage); } } // The drop rate should be roughly equal to the expectation. @@ -5374,7 +5494,7 @@ INSTANTIATE_TEST_SUITE_P(XdsTest, LdsTest, TestType(true, true)), &TestTypeName); -// LDS RDS Commmon tests depends on XdsResolver. +// LDS/RDS commmon tests depend on XdsResolver. INSTANTIATE_TEST_SUITE_P(XdsTest, LdsRdsTest, ::testing::Values(TestType(true, false), TestType(true, true),