diff --git a/test/common/upstream/cluster_factory_impl_test.cc b/test/common/upstream/cluster_factory_impl_test.cc index 084d5b7a4b96..8dc52cc0bd90 100644 --- a/test/common/upstream/cluster_factory_impl_test.cc +++ b/test/common/upstream/cluster_factory_impl_test.cc @@ -81,7 +81,6 @@ TEST_F(TestStaticClusterImplTest, CreateWithoutConfig) { connect_timeout: 0.25s lb_policy: ROUND_ROBIN load_assignment: - cluster_name: staticcluster endpoints: - lb_endpoints: - endpoint: @@ -96,7 +95,7 @@ TEST_F(TestStaticClusterImplTest, CreateWithoutConfig) { TestStaticClusterFactory factory; Registry::InjectFactory registered_factory(factory); - const envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + const envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); auto create_result = ClusterFactoryImplBase::create( cluster_config, cm_, stats_, tls_, dns_resolver_, ssl_context_manager_, runtime_, random_, dispatcher_, log_manager_, local_info_, admin_, singleton_manager_, @@ -124,7 +123,6 @@ TEST_F(TestStaticClusterImplTest, CreateWithStructConfig) { connect_timeout: 0.25s lb_policy: ROUND_ROBIN load_assignment: - cluster_name: staticcluster endpoints: - lb_endpoints: - endpoint: @@ -142,7 +140,7 @@ TEST_F(TestStaticClusterImplTest, CreateWithStructConfig) { port_value: 80 )EOF"; - const envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + const envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); auto create_result = ClusterFactoryImplBase::create( cluster_config, cm_, stats_, tls_, dns_resolver_, ssl_context_manager_, runtime_, random_, dispatcher_, log_manager_, local_info_, admin_, singleton_manager_, @@ -169,7 +167,6 @@ TEST_F(TestStaticClusterImplTest, CreateWithTypedConfig) { connect_timeout: 0.25s lb_policy: ROUND_ROBIN load_assignment: - cluster_name: staticcluster endpoints: - lb_endpoints: - endpoint: @@ -186,7 +183,7 @@ TEST_F(TestStaticClusterImplTest, CreateWithTypedConfig) { port_value: 80 )EOF"; - const envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + const envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); auto create_result = ClusterFactoryImplBase::create( cluster_config, cm_, stats_, tls_, dns_resolver_, ssl_context_manager_, runtime_, random_, dispatcher_, log_manager_, local_info_, admin_, singleton_manager_, @@ -213,7 +210,6 @@ TEST_F(TestStaticClusterImplTest, UnsupportedClusterType) { connect_timeout: 0.25s lb_policy: ROUND_ROBIN load_assignment: - cluster_name: staticcluster endpoints: - lb_endpoints: - endpoint: @@ -230,7 +226,7 @@ TEST_F(TestStaticClusterImplTest, UnsupportedClusterType) { // the factory is not registered, expect to throw EXPECT_THROW_WITH_MESSAGE( { - const envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + const envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); ClusterFactoryImplBase::create( cluster_config, cm_, stats_, tls_, dns_resolver_, ssl_context_manager_, runtime_, random_, dispatcher_, log_manager_, local_info_, admin_, singleton_manager_, @@ -250,7 +246,6 @@ TEST_F(TestStaticClusterImplTest, HostnameWithoutDNS) { consistent_hashing_lb_config: use_hostname_for_hashing: true load_assignment: - cluster_name: staticcluster endpoints: - lb_endpoints: - endpoint: @@ -264,7 +259,7 @@ TEST_F(TestStaticClusterImplTest, HostnameWithoutDNS) { EXPECT_THROW_WITH_MESSAGE( { - const envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + const envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); ClusterFactoryImplBase::create( cluster_config, cm_, stats_, tls_, dns_resolver_, ssl_context_manager_, runtime_, random_, dispatcher_, log_manager_, local_info_, admin_, singleton_manager_, diff --git a/test/common/upstream/cluster_manager_impl_test.cc b/test/common/upstream/cluster_manager_impl_test.cc index 386031b45516..37a078501974 100644 --- a/test/common/upstream/cluster_manager_impl_test.cc +++ b/test/common/upstream/cluster_manager_impl_test.cc @@ -2665,7 +2665,7 @@ TEST_F(ClusterManagerImplTest, MergedUpdatesDestroyedOnUpdate) { common_lb_config: update_merge_window: 3s )EOF"; - EXPECT_TRUE(cluster_manager_->addOrUpdateCluster(parseClusterFromV2Yaml(yaml), "version1")); + EXPECT_TRUE(cluster_manager_->addOrUpdateCluster(parseClusterFromV3Yaml(yaml), "version1")); Cluster& cluster = cluster_manager_->activeClusters().find("new_cluster")->second; HostVectorSharedPtr hosts( @@ -2734,7 +2734,7 @@ TEST_F(ClusterManagerImplTest, MergedUpdatesDestroyedOnUpdate) { .gauge("cluster_manager.warming_clusters", Stats::Gauge::ImportMode::NeverImport) .value()); EXPECT_TRUE( - cluster_manager_->addOrUpdateCluster(parseClusterFromV2Yaml(yaml_updated), "version2")); + cluster_manager_->addOrUpdateCluster(parseClusterFromV3Yaml(yaml_updated), "version2")); EXPECT_EQ(2, factory_.stats_ .gauge("cluster_manager.active_clusters", Stats::Gauge::ImportMode::NeverImport) .value()); diff --git a/test/common/upstream/eds_speed_test.cc b/test/common/upstream/eds_speed_test.cc index b1ede181e491..a03af737483e 100644 --- a/test/common/upstream/eds_speed_test.cc +++ b/test/common/upstream/eds_speed_test.cc @@ -48,7 +48,7 @@ class EdsSpeedTest { void resetCluster(const std::string& yaml_config, Cluster::InitializePhase initialize_phase) { local_info_.node_.mutable_locality()->set_zone("us-east-1a"); - eds_cluster_ = parseClusterFromV2Yaml(yaml_config); + eds_cluster_ = parseClusterFromV3Yaml(yaml_config); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format( "cluster.{}.", eds_cluster_.alt_stat_name().empty() ? eds_cluster_.name() : eds_cluster_.alt_stat_name())); diff --git a/test/common/upstream/eds_test.cc b/test/common/upstream/eds_test.cc index ef7f38002993..f08269380065 100644 --- a/test/common/upstream/eds_test.cc +++ b/test/common/upstream/eds_test.cc @@ -61,7 +61,7 @@ class EdsTest : public testing::Test { connect_timeout: 0.25s type: EDS lb_policy: ROUND_ROBIN - drain_connections_on_host_removal: true + ignore_health_on_host_removal: true eds_cluster_config: service_name: fare eds_config: @@ -89,7 +89,7 @@ class EdsTest : public testing::Test { void resetCluster(const std::string& yaml_config, Cluster::InitializePhase initialize_phase) { local_info_.node_.mutable_locality()->set_zone("us-east-1a"); - eds_cluster_ = parseClusterFromV2Yaml(yaml_config); + eds_cluster_ = parseClusterFromV3Yaml(yaml_config); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format( "cluster.{}.", eds_cluster_.alt_stat_name().empty() ? eds_cluster_.name() : eds_cluster_.alt_stat_name())); @@ -138,8 +138,8 @@ class EdsWithHealthCheckUpdateTest : public EdsTest { // Build the initial cluster with some endpoints. void initializeCluster(const std::vector endpoint_ports, - const bool drain_connections_on_host_removal) { - resetCluster(drain_connections_on_host_removal); + const bool ignore_health_on_host_removal) { + resetCluster(ignore_health_on_host_removal); auto health_checker = std::make_shared(); EXPECT_CALL(*health_checker, start()); @@ -173,13 +173,13 @@ class EdsWithHealthCheckUpdateTest : public EdsTest { } } - void resetCluster(const bool drain_connections_on_host_removal) { + void resetCluster(const bool ignore_health_on_host_removal) { const std::string config = R"EOF( name: name connect_timeout: 0.25s type: EDS lb_policy: ROUND_ROBIN - drain_connections_on_host_removal: {} + ignore_health_on_host_removal: {} eds_cluster_config: service_name: fare eds_config: @@ -189,7 +189,7 @@ class EdsWithHealthCheckUpdateTest : public EdsTest { - eds refresh_delay: 1s )EOF"; - EdsTest::resetCluster(fmt::format(config, drain_connections_on_host_removal), + EdsTest::resetCluster(fmt::format(config, ignore_health_on_host_removal), Cluster::InitializePhase::Secondary); } diff --git a/test/common/upstream/logical_dns_cluster_test.cc b/test/common/upstream/logical_dns_cluster_test.cc index a5158e3e3f59..df0aef7ca10e 100644 --- a/test/common/upstream/logical_dns_cluster_test.cc +++ b/test/common/upstream/logical_dns_cluster_test.cc @@ -43,10 +43,11 @@ class LogicalDnsClusterTest : public testing::Test { protected: LogicalDnsClusterTest() : api_(Api::createApiForTest(stats_store_)) {} - void setupFromV2Yaml(const std::string& yaml) { + void setupFromV3Yaml(const std::string& yaml, bool avoid_boosting = true) { resolve_timer_ = new Event::MockTimer(&dispatcher_); NiceMock cm; - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = + parseClusterFromV3Yaml(yaml, avoid_boosting); Envoy::Stats::ScopePtr scope = stats_store_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); @@ -75,7 +76,7 @@ class LogicalDnsClusterTest : public testing::Test { void testBasicSetup(const std::string& config, const std::string& expected_address, uint32_t expected_port, uint32_t expected_hc_port) { expectResolve(Network::DnsLookupFamily::V4Only, expected_address); - setupFromV2Yaml(config); + setupFromV3Yaml(config); EXPECT_CALL(membership_updated_, ready()); EXPECT_CALL(initialized_, ready()); @@ -264,10 +265,14 @@ TEST_P(LogicalDnsParamTest, ImmediateResolve) { lb_policy: round_robin )EOF" + std::get<0>(GetParam()) + R"EOF( - hosts: - - socket_address: - address: foo.bar.com - port_value: 443 + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: foo.bar.com + port_value: 443 )EOF"; EXPECT_CALL(membership_updated_, ready()); @@ -280,7 +285,7 @@ TEST_P(LogicalDnsParamTest, ImmediateResolve) { TestUtility::makeDnsResponse(std::get<2>(GetParam()))); return nullptr; })); - setupFromV2Yaml(yaml); + setupFromV3Yaml(yaml); EXPECT_EQ(1UL, cluster_->prioritySet().hostSetsPerPriority()[0]->hosts().size()); EXPECT_EQ(1UL, cluster_->prioritySet().hostSetsPerPriority()[0]->healthyHosts().size()); EXPECT_EQ("foo.bar.com", @@ -302,14 +307,18 @@ TEST_F(LogicalDnsParamTest, FailureRefreshRateBackoffResetsWhenSuccessHappens) { # Since the following expectResolve() requires Network::DnsLookupFamily::V4Only we need to set # dns_lookup_family to V4_ONLY explicitly for v2 .yaml config. dns_lookup_family: V4_ONLY - hosts: - - socket_address: - address: foo.bar.com - port_value: 443 + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: foo.bar.com + port_value: 443 )EOF"; expectResolve(Network::DnsLookupFamily::V4Only, "foo.bar.com"); - setupFromV2Yaml(yaml); + setupFromV3Yaml(yaml); // Failing response kicks the failure refresh backoff strategy. ON_CALL(random_, random()).WillByDefault(Return(8000)); @@ -342,14 +351,18 @@ TEST_F(LogicalDnsParamTest, TtlAsDnsRefreshRate) { # Since the following expectResolve() requires Network::DnsLookupFamily::V4Only we need to set # dns_lookup_family to V4_ONLY explicitly for v2 .yaml config. dns_lookup_family: V4_ONLY - hosts: - - socket_address: - address: foo.bar.com - port_value: 443 + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: foo.bar.com + port_value: 443 )EOF"; expectResolve(Network::DnsLookupFamily::V4Only, "foo.bar.com"); - setupFromV2Yaml(yaml); + setupFromV3Yaml(yaml); // TTL is recorded when the DNS response is successful and not empty EXPECT_CALL(membership_updated_, ready()); @@ -378,17 +391,25 @@ TEST_F(LogicalDnsClusterTest, BadConfig) { dns_refresh_rate: 4s connect_timeout: 0.25s lb_policy: ROUND_ROBIN - hosts: - - socket_address: - address: foo.bar.com - port_value: 443 - - socket_address: - address: foo2.bar.com - port_value: 443 + load_assignment: + cluster_name: name + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: foo.bar.com + port_value: 443 + - endpoint: + address: + socket_address: + address: foo2.bar.com + port_value: 443 )EOF"; - EXPECT_THROW_WITH_MESSAGE(setupFromV2Yaml(multiple_hosts_yaml), EnvoyException, - "LOGICAL_DNS clusters must have a single host"); + EXPECT_THROW_WITH_MESSAGE( + setupFromV3Yaml(multiple_hosts_yaml), EnvoyException, + "LOGICAL_DNS clusters must have a single locality_lb_endpoint and a single lb_endpoint"); const std::string multiple_lb_endpoints_yaml = R"EOF( name: name @@ -418,7 +439,7 @@ TEST_F(LogicalDnsClusterTest, BadConfig) { )EOF"; EXPECT_THROW_WITH_MESSAGE( - setupFromV2Yaml(multiple_lb_endpoints_yaml), EnvoyException, + setupFromV3Yaml(multiple_lb_endpoints_yaml), EnvoyException, "LOGICAL_DNS clusters must have a single locality_lb_endpoint and a single lb_endpoint"); const std::string multiple_endpoints_yaml = R"EOF( @@ -451,7 +472,7 @@ TEST_F(LogicalDnsClusterTest, BadConfig) { )EOF"; EXPECT_THROW_WITH_MESSAGE( - setupFromV2Yaml(multiple_endpoints_yaml), EnvoyException, + setupFromV3Yaml(multiple_endpoints_yaml), EnvoyException, "LOGICAL_DNS clusters must have a single locality_lb_endpoint and a single lb_endpoint"); const std::string custom_resolver_yaml = R"EOF( @@ -475,7 +496,7 @@ TEST_F(LogicalDnsClusterTest, BadConfig) { port_value: 8000 )EOF"; - EXPECT_THROW_WITH_MESSAGE(setupFromV2Yaml(custom_resolver_yaml), EnvoyException, + EXPECT_THROW_WITH_MESSAGE(setupFromV3Yaml(custom_resolver_yaml), EnvoyException, "LOGICAL_DNS clusters must NOT have a custom resolver name set"); } @@ -492,10 +513,14 @@ TEST_F(LogicalDnsClusterTest, Basic) { # Since the following expectResolve() requires Network::DnsLookupFamily::V4Only we need to set # dns_lookup_family to V4_ONLY explicitly for v2 .yaml config. dns_lookup_family: V4_ONLY - hosts: - - socket_address: - address: foo.bar.com - port_value: 443 + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: foo.bar.com + port_value: 443 )EOF"; const std::string basic_yaml_load_assignment = R"EOF( diff --git a/test/common/upstream/original_dst_cluster_test.cc b/test/common/upstream/original_dst_cluster_test.cc index 4f25099ba615..80bb3e2c8910 100644 --- a/test/common/upstream/original_dst_cluster_test.cc +++ b/test/common/upstream/original_dst_cluster_test.cc @@ -70,7 +70,9 @@ class OriginalDstClusterTest : public testing::Test { : cleanup_timer_(new Event::MockTimer(&dispatcher_)), api_(Api::createApiForTest(stats_store_)) {} - void setupFromYaml(const std::string& yaml) { setup(parseClusterFromV2Yaml(yaml)); } + void setupFromYaml(const std::string& yaml, bool avoid_boosting = true) { + setup(parseClusterFromV3Yaml(yaml, avoid_boosting)); + } void setup(const envoy::config::cluster::v3::Cluster& cluster_config) { NiceMock cm; @@ -115,7 +117,7 @@ TEST(OriginalDstClusterConfigTest, GoodConfig) { cleanup_interval: 1s )EOF"; // Help Emacs balance quotation marks: " - EXPECT_TRUE(parseClusterFromV2Yaml(yaml).has_cleanup_interval()); + EXPECT_TRUE(parseClusterFromV3Yaml(yaml).has_cleanup_interval()); } TEST_F(OriginalDstClusterTest, BadConfigWithLoadAssignment) { @@ -123,7 +125,7 @@ TEST_F(OriginalDstClusterTest, BadConfigWithLoadAssignment) { name: name connect_timeout: 0.25s type: ORIGINAL_DST - lb_policy: ORIGINAL_DST_LB + lb_policy: CLUSTER_PROVIDED cleanup_interval: 1s load_assignment: cluster_name: name @@ -155,7 +157,7 @@ TEST_F(OriginalDstClusterTest, BadConfigWithDeprecatedHosts) { )EOF"; EXPECT_THROW_WITH_MESSAGE( - setupFromYaml(yaml), EnvoyException, + setupFromYaml(yaml, false), EnvoyException, "ORIGINAL_DST clusters must have no load assignment or hosts configured"); } @@ -164,7 +166,7 @@ TEST_F(OriginalDstClusterTest, CleanupInterval) { name: name connect_timeout: 1.250s type: ORIGINAL_DST - lb_policy: ORIGINAL_DST_LB + lb_policy: CLUSTER_PROVIDED cleanup_interval: 1s )EOF"; // Help Emacs balance quotation marks: " @@ -182,7 +184,7 @@ TEST_F(OriginalDstClusterTest, NoContext) { name: name, connect_timeout: 0.125s type: ORIGINAL_DST - lb_policy: ORIGINAL_DST_LB + lb_policy: CLUSTER_PROVIDED )EOF"; EXPECT_CALL(initialized_, ready()); @@ -240,7 +242,7 @@ TEST_F(OriginalDstClusterTest, Membership) { name: name connect_timeout: 1.250s type: ORIGINAL_DST - lb_policy: ORIGINAL_DST_LB + lb_policy: CLUSTER_PROVIDED )EOF"; EXPECT_CALL(initialized_, ready()); @@ -331,7 +333,7 @@ TEST_F(OriginalDstClusterTest, Membership2) { name: name connect_timeout: 1.250s type: ORIGINAL_DST - lb_policy: ORIGINAL_DST_LB + lb_policy: CLUSTER_PROVIDED )EOF"; EXPECT_CALL(initialized_, ready()); @@ -419,7 +421,7 @@ TEST_F(OriginalDstClusterTest, Connection) { name: name connect_timeout: 1.250s type: ORIGINAL_DST - lb_policy: ORIGINAL_DST_LB + lb_policy: CLUSTER_PROVIDED )EOF"; EXPECT_CALL(initialized_, ready()); @@ -459,7 +461,7 @@ TEST_F(OriginalDstClusterTest, MultipleClusters) { name: name connect_timeout: 1.250s type: ORIGINAL_DST - lb_policy: ORIGINAL_DST_LB + lb_policy: CLUSTER_PROVIDED )EOF"; EXPECT_CALL(initialized_, ready()); @@ -511,7 +513,7 @@ TEST_F(OriginalDstClusterTest, UseHttpHeaderEnabled) { name: name connect_timeout: 1.250s type: ORIGINAL_DST - lb_policy: ORIGINAL_DST_LB + lb_policy: CLUSTER_PROVIDED original_dst_lb_config: use_http_header: true )EOF"; @@ -584,7 +586,7 @@ TEST_F(OriginalDstClusterTest, UseHttpHeaderDisabled) { name: name connect_timeout: 1.250s type: ORIGINAL_DST - lb_policy: ORIGINAL_DST_LB + lb_policy: CLUSTER_PROVIDED )EOF"; EXPECT_CALL(initialized_, ready()); diff --git a/test/common/upstream/upstream_impl_test.cc b/test/common/upstream/upstream_impl_test.cc index 15aba3773fed..c433faedc3d5 100644 --- a/test/common/upstream/upstream_impl_test.cc +++ b/test/common/upstream/upstream_impl_test.cc @@ -161,10 +161,14 @@ TEST_P(StrictDnsParamTest, ImmediateResolve) { )EOF" + std::get<0>(GetParam()) + R"EOF( lb_policy: round_robin - hosts: - - socket_address: - address: foo.bar.com - port_value: 443 + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: foo.bar.com + port_value: 443 )EOF"; EXPECT_CALL(initialized, ready()); EXPECT_CALL(*dns_resolver, resolve("foo.bar.com", std::get<1>(GetParam()), _)) @@ -174,7 +178,7 @@ TEST_P(StrictDnsParamTest, ImmediateResolve) { TestUtility::makeDnsResponse(std::get<2>(GetParam()))); return nullptr; })); - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); @@ -208,7 +212,7 @@ TEST_F(StrictDnsClusterImplTest, ZeroHostsIsInializedImmediately) { - lb_endpoints: )EOF"; - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); @@ -232,11 +236,18 @@ TEST_F(StrictDnsClusterImplTest, ZeroHostsHealthChecker) { connect_timeout: 0.25s type: STRICT_DNS lb_policy: ROUND_ROBIN - hosts: [{ socket_address: { address: foo.bar.com, port_value: 443 }}] + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: foo.bar.com + port_value: 443 )EOF"; ResolverData resolver(*dns_resolver_, dispatcher_); - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); @@ -292,12 +303,22 @@ TEST_F(StrictDnsClusterImplTest, Basic) { http_protocol_options: header_key_format: proper_case_words: {} - hosts: - - { socket_address: { address: localhost1, port_value: 11001 }} - - { socket_address: { address: localhost2, port_value: 11002 }} + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: localhost1 + port_value: 11001 + - endpoint: + address: + socket_address: + address: localhost2 + port_value: 11002 )EOF"; - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); @@ -437,12 +458,19 @@ TEST_F(StrictDnsClusterImplTest, HostRemovalActiveHealthSkipped) { connect_timeout: 0.25s type: STRICT_DNS lb_policy: ROUND_ROBIN - drain_connections_on_host_removal: true - hosts: [{ socket_address: { address: foo.bar.com, port_value: 443 }}] + ignore_health_on_host_removal: true + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: foo.bar.com + port_value: 443 )EOF"; ResolverData resolver(*dns_resolver_, dispatcher_); - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); @@ -492,11 +520,18 @@ TEST_F(StrictDnsClusterImplTest, HostRemovalAfterHcFail) { connect_timeout: 0.25s type: STRICT_DNS lb_policy: ROUND_ROBIN - hosts: [{ socket_address: { address: foo.bar.com, port_value: 443 }}] + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: foo.bar.com + port_value: 443 )EOF"; ResolverData resolver(*dns_resolver_, dispatcher_); - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); @@ -623,7 +658,7 @@ TEST_F(StrictDnsClusterImplTest, LoadAssignmentBasic) { port_value: 8000 )EOF"; - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); @@ -858,7 +893,7 @@ TEST_F(StrictDnsClusterImplTest, LoadAssignmentBasicMultiplePriorities) { port_value: 8000 )EOF"; - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); @@ -959,11 +994,19 @@ TEST_F(StrictDnsClusterImplTest, CustomResolverFails) { connect_timeout: 0.25s type: STRICT_DNS lb_policy: ROUND_ROBIN - drain_connections_on_host_removal: true - hosts: [{ socket_address: { address: foo.bar.com, port_value: 443, resolver_name: customresolver }}] + ignore_health_on_host_removal: true + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: foo.bar.com + port_value: 443 + resolver_name: customresolver )EOF"; - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format("cluster.{}.", cluster_config.name())); Envoy::Server::Configuration::TransportSocketFactoryContextImpl factory_context( @@ -988,10 +1031,17 @@ TEST_F(StrictDnsClusterImplTest, FailureRefreshRateBackoffResetsWhenSuccessHappe dns_failure_refresh_rate: base_interval: 7s max_interval: 10s - hosts: [{ socket_address: { address: localhost1, port_value: 11001 }}] + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: localhost1 + port_value: 11001 )EOF"; - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); @@ -1030,10 +1080,17 @@ TEST_F(StrictDnsClusterImplTest, TtlAsDnsRefreshRate) { lb_policy: ROUND_ROBIN dns_refresh_rate: 4s respect_dns_ttl: true - hosts: [{ socket_address: { address: localhost1, port_value: 11001 }}] + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: localhost1 + port_value: 11001 )EOF"; - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); @@ -1098,12 +1155,22 @@ TEST_F(StrictDnsClusterImplTest, Http2UserDefinedSettingsParametersValidation) { http_protocol_options: header_key_format: proper_case_words: {} - hosts: - - { socket_address: { address: localhost1, port_value: 11001 }} - - { socket_address: { address: localhost2, port_value: 11002 }} + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: localhost1 + port_value: 11001 + - endpoint: + address: + socket_address: + address: localhost2 + port_value: 11002 )EOF"; - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); @@ -1236,13 +1303,17 @@ TEST_F(StaticClusterImplTest, InitialHosts) { connect_timeout: 0.25s type: STATIC lb_policy: ROUND_ROBIN - hosts: - - socket_address: - address: 10.0.0.1 - port_value: 443 + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: 10.0.0.1 + port_value: 443 )EOF"; - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); @@ -1277,7 +1348,7 @@ TEST_F(StaticClusterImplTest, LoadAssignmentEmptyHostname) { port_value: 8000 )EOF"; - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); @@ -1312,7 +1383,7 @@ TEST_F(StaticClusterImplTest, LoadAssignmentNonEmptyHostname) { port_value: 8000 )EOF"; - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); @@ -1347,7 +1418,7 @@ TEST_F(StaticClusterImplTest, LoadAssignmentNonEmptyHostnameWithHealthChecks) { hostname: "foo2" )EOF"; - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); @@ -1400,7 +1471,7 @@ TEST_F(StaticClusterImplTest, LoadAssignmentMultiplePriorities) { port_value: 8000 )EOF"; - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); @@ -1445,7 +1516,7 @@ TEST_F(StaticClusterImplTest, LoadAssignmentLocality) { port_value: 8000 )EOF"; - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); @@ -1491,7 +1562,7 @@ TEST_F(StaticClusterImplTest, LoadAssignmentEdsHealth) { )EOF"; NiceMock cm; - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); @@ -1513,10 +1584,17 @@ TEST_F(StaticClusterImplTest, AltStatName) { connect_timeout: 0.25s type: STRICT_DNS lb_policy: ROUND_ROBIN - hosts: [{ socket_address: { address: 10.0.0.1, port_value: 443 }}] + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: 10.0.0.1 + port_value: 443 )EOF"; - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); @@ -1536,10 +1614,17 @@ TEST_F(StaticClusterImplTest, RingHash) { connect_timeout: 0.25s type: static lb_policy: ring_hash - hosts: [{ socket_address: { address: 10.0.0.1, port_value: 11001 }}] + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: 10.0.0.1 + port_value: 11001 )EOF"; - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); @@ -1560,12 +1645,22 @@ TEST_F(StaticClusterImplTest, OutlierDetector) { connect_timeout: 0.25s type: static lb_policy: random - hosts: - - { socket_address: { address: 10.0.0.1, port_value: 11001 }} - - { socket_address: { address: 10.0.0.1, port_value: 11002 }} + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: 10.0.0.1 + port_value: 11001 + - endpoint: + address: + socket_address: + address: 10.0.0.1 + port_value: 11002 )EOF"; - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); @@ -1608,12 +1703,22 @@ TEST_F(StaticClusterImplTest, HealthyStat) { connect_timeout: 0.25s type: static lb_policy: random - hosts: - - { socket_address: { address: 10.0.0.1, port_value: 11001 }} - - { socket_address: { address: 10.0.0.1, port_value: 11002 }} + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: 10.0.0.1 + port_value: 11001 + - endpoint: + address: + socket_address: + address: 10.0.0.1 + port_value: 11002 )EOF"; - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); @@ -1739,12 +1844,22 @@ TEST_F(StaticClusterImplTest, UrlConfig) { connect_timeout: 0.25s type: static lb_policy: random - hosts: - - { socket_address: { address: 10.0.0.1, port_value: 11001 }} - - { socket_address: { address: 10.0.0.2, port_value: 11002 }} + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: 10.0.0.1 + port_value: 11001 + - endpoint: + address: + socket_address: + address: 10.0.0.2 + port_value: 11002 )EOF"; - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); @@ -1795,7 +1910,7 @@ TEST_F(StaticClusterImplTest, UnsupportedLBType) { EXPECT_THROW_WITH_MESSAGE( { - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format("cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() @@ -1818,10 +1933,16 @@ TEST_F(StaticClusterImplTest, MalformedHostIP) { connect_timeout: 0.25s type: STATIC lb_policy: ROUND_ROBIN - hosts: [{ socket_address: { address: foo.bar.com }}] + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: foo.bar.com )EOF"; - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); @@ -1849,7 +1970,7 @@ TEST_F(StaticClusterImplTest, NoHostsTest) { - priority: 1 )EOF"; - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format("cluster.{}.", cluster_config.name())); Envoy::Server::Configuration::TransportSocketFactoryContextImpl factory_context( @@ -1918,9 +2039,16 @@ TEST_F(ClusterImplTest, CloseConnectionsOnHostHealthFailure) { type: STRICT_DNS lb_policy: ROUND_ROBIN close_connections_on_host_health_failure: true - hosts: [{ socket_address: { address: foo.bar.com, port_value: 443 }}] + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: foo.bar.com + port_value: 443 )EOF"; - envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); @@ -2050,8 +2178,9 @@ class ClusterInfoImplTest : public testing::Test { public: ClusterInfoImplTest() : api_(Api::createApiForTest(stats_)) {} - std::unique_ptr makeCluster(const std::string& yaml) { - cluster_config_ = parseClusterFromV2Yaml(yaml); + std::unique_ptr makeCluster(const std::string& yaml, + bool avoid_boosting = true) { + cluster_config_ = parseClusterFromV3Yaml(yaml, avoid_boosting); scope_ = stats_.createScope(fmt::format("cluster.{}.", cluster_config_.alt_stat_name().empty() ? cluster_config_.name() : cluster_config_.alt_stat_name())); @@ -2109,7 +2238,14 @@ TEST_F(ClusterInfoImplTest, Metadata) { connect_timeout: 0.25s type: STRICT_DNS lb_policy: MAGLEV - hosts: [{ socket_address: { address: foo.bar.com, port_value: 443 }}] + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: foo.bar.com + port_value: 443 metadata: { filter_metadata: { com.bar.foo: { baz: test_value }, baz: {name: meh } } } common_lb_config: @@ -2139,7 +2275,14 @@ TEST_F(ClusterInfoImplTest, EdsServiceNamePopulation) { lb_policy: MAGLEV eds_cluster_config: service_name: service_foo - hosts: [{ socket_address: { address: foo.bar.com, port_value: 443 }}] + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: foo.bar.com + port_value: 443 common_lb_config: healthy_panic_threshold: value: 0.3 @@ -2154,7 +2297,14 @@ TEST_F(ClusterInfoImplTest, EdsServiceNamePopulation) { lb_policy: MAGLEV eds_cluster_config: service_name: service_foo - hosts: [{ socket_address: { address: foo.bar.com, port_value: 443 }}] + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: foo.bar.com + port_value: 443 common_lb_config: healthy_panic_threshold: value: 0.3 @@ -2170,7 +2320,14 @@ TEST_F(ClusterInfoImplTest, BrokenTypedMetadata) { connect_timeout: 0.25s type: STRICT_DNS lb_policy: MAGLEV - hosts: [{ socket_address: { address: foo.bar.com, port_value: 443 }}] + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: foo.bar.com + port_value: 443 metadata: { filter_metadata: { com.bar.foo: { baz: test_value }, baz: {boom: meh} } } common_lb_config: @@ -2191,12 +2348,22 @@ TEST_F(ClusterInfoImplTest, ExtensionProtocolOptionsForUnknownFilter) { connect_timeout: 0.25s type: STRICT_DNS lb_policy: ROUND_ROBIN - hosts: [{ socket_address: { address: foo.bar.com, port_value: 443 }}] - extension_protocol_options: - no_such_filter: { option: value } + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: foo.bar.com + port_value: 443 + typed_extension_protocol_options: + no_such_filter: + "@type": type.googleapis.com/google.protobuf.Struct + value: + option: "value" )EOF"; - EXPECT_THROW_WITH_MESSAGE(makeCluster(yaml), EnvoyException, + EXPECT_THROW_WITH_MESSAGE(makeCluster(yaml, false), EnvoyException, "Didn't find a registered network or http filter implementation for " "name: 'no_such_filter'"); } @@ -2207,7 +2374,14 @@ TEST_F(ClusterInfoImplTest, TypedExtensionProtocolOptionsForUnknownFilter) { connect_timeout: 0.25s type: STRICT_DNS lb_policy: ROUND_ROBIN - hosts: [{ socket_address: { address: foo.bar.com, port_value: 443 }}] + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: foo.bar.com + port_value: 443 typed_extension_protocol_options: no_such_filter: "@type": type.googleapis.com/google.protobuf.Struct @@ -2218,6 +2392,7 @@ TEST_F(ClusterInfoImplTest, TypedExtensionProtocolOptionsForUnknownFilter) { "name: 'no_such_filter'"); } +// This test case can't be converted for V3 API as it is specific for extension_protocol_options TEST_F(ClusterInfoImplTest, OneofExtensionProtocolOptionsForUnknownFilter) { const std::string yaml = R"EOF( name: name @@ -2232,7 +2407,7 @@ TEST_F(ClusterInfoImplTest, OneofExtensionProtocolOptionsForUnknownFilter) { "@type": type.googleapis.com/google.protobuf.Struct )EOF"; - EXPECT_THROW_WITH_MESSAGE(makeCluster(yaml), EnvoyException, + EXPECT_THROW_WITH_MESSAGE(makeCluster(yaml, false), EnvoyException, "Only one of typed_extension_protocol_options or " "extension_protocol_options can be specified"); } @@ -2289,7 +2464,14 @@ TEST_F(ClusterInfoImplTest, Timeouts) { connect_timeout: 0.25s type: STRICT_DNS lb_policy: MAGLEV - hosts: [{ socket_address: { address: foo.bar.com, port_value: 443 }}] + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: foo.bar.com + port_value: 443 metadata: { filter_metadata: { com.bar.foo: { baz: test_value }, baz: {name: meh } } } common_lb_config: @@ -2469,22 +2651,32 @@ TEST_F(ClusterInfoImplTest, ExtensionProtocolOptionsForFilterWithoutOptions) { connect_timeout: 0.25s type: STRICT_DNS lb_policy: ROUND_ROBIN - hosts: [{ socket_address: { address: foo.bar.com, port_value: 443 }}] - extension_protocol_options: - envoy.test.filter: { option: value } + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: foo.bar.com + port_value: 443 + typed_extension_protocol_options: + envoy.test.filter: + "@type": type.googleapis.com/google.protobuf.Struct + value: + option: "value" )EOF"; { TestNetworkFilterConfigFactory factory(factoryBase); Registry::InjectFactory registry( factory); - EXPECT_THROW_WITH_MESSAGE(makeCluster(yaml), EnvoyException, + EXPECT_THROW_WITH_MESSAGE(makeCluster(yaml, false), EnvoyException, "filter envoy.test.filter does not support protocol options"); } { TestHttpFilterConfigFactory factory(factoryBase); Registry::InjectFactory registry(factory); - EXPECT_THROW_WITH_MESSAGE(makeCluster(yaml), EnvoyException, + EXPECT_THROW_WITH_MESSAGE(makeCluster(yaml, false), EnvoyException, "filter envoy.test.filter does not support protocol options"); } } @@ -2500,7 +2692,14 @@ TEST_F(ClusterInfoImplTest, TypedExtensionProtocolOptionsForFilterWithoutOptions connect_timeout: 0.25s type: STRICT_DNS lb_policy: ROUND_ROBIN - hosts: [{ socket_address: { address: foo.bar.com, port_value: 443 }}] + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: foo.bar.com + port_value: 443 typed_extension_protocol_options: envoy.test.filter: { "@type": type.googleapis.com/google.protobuf.Struct } )EOF"; @@ -2538,9 +2737,19 @@ TEST_F(ClusterInfoImplTest, ExtensionProtocolOptionsForFilterWithOptions) { connect_timeout: 0.25s type: STRICT_DNS lb_policy: ROUND_ROBIN - hosts: [{ socket_address: { address: foo.bar.com, port_value: 443 }}] - extension_protocol_options: - envoy.test.filter: { option: "value" } + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: foo.bar.com + port_value: 443 + typed_extension_protocol_options: + envoy.test.filter: + "@type": type.googleapis.com/google.protobuf.Struct + value: + option: "value" )EOF"; const std::string typed_yaml = R"EOF( @@ -2548,7 +2757,14 @@ TEST_F(ClusterInfoImplTest, ExtensionProtocolOptionsForFilterWithOptions) { connect_timeout: 0.25s type: STRICT_DNS lb_policy: ROUND_ROBIN - hosts: [{ socket_address: { address: foo.bar.com, port_value: 443 }}] + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: foo.bar.com + port_value: 443 typed_extension_protocol_options: envoy.test.filter: "@type": type.googleapis.com/google.protobuf.Struct diff --git a/test/common/upstream/utility.h b/test/common/upstream/utility.h index aba493bc22df..742efed4e9d3 100644 --- a/test/common/upstream/utility.h +++ b/test/common/upstream/utility.h @@ -56,9 +56,10 @@ inline envoy::config::cluster::v3::Cluster parseClusterFromV2Json(const std::str return cluster; } -inline envoy::config::cluster::v3::Cluster parseClusterFromV2Yaml(const std::string& yaml) { +inline envoy::config::cluster::v3::Cluster parseClusterFromV3Yaml(const std::string& yaml, + bool avoid_boosting = true) { envoy::config::cluster::v3::Cluster cluster; - TestUtility::loadFromYaml(yaml, cluster, true); + TestUtility::loadFromYaml(yaml, cluster, true, avoid_boosting); return cluster; } diff --git a/test/extensions/clusters/aggregate/cluster_test.cc b/test/extensions/clusters/aggregate/cluster_test.cc index 916fe3df8b10..2d3848206aae 100644 --- a/test/extensions/clusters/aggregate/cluster_test.cc +++ b/test/extensions/clusters/aggregate/cluster_test.cc @@ -88,7 +88,7 @@ class AggregateClusterTest : public testing::Test { void initialize(const std::string& yaml_config) { envoy::config::cluster::v3::Cluster cluster_config = - Upstream::parseClusterFromV2Yaml(yaml_config); + Upstream::parseClusterFromV3Yaml(yaml_config); envoy::extensions::clusters::aggregate::v3::ClusterConfig config; Config::Utility::translateOpaqueConfig(cluster_config.cluster_type().typed_config(), ProtobufWkt::Struct::default_instance(), diff --git a/test/extensions/clusters/dynamic_forward_proxy/cluster_test.cc b/test/extensions/clusters/dynamic_forward_proxy/cluster_test.cc index 2a90f3ee3878..08570d556bbe 100644 --- a/test/extensions/clusters/dynamic_forward_proxy/cluster_test.cc +++ b/test/extensions/clusters/dynamic_forward_proxy/cluster_test.cc @@ -30,7 +30,7 @@ class ClusterTest : public testing::Test, public: void initialize(const std::string& yaml_config, bool uses_tls) { envoy::config::cluster::v3::Cluster cluster_config = - Upstream::parseClusterFromV2Yaml(yaml_config); + Upstream::parseClusterFromV3Yaml(yaml_config); envoy::extensions::clusters::dynamic_forward_proxy::v3::ClusterConfig config; Config::Utility::translateOpaqueConfig(cluster_config.cluster_type().typed_config(), ProtobufWkt::Struct::default_instance(), @@ -199,9 +199,9 @@ TEST_F(ClusterTest, PopulatedCache) { class ClusterFactoryTest : public testing::Test { protected: - void createCluster(const std::string& yaml_config) { + void createCluster(const std::string& yaml_config, bool avoid_boosting = true) { envoy::config::cluster::v3::Cluster cluster_config = - Upstream::parseClusterFromV2Yaml(yaml_config); + Upstream::parseClusterFromV3Yaml(yaml_config, avoid_boosting); Upstream::ClusterFactoryContextImpl cluster_factory_context( cm_, stats_store_, tls_, nullptr, ssl_context_manager_, runtime_, random_, dispatcher_, log_manager_, local_info_, admin_, singleton_manager_, nullptr, true, validation_visitor_, @@ -250,7 +250,7 @@ connect_timeout: 0.25s )EOF"); EXPECT_THROW_WITH_MESSAGE( - createCluster(yaml_config), EnvoyException, + createCluster(yaml_config, false), EnvoyException, "dynamic_forward_proxy cluster cannot configure 'sni' or 'verify_subject_alt_name'"); } @@ -274,7 +274,7 @@ connect_timeout: 0.25s )EOF"); EXPECT_THROW_WITH_MESSAGE( - createCluster(yaml_config), EnvoyException, + createCluster(yaml_config, false), EnvoyException, "dynamic_forward_proxy cluster cannot configure 'sni' or 'verify_subject_alt_name'"); } diff --git a/test/extensions/clusters/redis/redis_cluster_test.cc b/test/extensions/clusters/redis/redis_cluster_test.cc index f630cdbd1a28..7c6a8cadf47d 100644 --- a/test/extensions/clusters/redis/redis_cluster_test.cc +++ b/test/extensions/clusters/redis/redis_cluster_test.cc @@ -41,10 +41,14 @@ const std::string BasicConfig = R"EOF( name: name connect_timeout: 0.25s dns_lookup_family: V4_ONLY - hosts: - - socket_address: - address: foo.bar.com - port_value: 22120 + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: foo.bar.com + port_value: 22120 cluster_type: name: envoy.clusters.redis typed_config: @@ -85,10 +89,10 @@ class RedisClusterTest : public testing::Test, return addresses; } - void setupFromV2Yaml(const std::string& yaml) { + void setupFromV3Yaml(const std::string& yaml) { expectRedisSessionCreated(); NiceMock cm; - envoy::config::cluster::v3::Cluster cluster_config = Upstream::parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = Upstream::parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_store_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); @@ -118,7 +122,7 @@ class RedisClusterTest : public testing::Test, void setupFactoryFromV2Yaml(const std::string& yaml) { NiceMock cm; - envoy::config::cluster::v3::Cluster cluster_config = Upstream::parseClusterFromV2Yaml(yaml); + envoy::config::cluster::v3::Cluster cluster_config = Upstream::parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_store_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); @@ -453,7 +457,7 @@ class RedisClusterTest : public testing::Test, } void testBasicSetup(const std::string& config, const std::string& expected_discovery_address) { - setupFromV2Yaml(config); + setupFromV3Yaml(config); const std::list resolved_addresses{"127.0.0.1", "127.0.0.2"}; expectResolveDiscovery(Network::DnsLookupFamily::V4Only, expected_discovery_address, resolved_addresses); @@ -615,10 +619,14 @@ TEST_P(RedisDnsParamTest, ImmediateResolveDns) { connect_timeout: 0.25s )EOF" + std::get<0>(GetParam()) + R"EOF( - hosts: - - socket_address: - address: foo.bar.com - port_value: 22120 + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: foo.bar.com + port_value: 22120 cluster_type: name: envoy.clusters.redis typed_config: @@ -628,7 +636,7 @@ TEST_P(RedisDnsParamTest, ImmediateResolveDns) { cluster_refresh_timeout: 0.25s )EOF"; - setupFromV2Yaml(config); + setupFromV3Yaml(config); expectRedisResolve(true); EXPECT_CALL(*dns_resolver_, resolve("foo.bar.com", std::get<1>(GetParam()), _)) @@ -652,7 +660,7 @@ TEST_P(RedisDnsParamTest, ImmediateResolveDns) { TEST_F(RedisClusterTest, EmptyDnsResponse) { Event::MockTimer* dns_timer = new NiceMock(&dispatcher_); - setupFromV2Yaml(BasicConfig); + setupFromV3Yaml(BasicConfig); const std::list resolved_addresses{}; EXPECT_CALL(*dns_timer, enableTimer(_, _)); expectResolveDiscovery(Network::DnsLookupFamily::V4Only, "foo.bar.com", resolved_addresses); @@ -676,7 +684,7 @@ TEST_F(RedisClusterTest, EmptyDnsResponse) { TEST_F(RedisClusterTest, FailedDnsResponse) { Event::MockTimer* dns_timer = new NiceMock(&dispatcher_); - setupFromV2Yaml(BasicConfig); + setupFromV3Yaml(BasicConfig); const std::list resolved_addresses{}; EXPECT_CALL(*dns_timer, enableTimer(_, _)); expectResolveDiscovery(Network::DnsLookupFamily::V4Only, "foo.bar.com", resolved_addresses, @@ -733,7 +741,7 @@ TEST_F(RedisClusterTest, Basic) { } TEST_F(RedisClusterTest, RedisResolveFailure) { - setupFromV2Yaml(BasicConfig); + setupFromV3Yaml(BasicConfig); const std::list resolved_addresses{"127.0.0.1", "127.0.0.2"}; expectResolveDiscovery(Network::DnsLookupFamily::V4Only, "foo.bar.com", resolved_addresses); expectRedisResolve(true); @@ -767,10 +775,14 @@ TEST_F(RedisClusterTest, FactoryInitNotRedisClusterTypeFailure) { name: name connect_timeout: 0.25s dns_lookup_family: V4_ONLY - hosts: - - socket_address: - address: foo.bar.com - port_value: 22120 + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: foo.bar.com + port_value: 22120 cluster_type: name: envoy.clusters.memcached typed_config: @@ -789,7 +801,7 @@ TEST_F(RedisClusterTest, FactoryInitRedisClusterTypeSuccess) { } TEST_F(RedisClusterTest, RedisErrorResponse) { - setupFromV2Yaml(BasicConfig); + setupFromV3Yaml(BasicConfig); const std::list resolved_addresses{"127.0.0.1", "127.0.0.2"}; expectResolveDiscovery(Network::DnsLookupFamily::V4Only, "foo.bar.com", resolved_addresses); expectRedisResolve(true); @@ -844,7 +856,7 @@ TEST_F(RedisClusterTest, RedisErrorResponse) { } TEST_F(RedisClusterTest, RedisReplicaErrorResponse) { - setupFromV2Yaml(BasicConfig); + setupFromV3Yaml(BasicConfig); const std::list resolved_addresses{"127.0.0.1", "127.0.0.2"}; expectResolveDiscovery(Network::DnsLookupFamily::V4Only, "foo.bar.com", resolved_addresses); expectRedisResolve(true); @@ -881,7 +893,7 @@ TEST_F(RedisClusterTest, RedisReplicaErrorResponse) { } TEST_F(RedisClusterTest, DnsDiscoveryResolverBasic) { - setupFromV2Yaml(BasicConfig); + setupFromV3Yaml(BasicConfig); testDnsResolve("foo.bar.com", 22120); } @@ -890,13 +902,19 @@ TEST_F(RedisClusterTest, MultipleDnsDiscovery) { name: name connect_timeout: 0.25s dns_lookup_family: V4_ONLY - hosts: - - socket_address: - address: foo.bar.com - port_value: 22120 - - socket_address: - address: foo1.bar.com - port_value: 22120 + load_assignment: + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: foo.bar.com + port_value: 22120 + - endpoint: + address: + socket_address: + address: foo1.bar.com + port_value: 22120 cluster_type: name: envoy.clusters.redis typed_config: @@ -906,7 +924,7 @@ TEST_F(RedisClusterTest, MultipleDnsDiscovery) { cluster_refresh_timeout: 0.25s )EOF"; - setupFromV2Yaml(config); + setupFromV3Yaml(config); // Only single in-flight "cluster slots" call. expectRedisResolve(true); @@ -937,7 +955,7 @@ TEST_F(RedisClusterTest, MultipleDnsDiscovery) { } TEST_F(RedisClusterTest, HostRemovalAfterHcFail) { - setupFromV2Yaml(BasicConfig); + setupFromV3Yaml(BasicConfig); auto health_checker = std::make_shared(); EXPECT_CALL(*health_checker, start()); EXPECT_CALL(*health_checker, addHostCheckCompleteCb(_)).Times(2); diff --git a/test/test_common/utility.h b/test/test_common/utility.h index e95302726494..0727b98729c7 100644 --- a/test/test_common/utility.h +++ b/test/test_common/utility.h @@ -553,7 +553,6 @@ class TestUtility { bool preserve_original_type = false, bool avoid_boosting = false) { MessageUtil::loadFromYaml(yaml, message, ProtobufMessage::getStrictValidationVisitor(), !avoid_boosting); - if (!preserve_original_type) { Config::VersionConverter::eraseOriginalTypeInformation(message); }