diff options
Diffstat (limited to 'test/cpp/end2end/xds/xds_ring_hash_end2end_test.cc')
-rw-r--r-- | test/cpp/end2end/xds/xds_ring_hash_end2end_test.cc | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/test/cpp/end2end/xds/xds_ring_hash_end2end_test.cc b/test/cpp/end2end/xds/xds_ring_hash_end2end_test.cc index d6de6167e8..9ad79d1507 100644 --- a/test/cpp/end2end/xds/xds_ring_hash_end2end_test.cc +++ b/test/cpp/end2end/xds/xds_ring_hash_end2end_test.cc @@ -32,6 +32,7 @@ #include "src/core/lib/gprpp/env.h" #include "src/proto/grpc/testing/xds/v3/aggregate_cluster.grpc.pb.h" #include "src/proto/grpc/testing/xds/v3/cluster.grpc.pb.h" +#include "test/core/util/resolve_localhost_ip46.h" #include "test/cpp/end2end/connection_attempt_injector.h" #include "test/cpp/end2end/xds/xds_end2end_test_lib.h" @@ -62,12 +63,12 @@ class RingHashTest : public XdsEnd2endTest { ResetStub(/*failover_timeout_ms=*/0, args); } - grpc_core::ServerAddressList CreateAddressListFromPortList( + grpc_core::EndpointAddressesList CreateAddressListFromPortList( const std::vector<int>& ports) { - grpc_core::ServerAddressList addresses; + grpc_core::EndpointAddressesList addresses; for (int port : ports) { - absl::StatusOr<grpc_core::URI> lb_uri = grpc_core::URI::Parse( - absl::StrCat(ipv6_only_ ? "ipv6:[::1]:" : "ipv4:127.0.0.1:", port)); + absl::StatusOr<grpc_core::URI> lb_uri = + grpc_core::URI::Parse(grpc_core::LocalIpUri(port)); GPR_ASSERT(lb_uri.ok()); grpc_resolved_address address; GPR_ASSERT(grpc_parse_uri(*lb_uri, &address)); @@ -77,7 +78,7 @@ class RingHashTest : public XdsEnd2endTest { } std::string CreateMetadataValueThatHashesToBackendPort(int port) { - return absl::StrCat(ipv6_only_ ? "[::1]" : "127.0.0.1", ":", port, "_0"); + return absl::StrCat(grpc_core::LocalIp(), ":", port, "_0"); } std::string CreateMetadataValueThatHashesToBackend(int index) { @@ -116,15 +117,16 @@ TEST_P(RingHashTest, AggregateClusterFallBackFromRingHashAtStartup) { new_cluster1.set_name(kNewCluster1Name); new_cluster1.mutable_eds_cluster_config()->set_service_name( kNewEdsService1Name); + new_cluster1.set_lb_policy(Cluster::RING_HASH); balancer_->ads_service()->SetCdsResource(new_cluster1); Cluster new_cluster2 = default_cluster_; new_cluster2.set_name(kNewCluster2Name); new_cluster2.mutable_eds_cluster_config()->set_service_name( kNewEdsService2Name); + new_cluster2.set_lb_policy(Cluster::RING_HASH); balancer_->ads_service()->SetCdsResource(new_cluster2); // Create Aggregate Cluster auto cluster = default_cluster_; - cluster.set_lb_policy(Cluster::RING_HASH); CustomClusterType* custom_cluster = cluster.mutable_cluster_type(); custom_cluster->set_name("envoy.clusters.aggregate"); ClusterConfig cluster_config; @@ -174,6 +176,7 @@ TEST_P(RingHashTest, // Populate new CDS resources. Cluster eds_cluster = default_cluster_; eds_cluster.set_name(kEdsClusterName); + eds_cluster.set_lb_policy(Cluster::RING_HASH); balancer_->ads_service()->SetCdsResource(eds_cluster); // Populate LOGICAL_DNS cluster. auto logical_dns_cluster = default_cluster_; @@ -190,7 +193,6 @@ TEST_P(RingHashTest, balancer_->ads_service()->SetCdsResource(logical_dns_cluster); // Create Aggregate Cluster auto cluster = default_cluster_; - cluster.set_lb_policy(Cluster::RING_HASH); CustomClusterType* custom_cluster = cluster.mutable_cluster_type(); custom_cluster->set_name("envoy.clusters.aggregate"); ClusterConfig cluster_config; @@ -242,6 +244,7 @@ TEST_P(RingHashTest, // Populate new CDS resources. Cluster eds_cluster = default_cluster_; eds_cluster.set_name(kEdsClusterName); + eds_cluster.set_lb_policy(Cluster::RING_HASH); balancer_->ads_service()->SetCdsResource(eds_cluster); // Populate LOGICAL_DNS cluster. auto logical_dns_cluster = default_cluster_; @@ -258,7 +261,6 @@ TEST_P(RingHashTest, balancer_->ads_service()->SetCdsResource(logical_dns_cluster); // Create Aggregate Cluster auto cluster = default_cluster_; - cluster.set_lb_policy(Cluster::RING_HASH); CustomClusterType* custom_cluster = cluster.mutable_cluster_type(); custom_cluster->set_name("envoy.clusters.aggregate"); ClusterConfig cluster_config; |