diff --git a/benchmarks/dynamic_test/test_cds_churn_with_traffic.py b/benchmarks/dynamic_test/test_cds_churn_with_traffic.py index 3776a0a8f..68f606edf 100644 --- a/benchmarks/dynamic_test/test_cds_churn_with_traffic.py +++ b/benchmarks/dynamic_test/test_cds_churn_with_traffic.py @@ -100,6 +100,7 @@ def _config_generation_single_cluster(temp_dir: str, endpoints: list[utility.Soc @pytest.mark.parametrize('dynamic_config_generator', [_config_generation_single_cluster]) def test_dynamic_http_single_cluster_traffic(inject_dynamic_envoy_http_proxy_fixture, proxy_config): # noqa + """Dynamic HTTP test on a single cluster.""" _run_benchmark(inject_dynamic_envoy_http_proxy_fixture) diff --git a/benchmarks/dynamic_test/test_eds_churn_with_traffic.py b/benchmarks/dynamic_test/test_eds_churn_with_traffic.py index c7c38d95c..1050906ff 100644 --- a/benchmarks/dynamic_test/test_eds_churn_with_traffic.py +++ b/benchmarks/dynamic_test/test_eds_churn_with_traffic.py @@ -96,4 +96,5 @@ def _config_generation_single_cluster(temp_dir: str, endpoints: list[utility.Soc @pytest.mark.parametrize('dynamic_config_generator', [_config_generation_single_cluster]) def test_dynamic_http_single_cluster_traffic(inject_dynamic_envoy_http_proxy_fixture, proxy_config): # noqa + """Dynamic HTTP test on a single cluster.""" _run_benchmark(inject_dynamic_envoy_http_proxy_fixture) diff --git a/benchmarks/test/test_discovery.py b/benchmarks/test/test_discovery.py index 2cea505d0..11c00f50d 100644 --- a/benchmarks/test/test_discovery.py +++ b/benchmarks/test/test_discovery.py @@ -57,36 +57,42 @@ def _run_benchmark(fixture, utilities.output_benchmark_results(parsed_json, fixture) -# Test via injected Envoy @pytest.mark.parametrize('proxy_config', ["nighthawk/benchmarks/configurations/envoy_proxy.yaml"]) @pytest.mark.parametrize('server_config', ["nighthawk/test/integration/configurations/nighthawk_http_origin.yaml"]) def test_http_h1_small_request_small_reply_via(inject_envoy_http_proxy_fixture, proxy_config): # noqa + """H1 test with small request and reply via injected Envoy.""" _run_benchmark(inject_envoy_http_proxy_fixture) -# via Envoy, 4 workers. global targets: 1000 qps / 4 connections. @pytest.mark.parametrize('proxy_config', ["nighthawk/benchmarks/configurations/envoy_proxy.yaml"]) @pytest.mark.parametrize('server_config', ["nighthawk/test/integration/configurations/nighthawk_http_origin.yaml"]) def test_http_h1_small_request_small_reply_via_multiple_workers(inject_envoy_http_proxy_fixture, proxy_config): # noqa + """H1 test with small request and reply via multiple workers. + + via Envoy, 4 workers. global targets: 1000 qps / 4 connections. + """ _run_benchmark(inject_envoy_http_proxy_fixture, rps=125, concurrency=4) -# Test the origin directly, using a stock fixture @pytest.mark.parametrize('server_config', ["nighthawk/test/integration/configurations/nighthawk_http_origin.yaml"]) def test_http_h1_small_request_small_reply_direct(http_test_server_fixture): # noqa + """H1 test with small request and reply that tests the origin directly, using a stock fixture.""" _run_benchmark(http_test_server_fixture) -# Direct, 4 workers. global targets: 1000 qps / 4 connections. @pytest.mark.parametrize('server_config', ["nighthawk/test/integration/configurations/nighthawk_http_origin.yaml"]) def test_http_h1_small_request_small_reply_direct_multiple_workers( http_test_server_fixture): # noqa + """H1 test with small request and reply that tests the origin directly. + + 4 workers. global targets: 1000 qps / 4 connections. + """ _run_benchmark(http_test_server_fixture, rps=125, concurrency=4) diff --git a/ci/do_ci.sh b/ci/do_ci.sh index a7246f701..b8fb9340c 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -220,8 +220,6 @@ function do_benchmark_with_own_binaries() { } function do_check_format() { - # TODO(1032): Remove this once all files are formatted correctly. - set +eo pipefail echo "check_format..." cd "${SRCDIR}" ./tools/check_format.sh check diff --git a/include/nighthawk/adaptive_load/input_variable_setter.h b/include/nighthawk/adaptive_load/input_variable_setter.h index 2659a624b..aec49dfd5 100644 --- a/include/nighthawk/adaptive_load/input_variable_setter.h +++ b/include/nighthawk/adaptive_load/input_variable_setter.h @@ -1,7 +1,7 @@ -// Interfaces for InputVariableSetter plugins and plugin factories. - #pragma once +// Interfaces for InputVariableSetter plugins and plugin factories. + #include "envoy/common/pure.h" #include "envoy/config/typed_config.h" diff --git a/include/nighthawk/adaptive_load/metrics_plugin.h b/include/nighthawk/adaptive_load/metrics_plugin.h index a4599ca5e..4e0ba43ed 100644 --- a/include/nighthawk/adaptive_load/metrics_plugin.h +++ b/include/nighthawk/adaptive_load/metrics_plugin.h @@ -1,7 +1,7 @@ -// Interfaces for MetricsPlugin plugins and plugin factories. - #pragma once +// Interfaces for MetricsPlugin plugins and plugin factories. + #include "envoy/common/pure.h" #include "envoy/config/typed_config.h" @@ -20,10 +20,10 @@ struct ReportingPeriod { // start time of the latest (current) iteration of Nighthawk test in the adaptive stage. See // https://github.com/envoyproxy/nighthawk/blob/main/docs/root/adaptive_load_controller.md#the-adaptive-load-controller // for more information on adaptive load testing. - google::protobuf::Timestamp start_time; + Envoy::ProtobufWkt::Timestamp start_time; // The duration of the time where nighthawk is sending the intended load in the adaptive stage. - google::protobuf::Duration duration; + Envoy::ProtobufWkt::Duration duration; }; /** diff --git a/include/nighthawk/adaptive_load/scoring_function.h b/include/nighthawk/adaptive_load/scoring_function.h index 591c4919c..da9f18931 100644 --- a/include/nighthawk/adaptive_load/scoring_function.h +++ b/include/nighthawk/adaptive_load/scoring_function.h @@ -1,7 +1,7 @@ -// Interfaces for ScoringFunction plugins and plugin factories. - #pragma once +// Interfaces for ScoringFunction plugins and plugin factories. + #include "envoy/common/pure.h" #include "envoy/config/typed_config.h" diff --git a/include/nighthawk/adaptive_load/step_controller.h b/include/nighthawk/adaptive_load/step_controller.h index 7ccc61261..1d33b531e 100644 --- a/include/nighthawk/adaptive_load/step_controller.h +++ b/include/nighthawk/adaptive_load/step_controller.h @@ -1,7 +1,7 @@ -// Interfaces for StepController plugins and plugin factories. - #pragma once +// Interfaces for StepController plugins and plugin factories. + #include "envoy/common/pure.h" #include "envoy/config/typed_config.h" diff --git a/include/nighthawk/common/operation_callback.h b/include/nighthawk/common/operation_callback.h index fc564597e..945b570b6 100644 --- a/include/nighthawk/common/operation_callback.h +++ b/include/nighthawk/common/operation_callback.h @@ -1,3 +1,5 @@ +#pragma once + #include namespace Nighthawk { @@ -9,4 +11,4 @@ namespace Nighthawk { * a success, and is meaningful only when done equals true. */ using OperationCallback = std::function; -} // namespace Nighthawk \ No newline at end of file +} // namespace Nighthawk diff --git a/include/nighthawk/common/phase.h b/include/nighthawk/common/phase.h index bcbed7cf6..64ad31b03 100644 --- a/include/nighthawk/common/phase.h +++ b/include/nighthawk/common/phase.h @@ -1,4 +1,3 @@ - #pragma once #include @@ -48,4 +47,4 @@ class Phase { using PhasePtr = std::unique_ptr; -} // namespace Nighthawk \ No newline at end of file +} // namespace Nighthawk diff --git a/include/nighthawk/common/sequencer.h b/include/nighthawk/common/sequencer.h index 56e177032..4f1c05202 100644 --- a/include/nighthawk/common/sequencer.h +++ b/include/nighthawk/common/sequencer.h @@ -1,4 +1,3 @@ - #pragma once #include @@ -59,4 +58,4 @@ class Sequencer { using SequencerPtr = std::unique_ptr; -} // namespace Nighthawk \ No newline at end of file +} // namespace Nighthawk diff --git a/include/nighthawk/sink/sink.h b/include/nighthawk/sink/sink.h index 10eeb6ce2..4813259ba 100644 --- a/include/nighthawk/sink/sink.h +++ b/include/nighthawk/sink/sink.h @@ -1,4 +1,3 @@ - #pragma once #include @@ -44,4 +43,4 @@ class Sink { LoadExecutionResult(absl::string_view execution_id) const PURE; }; -} // namespace Nighthawk \ No newline at end of file +} // namespace Nighthawk diff --git a/source/adaptive_load/adaptive_load_client_main.cc b/source/adaptive_load/adaptive_load_client_main.cc index 63b40f380..edeedc5af 100644 --- a/source/adaptive_load/adaptive_load_client_main.cc +++ b/source/adaptive_load/adaptive_load_client_main.cc @@ -105,8 +105,8 @@ uint32_t AdaptiveLoadClientMain::Run() { if (!spec_textproto.ok()) { throw Nighthawk::NighthawkException("Failed to read spec textproto file \"" + spec_filename_ + "\": " + std::string(spec_textproto.status().message())); - } - + } + nighthawk::adaptive_load::AdaptiveLoadSessionSpec spec; if (!Envoy::Protobuf::TextFormat::ParseFromString(*spec_textproto, &spec)) { throw Nighthawk::NighthawkException("Unable to parse file \"" + spec_filename_ + diff --git a/source/adaptive_load/adaptive_load_controller_impl.h b/source/adaptive_load/adaptive_load_controller_impl.h index 4dc073892..7cd6b1e58 100644 --- a/source/adaptive_load/adaptive_load_controller_impl.h +++ b/source/adaptive_load/adaptive_load_controller_impl.h @@ -1,3 +1,5 @@ +#pragma once + #include "envoy/common/time.h" #include "nighthawk/adaptive_load/adaptive_load_controller.h" diff --git a/source/adaptive_load/config_validator_impl.h b/source/adaptive_load/config_validator_impl.h index 3ee2c8113..94776d600 100644 --- a/source/adaptive_load/config_validator_impl.h +++ b/source/adaptive_load/config_validator_impl.h @@ -1,3 +1,5 @@ +#pragma once + #include "nighthawk/adaptive_load/config_validator.h" namespace Nighthawk { diff --git a/source/adaptive_load/metrics_evaluator_impl.cc b/source/adaptive_load/metrics_evaluator_impl.cc index 71ec07f81..59e1b424c 100644 --- a/source/adaptive_load/metrics_evaluator_impl.cc +++ b/source/adaptive_load/metrics_evaluator_impl.cc @@ -24,8 +24,8 @@ absl::StatusOr GetReportingPeriod(const nighthawk::client::Outp // Find the reporting_period in which all workers are active and thus sending the intended amount // of traffic. ReportingPeriod reporting_period; - google::protobuf::Timestamp max_start_time = output.results(0).execution_start(); - google::protobuf::Timestamp min_end_time = + Envoy::ProtobufWkt::Timestamp max_start_time = output.results(0).execution_start(); + Envoy::ProtobufWkt::Timestamp min_end_time = output.results(0).execution_start() + output.results(0).execution_duration(); for (const auto& result : output.results()) { if (result.execution_start() > max_start_time) { diff --git a/source/adaptive_load/metrics_evaluator_impl.h b/source/adaptive_load/metrics_evaluator_impl.h index 432571730..50b9d00e3 100644 --- a/source/adaptive_load/metrics_evaluator_impl.h +++ b/source/adaptive_load/metrics_evaluator_impl.h @@ -1,3 +1,5 @@ +#pragma once + #include "nighthawk/adaptive_load/metrics_evaluator.h" namespace Nighthawk { diff --git a/source/adaptive_load/scoring_function_impl.h b/source/adaptive_load/scoring_function_impl.h index 94bfe88d9..05f69d9db 100644 --- a/source/adaptive_load/scoring_function_impl.h +++ b/source/adaptive_load/scoring_function_impl.h @@ -1,6 +1,7 @@ -// Implementations of ScoringFunction plugins and corresponding factories. #pragma once +// Implementations of ScoringFunction plugins and corresponding factories. + #include "envoy/registry/registry.h" #include "nighthawk/adaptive_load/scoring_function.h" diff --git a/source/adaptive_load/session_spec_proto_helper_impl.h b/source/adaptive_load/session_spec_proto_helper_impl.h index d26dcd586..8a9b57c88 100644 --- a/source/adaptive_load/session_spec_proto_helper_impl.h +++ b/source/adaptive_load/session_spec_proto_helper_impl.h @@ -1,3 +1,5 @@ +#pragma once + #include "nighthawk/adaptive_load/session_spec_proto_helper.h" namespace Nighthawk { diff --git a/source/client/flush_worker_impl.h b/source/client/flush_worker_impl.h index eb916771f..48b08118a 100644 --- a/source/client/flush_worker_impl.h +++ b/source/client/flush_worker_impl.h @@ -1,6 +1,7 @@ +#pragma once + // Flush worker implementation. Flush worker periodically flushes metrics // snapshot to all configured stats sinks in Nighthawk. -#pragma once #include diff --git a/source/client/process_bootstrap.h b/source/client/process_bootstrap.h index 5592403cd..f83cd03d8 100644 --- a/source/client/process_bootstrap.h +++ b/source/client/process_bootstrap.h @@ -1,3 +1,5 @@ +#pragma once + #include #include "nighthawk/client/options.h" diff --git a/source/client/process_impl.cc b/source/client/process_impl.cc index d790b658b..164b9220a 100644 --- a/source/client/process_impl.cc +++ b/source/client/process_impl.cc @@ -142,9 +142,7 @@ class NighthawkServerInstance : public Envoy::Server::Instance { local_info_(local_info), validation_context_(validation_context), grpc_context_(grpc_context), router_context_(router_context) {} - void run() override { - PANIC("NighthawkServerInstance::run not implemented"); - } + void run() override { PANIC("NighthawkServerInstance::run not implemented"); } Envoy::OptRef admin() override { return admin_; } Envoy::Api::Api& api() override { return api_; } Envoy::Upstream::ClusterManager& clusterManager() override { @@ -313,8 +311,6 @@ class NighthawkServerFactoryContext : public Envoy::Server::Configuration::Serve PANIC("NighthawkServerFactoryContext::initManager not implemented"); }; - - Envoy::Grpc::Context& grpcContext() override { return server_.grpcContext(); }; Envoy::Router::Context& routerContext() override { return server_.routerContext(); }; diff --git a/source/common/nighthawk_service_client_impl.h b/source/common/nighthawk_service_client_impl.h index d8a14eb44..410f2a660 100644 --- a/source/common/nighthawk_service_client_impl.h +++ b/source/common/nighthawk_service_client_impl.h @@ -1,3 +1,5 @@ +#pragma once + #include "nighthawk/common/nighthawk_service_client.h" #include "external/envoy/source/common/common/statusor.h" diff --git a/source/common/phase_impl.h b/source/common/phase_impl.h index 1b40164c3..03731549f 100644 --- a/source/common/phase_impl.h +++ b/source/common/phase_impl.h @@ -1,4 +1,3 @@ - #pragma once #include "envoy/common/time.h" @@ -35,4 +34,4 @@ class PhaseImpl : public Phase, public Envoy::Logger::Loggable #include "envoy/common/time.h" @@ -61,4 +63,4 @@ class StatsCounterAbsoluteThresholdTerminationPredicateImpl : public Termination const TerminationPredicate::Status termination_status_; }; -} // namespace Nighthawk \ No newline at end of file +} // namespace Nighthawk diff --git a/source/request_source/request_options_list_plugin_impl.h b/source/request_source/request_options_list_plugin_impl.h index 8f35fdb42..155e82500 100644 --- a/source/request_source/request_options_list_plugin_impl.h +++ b/source/request_source/request_options_list_plugin_impl.h @@ -1,6 +1,7 @@ -// Implementations of RequestSourceConfigFactories that make a OptionsListRequestSource. #pragma once +// Implementations of RequestSourceConfigFactories that make a OptionsListRequestSource. + #include "envoy/registry/registry.h" #include "nighthawk/request_source/request_source_plugin_config_factory.h" diff --git a/test/adaptive_load/adaptive_load_client_main_test.cc b/test/adaptive_load/adaptive_load_client_main_test.cc index 83914122b..49077f485 100644 --- a/test/adaptive_load/adaptive_load_client_main_test.cc +++ b/test/adaptive_load/adaptive_load_client_main_test.cc @@ -183,8 +183,10 @@ TEST(AdaptiveLoadClientMainTest, FailsIfOpeningOutputFileFails) { NiceMock filesystem; std::string infile_contents = - Envoy::Filesystem::fileSystemForTest().fileReadToEnd(Nighthawk::TestEnvironment::runfilesPath( - std::string("test/adaptive_load/test_data/valid_session_spec.textproto"))).value(); + Envoy::Filesystem::fileSystemForTest() + .fileReadToEnd(Nighthawk::TestEnvironment::runfilesPath( + std::string("test/adaptive_load/test_data/valid_session_spec.textproto"))) + .value(); EXPECT_CALL(filesystem, fileReadToEnd(_)).WillOnce(Return(infile_contents)); auto* mock_file = new NiceMock; @@ -213,8 +215,10 @@ TEST(AdaptiveLoadClientMainTest, FailsIfWritingOutputFileFails) { NiceMock filesystem; std::string infile_contents = - Envoy::Filesystem::fileSystemForTest().fileReadToEnd(Nighthawk::TestEnvironment::runfilesPath( - std::string("test/adaptive_load/test_data/valid_session_spec.textproto"))).value(); + Envoy::Filesystem::fileSystemForTest() + .fileReadToEnd(Nighthawk::TestEnvironment::runfilesPath( + std::string("test/adaptive_load/test_data/valid_session_spec.textproto"))) + .value(); EXPECT_CALL(filesystem, fileReadToEnd(_)).WillOnce(Return(infile_contents)); auto* mock_file = new NiceMock; @@ -246,8 +250,10 @@ TEST(AdaptiveLoadClientMainTest, FailsIfClosingOutputFileFails) { NiceMock filesystem; std::string infile_contents = - Envoy::Filesystem::fileSystemForTest().fileReadToEnd(Nighthawk::TestEnvironment::runfilesPath( - std::string("test/adaptive_load/test_data/valid_session_spec.textproto"))).value(); + Envoy::Filesystem::fileSystemForTest() + .fileReadToEnd(Nighthawk::TestEnvironment::runfilesPath( + std::string("test/adaptive_load/test_data/valid_session_spec.textproto"))) + .value(); EXPECT_CALL(filesystem, fileReadToEnd(_)).WillOnce(Return(infile_contents)); auto* mock_file = new NiceMock; @@ -285,8 +291,10 @@ TEST(AdaptiveLoadClientMainTest, WritesOutputProtoToFile) { NiceMock filesystem; std::string infile_contents = - Envoy::Filesystem::fileSystemForTest().fileReadToEnd(Nighthawk::TestEnvironment::runfilesPath( - std::string("test/adaptive_load/test_data/valid_session_spec.textproto"))).value(); + Envoy::Filesystem::fileSystemForTest() + .fileReadToEnd(Nighthawk::TestEnvironment::runfilesPath( + std::string("test/adaptive_load/test_data/valid_session_spec.textproto"))) + .value(); EXPECT_CALL(filesystem, fileReadToEnd(_)).WillOnce(Return(infile_contents)); std::string actual_outfile_contents; @@ -313,9 +321,10 @@ TEST(AdaptiveLoadClientMainTest, WritesOutputProtoToFile) { AdaptiveLoadClientMain main(5, argv.data(), controller, filesystem); main.Run(); - std::string golden_text = - Envoy::Filesystem::fileSystemForTest().fileReadToEnd(Nighthawk::TestEnvironment::runfilesPath( - std::string("test/adaptive_load/test_data/golden_output.textproto"))).value(); + std::string golden_text = Envoy::Filesystem::fileSystemForTest() + .fileReadToEnd(Nighthawk::TestEnvironment::runfilesPath(std::string( + "test/adaptive_load/test_data/golden_output.textproto"))) + .value(); nighthawk::adaptive_load::AdaptiveLoadSessionOutput golden_proto; Envoy::Protobuf::TextFormat::ParseFromString(golden_text, &golden_proto); EXPECT_EQ(actual_outfile_contents, golden_proto.DebugString()); diff --git a/test/adaptive_load/fake_plugins/fake_input_variable_setter/fake_input_variable_setter.h b/test/adaptive_load/fake_plugins/fake_input_variable_setter/fake_input_variable_setter.h index 5f3b75d97..b84ced041 100644 --- a/test/adaptive_load/fake_plugins/fake_input_variable_setter/fake_input_variable_setter.h +++ b/test/adaptive_load/fake_plugins/fake_input_variable_setter/fake_input_variable_setter.h @@ -1,4 +1,3 @@ - #pragma once #include "envoy/registry/registry.h" diff --git a/test/benchmark_http_client_test.cc b/test/benchmark_http_client_test.cc index 6f051a3a9..096ae7dad 100644 --- a/test/benchmark_http_client_test.cc +++ b/test/benchmark_http_client_test.cc @@ -34,7 +34,7 @@ namespace Nighthawk { namespace { using ::envoy::config::core::v3::TypedExtensionConfig; -using ::google::protobuf::TextFormat; +using ::Envoy::Protobuf::TextFormat; // Helper function to get headers in a set that should be verified during the test. std::string getPathFromRequest(const Envoy::Http::RequestHeaderMap& header) { diff --git a/test/client_worker_test.cc b/test/client_worker_test.cc index 7de52a3b0..7cc62778c 100644 --- a/test/client_worker_test.cc +++ b/test/client_worker_test.cc @@ -38,7 +38,7 @@ class ClientWorkerTest : public Test { ClientWorkerTest() : api_(Envoy::Api::createApiForTest()), thread_id_(std::this_thread::get_id()) { loader_ = Envoy::Runtime::LoaderPtr{new Envoy::Runtime::LoaderImpl( - dispatcher_, tls_, {}, local_info_, store_, rand_, validation_visitor_, *api_)}; + dispatcher_, tls_, {}, local_info_, store_, rand_, validation_visitor_, *api_)}; benchmark_client_ = new MockBenchmarkClient(); sequencer_ = new MockSequencer(); request_generator_ = new MockRequestSource(); diff --git a/test/flush_worker_test.cc b/test/flush_worker_test.cc index 67b8de227..f436867a5 100644 --- a/test/flush_worker_test.cc +++ b/test/flush_worker_test.cc @@ -37,7 +37,7 @@ class FlushWorkerTest : public Test { NiceMock local_info; NiceMock validation_visitor; loader_ = Envoy::Runtime::LoaderPtr{new Envoy::Runtime::LoaderImpl( - *dispatcher_, tls_, {}, local_info, store_, rand, validation_visitor, api_)}; + *dispatcher_, tls_, {}, local_info, store_, rand, validation_visitor, api_)}; sink_ = new StrictMock(); stats_sinks_.emplace_back(sink_); diff --git a/test/output_collector_test.cc b/test/output_collector_test.cc index 81756380f..66abe1fd7 100644 --- a/test/output_collector_test.cc +++ b/test/output_collector_test.cc @@ -15,7 +15,7 @@ namespace Nighthawk { namespace Client { namespace { -using ::google::protobuf::TextFormat; +using ::Envoy::Protobuf::TextFormat; using ::nighthawk::client::UserDefinedOutput; class OutputCollectorTest : public Test, public Envoy::Event::TestUsingSimulatedTime { diff --git a/test/output_formatter_test.cc b/test/output_formatter_test.cc index ea4a4d08d..8ccf845bb 100644 --- a/test/output_formatter_test.cc +++ b/test/output_formatter_test.cc @@ -29,6 +29,7 @@ using namespace testing; namespace Nighthawk { namespace Client { +using ::Envoy::Protobuf::TextFormat; using ::nighthawk::client::Protocol; class OutputCollectorTest : public Test { @@ -78,8 +79,9 @@ class OutputCollectorTest : public Test { } std::string readGoldFile(absl::string_view path) { - std::string s = Envoy::Filesystem::fileSystemForTest().fileReadToEnd( - TestEnvironment::runfilesPath(std::string(path))).value(); + std::string s = Envoy::Filesystem::fileSystemForTest() + .fileReadToEnd(TestEnvironment::runfilesPath(std::string(path))) + .value(); const auto version = VersionInfo::buildVersion().version(); const std::string major = fmt::format("{}", version.major_number()); const std::string minor = fmt::format("{}", version.minor_number()); @@ -115,9 +117,9 @@ TEST_F(OutputCollectorTest, JsonFormatter) { EXPECT_EQ((formatter.formatProto(collector_->toProto())).ok(), true); std::string expected_str = readGoldFile("test/test_data/output_formatter.json.gold"); nighthawk::client::Output expected_output_proto, output_proto; - google::protobuf::TextFormat::ParseFromString(expected_str, &expected_output_proto); - google::protobuf::TextFormat::ParseFromString( - (formatter.formatProto(collector_->toProto())).value(), &output_proto); + TextFormat::ParseFromString(expected_str, &expected_output_proto); + TextFormat::ParseFromString((formatter.formatProto(collector_->toProto())).value(), + &output_proto); EXPECT_THAT(output_proto, EqualsProto(expected_output_proto)); } @@ -126,9 +128,9 @@ TEST_F(OutputCollectorTest, YamlFormatter) { EXPECT_EQ((formatter.formatProto(collector_->toProto())).ok(), true); std::string expected_str = readGoldFile("test/test_data/output_formatter.yaml.gold"); nighthawk::client::Output expected_output_proto, output_proto; - google::protobuf::TextFormat::ParseFromString(expected_str, &expected_output_proto); - google::protobuf::TextFormat::ParseFromString( - (formatter.formatProto(collector_->toProto())).value(), &output_proto); + TextFormat::ParseFromString(expected_str, &expected_output_proto); + TextFormat::ParseFromString((formatter.formatProto(collector_->toProto())).value(), + &output_proto); EXPECT_THAT(output_proto, EqualsProto(expected_output_proto)); } @@ -211,8 +213,9 @@ class MediumOutputCollectorTest : public OutputCollectorTest { public: nighthawk::client::Output loadProtoFromFile(absl::string_view path) { nighthawk::client::Output proto; - const auto contents = Envoy::Filesystem::fileSystemForTest().fileReadToEnd( - TestEnvironment::runfilesPath(std::string(path))).value(); + const auto contents = Envoy::Filesystem::fileSystemForTest() + .fileReadToEnd(TestEnvironment::runfilesPath(std::string(path))) + .value(); Envoy::MessageUtil::loadFromJson(contents, proto, Envoy::ProtobufMessage::getStrictValidationVisitor()); return proto; @@ -224,10 +227,9 @@ TEST_F(MediumOutputCollectorTest, FortioFormatter) { loadProtoFromFile("test/test_data/output_formatter.medium.proto.gold"); std::string expected_str = readGoldFile("test/test_data/output_formatter.medium.fortio.gold"); nighthawk::client::Output expected_output_proto, output_proto; - google::protobuf::TextFormat::ParseFromString(expected_str, &expected_output_proto); + TextFormat::ParseFromString(expected_str, &expected_output_proto); FortioOutputFormatterImpl formatter; - google::protobuf::TextFormat::ParseFromString((formatter.formatProto(input_proto)).value(), - &output_proto); + TextFormat::ParseFromString((formatter.formatProto(input_proto)).value(), &output_proto); EXPECT_THAT(output_proto, EqualsProto(expected_output_proto)); } @@ -286,10 +288,9 @@ TEST_F(MediumOutputCollectorTest, FortioPedanticFormatter) { std::string expected_str = readGoldFile("test/test_data/output_formatter.medium.fortio-noquirks.gold"); nighthawk::client::Output expected_output_proto, output_proto; - google::protobuf::TextFormat::ParseFromString(expected_str, &expected_output_proto); + TextFormat::ParseFromString(expected_str, &expected_output_proto); FortioPedanticOutputFormatterImpl formatter; - google::protobuf::TextFormat::ParseFromString((formatter.formatProto(input_proto)).value(), - &output_proto); + TextFormat::ParseFromString((formatter.formatProto(input_proto)).value(), &output_proto); EXPECT_THAT(output_proto, EqualsProto(expected_output_proto)); } diff --git a/test/process_test.cc b/test/process_test.cc index c08a1ee53..21074c84c 100644 --- a/test/process_test.cc +++ b/test/process_test.cc @@ -30,7 +30,7 @@ namespace Client { namespace { using ::envoy::config::core::v3::TypedExtensionConfig; -using ::google::protobuf::TextFormat; +using ::Envoy::Protobuf::TextFormat; using ::testing::HasSubstr; using ::testing::TestWithParam; using ::testing::ValuesIn; diff --git a/test/request_source/stub_plugin_impl.h b/test/request_source/stub_plugin_impl.h index f5bcf46d3..f9cbed71c 100644 --- a/test/request_source/stub_plugin_impl.h +++ b/test/request_source/stub_plugin_impl.h @@ -1,6 +1,7 @@ +#pragma once + // Test implementations of RequestSourceConfigFactory and RequestSource that perform minimum // functionality for testing purposes. -#pragma once #include "envoy/registry/registry.h" diff --git a/test/statistic_test.cc b/test/statistic_test.cc index 74f97f21c..e7ece0b8c 100644 --- a/test/statistic_test.cc +++ b/test/statistic_test.cc @@ -340,9 +340,11 @@ TEST(StatisticTest, HdrStatisticPercentilesProto) { } Envoy::MessageUtil util; - util.loadFromJson(Envoy::Filesystem::fileSystemForTest().fileReadToEnd( - TestEnvironment::runfilesPath("test/test_data/hdr_proto_json.gold")).value(), - parsed_json_proto, Envoy::ProtobufMessage::getStrictValidationVisitor()); + util.loadFromJson( + Envoy::Filesystem::fileSystemForTest() + .fileReadToEnd(TestEnvironment::runfilesPath("test/test_data/hdr_proto_json.gold")) + .value(), + parsed_json_proto, Envoy::ProtobufMessage::getStrictValidationVisitor()); const std::string json = util.getJsonStringFromMessageOrError( statistic.toProto(Statistic::SerializationDomain::DURATION), true, true); const std::string golden_json = @@ -363,9 +365,11 @@ TEST(StatisticTest, CircllhistStatisticPercentilesProto) { } Envoy::MessageUtil util; - util.loadFromJson(Envoy::Filesystem::fileSystemForTest().fileReadToEnd( - TestEnvironment::runfilesPath("test/test_data/circllhist_proto_json.gold")).value(), - parsed_json_proto, Envoy::ProtobufMessage::getStrictValidationVisitor()); + util.loadFromJson( + Envoy::Filesystem::fileSystemForTest() + .fileReadToEnd(TestEnvironment::runfilesPath("test/test_data/circllhist_proto_json.gold")) + .value(), + parsed_json_proto, Envoy::ProtobufMessage::getStrictValidationVisitor()); const std::string json = util.getJsonStringFromMessageOrError( statistic.toProto(Statistic::SerializationDomain::DURATION), true, true); const std::string golden_json = diff --git a/test/test_common/proto_matchers.h b/test/test_common/proto_matchers.h index 0a090593d..8809dea48 100644 --- a/test/test_common/proto_matchers.h +++ b/test/test_common/proto_matchers.h @@ -1,3 +1,5 @@ +#pragma once + #include #include "external/envoy/source/common/protobuf/protobuf.h" diff --git a/test/user_defined_output/fake_plugin/fake_user_defined_output_test.cc b/test/user_defined_output/fake_plugin/fake_user_defined_output_test.cc index ea8f32132..e231f96a4 100644 --- a/test/user_defined_output/fake_plugin/fake_user_defined_output_test.cc +++ b/test/user_defined_output/fake_plugin/fake_user_defined_output_test.cc @@ -19,7 +19,7 @@ namespace Nighthawk { namespace { using ::Envoy::Http::TestResponseHeaderMapImpl; -using ::google::protobuf::TextFormat; +using ::Envoy::Protobuf::TextFormat; using ::nighthawk::FakeUserDefinedOutput; using ::nighthawk::FakeUserDefinedOutputConfig; using ::testing::HasSubstr; @@ -220,4 +220,4 @@ TEST(AggregateGlobalOutput, FailsElegantlyWithIncorrectInput) { } } // namespace -} // namespace Nighthawk \ No newline at end of file +} // namespace Nighthawk diff --git a/test/user_defined_output/log_response_headers_plugin_test.cc b/test/user_defined_output/log_response_headers_plugin_test.cc index f055c9764..cca349356 100644 --- a/test/user_defined_output/log_response_headers_plugin_test.cc +++ b/test/user_defined_output/log_response_headers_plugin_test.cc @@ -22,7 +22,7 @@ namespace { using ::Envoy::Http::HeaderEntry; using ::Envoy::Http::TestResponseHeaderMapImpl; -using ::google::protobuf::TextFormat; +using ::Envoy::Protobuf::TextFormat; using ::nighthawk::LogResponseHeadersConfig; using ::nighthawk::LogResponseHeadersOutput; using ::testing::HasSubstr; diff --git a/test/user_defined_output/user_defined_output_plugin_creator_test.cc b/test/user_defined_output/user_defined_output_plugin_creator_test.cc index 859b88e89..5464d694e 100644 --- a/test/user_defined_output/user_defined_output_plugin_creator_test.cc +++ b/test/user_defined_output/user_defined_output_plugin_creator_test.cc @@ -15,7 +15,7 @@ namespace Nighthawk { namespace { using ::envoy::config::core::v3::TypedExtensionConfig; -using ::google::protobuf::TextFormat; +using ::Envoy::Protobuf::TextFormat; using ::nighthawk::FakeUserDefinedOutputConfig; using ::nighthawk::LogResponseHeadersConfig; using ::testing::HasSubstr; diff --git a/test/worker_test.cc b/test/worker_test.cc index 2ad271271..492782eae 100644 --- a/test/worker_test.cc +++ b/test/worker_test.cc @@ -50,9 +50,8 @@ TEST_F(WorkerTest, WorkerExecutesOnThread) { TestWorker worker(*api_, tls_); NiceMock dispatcher; - Envoy::Runtime::LoaderPtr loader = - Envoy::Runtime::LoaderPtr{new Envoy::Runtime::LoaderImpl( - dispatcher, tls_, {}, local_info_, test_store_, rand_, validation_visitor_, *api_)}; + Envoy::Runtime::LoaderPtr loader = Envoy::Runtime::LoaderPtr{new Envoy::Runtime::LoaderImpl( + dispatcher, tls_, {}, local_info_, test_store_, rand_, validation_visitor_, *api_)}; worker.start(); worker.waitForCompletion();