From 361480d379e4a2d82026b833115724712c86c4eb Mon Sep 17 00:00:00 2001 From: Alyssa Wilk Date: Wed, 23 Nov 2022 09:48:39 -0500 Subject: [PATCH] test: not validating all protos in every test Signed-off-by: Alyssa Wilk --- source/exe/process_wide.cc | 6 ++++-- source/exe/process_wide.h | 2 +- test/integration/BUILD | 1 + test/integration/base_integration_test.cc | 2 ++ test/test_runner.cc | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/source/exe/process_wide.cc b/source/exe/process_wide.cc index 9e93e9c48f4b4..212f80c53c15a 100644 --- a/source/exe/process_wide.cc +++ b/source/exe/process_wide.cc @@ -21,7 +21,7 @@ struct InitData { InitData& processWideInitData() { MUTABLE_CONSTRUCT_ON_FIRST_USE(InitData); }; } // namespace -ProcessWide::ProcessWide() { +ProcessWide::ProcessWide(bool validate_proto_descriptors) { // Note that the following lock has the dual use of making sure that initialization is complete // before a second caller can enter and leave this function. auto& init_data = processWideInitData(); @@ -31,7 +31,9 @@ ProcessWide::ProcessWide() { // TODO(mattklein123): Audit the following as not all of these have to be re-initialized in the // edge case where something does init/destroy/init/destroy. Event::Libevent::Global::initialize(); - Envoy::Server::validateProtoDescriptors(); + if (validate_proto_descriptors) { + Envoy::Server::validateProtoDescriptors(); + } Http::Http2::initializeNghttp2Logging(); // We do not initialize Google gRPC here -- we instead instantiate diff --git a/source/exe/process_wide.h b/source/exe/process_wide.h index 375faad54ee06..2d0147d063bef 100644 --- a/source/exe/process_wide.h +++ b/source/exe/process_wide.h @@ -8,7 +8,7 @@ namespace Envoy { // e.g. c-ares. There should only ever be a single instance of this. class ProcessWide { public: - ProcessWide(); + ProcessWide(bool validate_proto_descriptors = true); ~ProcessWide(); }; diff --git a/test/integration/BUILD b/test/integration/BUILD index 6e058a241e81a..dd5bb88d16aee 100644 --- a/test/integration/BUILD +++ b/test/integration/BUILD @@ -892,6 +892,7 @@ envoy_cc_test_library( "base_integration_test.h", ], deps = [ + "//source/server:proto_descriptors_lib", "//source/extensions/request_id/uuid:config", ":autonomous_upstream_lib", ":fake_upstream_lib", diff --git a/test/integration/base_integration_test.cc b/test/integration/base_integration_test.cc index b805eb2cf69c8..df479f1576219 100644 --- a/test/integration/base_integration_test.cc +++ b/test/integration/base_integration_test.cc @@ -20,6 +20,7 @@ #include "source/common/network/utility.h" #include "source/extensions/transport_sockets/tls/context_config_impl.h" #include "source/extensions/transport_sockets/tls/ssl_socket.h" +#include "source/server/proto_descriptors.h" #include "test/integration/utility.h" #include "test/test_common/environment.h" @@ -47,6 +48,7 @@ BaseIntegrationTest::BaseIntegrationTest(const InstanceConstSharedPtrFn& upstrea version_(version), upstream_address_fn_(upstream_address_fn), config_helper_(version, *api_, config), default_log_level_(TestEnvironment::getOptions().logLevel()) { + Envoy::Server::validateProtoDescriptors(); // This is a hack, but there are situations where we disconnect fake upstream connections and // then we expect the server connection pool to get the disconnect before the next test starts. // This does not always happen. This pause should allow the server to pick up the disconnect diff --git a/test/test_runner.cc b/test/test_runner.cc index c6b4dbc359d2d..ed1ca1b845ef1 100644 --- a/test/test_runner.cc +++ b/test/test_runner.cc @@ -70,7 +70,7 @@ int TestRunner::RunTests(int argc, char** argv) { ::testing::InitGoogleMock(&argc, argv); // We hold on to process_wide to provide RAII cleanup of process-wide // state. - ProcessWide process_wide; + ProcessWide process_wide(false); // Add a test-listener so we can call a hook where we can do a quiescence // check after each method. See // https://github.com/google/googletest/blob/master/googletest/docs/advanced.md