Skip to content

Commit

Permalink
tests: disable more extension lookup by name
Browse files Browse the repository at this point in the history
Change-Id: I1e585541b28e2ebca54ec6135616cdd2ff081d2a
Signed-off-by: Kuat Yessenov <kuat@google.com>
  • Loading branch information
kyessenov committed May 9, 2024
1 parent 7b7ab06 commit 14d7701
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 26 deletions.
7 changes: 4 additions & 3 deletions test/common/router/config_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9260,9 +9260,6 @@ TEST_F(RouteConfigurationV2, ConnectTerminate) {
// Verifies that we're creating a new instance of the retry plugins on each call instead of
// always returning the same one.
TEST_F(RouteConfigurationV2, RetryPluginsAreNotReused) {
TestScopedRuntime scoped_runtime;
scoped_runtime.mergeValues({{"envoy.reloadable_features.no_extension_lookup_by_name", "false"}});

const std::string yaml = R"EOF(
virtual_hosts:
- name: regex
Expand All @@ -9276,8 +9273,12 @@ TEST_F(RouteConfigurationV2, RetryPluginsAreNotReused) {
retry_policy:
retry_host_predicate:
- name: envoy.test_host_predicate
typed_config:
"@type": type.googleapis.com/google.protobuf.Struct
retry_priority:
name: envoy.test_retry_priority
typed_config:
"@type": type.googleapis.com/google.protobuf.Struct
)EOF";

Upstream::MockRetryPriority priority{{}, {}};
Expand Down
1 change: 0 additions & 1 deletion test/common/tls/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ envoy_cc_test(
"//test/mocks/ssl:ssl_mocks",
"//test/mocks/stats:stats_mocks",
"//test/test_common:registry_lib",
"//test/test_common:test_runtime_lib",
"@envoy_api//envoy/extensions/transport_sockets/tls/v3:pkg_cc_proto",
],
)
Expand Down
20 changes: 11 additions & 9 deletions test/common/tls/handshaker_factory_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "test/mocks/network/connection.h"
#include "test/mocks/server/transport_socket_factory_context.h"
#include "test/test_common/registry.h"
#include "test/test_common/test_runtime.h"

#include "gmock/gmock.h"
#include "gtest/gtest.h"
Expand Down Expand Up @@ -64,6 +63,10 @@ class HandshakerFactoryImplForTest

std::string name() const override { return kFactoryName; }

ProtobufTypes::MessagePtr createEmptyConfigProto() override {
return ProtobufTypes::MessagePtr{new ProtobufWkt::StringValue()};
}

Ssl::HandshakerFactoryCb
createHandshakerCb(const Protobuf::Message& message, Ssl::HandshakerFactoryContext& context,
ProtobufMessage::ValidationVisitor& validation_visitor) override {
Expand Down Expand Up @@ -95,12 +98,11 @@ class HandshakerFactoryTest : public testing::Test {
: context_manager_(std::make_unique<Extensions::TransportSockets::Tls::ContextManagerImpl>(
server_factory_context_)),
registered_factory_(handshaker_factory_) {
scoped_runtime_.mergeValues(
{{"envoy.reloadable_features.no_extension_lookup_by_name", "false"}});
// UpstreamTlsContext proto expects to use the newly-registered handshaker.
envoy::config::core::v3::TypedExtensionConfig* custom_handshaker =
tls_context_.mutable_common_tls_context()->mutable_custom_handshaker();
custom_handshaker->set_name(HandshakerFactoryImplForTest::kFactoryName);
custom_handshaker->mutable_typed_config()->PackFrom(ProtobufWkt::StringValue());
}

// Helper for downcasting a socket to a test socket so we can examine its
Expand All @@ -117,7 +119,6 @@ class HandshakerFactoryTest : public testing::Test {
HandshakerFactoryImplForTest handshaker_factory_;
Registry::InjectFactory<Ssl::HandshakerFactory> registered_factory_;
envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext tls_context_;
TestScopedRuntime scoped_runtime_;
};

TEST_F(HandshakerFactoryTest, SetMockFunctionCb) {
Expand Down Expand Up @@ -217,6 +218,10 @@ class HandshakerFactoryImplForDownstreamTest

std::string name() const override { return kFactoryName; }

ProtobufTypes::MessagePtr createEmptyConfigProto() override {
return ProtobufTypes::MessagePtr{new ProtobufWkt::BoolValue()};
}

Ssl::HandshakerFactoryCb
createHandshakerCb(const Protobuf::Message& message, Ssl::HandshakerFactoryContext& context,
ProtobufMessage::ValidationVisitor& validation_visitor) override {
Expand Down Expand Up @@ -250,10 +255,7 @@ class HandshakerFactoryDownstreamTest : public testing::Test {
protected:
HandshakerFactoryDownstreamTest()
: context_manager_(std::make_unique<Extensions::TransportSockets::Tls::ContextManagerImpl>(
server_factory_context_)) {
scoped_runtime_.mergeValues(
{{"envoy.reloadable_features.no_extension_lookup_by_name", "false"}});
}
server_factory_context_)) {}

// Helper for downcasting a socket to a test socket so we can examine its
// SSL_CTX.
Expand All @@ -267,7 +269,6 @@ class HandshakerFactoryDownstreamTest : public testing::Test {
Stats::IsolatedStoreImpl stats_store_;
std::unique_ptr<Extensions::TransportSockets::Tls::ContextManagerImpl> context_manager_;
envoy::extensions::transport_sockets::tls::v3::DownstreamTlsContext tls_context_;
TestScopedRuntime scoped_runtime_;
Ssl::HandshakerCapabilities capabilities_;
};

Expand All @@ -283,6 +284,7 @@ TEST_F(HandshakerFactoryDownstreamTest, ServerHandshakerProvidesCertificates) {
envoy::config::core::v3::TypedExtensionConfig* custom_handshaker =
tls_context_.mutable_common_tls_context()->mutable_custom_handshaker();
custom_handshaker->set_name(HandshakerFactoryImplForDownstreamTest::kFactoryName);
custom_handshaker->mutable_typed_config()->PackFrom(ProtobufWkt::BoolValue());

CustomProcessObjectForTest custom_process_object_for_test(
/*cb=*/[](SSL_CTX* ssl_ctx) { SSL_CTX_set_options(ssl_ctx, SSL_OP_NO_TLSv1); });
Expand Down
1 change: 0 additions & 1 deletion test/extensions/filters/http/geoip/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ envoy_extension_cc_test(
"//test/common/http:common_lib",
"//test/mocks/http:http_mocks",
"//test/test_common:registry_lib",
"//test/test_common:test_runtime_lib",
"@envoy_api//envoy/extensions/filters/http/geoip/v3:pkg_cc_proto",
],
)
Expand Down
14 changes: 10 additions & 4 deletions test/extensions/filters/http/geoip/geoip_filter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "test/mocks/http/mocks.h"
#include "test/mocks/stats/mocks.h"
#include "test/test_common/registry.h"
#include "test/test_common/test_runtime.h"
#include "test/test_common/utility.h"

#include "gmock/gmock.h"
Expand Down Expand Up @@ -58,9 +57,6 @@ class GeoipFilterTest : public testing::Test {
}

void initializeProviderFactory() {
TestScopedRuntime scoped_runtime;
scoped_runtime.mergeValues(
{{"envoy.reloadable_features.no_extension_lookup_by_name", "false"}});
Registry::InjectFactory<Geolocation::GeoipProviderFactory> registered(*dummy_factory_);
}

Expand Down Expand Up @@ -120,6 +116,8 @@ TEST_F(GeoipFilterTest, UseXffSuccessfulLookup) {
xff_num_trusted_hops: 1
provider:
name: "envoy.geoip_providers.dummy"
typed_config:
"@type": type.googleapis.com/test.extensions.filters.http.geoip.DummyProvider
)EOF";
initializeFilter(external_request_yaml);
Http::TestRequestHeaderMapImpl request_headers;
Expand Down Expand Up @@ -150,6 +148,8 @@ TEST_F(GeoipFilterTest, GeoHeadersOverridenForIncomingRequest) {
const std::string external_request_yaml = R"EOF(
provider:
name: "envoy.geoip_providers.dummy"
typed_config:
"@type": type.googleapis.com/test.extensions.filters.http.geoip.DummyProvider
)EOF";
initializeFilter(external_request_yaml);
Http::TestRequestHeaderMapImpl request_headers;
Expand Down Expand Up @@ -184,6 +184,8 @@ TEST_F(GeoipFilterTest, AllHeadersPropagatedCorrectly) {
const std::string external_request_yaml = R"EOF(
provider:
name: "envoy.geoip_providers.dummy"
typed_config:
"@type": type.googleapis.com/test.extensions.filters.http.geoip.DummyProvider
)EOF";
initializeFilter(external_request_yaml);
Http::TestRequestHeaderMapImpl request_headers;
Expand Down Expand Up @@ -239,6 +241,8 @@ TEST_F(GeoipFilterTest, GeoHeaderNotAppendedOnEmptyLookup) {
const std::string external_request_yaml = R"EOF(
provider:
name: "envoy.geoip_providers.dummy"
typed_config:
"@type": type.googleapis.com/test.extensions.filters.http.geoip.DummyProvider
)EOF";
initializeFilter(external_request_yaml);
Http::TestRequestHeaderMapImpl request_headers;
Expand Down Expand Up @@ -268,6 +272,8 @@ TEST_F(GeoipFilterTest, NoCrashIfFilterDestroyedBeforeCallbackCalled) {
const std::string external_request_yaml = R"EOF(
provider:
name: "envoy.geoip_providers.dummy"
typed_config:
"@type": type.googleapis.com/test.extensions.filters.http.geoip.DummyProvider
)EOF";
initializeFilter(external_request_yaml);
Http::TestRequestHeaderMapImpl request_headers;
Expand Down
1 change: 0 additions & 1 deletion test/server/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,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",
"//test/test_common:utility_lib",
"@envoy_api//envoy/config/overload/v3:pkg_cc_proto",
],
Expand Down
53 changes: 46 additions & 7 deletions test/server/overload_manager_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "test/mocks/thread_local/mocks.h"
#include "test/test_common/registry.h"
#include "test/test_common/simulated_time_system.h"
#include "test/test_common/test_runtime.h"
#include "test/test_common/utility.h"

#include "gmock/gmock.h"
Expand Down Expand Up @@ -207,10 +206,7 @@ class OverloadManagerImplTest : public testing::Test {
factory5_("envoy.resource_monitors.global_downstream_max_connections"),
register_factory1_(factory1_), register_factory2_(factory2_), register_factory3_(factory3_),
register_factory4_(factory4_), register_factory5_(factory5_),
api_(Api::createApiForTest(stats_)) {
scoped_runtime_.mergeValues(
{{"envoy.reloadable_features.no_extension_lookup_by_name", "false"}});
}
api_(Api::createApiForTest(stats_)) {}

void setDispatcherExpectation() {
timer_ = new NiceMock<Event::MockTimer>();
Expand All @@ -236,7 +232,7 @@ class OverloadManagerImplTest : public testing::Test {
FakeResourceMonitorFactory<Envoy::ProtobufWkt::Timestamp> factory2_;
FakeResourceMonitorFactory<Envoy::ProtobufWkt::Duration> factory3_;
FakeResourceMonitorFactory<Envoy::ProtobufWkt::StringValue> factory4_;
FakeProactiveResourceMonitorFactory<Envoy::ProtobufWkt::Timestamp> factory5_;
FakeProactiveResourceMonitorFactory<Envoy::ProtobufWkt::BoolValue> factory5_;
Registry::InjectFactory<Configuration::ResourceMonitorFactory> register_factory1_;
Registry::InjectFactory<Configuration::ResourceMonitorFactory> register_factory2_;
Registry::InjectFactory<Configuration::ResourceMonitorFactory> register_factory3_;
Expand All @@ -250,17 +246,24 @@ class OverloadManagerImplTest : public testing::Test {
NiceMock<ProtobufMessage::MockValidationVisitor> validation_visitor_;
Api::ApiPtr api_;
Server::MockOptions options_;
TestScopedRuntime scoped_runtime_;
};

constexpr char kRegularStateConfig[] = R"YAML(
refresh_interval:
seconds: 1
resource_monitors:
- name: envoy.resource_monitors.fake_resource1
typed_config:
"@type": type.googleapis.com/google.protobuf.Struct
- name: envoy.resource_monitors.fake_resource2
typed_config:
"@type": type.googleapis.com/google.protobuf.Timestamp
- name: envoy.resource_monitors.fake_resource3
typed_config:
"@type": type.googleapis.com/google.protobuf.Duration
- name: envoy.resource_monitors.fake_resource4
typed_config:
"@type": type.googleapis.com/google.protobuf.StringValue
actions:
- name: envoy.overload_actions.stop_accepting_requests
triggers:
Expand All @@ -285,7 +288,11 @@ constexpr char proactiveResourceConfig[] = R"YAML(
seconds: 1
resource_monitors:
- name: envoy.resource_monitors.fake_resource1
typed_config:
"@type": type.googleapis.com/google.protobuf.Struct
- name: envoy.resource_monitors.global_downstream_max_connections
typed_config:
"@type": type.googleapis.com/google.protobuf.BoolValue
actions:
- name: envoy.overload_actions.shrink_heap
triggers:
Expand Down Expand Up @@ -575,6 +582,8 @@ constexpr char kReducedTimeoutsConfig[] = R"YAML(
seconds: 1
resource_monitors:
- name: envoy.resource_monitors.fake_resource1
typed_config:
"@type": type.googleapis.com/google.protobuf.Struct
actions:
- name: envoy.overload_actions.reduce_timeouts
typed_config:
Expand Down Expand Up @@ -645,7 +654,11 @@ TEST_F(OverloadManagerImplTest, DuplicateResourceMonitor) {
const std::string config = R"EOF(
resource_monitors:
- name: "envoy.resource_monitors.fake_resource1"
typed_config:
"@type": type.googleapis.com/google.protobuf.Struct
- name: "envoy.resource_monitors.fake_resource1"
typed_config:
"@type": type.googleapis.com/google.protobuf.Struct
)EOF";

EXPECT_THROW_WITH_REGEX(createOverloadManager(config), EnvoyException,
Expand All @@ -656,7 +669,11 @@ TEST_F(OverloadManagerImplTest, DuplicateProactiveResourceMonitor) {
const std::string config = R"EOF(
resource_monitors:
- name: "envoy.resource_monitors.global_downstream_max_connections"
typed_config:
"@type": type.googleapis.com/google.protobuf.BoolValue
- name: "envoy.resource_monitors.global_downstream_max_connections"
typed_config:
"@type": type.googleapis.com/google.protobuf.BoolValue
)EOF";

EXPECT_THROW_WITH_REGEX(createOverloadManager(config), EnvoyException,
Expand Down Expand Up @@ -725,6 +742,8 @@ TEST_F(OverloadManagerImplTest, ScaledTriggerSaturationLessThanScalingThreshold)
const std::string config = R"EOF(
resource_monitors:
- name: "envoy.resource_monitors.fake_resource1"
typed_config:
"@type": type.googleapis.com/google.protobuf.Struct
actions:
- name: "envoy.overload_actions.shrink_heap"
triggers:
Expand All @@ -743,6 +762,8 @@ TEST_F(OverloadManagerImplTest, ScaledTriggerThresholdsEqual) {
const std::string config = R"EOF(
resource_monitors:
- name: "envoy.resource_monitors.fake_resource1"
typed_config:
"@type": type.googleapis.com/google.protobuf.Struct
actions:
- name: "envoy.overload_actions.shrink_heap"
triggers:
Expand All @@ -760,6 +781,8 @@ TEST_F(OverloadManagerImplTest, UnknownActionShouldError) {
const std::string config = R"EOF(
resource_monitors:
- name: "envoy.resource_monitors.fake_resource1"
typed_config:
"@type": type.googleapis.com/google.protobuf.Struct
actions:
- name: "envoy.overload_actions.not_a_valid_action"
triggers:
Expand Down Expand Up @@ -790,6 +813,8 @@ TEST_F(OverloadManagerImplTest, DuplicateTrigger) {
const std::string config = R"EOF(
resource_monitors:
- name: "envoy.resource_monitors.fake_resource1"
typed_config:
"@type": type.googleapis.com/google.protobuf.Struct
actions:
- name: "envoy.overload_actions.shrink_heap"
triggers:
Expand Down Expand Up @@ -927,6 +952,8 @@ TEST_F(OverloadManagerLoadShedPointImplTest, ThrowsIfDuplicateTrigger) {
const std::string config = R"EOF(
resource_monitors:
- name: envoy.resource_monitors.fake_resource1
typed_config:
"@type": type.googleapis.com/google.protobuf.Struct
loadshed_points:
- name: "envoy.load_shed_point.dummy_point"
triggers:
Expand All @@ -947,6 +974,8 @@ TEST_F(OverloadManagerLoadShedPointImplTest, ReturnsNullIfNonExistentLoadShedPoi
const std::string config = R"EOF(
resource_monitors:
- name: envoy.resource_monitors.fake_resource1
typed_config:
"@type": type.googleapis.com/google.protobuf.Struct
loadshed_points:
- name: "test_point"
triggers:
Expand All @@ -966,6 +995,8 @@ TEST_F(OverloadManagerLoadShedPointImplTest, PointUsesTriggerToDetermineWhetherT
const std::string config = R"EOF(
resource_monitors:
- name: envoy.resource_monitors.fake_resource1
typed_config:
"@type": type.googleapis.com/google.protobuf.Struct
loadshed_points:
- name: "test_point"
triggers:
Expand Down Expand Up @@ -1007,6 +1038,8 @@ TEST_F(OverloadManagerLoadShedPointImplTest, TriggerLoadShedCunterTest) {
const std::string config = R"EOF(
resource_monitors:
- name: envoy.resource_monitors.fake_resource1
typed_config:
"@type": type.googleapis.com/google.protobuf.Struct
loadshed_points:
- name: "test_point"
triggers:
Expand Down Expand Up @@ -1051,7 +1084,11 @@ TEST_F(OverloadManagerLoadShedPointImplTest, PointWithMultipleTriggers) {
const std::string config = R"EOF(
resource_monitors:
- name: envoy.resource_monitors.fake_resource1
typed_config:
"@type": type.googleapis.com/google.protobuf.Struct
- name: envoy.resource_monitors.fake_resource2
typed_config:
"@type": type.googleapis.com/google.protobuf.Timestamp
loadshed_points:
- name: "test_point"
triggers:
Expand Down Expand Up @@ -1106,6 +1143,8 @@ TEST_F(OverloadManagerLoadShedPointImplTest, LoadShedPointShouldUseCurrentReadin
const std::string config = R"EOF(
resource_monitors:
- name: envoy.resource_monitors.fake_resource1
typed_config:
"@type": type.googleapis.com/google.protobuf.Struct
loadshed_points:
- name: "test_point"
triggers:
Expand Down

0 comments on commit 14d7701

Please sign in to comment.