Skip to content

Commit

Permalink
tests: remove additional no_extension_lookup_by_name runtime override…
Browse files Browse the repository at this point in the history
… in tests (envoyproxy#27642)

Signed-off-by: Kuat Yessenov <kuat@google.com>
  • Loading branch information
kyessenov committed Jun 6, 2023
1 parent 2904bdb commit 878d26f
Show file tree
Hide file tree
Showing 40 changed files with 204 additions and 160 deletions.
1 change: 0 additions & 1 deletion test/common/config/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,5 @@ envoy_cc_test(
"//test/mocks/protobuf:protobuf_mocks",
"//test/mocks/server:instance_mocks",
"//test/test_common:registry_lib",
"//test/test_common:test_runtime_lib",
],
)
26 changes: 13 additions & 13 deletions test/common/config/custom_config_validators_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "test/mocks/protobuf/mocks.h"
#include "test/mocks/server/instance.h"
#include "test/test_common/registry.h"
#include "test/test_common/test_runtime.h"

#include "gtest/gtest.h"

Expand Down Expand Up @@ -44,11 +43,10 @@ class FakeConfigValidatorFactory : public ConfigValidatorFactory {

Envoy::ProtobufTypes::MessagePtr createEmptyConfigProto() override {
// Using Struct instead of a custom empty config proto. This is only allowed in tests.
return ProtobufTypes::MessagePtr{new Envoy::ProtobufWkt::Struct()};
return should_reject_ ? ProtobufTypes::MessagePtr{new Envoy::ProtobufWkt::Struct()}
: ProtobufTypes::MessagePtr{new Envoy::ProtobufWkt::Value()};
}

std::set<std::string> configTypes() override { return {}; }

std::string name() const override {
return absl::StrCat(category(), ".fake_config_validator_",
should_reject_ ? "reject" : "accept");
Expand All @@ -65,10 +63,7 @@ class CustomConfigValidatorsImplTest : public testing::Test {
public:
CustomConfigValidatorsImplTest()
: factory_accept_(false), factory_reject_(true), register_factory_accept_(factory_accept_),
register_factory_reject_(factory_reject_) {
scoped_runtime_.mergeValues(
{{"envoy.reloadable_features.no_extension_lookup_by_name", "false"}});
}
register_factory_reject_(factory_reject_) {}

static envoy::config::core::v3::TypedExtensionConfig parseConfig(const std::string& config) {
envoy::config::core::v3::TypedExtensionConfig proto;
Expand All @@ -83,12 +78,17 @@ class CustomConfigValidatorsImplTest : public testing::Test {
testing::NiceMock<ProtobufMessage::MockValidationVisitor> validation_visitor_;
const testing::NiceMock<Server::MockInstance> server_;
const std::string type_url_{Envoy::Config::getTypeUrl<envoy::config::cluster::v3::Cluster>()};
TestScopedRuntime scoped_runtime_;

static constexpr char AcceptValidatorConfig[] =
"name: envoy.config.validators.fake_config_validator_accept";
static constexpr char RejectValidatorConfig[] =
"name: envoy.config.validators.fake_config_validator_reject";
static constexpr char AcceptValidatorConfig[] = R"EOF(
name: envoy.config.validators.fake_config_validator_accept
typed_config:
"@type": type.googleapis.com/google.protobuf.Value
)EOF";
static constexpr char RejectValidatorConfig[] = R"EOF(
name: envoy.config.validators.fake_config_validator_reject
typed_config:
"@type": type.googleapis.com/google.protobuf.Struct
)EOF";
};

// Validates that empty config that has no validators is always accepted.
Expand Down
16 changes: 6 additions & 10 deletions test/common/tracing/tracer_manager_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ TEST_F(TracerManagerImplTest, ShouldReturnWhenNoTracingProviderHasBeenConfigured
}

TEST_F(TracerManagerImplTest, ShouldUseProperTracerFactory) {
TestScopedRuntime scoped_runtime;
scoped_runtime.mergeValues({{"envoy.reloadable_features.no_extension_lookup_by_name", "false"}});
envoy::config::trace::v3::Tracing_Http tracing_config;
tracing_config.set_name("envoy.tracers.sample");
tracing_config.mutable_typed_config()->PackFrom(ProtobufWkt::Struct());

auto tracer = tracer_manager_.getOrCreateTracer(&tracing_config);

Expand Down Expand Up @@ -119,28 +118,25 @@ TEST_F(TracerManagerImplTest, ShouldCacheTracersBasedOnFullConfig) {
}

TEST_F(TracerManagerImplTest, ShouldFailIfTracerProviderIsUnknown) {
TestScopedRuntime scoped_runtime;
scoped_runtime.mergeValues({{"envoy.reloadable_features.no_extension_lookup_by_name", "false"}});
envoy::config::trace::v3::Tracing_Http tracing_config;
tracing_config.set_name("invalid");
tracing_config.mutable_typed_config()->PackFrom(ProtobufWkt::Value());

EXPECT_THROW_WITH_MESSAGE(tracer_manager_.getOrCreateTracer(&tracing_config), EnvoyException,
"Didn't find a registered implementation for name: 'invalid'");
"Didn't find a registered implementation for 'invalid' "
"with type URL: 'google.protobuf.Value'");
}

TEST_F(TracerManagerImplTest, ShouldFailIfProviderSpecificConfigIsNotValid) {
TestScopedRuntime scoped_runtime;
scoped_runtime.mergeValues({{"envoy.reloadable_features.no_extension_lookup_by_name", "false"}});

envoy::config::trace::v3::Tracing_Http tracing_config;
tracing_config.set_name("envoy.tracers.sample");
tracing_config.mutable_typed_config()->PackFrom(ValueUtil::stringValue("value"));

ProtobufWkt::Any expected_any_proto;
expected_any_proto.PackFrom(ValueUtil::stringValue("value"));
EXPECT_THROW_WITH_MESSAGE(tracer_manager_.getOrCreateTracer(&tracing_config), EnvoyException,
fmt::format("Unable to unpack as google.protobuf.Struct: {}",
expected_any_proto.DebugString()));
"Didn't find a registered implementation for 'envoy.tracers.sample' "
"with type URL: 'google.protobuf.Value'");
}

class TracerManagerImplCacheTest : public testing::Test {
Expand Down
10 changes: 4 additions & 6 deletions test/common/upstream/cluster_manager_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1028,9 +1028,6 @@ TEST_F(ClusterManagerImplTest, ClusterProvidedLbNotConfigured) {
// Verify that multiple load balancing policies can be specified, and Envoy selects the first
// policy that it has a factory for.
TEST_F(ClusterManagerImplTest, LbPolicyConfig) {
TestScopedRuntime scoped_runtime;
scoped_runtime.mergeValues({{"envoy.reloadable_features.no_extension_lookup_by_name", "false"}});

// envoy.load_balancers.custom_lb is registered by linking in
// //test/integration/load_balancers:custom_lb_policy.
const std::string yaml = fmt::format(R"EOF(
Expand All @@ -1046,6 +1043,8 @@ TEST_F(ClusterManagerImplTest, LbPolicyConfig) {
name: envoy.load_balancers.unknown_lb
- typed_extension_config:
name: envoy.load_balancers.custom_lb
typed_config:
"@type": type.googleapis.com/test.integration.custom_lb.CustomLbConfig
load_assignment:
cluster_name: cluster_1
endpoints:
Expand Down Expand Up @@ -4433,9 +4432,6 @@ class TestUpstreamNetworkFilterConfigFactory

// Verify that configured upstream filters are added to client connections.
TEST_F(ClusterManagerImplTest, AddUpstreamFilters) {
TestScopedRuntime scoped_runtime;
scoped_runtime.mergeValues({{"envoy.reloadable_features.no_extension_lookup_by_name", "false"}});

TestUpstreamNetworkFilterConfigFactory factory;
Registry::InjectFactory<Server::Configuration::NamedUpstreamNetworkFilterConfigFactory> registry(
factory);
Expand All @@ -4457,6 +4453,8 @@ TEST_F(ClusterManagerImplTest, AddUpstreamFilters) {
port_value: 11001
filters:
- name: envoy.test.filter
typed_config:
"@type": type.googleapis.com/google.protobuf.Struct
)EOF";

create(parseBootstrapFromV3Yaml(yaml));
Expand Down
33 changes: 12 additions & 21 deletions test/common/upstream/upstream_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2348,9 +2348,6 @@ TEST_F(StaticClusterImplTest, UnsupportedLBType) {

// load_balancing_policy should be used when lb_policy is set to LOAD_BALANCING_POLICY_CONFIG.
TEST_F(StaticClusterImplTest, LoadBalancingPolicyWithLbPolicy) {
TestScopedRuntime scoped_runtime;
scoped_runtime.mergeValues({{"envoy.reloadable_features.no_extension_lookup_by_name", "false"}});

const std::string yaml = R"EOF(
name: staticcluster
connect_timeout: 0.25s
Expand All @@ -2360,6 +2357,8 @@ TEST_F(StaticClusterImplTest, LoadBalancingPolicyWithLbPolicy) {
policies:
- typed_extension_config:
name: custom_lb
typed_config:
"@type": type.googleapis.com/google.protobuf.Struct
load_assignment:
endpoints:
- lb_endpoints:
Expand Down Expand Up @@ -2392,9 +2391,6 @@ TEST_F(StaticClusterImplTest, LoadBalancingPolicyWithLbPolicy) {

// lb_policy is set to LOAD_BALANCING_POLICY_CONFIG and has no load_balancing_policy.
TEST_F(StaticClusterImplTest, LoadBalancingPolicyWithoutConfiguration) {
TestScopedRuntime scoped_runtime;
scoped_runtime.mergeValues({{"envoy.reloadable_features.no_extension_lookup_by_name", "false"}});

const std::string yaml = R"EOF(
name: staticcluster
connect_timeout: 0.25s
Expand Down Expand Up @@ -2426,9 +2422,6 @@ TEST_F(StaticClusterImplTest, LoadBalancingPolicyWithoutConfiguration) {

// load_balancing_policy is set and common_lb_config is set.
TEST_F(StaticClusterImplTest, LoadBalancingPolicyWithCommonLbConfig) {
TestScopedRuntime scoped_runtime;
scoped_runtime.mergeValues({{"envoy.reloadable_features.no_extension_lookup_by_name", "false"}});

const std::string yaml = R"EOF(
name: staticcluster
connect_timeout: 0.25s
Expand All @@ -2437,6 +2430,8 @@ TEST_F(StaticClusterImplTest, LoadBalancingPolicyWithCommonLbConfig) {
policies:
- typed_extension_config:
name: custom_lb
typed_config:
"@type": type.googleapis.com/google.protobuf.Struct
common_lb_config:
update_merge_window: 1s
load_assignment:
Expand Down Expand Up @@ -2464,9 +2459,6 @@ TEST_F(StaticClusterImplTest, LoadBalancingPolicyWithCommonLbConfig) {

// load_balancing_policy is set and some fields in common_lb_config are set.
TEST_F(StaticClusterImplTest, LoadBalancingPolicyWithCommonLbConfigAndSpecificFields) {
TestScopedRuntime scoped_runtime;
scoped_runtime.mergeValues({{"envoy.reloadable_features.no_extension_lookup_by_name", "false"}});

const std::string yaml = R"EOF(
name: staticcluster
connect_timeout: 0.25s
Expand All @@ -2475,6 +2467,8 @@ TEST_F(StaticClusterImplTest, LoadBalancingPolicyWithCommonLbConfigAndSpecificFi
policies:
- typed_extension_config:
name: custom_lb
typed_config:
"@type": type.googleapis.com/google.protobuf.Struct
common_lb_config:
locality_weighted_lb_config: {}
load_assignment:
Expand Down Expand Up @@ -2506,9 +2500,6 @@ TEST_F(StaticClusterImplTest, LoadBalancingPolicyWithCommonLbConfigAndSpecificFi

// load_balancing_policy is set and lb_subset_config is set.
TEST_F(StaticClusterImplTest, LoadBalancingPolicyWithLbSubsetConfig) {
TestScopedRuntime scoped_runtime;
scoped_runtime.mergeValues({{"envoy.reloadable_features.no_extension_lookup_by_name", "false"}});

const std::string yaml = R"EOF(
name: staticcluster
connect_timeout: 0.25s
Expand All @@ -2517,6 +2508,8 @@ TEST_F(StaticClusterImplTest, LoadBalancingPolicyWithLbSubsetConfig) {
policies:
- typed_extension_config:
name: custom_lb
typed_config:
"@type": type.googleapis.com/google.protobuf.Struct
lb_subset_config:
fallback_policy: ANY_ENDPOINT
subset_selectors:
Expand Down Expand Up @@ -2590,9 +2583,6 @@ TEST_F(StaticClusterImplTest, LbPolicyConfigThrowsExceptionIfNoLbPoliciesFound)
// load_balancing_policy should also be used when lb_policy is set to something else besides
// LOAD_BALANCING_POLICY_CONFIG.
TEST_F(StaticClusterImplTest, LoadBalancingPolicyWithOtherLbPolicy) {
TestScopedRuntime scoped_runtime;
scoped_runtime.mergeValues({{"envoy.reloadable_features.no_extension_lookup_by_name", "false"}});

const std::string yaml = R"EOF(
name: staticcluster
connect_timeout: 0.25s
Expand All @@ -2602,6 +2592,8 @@ TEST_F(StaticClusterImplTest, LoadBalancingPolicyWithOtherLbPolicy) {
policies:
- typed_extension_config:
name: custom_lb
typed_config:
"@type": type.googleapis.com/google.protobuf.Struct
load_assignment:
endpoints:
- lb_endpoints:
Expand Down Expand Up @@ -2632,9 +2624,6 @@ TEST_F(StaticClusterImplTest, LoadBalancingPolicyWithOtherLbPolicy) {

// load_balancing_policy should also be used when lb_policy is omitted.
TEST_F(StaticClusterImplTest, LoadBalancingPolicyWithoutLbPolicy) {
TestScopedRuntime scoped_runtime;
scoped_runtime.mergeValues({{"envoy.reloadable_features.no_extension_lookup_by_name", "false"}});

const std::string yaml = R"EOF(
name: staticcluster
connect_timeout: 0.25s
Expand All @@ -2643,6 +2632,8 @@ TEST_F(StaticClusterImplTest, LoadBalancingPolicyWithoutLbPolicy) {
policies:
- typed_extension_config:
name: custom_lb
typed_config:
"@type": type.googleapis.com/google.protobuf.Struct
load_assignment:
endpoints:
- lb_endpoints:
Expand Down
2 changes: 1 addition & 1 deletion test/config/utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ std::string ConfigHelper::testInspectorFilter() {
return R"EOF(
name: "envoy.filters.listener.test"
typed_config:
"@type": type.googleapis.com/google.protobuf.Struct
"@type": type.googleapis.com/test.integration.filters.TestInspectorFilterConfig
)EOF";
}

Expand Down
1 change: 1 addition & 0 deletions test/extensions/access_loggers/grpc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ envoy_extension_cc_test(
"@envoy_api//envoy/config/bootstrap/v3:pkg_cc_proto",
"@envoy_api//envoy/config/core/v3:pkg_cc_proto",
"@envoy_api//envoy/extensions/access_loggers/grpc/v3:pkg_cc_proto",
"@envoy_api//envoy/extensions/filters/network/echo/v3:pkg_cc_proto",
"@envoy_api//envoy/extensions/filters/network/rbac/v3:pkg_cc_proto",
"@envoy_api//envoy/extensions/filters/network/tcp_proxy/v3:pkg_cc_proto",
"@envoy_api//envoy/service/accesslog/v3:pkg_cc_proto",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "envoy/config/bootstrap/v3/bootstrap.pb.h"
#include "envoy/config/core/v3/address.pb.h"
#include "envoy/extensions/access_loggers/grpc/v3/als.pb.h"
#include "envoy/extensions/filters/network/echo/v3/echo.pb.h"
#include "envoy/extensions/filters/network/echo/v3/echo.pb.validate.h"
#include "envoy/extensions/filters/network/rbac/v3/rbac.pb.h"
#include "envoy/extensions/filters/network/rbac/v3/rbac.pb.validate.h"
#include "envoy/extensions/filters/network/tcp_proxy/v3/tcp_proxy.pb.h"
Expand Down Expand Up @@ -125,8 +127,9 @@ class TcpGrpcAccessLogIntegrationTest : public Grpc::GrpcClientIntegrationParamT
auto* alpn = filter_chain->mutable_filter_chain_match()->add_application_protocols();
*alpn = "envoyalpn";
auto* filter = filter_chain->mutable_filters(0);
envoy::extensions::filters::network::echo::v3::Echo echo;
filter->set_name("envoy.filters.network.echo");
filter->clear_typed_config();
filter->mutable_typed_config()->PackFrom(echo);
});
if (ssl_terminate) {
config_helper_.addSslConfig();
Expand Down
1 change: 0 additions & 1 deletion test/extensions/clusters/eds/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ envoy_cc_test(
"//test/mocks/ssl:ssl_mocks",
"//test/mocks/upstream:cluster_manager_mocks",
"//test/mocks/upstream:health_checker_mocks",
"//test/test_common:test_runtime_lib",
"//test/test_common:utility_lib",
"@envoy_api//envoy/config/cluster/v3:pkg_cc_proto",
"@envoy_api//envoy/config/core/v3:pkg_cc_proto",
Expand Down
6 changes: 2 additions & 4 deletions test/extensions/clusters/eds/eds_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "test/mocks/ssl/mocks.h"
#include "test/mocks/upstream/cluster_manager.h"
#include "test/mocks/upstream/health_checker.h"
#include "test/test_common/test_runtime.h"
#include "test/test_common/utility.h"

#include "gmock/gmock.h"
Expand Down Expand Up @@ -1781,9 +1780,6 @@ TEST_F(EdsLocalityWeightsTest, WeightsPresentWithLocalityWeightedConfig) {
// Validate that onConfigUpdate() propagates locality weights to the host set when the cluster uses
// load balancing policy extensions.
TEST_F(EdsLocalityWeightsTest, WeightsPresentWithLoadBalancingPolicyConfig) {
TestScopedRuntime scoped_runtime;
scoped_runtime.mergeValues({{"envoy.reloadable_features.no_extension_lookup_by_name", "false"}});

// envoy.load_balancers.custom_lb is registered by linking in
// //test/integration/load_balancers:custom_lb_policy.
expectLocalityWeightsPresentForClusterConfig(R"EOF(
Expand All @@ -1795,6 +1791,8 @@ TEST_F(EdsLocalityWeightsTest, WeightsPresentWithLoadBalancingPolicyConfig) {
policies:
- typed_extension_config:
name: envoy.load_balancers.custom_lb
typed_config:
"@type": type.googleapis.com/test.integration.custom_lb.CustomLbConfig
eds_cluster_config:
service_name: fare
eds_config:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class AwsMetadataIntegrationTestBase : public ::testing::Test, public BaseIntegr
numerator: 100
denominator: HUNDRED
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
codec_type: HTTP1
route_config:
virtual_hosts:
Expand Down
1 change: 0 additions & 1 deletion test/extensions/common/dynamic_forward_proxy/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ envoy_cc_test(
"//test/mocks/thread_local:thread_local_mocks",
"//test/test_common:registry_lib",
"//test/test_common:simulated_time_system_lib",
"//test/test_common:test_runtime_lib",
"@envoy_api//envoy/config/cluster/v3:pkg_cc_proto",
"@envoy_api//envoy/config/core/v3:pkg_cc_proto",
"@envoy_api//envoy/extensions/common/dynamic_forward_proxy/v3:pkg_cc_proto",
Expand Down
Loading

0 comments on commit 878d26f

Please sign in to comment.