From bf31bbd341445f1eed738cd09bb110c7d16d5dd6 Mon Sep 17 00:00:00 2001 From: Matt Klein Date: Tue, 4 Jul 2017 19:59:22 -0700 Subject: [PATCH 1/3] format: upgrade to clang-format-5.0 This most enforces namespace comments but also churns/fixes a few other things. Fixes https://github.com/lyft/envoy/issues/1200 Fixes https://github.com/lyft/envoy/issues/673 --- ci/README.md | 4 +- ci/envoy_build_sha.sh | 2 +- include/envoy/access_log/access_log.h | 4 +- include/envoy/api/api.h | 4 +- include/envoy/buffer/buffer.h | 4 +- include/envoy/common/exception.h | 2 +- include/envoy/common/optional.h | 2 +- include/envoy/common/time.h | 2 +- include/envoy/event/deferred_deletable.h | 4 +- include/envoy/event/dispatcher.h | 4 +- include/envoy/event/file_event.h | 4 +- include/envoy/event/signal.h | 4 +- include/envoy/event/timer.h | 4 +- include/envoy/filesystem/filesystem.h | 4 +- include/envoy/grpc/async_client.h | 4 +- include/envoy/grpc/rpc_channel.h | 4 +- include/envoy/grpc/status.h | 4 +- include/envoy/http/access_log.h | 6 +- include/envoy/http/async_client.h | 4 +- include/envoy/http/codec.h | 4 +- include/envoy/http/codes.h | 4 +- include/envoy/http/conn_pool.h | 6 +- include/envoy/http/filter.h | 4 +- include/envoy/http/header_map.h | 4 +- include/envoy/http/message.h | 4 +- include/envoy/http/protocol.h | 4 +- include/envoy/init/init.h | 4 +- include/envoy/json/json_object.h | 4 +- include/envoy/local_info/local_info.h | 4 +- include/envoy/mongo/bson.h | 4 +- include/envoy/mongo/codec.h | 4 +- include/envoy/network/address.h | 6 +- include/envoy/network/connection.h | 4 +- include/envoy/network/connection_handler.h | 4 +- include/envoy/network/dns.h | 4 +- include/envoy/network/drain_decision.h | 4 +- include/envoy/network/filter.h | 4 +- include/envoy/network/listen_socket.h | 4 +- include/envoy/network/listener.h | 4 +- include/envoy/ratelimit/ratelimit.h | 4 +- include/envoy/redis/codec.h | 4 +- include/envoy/redis/command_splitter.h | 6 +- include/envoy/redis/conn_pool.h | 6 +- include/envoy/registry/registry.h | 4 +- include/envoy/router/rds.h | 4 +- include/envoy/router/router.h | 4 +- include/envoy/router/router_ratelimit.h | 4 +- include/envoy/router/shadow_writer.h | 4 +- include/envoy/runtime/runtime.h | 4 +- include/envoy/server/admin.h | 4 +- include/envoy/server/configuration.h | 6 +- include/envoy/server/drain_manager.h | 4 +- include/envoy/server/filter_config.h | 6 +- include/envoy/server/guarddog.h | 4 +- include/envoy/server/hot_restart.h | 4 +- include/envoy/server/instance.h | 4 +- include/envoy/server/listener_manager.h | 4 +- include/envoy/server/options.h | 8 +- include/envoy/server/watchdog.h | 4 +- include/envoy/server/worker.h | 4 +- include/envoy/ssl/connection.h | 4 +- include/envoy/ssl/context.h | 4 +- include/envoy/ssl/context_config.h | 4 +- include/envoy/ssl/context_manager.h | 4 +- include/envoy/stats/stats.h | 4 +- include/envoy/thread/thread.h | 4 +- include/envoy/thread_local/thread_local.h | 4 +- include/envoy/tracing/context.h | 4 +- include/envoy/tracing/http_tracer.h | 4 +- include/envoy/upstream/cluster_manager.h | 4 +- include/envoy/upstream/health_checker.h | 4 +- include/envoy/upstream/host_description.h | 2 +- include/envoy/upstream/load_balancer.h | 4 +- include/envoy/upstream/load_balancer_type.h | 4 +- include/envoy/upstream/outlier_detection.h | 6 +- include/envoy/upstream/resource_manager.h | 4 +- include/envoy/upstream/thread_local_cluster.h | 4 +- include/envoy/upstream/upstream.h | 7 +- .../access_log/access_log_manager_impl.cc | 4 +- .../access_log/access_log_manager_impl.h | 4 +- source/common/api/api_impl.cc | 4 +- source/common/api/api_impl.h | 4 +- source/common/buffer/buffer_impl.cc | 4 +- source/common/buffer/buffer_impl.h | 4 +- .../buffer/zero_copy_input_stream_impl.cc | 4 +- source/common/common/base64.cc | 2 +- source/common/common/base64.h | 2 +- source/common/common/c_smart_ptr.h | 2 +- source/common/common/empty_string.h | 2 +- source/common/common/enum_to_int.h | 2 +- source/common/common/hex.cc | 2 +- source/common/common/hex.h | 2 +- source/common/common/linked_object.h | 2 +- source/common/common/logger.cc | 2 +- source/common/common/logger.h | 2 +- source/common/common/non_copyable.h | 2 +- source/common/common/singleton.h | 2 +- source/common/common/stl_helpers.h | 7 +- source/common/common/thread.cc | 14 +- source/common/common/thread.h | 4 +- source/common/common/to_lower_table.cc | 2 +- source/common/common/to_lower_table.h | 2 +- source/common/common/utility.cc | 2 +- source/common/common/utility.h | 2 +- source/common/common/version.cc | 4 +- source/common/common/version.h | 2 +- source/common/config/grpc_subscription_impl.h | 21 +- source/common/config/subscription_factory.h | 4 +- source/common/config/utility.h | 4 +- source/common/dynamo/dynamo_filter.cc | 28 +- source/common/dynamo/dynamo_filter.h | 4 +- source/common/dynamo/dynamo_request_parser.cc | 4 +- source/common/dynamo/dynamo_request_parser.h | 4 +- source/common/dynamo/dynamo_utility.cc | 4 +- source/common/dynamo/dynamo_utility.h | 4 +- source/common/event/dispatched_thread.cc | 4 +- source/common/event/dispatched_thread.h | 4 +- source/common/event/dispatcher_impl.cc | 4 +- source/common/event/dispatcher_impl.h | 4 +- source/common/event/event_impl_base.cc | 4 +- source/common/event/event_impl_base.h | 4 +- source/common/event/file_event_impl.cc | 4 +- source/common/event/file_event_impl.h | 4 +- source/common/event/libevent.cc | 6 +- source/common/event/libevent.h | 6 +- source/common/event/signal_impl.cc | 12 +- source/common/event/signal_impl.h | 4 +- source/common/event/timer_impl.cc | 10 +- source/common/event/timer_impl.h | 4 +- source/common/filesystem/filesystem_impl.cc | 4 +- source/common/filesystem/filesystem_impl.h | 2 +- source/common/filesystem/watcher_impl.cc | 17 +- source/common/filesystem/watcher_impl.h | 4 +- source/common/filter/auth/client_ssl.cc | 19 +- source/common/filter/auth/client_ssl.h | 6 +- source/common/filter/echo.cc | 4 +- source/common/filter/echo.h | 4 +- source/common/filter/ratelimit.cc | 6 +- source/common/filter/ratelimit.h | 4 +- source/common/filter/tcp_proxy.cc | 4 +- source/common/filter/tcp_proxy.h | 2 +- source/common/grpc/codec.cc | 2 +- source/common/grpc/codec.h | 4 +- source/common/grpc/common.cc | 4 +- source/common/grpc/common.h | 16 +- source/common/grpc/grpc_web_filter.cc | 16 +- source/common/grpc/http1_bridge_filter.cc | 4 +- source/common/grpc/http1_bridge_filter.h | 4 +- source/common/grpc/json_transcoder_filter.cc | 2 +- source/common/grpc/rpc_channel_impl.cc | 4 +- source/common/grpc/rpc_channel_impl.h | 4 +- .../http/access_log/access_log_formatter.cc | 11 +- .../http/access_log/access_log_formatter.h | 6 +- .../common/http/access_log/access_log_impl.cc | 6 +- .../common/http/access_log/access_log_impl.h | 6 +- .../http/access_log/request_info_impl.h | 6 +- source/common/http/async_client_impl.cc | 20 +- source/common/http/async_client_impl.h | 6 +- source/common/http/codec_client.cc | 4 +- source/common/http/codec_client.h | 4 +- source/common/http/codec_helper.h | 4 +- source/common/http/codec_wrappers.h | 4 +- source/common/http/codes.cc | 50 ++- source/common/http/codes.h | 4 +- source/common/http/conn_manager_impl.cc | 34 +- source/common/http/conn_manager_impl.h | 6 +- source/common/http/conn_manager_utility.cc | 4 +- source/common/http/conn_manager_utility.h | 4 +- source/common/http/date_provider.h | 4 +- source/common/http/date_provider_impl.cc | 4 +- source/common/http/date_provider_impl.h | 4 +- source/common/http/exception.h | 4 +- source/common/http/filter/buffer_filter.cc | 4 +- source/common/http/filter/buffer_filter.h | 2 +- source/common/http/filter/fault_filter.cc | 4 +- source/common/http/filter/fault_filter.h | 2 +- .../common/http/filter/ip_tagging_filter.cc | 4 +- source/common/http/filter/ip_tagging_filter.h | 4 +- source/common/http/filter/ratelimit.cc | 21 +- source/common/http/filter/ratelimit.h | 6 +- source/common/http/filter_utility.cc | 4 +- source/common/http/filter_utility.h | 4 +- source/common/http/header_map_impl.cc | 28 +- source/common/http/header_map_impl.h | 2 +- source/common/http/headers.h | 4 +- source/common/http/http1/codec_impl.cc | 47 +-- source/common/http/http1/codec_impl.h | 10 +- source/common/http/http1/conn_pool.cc | 6 +- source/common/http/http1/conn_pool.h | 6 +- source/common/http/http2/codec_impl.cc | 78 ++-- source/common/http/http2/codec_impl.h | 6 +- source/common/http/http2/conn_pool.cc | 6 +- source/common/http/http2/conn_pool.h | 6 +- source/common/http/message_impl.cc | 4 +- source/common/http/message_impl.h | 4 +- source/common/http/rest_api_fetcher.cc | 4 +- source/common/http/rest_api_fetcher.h | 4 +- source/common/http/user_agent.cc | 4 +- source/common/http/user_agent.h | 2 +- source/common/http/utility.cc | 62 +-- source/common/http/utility.h | 4 +- source/common/json/config_schemas.cc | 2 +- source/common/json/config_schemas.h | 4 +- source/common/json/json_loader.cc | 4 +- source/common/json/json_loader.h | 4 +- source/common/json/json_validator.h | 4 +- source/common/local_info/local_info_impl.h | 4 +- source/common/memory/stats.cc | 8 +- source/common/memory/stats.h | 4 +- source/common/mongo/bson_impl.cc | 4 +- source/common/mongo/bson_impl.h | 4 +- source/common/mongo/codec_impl.cc | 4 +- source/common/mongo/codec_impl.h | 4 +- source/common/mongo/proxy.cc | 4 +- source/common/mongo/proxy.h | 2 +- source/common/mongo/utility.cc | 4 +- source/common/mongo/utility.h | 4 +- source/common/network/address_impl.cc | 6 +- source/common/network/address_impl.h | 6 +- source/common/network/cidr_range.cc | 6 +- source/common/network/cidr_range.h | 6 +- source/common/network/connection_impl.cc | 10 +- source/common/network/connection_impl.h | 4 +- source/common/network/dns_impl.cc | 21 +- source/common/network/dns_impl.h | 4 +- source/common/network/filter_impl.h | 4 +- source/common/network/filter_manager_impl.cc | 4 +- source/common/network/filter_manager_impl.h | 4 +- source/common/network/listen_socket_impl.cc | 4 +- source/common/network/listen_socket_impl.h | 4 +- source/common/network/listener_impl.cc | 4 +- source/common/network/listener_impl.h | 4 +- source/common/network/proxy_protocol.cc | 17 +- source/common/network/proxy_protocol.h | 4 +- source/common/network/utility.cc | 4 +- source/common/network/utility.h | 28 +- source/common/profiler/profiler.cc | 8 +- source/common/profiler/profiler.h | 4 +- source/common/ratelimit/ratelimit_impl.cc | 4 +- source/common/ratelimit/ratelimit_impl.h | 4 +- source/common/redis/codec_impl.cc | 4 +- source/common/redis/codec_impl.h | 4 +- source/common/redis/command_splitter_impl.cc | 10 +- source/common/redis/command_splitter_impl.h | 6 +- source/common/redis/conn_pool_impl.cc | 20 +- source/common/redis/conn_pool_impl.h | 6 +- source/common/redis/proxy_filter.cc | 4 +- source/common/redis/proxy_filter.h | 2 +- source/common/router/config_impl.cc | 4 +- source/common/router/config_impl.h | 4 +- source/common/router/config_utility.cc | 4 +- source/common/router/config_utility.h | 4 +- source/common/router/rds_impl.cc | 4 +- source/common/router/rds_impl.h | 4 +- source/common/router/retry_state_impl.cc | 4 +- source/common/router/retry_state_impl.h | 4 +- source/common/router/router.cc | 76 ++-- source/common/router/router.h | 6 +- source/common/router/router_ratelimit.cc | 9 +- source/common/router/router_ratelimit.h | 8 +- source/common/router/shadow_writer_impl.cc | 8 +- source/common/router/shadow_writer_impl.h | 4 +- source/common/runtime/runtime_impl.cc | 9 +- source/common/runtime/runtime_impl.h | 4 +- source/common/runtime/uuid_util.cc | 2 +- source/common/runtime/uuid_util.h | 2 +- source/common/ssl/connection_impl.cc | 4 +- source/common/ssl/connection_impl.h | 4 +- source/common/ssl/context_config_impl.cc | 4 +- source/common/ssl/context_config_impl.h | 4 +- source/common/ssl/context_impl.cc | 8 +- source/common/ssl/context_manager_impl.cc | 4 +- source/common/ssl/context_manager_impl.h | 4 +- source/common/stats/stats_impl.cc | 4 +- source/common/stats/stats_impl.h | 18 +- source/common/stats/statsd.cc | 6 +- source/common/stats/statsd.h | 6 +- source/common/stats/thread_local_store.cc | 4 +- source/common/stats/thread_local_store.h | 4 +- .../common/thread_local/thread_local_impl.cc | 4 +- .../common/thread_local/thread_local_impl.h | 4 +- source/common/tracing/http_tracer_impl.cc | 4 +- source/common/tracing/http_tracer_impl.h | 4 +- .../common/tracing/lightstep_tracer_impl.cc | 8 +- source/common/tracing/lightstep_tracer_impl.h | 2 +- source/common/tracing/zipkin/span_buffer.cc | 4 +- source/common/tracing/zipkin/span_buffer.h | 4 +- source/common/tracing/zipkin/span_context.cc | 4 +- source/common/tracing/zipkin/span_context.h | 4 +- source/common/tracing/zipkin/tracer.cc | 10 +- source/common/tracing/zipkin/tracer.h | 4 +- .../common/tracing/zipkin/tracer_interface.h | 4 +- source/common/tracing/zipkin/util.cc | 7 +- source/common/tracing/zipkin/util.h | 4 +- .../tracing/zipkin/zipkin_core_constants.h | 4 +- .../tracing/zipkin/zipkin_core_types.cc | 13 +- .../common/tracing/zipkin/zipkin_core_types.h | 16 +- .../tracing/zipkin/zipkin_json_field_names.h | 4 +- .../tracing/zipkin/zipkin_tracer_impl.cc | 29 +- .../tracing/zipkin/zipkin_tracer_impl.h | 2 +- source/common/upstream/cds_api_impl.cc | 4 +- source/common/upstream/cds_api_impl.h | 2 +- .../common/upstream/cluster_manager_impl.cc | 14 +- source/common/upstream/cluster_manager_impl.h | 4 +- source/common/upstream/eds.cc | 19 +- source/common/upstream/eds.h | 4 +- source/common/upstream/health_checker_impl.cc | 9 +- source/common/upstream/health_checker_impl.h | 4 +- source/common/upstream/host_utility.cc | 4 +- source/common/upstream/host_utility.h | 4 +- source/common/upstream/load_balancer_impl.cc | 14 +- source/common/upstream/load_balancer_impl.h | 4 +- source/common/upstream/logical_dns_cluster.cc | 8 +- source/common/upstream/logical_dns_cluster.h | 4 +- .../common/upstream/outlier_detection_impl.cc | 6 +- .../common/upstream/outlier_detection_impl.h | 6 +- .../common/upstream/resource_manager_impl.h | 4 +- source/common/upstream/ring_hash_lb.cc | 9 +- source/common/upstream/ring_hash_lb.h | 4 +- source/common/upstream/sds_subscription.cc | 4 +- source/common/upstream/sds_subscription.h | 4 +- source/common/upstream/upstream_impl.cc | 4 +- source/common/upstream/upstream_impl.h | 8 +- source/exe/hot_restart.cc | 17 +- source/exe/hot_restart.h | 4 +- source/exe/main_common.cc | 4 +- source/exe/main_common.h | 2 +- source/exe/signal_action.cc | 2 +- source/exe/signal_action.h | 2 +- source/server/config/http/buffer.cc | 6 +- source/server/config/http/buffer.h | 6 +- source/server/config/http/dynamo.cc | 6 +- source/server/config/http/dynamo.h | 6 +- source/server/config/http/fault.cc | 6 +- source/server/config/http/fault.h | 6 +- .../server/config/http/grpc_http1_bridge.cc | 6 +- source/server/config/http/grpc_http1_bridge.h | 6 +- .../config/http/grpc_json_transcoder.cc | 6 +- .../server/config/http/grpc_json_transcoder.h | 6 +- source/server/config/http/ip_tagging.cc | 6 +- source/server/config/http/ip_tagging.h | 6 +- .../config/http/lightstep_http_tracer.cc | 6 +- .../config/http/lightstep_http_tracer.h | 6 +- source/server/config/http/ratelimit.cc | 6 +- source/server/config/http/ratelimit.h | 6 +- source/server/config/http/router.cc | 11 +- source/server/config/http/router.h | 6 +- .../server/config/http/zipkin_http_tracer.cc | 6 +- .../server/config/http/zipkin_http_tracer.h | 6 +- .../server/config/network/client_ssl_auth.cc | 6 +- .../server/config/network/client_ssl_auth.h | 6 +- source/server/config/network/echo.cc | 11 +- .../config/network/http_connection_manager.cc | 14 +- .../config/network/http_connection_manager.h | 6 +- source/server/config/network/mongo_proxy.cc | 6 +- source/server/config/network/mongo_proxy.h | 6 +- source/server/config/network/ratelimit.cc | 6 +- source/server/config/network/ratelimit.h | 6 +- source/server/config/network/redis_proxy.cc | 6 +- source/server/config/network/redis_proxy.h | 6 +- source/server/config/network/tcp_proxy.cc | 6 +- source/server/config/network/tcp_proxy.h | 6 +- source/server/config_validation/api.cc | 4 +- source/server/config_validation/api.h | 4 +- .../server/config_validation/async_client.cc | 4 +- .../server/config_validation/async_client.h | 4 +- .../config_validation/cluster_manager.cc | 4 +- .../config_validation/cluster_manager.h | 4 +- source/server/config_validation/dispatcher.cc | 6 +- source/server/config_validation/dispatcher.h | 4 +- source/server/config_validation/dns.cc | 4 +- source/server/config_validation/dns.h | 4 +- source/server/config_validation/server.cc | 8 +- source/server/config_validation/server.h | 4 +- source/server/configuration_impl.cc | 6 +- source/server/configuration_impl.h | 28 +- source/server/connection_handler_impl.cc | 9 +- source/server/connection_handler_impl.h | 2 +- source/server/drain_manager_impl.cc | 4 +- source/server/drain_manager_impl.h | 4 +- source/server/guarddog_impl.cc | 4 +- source/server/guarddog_impl.h | 4 +- source/server/http/admin.cc | 2 +- source/server/http/admin.h | 4 +- source/server/http/health_check.cc | 10 +- source/server/http/health_check.h | 6 +- source/server/init_manager_impl.cc | 4 +- source/server/init_manager_impl.h | 4 +- source/server/listener_manager_impl.cc | 4 +- source/server/listener_manager_impl.h | 4 +- source/server/options_impl.cc | 2 +- source/server/options_impl.h | 2 +- source/server/server.cc | 9 +- source/server/server.h | 2 +- source/server/test_hooks.h | 2 +- source/server/watchdog_impl.cc | 4 +- source/server/watchdog_impl.h | 2 +- source/server/worker_impl.cc | 4 +- source/server/worker_impl.h | 4 +- .../access_log_manager_impl_test.cc | 6 +- test/common/api/api_impl_test.cc | 4 +- test/common/common/base64_test.cc | 2 +- test/common/common/hex_test.cc | 2 +- test/common/common/log_macros_test.cc | 2 +- test/common/common/optional_test.cc | 2 +- test/common/common/to_lower_table_test.cc | 2 +- test/common/common/utility_test.cc | 2 +- .../filesystem_subscription_test_harness.h | 5 +- .../config/grpc_subscription_test_harness.h | 13 +- .../config/http_subscription_test_harness.h | 18 +- .../config/subscription_factory_test.cc | 2 +- test/common/dynamo/dynamo_filter_test.cc | 6 +- .../dynamo/dynamo_request_parser_test.cc | 22 +- test/common/dynamo/dynamo_utility_test.cc | 4 +- .../event/dispatched_thread_impl_test.cc | 4 +- test/common/event/dispatcher_impl_test.cc | 4 +- test/common/event/file_event_impl_test.cc | 77 ++-- .../common/filesystem/filesystem_impl_test.cc | 4 +- test/common/filesystem/watcher_impl_test.cc | 4 +- test/common/filter/auth/client_ssl_test.cc | 10 +- test/common/filter/ratelimit_test.cc | 18 +- test/common/filter/tcp_proxy_test.cc | 6 +- test/common/grpc/async_client_impl_test.cc | 4 +- test/common/grpc/codec_test.cc | 4 +- test/common/grpc/common_test.cc | 4 +- test/common/grpc/grpc_web_filter_test.cc | 7 +- test/common/grpc/http1_bridge_filter_test.cc | 6 +- .../grpc/json_transcoder_filter_test.cc | 2 +- test/common/grpc/rpc_channel_impl_test.cc | 10 +- .../access_log/access_log_formatter_test.cc | 28 +- .../http/access_log/access_log_impl_test.cc | 8 +- test/common/http/async_client_impl_test.cc | 356 +++++++++--------- test/common/http/codec_client_test.cc | 24 +- test/common/http/codes_test.cc | 32 +- test/common/http/common.cc | 2 +- test/common/http/common.h | 2 +- test/common/http/conn_manager_impl_test.cc | 345 ++++++++--------- test/common/http/conn_manager_utility_test.cc | 6 +- test/common/http/date_provider_impl_test.cc | 4 +- test/common/http/filter/buffer_filter_test.cc | 6 +- test/common/http/filter/fault_filter_test.cc | 31 +- .../http/filter/ip_tagging_filter_test.cc | 6 +- test/common/http/filter/ratelimit_test.cc | 106 +++--- test/common/http/header_map_impl_test.cc | 4 +- test/common/http/http1/codec_impl_test.cc | 13 +- test/common/http/http1/conn_pool_test.cc | 39 +- test/common/http/http2/codec_impl_test.cc | 61 ++- test/common/http/http2/conn_pool_test.cc | 15 +- test/common/http/user_agent_test.cc | 4 +- test/common/http/utility_test.cc | 6 +- test/common/json/config_schemas_test.cc | 6 +- test/common/json/json_loader_test.cc | 4 +- test/common/mongo/bson_impl_test.cc | 4 +- test/common/mongo/codec_impl_test.cc | 4 +- test/common/mongo/proxy_test.cc | 290 +++++++------- test/common/mongo/utility_test.cc | 4 +- test/common/network/address_impl_test.cc | 6 +- test/common/network/cidr_range_test.cc | 10 +- test/common/network/connection_impl_test.cc | 23 +- test/common/network/dns_impl_test.cc | 32 +- .../network/filter_manager_impl_test.cc | 16 +- .../common/network/listen_socket_impl_test.cc | 4 +- test/common/network/listener_impl_test.cc | 33 +- test/common/network/proxy_protocol_test.cc | 54 ++- test/common/network/utility_test.cc | 4 +- test/common/ratelimit/ratelimit_impl_test.cc | 11 +- test/common/redis/codec_impl_test.cc | 4 +- .../redis/command_splitter_impl_test.cc | 8 +- test/common/redis/conn_pool_impl_test.cc | 69 ++-- test/common/redis/proxy_filter_test.cc | 77 ++-- test/common/router/config_impl_test.cc | 60 +-- test/common/router/rds_impl_test.cc | 6 +- test/common/router/retry_state_impl_test.cc | 6 +- test/common/router/router_ratelimit_test.cc | 6 +- test/common/router/router_test.cc | 297 ++++++++------- test/common/router/shadow_writer_impl_test.cc | 6 +- test/common/runtime/runtime_impl_test.cc | 4 +- test/common/runtime/uuid_util_test.cc | 2 +- test/common/ssl/connection_impl_test.cc | 6 +- test/common/ssl/context_impl_test.cc | 4 +- test/common/ssl/ssl_certs_test.h | 2 +- test/common/stats/stats_impl_test.cc | 4 +- test/common/stats/statsd_test.cc | 8 +- test/common/stats/thread_local_store_test.cc | 17 +- test/common/stats/udp_statsd_test.cc | 8 +- test/common/tracing/http_tracer_impl_test.cc | 6 +- .../tracing/lightstep_tracer_impl_test.cc | 6 +- .../common/tracing/zipkin/span_buffer_test.cc | 4 +- .../tracing/zipkin/span_context_test.cc | 4 +- test/common/tracing/zipkin/tracer_test.cc | 6 +- test/common/tracing/zipkin/util_test.cc | 4 +- .../tracing/zipkin/zipkin_core_types_test.cc | 82 ++-- .../tracing/zipkin/zipkin_tracer_impl_test.cc | 6 +- test/common/upstream/cds_api_impl_test.cc | 6 +- .../upstream/cluster_manager_impl_test.cc | 21 +- test/common/upstream/eds_test.cc | 4 +- .../upstream/health_checker_impl_test.cc | 16 +- test/common/upstream/host_utility_test.cc | 4 +- .../upstream/load_balancer_impl_test.cc | 4 +- .../upstream/load_balancer_simulation_test.cc | 9 +- .../upstream/logical_dns_cluster_test.cc | 11 +- .../upstream/outlier_detection_impl_test.cc | 33 +- .../upstream/resource_manager_impl_test.cc | 4 +- test/common/upstream/ring_hash_lb_test.cc | 6 +- test/common/upstream/sds_test.cc | 11 +- test/common/upstream/upstream_impl_test.cc | 11 +- test/config_test/config_test.cc | 27 +- test/config_test/config_test.h | 4 +- test/config_test/example_configs_test.cc | 2 +- test/coverage/gcc_only_test/gcc_only_test.cc | 2 +- test/exe/signals_test.cc | 56 +-- test/integration/echo_integration_test.cc | 13 +- test/integration/fake_upstream.cc | 6 +- test/integration/fake_upstream.h | 2 +- .../grpc_json_transcoder_integration_test.cc | 40 +- test/integration/http2_integration_test.cc | 28 +- test/integration/http2_integration_test.h | 2 +- .../http2_upstream_integration_test.cc | 14 +- .../http2_upstream_integration_test.h | 2 +- test/integration/integration.cc | 107 +++--- test/integration/integration.h | 2 +- test/integration/integration_admin_test.cc | 4 +- test/integration/integration_admin_test.h | 2 +- test/integration/integration_test.cc | 28 +- test/integration/integration_test.h | 2 +- .../proxy_proto_integration_test.cc | 2 +- .../proxy_proto_integration_test.h | 2 +- test/integration/server.cc | 4 +- test/integration/server.h | 6 +- test/integration/ssl_integration_test.cc | 6 +- test/integration/ssl_integration_test.h | 4 +- test/integration/uds_integration_test.cc | 2 +- test/integration/uds_integration_test.h | 2 +- test/integration/utility.cc | 12 +- test/integration/utility.h | 2 +- test/integration/xfcc_integration_test.cc | 10 +- test/integration/xfcc_integration_test.h | 4 +- test/main.cc | 6 +- test/mocks/access_log/mocks.cc | 6 +- test/mocks/access_log/mocks.h | 4 +- test/mocks/api/mocks.cc | 6 +- test/mocks/api/mocks.h | 4 +- test/mocks/buffer/mocks.h | 2 +- test/mocks/common.cc | 2 +- test/mocks/common.h | 2 +- test/mocks/config/mocks.h | 4 +- test/mocks/event/mocks.cc | 11 +- test/mocks/event/mocks.h | 4 +- test/mocks/filesystem/mocks.cc | 4 +- test/mocks/filesystem/mocks.h | 4 +- test/mocks/grpc/mocks.cc | 4 +- test/mocks/grpc/mocks.h | 4 +- test/mocks/http/mocks.cc | 49 +-- test/mocks/http/mocks.h | 10 +- test/mocks/init/mocks.cc | 11 +- test/mocks/init/mocks.h | 4 +- test/mocks/local_info/mocks.cc | 4 +- test/mocks/local_info/mocks.h | 4 +- test/mocks/network/mocks.cc | 22 +- test/mocks/network/mocks.h | 4 +- test/mocks/ratelimit/mocks.cc | 4 +- test/mocks/ratelimit/mocks.h | 4 +- test/mocks/redis/mocks.cc | 26 +- test/mocks/redis/mocks.h | 8 +- test/mocks/router/mocks.cc | 6 +- test/mocks/router/mocks.h | 4 +- test/mocks/runtime/mocks.cc | 6 +- test/mocks/runtime/mocks.h | 4 +- test/mocks/server/mocks.cc | 8 +- test/mocks/server/mocks.h | 8 +- test/mocks/ssl/mocks.cc | 4 +- test/mocks/ssl/mocks.h | 4 +- test/mocks/stats/mocks.cc | 4 +- test/mocks/stats/mocks.h | 4 +- test/mocks/thread_local/mocks.cc | 6 +- test/mocks/thread_local/mocks.h | 4 +- test/mocks/tracing/mocks.cc | 4 +- test/mocks/tracing/mocks.h | 4 +- test/mocks/upstream/cluster_info.h | 4 +- test/mocks/upstream/host.h | 6 +- test/mocks/upstream/mocks.cc | 27 +- test/mocks/upstream/mocks.h | 4 +- test/server/backtrace_test.cc | 2 +- test/server/config/http/config_test.cc | 8 +- test/server/config/network/config_test.cc | 8 +- .../network/http_connection_manager_test.cc | 6 +- .../config_validation/async_client_test.cc | 4 +- .../config_validation/cluster_manager_test.cc | 4 +- test/server/config_validation/server_test.cc | 4 +- test/server/configuration_impl_test.cc | 6 +- test/server/connection_handler_test.cc | 6 +- test/server/drain_manager_impl_test.cc | 6 +- test/server/guarddog_impl_test.cc | 32 +- test/server/http/admin_test.cc | 11 +- test/server/http/health_check_test.cc | 4 +- test/server/init_manager_impl_test.cc | 11 +- test/server/listener_manager_impl_test.cc | 19 +- test/server/options_impl_test.cc | 4 +- test/server/server_test.cc | 4 +- test/server/worker_impl_test.cc | 20 +- test/test_common/environment.cc | 2 +- test/test_common/environment.h | 2 +- test/test_common/network_utility.cc | 10 +- test/test_common/network_utility.h | 6 +- test/test_common/network_utility_test.cc | 2 +- test/test_common/printers.cc | 18 +- test/test_common/printers.h | 8 +- test/test_common/utility.cc | 6 +- test/test_common/utility.h | 2 +- test/test_runner.h | 2 +- .../config_load_check/config_load_check.cc | 5 +- .../router_check/json/tool_config_schemas.cc | 2 +- .../router_check/json/tool_config_schemas.h | 4 +- test/tools/router_check/router.cc | 45 ++- test/tools/router_check/router.h | 2 +- tools/check_format.py | 2 +- 616 files changed, 3205 insertions(+), 2985 deletions(-) mode change 100755 => 100644 test/mocks/ssl/mocks.h diff --git a/ci/README.md b/ci/README.md index 49f865d663e09..36f1f6e736bac 100644 --- a/ci/README.md +++ b/ci/README.md @@ -69,5 +69,5 @@ The `./ci/run_envoy_docker.sh './ci/do_ci.sh '` targets are: * `bazel.release.server_only` — build Envoy static binary under `-c opt` with gcc. * `bazel.coverage` — build and run tests under `-c dbg` with gcc, generating coverage information in `$ENVOY_DOCKER_BUILD_DIR/envoy/generated/coverage/coverage.html`. * `bazel.tsan` — build and run tests under `-c dbg --config=clang-tsan` with clang-5.0. -* `check_format`— run `clang-format` 3.6 and `buildifier` on entire source tree. -* `fix_format`— run and enforce `clang-format` 3.6 and `buildifier` on entire source tree. +* `check_format`— run `clang-format` 5.0 and `buildifier` on entire source tree. +* `fix_format`— run and enforce `clang-format` 5.0 and `buildifier` on entire source tree. diff --git a/ci/envoy_build_sha.sh b/ci/envoy_build_sha.sh index dc854c42ec6b8..82e76b80a742f 100644 --- a/ci/envoy_build_sha.sh +++ b/ci/envoy_build_sha.sh @@ -1 +1 @@ -ENVOY_BUILD_SHA=cd7f513444fb24270175f0c961996d184b764f32 +ENVOY_BUILD_SHA=146fb40d0c8b8e48416470b50d60929a3f344711 diff --git a/include/envoy/access_log/access_log.h b/include/envoy/access_log/access_log.h index 67a13857d428c..12190367c41b6 100644 --- a/include/envoy/access_log/access_log.h +++ b/include/envoy/access_log/access_log.h @@ -28,5 +28,5 @@ class AccessLogManager { typedef std::unique_ptr AccessLogManagerPtr; -} // AccessLog -} // Envoy +} // namespace AccessLog +} // namespace Envoy diff --git a/include/envoy/api/api.h b/include/envoy/api/api.h index 9cf1ea0398b30..b93ced719fd6b 100644 --- a/include/envoy/api/api.h +++ b/include/envoy/api/api.h @@ -47,5 +47,5 @@ class Api { typedef std::unique_ptr ApiPtr; -} // Api -} // Envoy +} // namespace Api +} // namespace Envoy diff --git a/include/envoy/buffer/buffer.h b/include/envoy/buffer/buffer.h index d7db854ac9a09..2d6c1d5d07255 100644 --- a/include/envoy/buffer/buffer.h +++ b/include/envoy/buffer/buffer.h @@ -133,5 +133,5 @@ class Instance { typedef std::unique_ptr InstancePtr; -} // Buffer -} // Envoy +} // namespace Buffer +} // namespace Envoy diff --git a/include/envoy/common/exception.h b/include/envoy/common/exception.h index 41eec9b4912d7..d5b9255ead1e2 100644 --- a/include/envoy/common/exception.h +++ b/include/envoy/common/exception.h @@ -11,4 +11,4 @@ class EnvoyException : public std::runtime_error { public: EnvoyException(const std::string& message) : std::runtime_error(message) {} }; -} // Envoy +} // namespace Envoy diff --git a/include/envoy/common/optional.h b/include/envoy/common/optional.h index 922e2e3bec971..8deec8eaf52ba 100644 --- a/include/envoy/common/optional.h +++ b/include/envoy/common/optional.h @@ -58,4 +58,4 @@ template class Optional { T value_; bool valid_{}; }; -} // Envoy +} // namespace Envoy diff --git a/include/envoy/common/time.h b/include/envoy/common/time.h index d9fcf8b58d48c..fb09f1db76abc 100644 --- a/include/envoy/common/time.h +++ b/include/envoy/common/time.h @@ -39,4 +39,4 @@ class MonotonicTimeSource { */ virtual MonotonicTime currentTime() PURE; }; -} // Envoy +} // namespace Envoy diff --git a/include/envoy/event/deferred_deletable.h b/include/envoy/event/deferred_deletable.h index c05a8b8731e7d..f92137314aa28 100644 --- a/include/envoy/event/deferred_deletable.h +++ b/include/envoy/event/deferred_deletable.h @@ -17,5 +17,5 @@ class DeferredDeletable { typedef std::unique_ptr DeferredDeletablePtr; -} // Event -} // Envoy +} // namespace Event +} // namespace Envoy diff --git a/include/envoy/event/dispatcher.h b/include/envoy/event/dispatcher.h index 94086932ed262..c66815fbfc734 100644 --- a/include/envoy/event/dispatcher.h +++ b/include/envoy/event/dispatcher.h @@ -157,5 +157,5 @@ class Dispatcher { typedef std::unique_ptr DispatcherPtr; -} // Event -} // Envoy +} // namespace Event +} // namespace Envoy diff --git a/include/envoy/event/file_event.h b/include/envoy/event/file_event.h index cf58f8d8e4375..8c25a904e955d 100644 --- a/include/envoy/event/file_event.h +++ b/include/envoy/event/file_event.h @@ -49,5 +49,5 @@ class FileEvent { typedef std::unique_ptr FileEventPtr; -} // Event -} // Envoy +} // namespace Event +} // namespace Envoy diff --git a/include/envoy/event/signal.h b/include/envoy/event/signal.h index 6a378474b2516..4a2b4634c674b 100644 --- a/include/envoy/event/signal.h +++ b/include/envoy/event/signal.h @@ -21,5 +21,5 @@ class SignalEvent { typedef std::unique_ptr SignalEventPtr; -} // Event -} // Envoy +} // namespace Event +} // namespace Envoy diff --git a/include/envoy/event/timer.h b/include/envoy/event/timer.h index 7ab865c0864fe..8d90cb961094d 100644 --- a/include/envoy/event/timer.h +++ b/include/envoy/event/timer.h @@ -34,5 +34,5 @@ class Timer { typedef std::unique_ptr TimerPtr; -} // Event -} // Envoy +} // namespace Event +} // namespace Envoy diff --git a/include/envoy/filesystem/filesystem.h b/include/envoy/filesystem/filesystem.h index d3c0496a285c3..fd61d38d366ed 100644 --- a/include/envoy/filesystem/filesystem.h +++ b/include/envoy/filesystem/filesystem.h @@ -79,5 +79,5 @@ class Watcher { typedef std::unique_ptr WatcherPtr; -} // Filesystem -} // Envoy +} // namespace Filesystem +} // namespace Envoy diff --git a/include/envoy/grpc/async_client.h b/include/envoy/grpc/async_client.h index f80810321bd51..3621d947c8bd9 100644 --- a/include/envoy/grpc/async_client.h +++ b/include/envoy/grpc/async_client.h @@ -109,5 +109,5 @@ template class AsyncClient { const Optional& timeout) PURE; }; -} // Grpc -} // Envoy +} // namespace Grpc +} // namespace Envoy diff --git a/include/envoy/grpc/rpc_channel.h b/include/envoy/grpc/rpc_channel.h index 06d8258de9da4..830e352ece27b 100644 --- a/include/envoy/grpc/rpc_channel.h +++ b/include/envoy/grpc/rpc_channel.h @@ -75,5 +75,5 @@ class RpcChannelFactory { const Optional& timeout) PURE; }; -} // Grpc -} // Envoy +} // namespace Grpc +} // namespace Envoy diff --git a/include/envoy/grpc/status.h b/include/envoy/grpc/status.h index f8c95b520cfcf..da3b4b2b4fd97 100644 --- a/include/envoy/grpc/status.h +++ b/include/envoy/grpc/status.h @@ -47,5 +47,5 @@ class Status { }; }; -} // Grpc -} // Envoy +} // namespace Grpc +} // namespace Envoy diff --git a/include/envoy/http/access_log.h b/include/envoy/http/access_log.h index b2794524d1deb..79cc83a7736c6 100644 --- a/include/envoy/http/access_log.h +++ b/include/envoy/http/access_log.h @@ -166,6 +166,6 @@ class Formatter { typedef std::unique_ptr FormatterPtr; -} // AccessLog -} // Http -} // Envoy +} // namespace AccessLog +} // namespace Http +} // namespace Envoy diff --git a/include/envoy/http/async_client.h b/include/envoy/http/async_client.h index c8879f78cfb43..bc8f7ecc56dd0 100644 --- a/include/envoy/http/async_client.h +++ b/include/envoy/http/async_client.h @@ -156,5 +156,5 @@ class AsyncClient { typedef std::unique_ptr AsyncClientPtr; -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/include/envoy/http/codec.h b/include/envoy/http/codec.h index a1ced838c2075..4c0b53726ac61 100644 --- a/include/envoy/http/codec.h +++ b/include/envoy/http/codec.h @@ -264,5 +264,5 @@ class ClientConnection : public virtual Connection { typedef std::unique_ptr ClientConnectionPtr; -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/include/envoy/http/codes.h b/include/envoy/http/codes.h index 56f5e4a3a1deb..ad5eb787d3751 100644 --- a/include/envoy/http/codes.h +++ b/include/envoy/http/codes.h @@ -72,5 +72,5 @@ enum class Code { // clang-format on }; -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/include/envoy/http/conn_pool.h b/include/envoy/http/conn_pool.h index b9ee6511d3fdb..7a98035946b9e 100644 --- a/include/envoy/http/conn_pool.h +++ b/include/envoy/http/conn_pool.h @@ -99,6 +99,6 @@ class Instance : public Event::DeferredDeletable { typedef std::unique_ptr InstancePtr; -} // ConnectionPool -} // Http -} // Envoy +} // namespace ConnectionPool +} // namespace Http +} // namespace Envoy diff --git a/include/envoy/http/filter.h b/include/envoy/http/filter.h index b68818065c441..408adb3f8551c 100644 --- a/include/envoy/http/filter.h +++ b/include/envoy/http/filter.h @@ -385,5 +385,5 @@ class FilterChainFactory { virtual void createFilterChain(FilterChainFactoryCallbacks& callbacks) PURE; }; -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/include/envoy/http/header_map.h b/include/envoy/http/header_map.h index ac9cfc0d4466e..a2801e4e81562 100644 --- a/include/envoy/http/header_map.h +++ b/include/envoy/http/header_map.h @@ -321,5 +321,5 @@ class HeaderMap { typedef std::unique_ptr HeaderMapPtr; -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/include/envoy/http/message.h b/include/envoy/http/message.h index 100e662501535..167fcd6e492c6 100644 --- a/include/envoy/http/message.h +++ b/include/envoy/http/message.h @@ -46,5 +46,5 @@ class Message { typedef std::unique_ptr MessagePtr; -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/include/envoy/http/protocol.h b/include/envoy/http/protocol.h index 655c38ebb96b4..b205529647812 100644 --- a/include/envoy/http/protocol.h +++ b/include/envoy/http/protocol.h @@ -8,5 +8,5 @@ namespace Http { */ enum class Protocol { Http10, Http11, Http2 }; -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/include/envoy/init/init.h b/include/envoy/init/init.h index fe062c0d60630..1f6008dfeb570 100644 --- a/include/envoy/init/init.h +++ b/include/envoy/init/init.h @@ -36,5 +36,5 @@ class Manager { virtual void registerTarget(Target& target) PURE; }; -} // Init -} // Envoy +} // namespace Init +} // namespace Envoy diff --git a/include/envoy/json/json_object.h b/include/envoy/json/json_object.h index 57d24cf8d0fbf..26a9fb24358ec 100644 --- a/include/envoy/json/json_object.h +++ b/include/envoy/json/json_object.h @@ -160,5 +160,5 @@ class Object { virtual bool empty() const PURE; }; -} // Json -} // Envoy +} // namespace Json +} // namespace Envoy diff --git a/include/envoy/local_info/local_info.h b/include/envoy/local_info/local_info.h index c2c0fe9663b09..f365d9f9689fc 100644 --- a/include/envoy/local_info/local_info.h +++ b/include/envoy/local_info/local_info.h @@ -36,5 +36,5 @@ class LocalInfo { virtual const std::string& nodeName() const PURE; }; -} // LocalInfo -} // Envoy +} // namespace LocalInfo +} // namespace Envoy diff --git a/include/envoy/mongo/bson.h b/include/envoy/mongo/bson.h index cc97045432696..7ed9beb8529b8 100644 --- a/include/envoy/mongo/bson.h +++ b/include/envoy/mongo/bson.h @@ -114,5 +114,5 @@ class Document { virtual const std::list& values() const PURE; }; -} // Bson -} // Envoy +} // namespace Bson +} // namespace Envoy diff --git a/include/envoy/mongo/codec.h b/include/envoy/mongo/codec.h index 6100ad19d0a85..291c1be22adf6 100644 --- a/include/envoy/mongo/codec.h +++ b/include/envoy/mongo/codec.h @@ -185,5 +185,5 @@ class Encoder { virtual void encodeReply(const ReplyMessage& message) PURE; }; -} // Mongo -} // Envoy +} // namespace Mongo +} // namespace Envoy diff --git a/include/envoy/network/address.h b/include/envoy/network/address.h index f508129691c76..27292e10db596 100644 --- a/include/envoy/network/address.h +++ b/include/envoy/network/address.h @@ -139,6 +139,6 @@ class Instance { typedef std::shared_ptr InstanceConstSharedPtr; -} // Address -} // Network -} // Envoy +} // namespace Address +} // namespace Network +} // namespace Envoy diff --git a/include/envoy/network/connection.h b/include/envoy/network/connection.h index df931fa2a88e1..355cb7e395f3c 100644 --- a/include/envoy/network/connection.h +++ b/include/envoy/network/connection.h @@ -180,5 +180,5 @@ class ClientConnection : public virtual Connection { typedef std::unique_ptr ClientConnectionPtr; -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/include/envoy/network/connection_handler.h b/include/envoy/network/connection_handler.h index 5908437f52faa..354304baf2905 100644 --- a/include/envoy/network/connection_handler.h +++ b/include/envoy/network/connection_handler.h @@ -79,5 +79,5 @@ class ConnectionHandler { typedef std::unique_ptr ConnectionHandlerPtr; -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/include/envoy/network/dns.h b/include/envoy/network/dns.h index 3ffeb13a76018..f89cac1ef4617 100644 --- a/include/envoy/network/dns.h +++ b/include/envoy/network/dns.h @@ -54,5 +54,5 @@ class DnsResolver { typedef std::shared_ptr DnsResolverSharedPtr; -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/include/envoy/network/drain_decision.h b/include/envoy/network/drain_decision.h index 381243f729ed1..5c5b60a2aac81 100644 --- a/include/envoy/network/drain_decision.h +++ b/include/envoy/network/drain_decision.h @@ -16,5 +16,5 @@ class DrainDecision { virtual bool drainClose() PURE; }; -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/include/envoy/network/filter.h b/include/envoy/network/filter.h index 47d458ea1a75b..1114f77bdb4dc 100644 --- a/include/envoy/network/filter.h +++ b/include/envoy/network/filter.h @@ -163,5 +163,5 @@ class FilterChainFactory { virtual bool createFilterChain(Connection& connection) PURE; }; -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/include/envoy/network/listen_socket.h b/include/envoy/network/listen_socket.h index 588fadbd80c73..561ec64f0c28a 100644 --- a/include/envoy/network/listen_socket.h +++ b/include/envoy/network/listen_socket.h @@ -33,5 +33,5 @@ class ListenSocket { typedef std::unique_ptr ListenSocketPtr; -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/include/envoy/network/listener.h b/include/envoy/network/listener.h index 515b624ec93b9..be0cecdbdcb24 100644 --- a/include/envoy/network/listener.h +++ b/include/envoy/network/listener.h @@ -70,5 +70,5 @@ class CreateListenerException : public EnvoyException { CreateListenerException(const std::string& what) : EnvoyException(what) {} }; -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/include/envoy/ratelimit/ratelimit.h b/include/envoy/ratelimit/ratelimit.h index eac26644f674a..d9427d5fb9e1b 100644 --- a/include/envoy/ratelimit/ratelimit.h +++ b/include/envoy/ratelimit/ratelimit.h @@ -98,5 +98,5 @@ class ClientFactory { typedef std::unique_ptr ClientFactoryPtr; -} // RateLimit -} // Envoy +} // namespace RateLimit +} // namespace Envoy diff --git a/include/envoy/redis/codec.h b/include/envoy/redis/codec.h index b2a5dcae32a6c..ceff545afeef0 100644 --- a/include/envoy/redis/codec.h +++ b/include/envoy/redis/codec.h @@ -131,5 +131,5 @@ class ProtocolError : public EnvoyException { ProtocolError(const std::string& error) : EnvoyException(error) {} }; -} // Redis -} // Envoy +} // namespace Redis +} // namespace Envoy diff --git a/include/envoy/redis/command_splitter.h b/include/envoy/redis/command_splitter.h index 6e274d5cb14b0..8dd72d6fc64a4 100644 --- a/include/envoy/redis/command_splitter.h +++ b/include/envoy/redis/command_splitter.h @@ -57,6 +57,6 @@ class Instance { virtual SplitRequestPtr makeRequest(const RespValue& request, SplitCallbacks& callbacks) PURE; }; -} // CommandSplitter -} // Redis -} // Envoy +} // namespace CommandSplitter +} // namespace Redis +} // namespace Envoy diff --git a/include/envoy/redis/conn_pool.h b/include/envoy/redis/conn_pool.h index 38ba8a11839c5..429997fb11278 100644 --- a/include/envoy/redis/conn_pool.h +++ b/include/envoy/redis/conn_pool.h @@ -126,6 +126,6 @@ class Instance { typedef std::unique_ptr InstancePtr; -} // ConnPool -} // Redis -} // Envoy +} // namespace ConnPool +} // namespace Redis +} // namespace Envoy diff --git a/include/envoy/registry/registry.h b/include/envoy/registry/registry.h index 22f3ebf32c7f5..4839f12e94bdf 100644 --- a/include/envoy/registry/registry.h +++ b/include/envoy/registry/registry.h @@ -78,5 +78,5 @@ template class RegisterFactory { } }; -} // Registry -} // Envoy +} // namespace Registry +} // namespace Envoy diff --git a/include/envoy/router/rds.h b/include/envoy/router/rds.h index 9574fc5196c04..dd8d0d725b34b 100644 --- a/include/envoy/router/rds.h +++ b/include/envoy/router/rds.h @@ -25,5 +25,5 @@ class RouteConfigProvider { typedef std::unique_ptr RouteConfigProviderPtr; -} // Router -} // Envoy +} // namespace Router +} // namespace Envoy diff --git a/include/envoy/router/router.h b/include/envoy/router/router.h index d0bb03ba991f7..d47b4ac8954a3 100644 --- a/include/envoy/router/router.h +++ b/include/envoy/router/router.h @@ -322,5 +322,5 @@ class Config { typedef std::shared_ptr ConfigConstSharedPtr; -} // Router -} // Envoy +} // namespace Router +} // namespace Envoy diff --git a/include/envoy/router/router_ratelimit.h b/include/envoy/router/router_ratelimit.h index ec3f05e9afc80..819b099a01fed 100644 --- a/include/envoy/router/router_ratelimit.h +++ b/include/envoy/router/router_ratelimit.h @@ -87,5 +87,5 @@ class RateLimitPolicy { getApplicableRateLimit(uint64_t stage) const PURE; }; -} // Router -} // Envoy +} // namespace Router +} // namespace Envoy diff --git a/include/envoy/router/shadow_writer.h b/include/envoy/router/shadow_writer.h index bfe7e325ca182..9db8d2ba3eb6e 100644 --- a/include/envoy/router/shadow_writer.h +++ b/include/envoy/router/shadow_writer.h @@ -30,5 +30,5 @@ class ShadowWriter { typedef std::unique_ptr ShadowWriterPtr; -} // Router -} // Envoy +} // namespace Router +} // namespace Envoy diff --git a/include/envoy/runtime/runtime.h b/include/envoy/runtime/runtime.h index 9f6a719972593..c366fa9235f81 100644 --- a/include/envoy/runtime/runtime.h +++ b/include/envoy/runtime/runtime.h @@ -115,5 +115,5 @@ class Loader { typedef std::unique_ptr LoaderPtr; -} // Runtime -} // Envoy +} // namespace Runtime +} // namespace Envoy diff --git a/include/envoy/server/admin.h b/include/envoy/server/admin.h index 60800f5f2b325..956b5b76ff727 100644 --- a/include/envoy/server/admin.h +++ b/include/envoy/server/admin.h @@ -42,5 +42,5 @@ class Admin { virtual const Network::ListenSocket& socket() PURE; }; -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/include/envoy/server/configuration.h b/include/envoy/server/configuration.h index 87f4af05fe1e1..2d86379e7232c 100644 --- a/include/envoy/server/configuration.h +++ b/include/envoy/server/configuration.h @@ -156,6 +156,6 @@ class Initial { virtual Runtime* runtime() PURE; }; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/include/envoy/server/drain_manager.h b/include/envoy/server/drain_manager.h index 1b1a7691cb7c5..c28402347acb3 100644 --- a/include/envoy/server/drain_manager.h +++ b/include/envoy/server/drain_manager.h @@ -32,5 +32,5 @@ class DrainManager : public Network::DrainDecision { typedef std::unique_ptr DrainManagerPtr; -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/include/envoy/server/filter_config.h b/include/envoy/server/filter_config.h index 08d608961ed04..1f6ea104cec6b 100644 --- a/include/envoy/server/filter_config.h +++ b/include/envoy/server/filter_config.h @@ -201,6 +201,6 @@ class NamedHttpFilterConfigFactory { virtual HttpFilterType type() PURE; }; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/include/envoy/server/guarddog.h b/include/envoy/server/guarddog.h index 2bf4779c04e3e..bb09d37eaf847 100644 --- a/include/envoy/server/guarddog.h +++ b/include/envoy/server/guarddog.h @@ -41,5 +41,5 @@ class GuardDog { virtual void stopWatching(WatchDogSharedPtr wd) PURE; }; -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/include/envoy/server/hot_restart.h b/include/envoy/server/hot_restart.h index 9deede2760074..30abed36d9c39 100644 --- a/include/envoy/server/hot_restart.h +++ b/include/envoy/server/hot_restart.h @@ -80,5 +80,5 @@ class HotRestart { virtual std::string version() PURE; }; -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/include/envoy/server/instance.h b/include/envoy/server/instance.h index 49254a236295b..b922a6f2c757b 100644 --- a/include/envoy/server/instance.h +++ b/include/envoy/server/instance.h @@ -182,5 +182,5 @@ class Instance { virtual const LocalInfo::LocalInfo& localInfo() PURE; }; -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/include/envoy/server/listener_manager.h b/include/envoy/server/listener_manager.h index 6c72d8be3a9af..2c5a53ab118d0 100644 --- a/include/envoy/server/listener_manager.h +++ b/include/envoy/server/listener_manager.h @@ -153,5 +153,5 @@ class ListenerManager { virtual void stopWorkers() PURE; }; -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/include/envoy/server/options.h b/include/envoy/server/options.h index cd2d0f820bc23..3b22b4b797966 100644 --- a/include/envoy/server/options.h +++ b/include/envoy/server/options.h @@ -97,10 +97,10 @@ class Options { virtual Mode mode() const PURE; /** - * @return std::chrono::milliseconds the duration in msec between log flushes. - */ + * @return std::chrono::milliseconds the duration in msec between log flushes. + */ virtual std::chrono::milliseconds fileFlushIntervalMsec() PURE; }; -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/include/envoy/server/watchdog.h b/include/envoy/server/watchdog.h index b1fa57069ec88..4d8723a0e6d68 100644 --- a/include/envoy/server/watchdog.h +++ b/include/envoy/server/watchdog.h @@ -41,5 +41,5 @@ class WatchDog { typedef std::shared_ptr WatchDogSharedPtr; -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/include/envoy/server/worker.h b/include/envoy/server/worker.h index 2da0aaf9dd8bf..8d5a3c9e1165e 100644 --- a/include/envoy/server/worker.h +++ b/include/envoy/server/worker.h @@ -73,5 +73,5 @@ class WorkerFactory { virtual WorkerPtr createWorker() PURE; }; -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/include/envoy/ssl/connection.h b/include/envoy/ssl/connection.h index 9b7e3a9245997..fbe62d4293f69 100644 --- a/include/envoy/ssl/connection.h +++ b/include/envoy/ssl/connection.h @@ -44,5 +44,5 @@ class Connection { virtual std::string uriSanPeerCertificate() PURE; }; -} // Ssl -} // Envoy +} // namespace Ssl +} // namespace Envoy diff --git a/include/envoy/ssl/context.h b/include/envoy/ssl/context.h index 98d2e74f4f3d4..3c2353c241885 100644 --- a/include/envoy/ssl/context.h +++ b/include/envoy/ssl/context.h @@ -39,5 +39,5 @@ typedef std::unique_ptr ClientContextPtr; class ServerContext : public virtual Context {}; typedef std::unique_ptr ServerContextPtr; -} // SSL -} // Envoy +} // namespace Ssl +} // namespace Envoy diff --git a/include/envoy/ssl/context_config.h b/include/envoy/ssl/context_config.h index 593cf52341be3..ec0048b2bffda 100644 --- a/include/envoy/ssl/context_config.h +++ b/include/envoy/ssl/context_config.h @@ -70,5 +70,5 @@ class ContextConfig { virtual const std::string& serverNameIndication() const PURE; }; -} // Ssl -} // Envoy +} // namespace Ssl +} // namespace Envoy diff --git a/include/envoy/ssl/context_manager.h b/include/envoy/ssl/context_manager.h index c365b40b8c00c..fa4855a99cbfe 100644 --- a/include/envoy/ssl/context_manager.h +++ b/include/envoy/ssl/context_manager.h @@ -37,5 +37,5 @@ class ContextManager { virtual void iterateContexts(std::function callback) PURE; }; -} // Ssl -} // Envoy +} // namespace Ssl +} // namespace Envoy diff --git a/include/envoy/stats/stats.h b/include/envoy/stats/stats.h index 45c89650bbff7..13d7e2fad9e20 100644 --- a/include/envoy/stats/stats.h +++ b/include/envoy/stats/stats.h @@ -209,5 +209,5 @@ class StoreRoot : public Store { typedef std::unique_ptr StoreRootPtr; -} // Stats -} // Envoy +} // namespace Stats +} // namespace Envoy diff --git a/include/envoy/thread/thread.h b/include/envoy/thread/thread.h index 2e6dd717c7e52..9475ac8c97446 100644 --- a/include/envoy/thread/thread.h +++ b/include/envoy/thread/thread.h @@ -38,5 +38,5 @@ template class OptionalLockGuard { T* lock_; }; -} // Thread -} // Envoy +} // namespace Thread +} // namespace Envoy diff --git a/include/envoy/thread_local/thread_local.h b/include/envoy/thread_local/thread_local.h index 2aeb95c87b541..cd6935349a204 100644 --- a/include/envoy/thread_local/thread_local.h +++ b/include/envoy/thread_local/thread_local.h @@ -83,5 +83,5 @@ class Instance { virtual void shutdownThread() PURE; }; -} // ThreadLocal -} // Envoy +} // namespace ThreadLocal +} // namespace Envoy diff --git a/include/envoy/tracing/context.h b/include/envoy/tracing/context.h index 1b187c92b78ed..4a05e16059ade 100644 --- a/include/envoy/tracing/context.h +++ b/include/envoy/tracing/context.h @@ -12,5 +12,5 @@ struct TransportContext { static const TransportContext EMPTY_CONTEXT = {"", ""}; -} // Tracing -} // Envoy +} // namespace Tracing +} // namespace Envoy diff --git a/include/envoy/tracing/http_tracer.h b/include/envoy/tracing/http_tracer.h index 109debdf51453..8e090ef554f2d 100644 --- a/include/envoy/tracing/http_tracer.h +++ b/include/envoy/tracing/http_tracer.h @@ -115,5 +115,5 @@ class HttpTracer { typedef std::unique_ptr HttpTracerPtr; -} // Tracing -} // Envoy +} // namespace Tracing +} // namespace Envoy diff --git a/include/envoy/upstream/cluster_manager.h b/include/envoy/upstream/cluster_manager.h index f0dabaac6518a..e15e528190e7a 100644 --- a/include/envoy/upstream/cluster_manager.h +++ b/include/envoy/upstream/cluster_manager.h @@ -174,5 +174,5 @@ class ClusterManagerFactory { virtual CdsApiPtr createCds(const Json::Object& config, ClusterManager& cm) PURE; }; -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/include/envoy/upstream/health_checker.h b/include/envoy/upstream/health_checker.h index 260adcb5408bb..ff63cee42225c 100644 --- a/include/envoy/upstream/health_checker.h +++ b/include/envoy/upstream/health_checker.h @@ -38,5 +38,5 @@ class HealthChecker { typedef std::unique_ptr HealthCheckerPtr; -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/include/envoy/upstream/host_description.h b/include/envoy/upstream/host_description.h index db4907bebdcbb..7de0a3b1bf584 100644 --- a/include/envoy/upstream/host_description.h +++ b/include/envoy/upstream/host_description.h @@ -79,4 +79,4 @@ class HostDescription { typedef std::shared_ptr HostDescriptionConstSharedPtr; } // Upstream -} // Envoy +} // namespace Envoy diff --git a/include/envoy/upstream/load_balancer.h b/include/envoy/upstream/load_balancer.h index 3c47c97dd7d42..24c79a10e39f2 100644 --- a/include/envoy/upstream/load_balancer.h +++ b/include/envoy/upstream/load_balancer.h @@ -41,5 +41,5 @@ class LoadBalancer { typedef std::unique_ptr LoadBalancerPtr; -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/include/envoy/upstream/load_balancer_type.h b/include/envoy/upstream/load_balancer_type.h index d6fd26565776e..2c5628310533f 100644 --- a/include/envoy/upstream/load_balancer_type.h +++ b/include/envoy/upstream/load_balancer_type.h @@ -8,5 +8,5 @@ namespace Upstream { */ enum class LoadBalancerType { RoundRobin, LeastRequest, Random, RingHash }; -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/include/envoy/upstream/outlier_detection.h b/include/envoy/upstream/outlier_detection.h index 169c7b6325a09..895ab0a9878bd 100644 --- a/include/envoy/upstream/outlier_detection.h +++ b/include/envoy/upstream/outlier_detection.h @@ -131,6 +131,6 @@ class EventLogger { typedef std::shared_ptr EventLoggerSharedPtr; -} // Outlier -} // Upstream -} // Envoy +} // namespace Outlier +} // namespace Upstream +} // namespace Envoy diff --git a/include/envoy/upstream/resource_manager.h b/include/envoy/upstream/resource_manager.h index 9d8cfa02e74ba..839ddfab34d76 100644 --- a/include/envoy/upstream/resource_manager.h +++ b/include/envoy/upstream/resource_manager.h @@ -74,5 +74,5 @@ class ResourceManager { virtual Resource& retries() PURE; }; -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/include/envoy/upstream/thread_local_cluster.h b/include/envoy/upstream/thread_local_cluster.h index c9f9d3d34014c..50d7e13f03982 100644 --- a/include/envoy/upstream/thread_local_cluster.h +++ b/include/envoy/upstream/thread_local_cluster.h @@ -31,5 +31,5 @@ class ThreadLocalCluster { virtual LoadBalancer& loadBalancer() PURE; }; -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/include/envoy/upstream/upstream.h b/include/envoy/upstream/upstream.h index f40d11f401d4d..41f489711e64f 100644 --- a/include/envoy/upstream/upstream.h +++ b/include/envoy/upstream/upstream.h @@ -112,7 +112,8 @@ class HostSet { * @param hosts_removed supplies the removed hosts, if any. */ typedef std::function& hosts_added, - const std::vector& hosts_removed)> MemberUpdateCb; + const std::vector& hosts_removed)> + MemberUpdateCb; /** * Install a callback that will be invoked when the cluster membership changes. @@ -341,5 +342,5 @@ class Cluster : public virtual HostSet { typedef std::unique_ptr ClusterPtr; -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/source/common/access_log/access_log_manager_impl.cc b/source/common/access_log/access_log_manager_impl.cc index 951596820a9f6..56933387b348b 100644 --- a/source/common/access_log/access_log_manager_impl.cc +++ b/source/common/access_log/access_log_manager_impl.cc @@ -20,5 +20,5 @@ Filesystem::FileSharedPtr AccessLogManagerImpl::createAccessLog(const std::strin return access_logs_[file_name]; } -} // AccessLog -} // Envoy +} // namespace AccessLog +} // namespace Envoy diff --git a/source/common/access_log/access_log_manager_impl.h b/source/common/access_log/access_log_manager_impl.h index a411bd818ee62..3c6c0208a2cdf 100644 --- a/source/common/access_log/access_log_manager_impl.h +++ b/source/common/access_log/access_log_manager_impl.h @@ -27,5 +27,5 @@ class AccessLogManagerImpl : public AccessLogManager { std::unordered_map access_logs_; }; -} // AccessLog -} // Envoy +} // namespace AccessLog +} // namespace Envoy diff --git a/source/common/api/api_impl.cc b/source/common/api/api_impl.cc index 5589fb5926414..8934463697dac 100644 --- a/source/common/api/api_impl.cc +++ b/source/common/api/api_impl.cc @@ -27,5 +27,5 @@ bool Impl::fileExists(const std::string& path) { return Filesystem::fileExists(p std::string Impl::fileReadToEnd(const std::string& path) { return Filesystem::fileReadToEnd(path); } -} // Api -} // Envoy +} // namespace Api +} // namespace Envoy diff --git a/source/common/api/api_impl.h b/source/common/api/api_impl.h index 5ca418618d8e5..e2544dd245181 100644 --- a/source/common/api/api_impl.h +++ b/source/common/api/api_impl.h @@ -29,5 +29,5 @@ class Impl : public Api::Api { std::chrono::milliseconds file_flush_interval_msec_; }; -} // Api -} // Envoy +} // namespace Api +} // namespace Envoy diff --git a/source/common/buffer/buffer_impl.cc b/source/common/buffer/buffer_impl.cc index 321c293c06372..013654637925c 100644 --- a/source/common/buffer/buffer_impl.cc +++ b/source/common/buffer/buffer_impl.cc @@ -110,5 +110,5 @@ OwnedImpl::OwnedImpl(const Instance& data) : OwnedImpl() { add(data); } OwnedImpl::OwnedImpl(const void* data, uint64_t size) : OwnedImpl() { add(data, size); } -} // Buffer -} // Envoy +} // namespace Buffer +} // namespace Envoy diff --git a/source/common/buffer/buffer_impl.h b/source/common/buffer/buffer_impl.h index d4c5f4780d52d..36c308b1dcf50 100644 --- a/source/common/buffer/buffer_impl.h +++ b/source/common/buffer/buffer_impl.h @@ -40,5 +40,5 @@ class OwnedImpl : public Instance { Event::Libevent::BufferPtr buffer_; }; -} // Buffer -} // Envoy +} // namespace Buffer +} // namespace Envoy diff --git a/source/common/buffer/zero_copy_input_stream_impl.cc b/source/common/buffer/zero_copy_input_stream_impl.cc index 9183ca502bd30..f6030f69eec72 100644 --- a/source/common/buffer/zero_copy_input_stream_impl.cc +++ b/source/common/buffer/zero_copy_input_stream_impl.cc @@ -58,5 +58,5 @@ void ZeroCopyInputStreamImpl::BackUp(int count) { position_ -= count; byte_count_ -= count; } -} -} +} // namespace Buffer +} // namespace Envoy diff --git a/source/common/common/base64.cc b/source/common/common/base64.cc index e4feff167850a..60cba5c4fcaf7 100644 --- a/source/common/common/base64.cc +++ b/source/common/common/base64.cc @@ -151,4 +151,4 @@ std::string Base64::encode(const char* input, uint64_t length) { return ret; } -} // Envoy +} // namespace Envoy diff --git a/source/common/common/base64.h b/source/common/common/base64.h index 6d29f5aff8bc2..73b487160619a 100644 --- a/source/common/common/base64.h +++ b/source/common/common/base64.h @@ -43,4 +43,4 @@ class Base64 { */ static void encodeLast(uint64_t pos, uint8_t last_char, std::string& ret); }; -} // Envoy +} // namespace Envoy diff --git a/source/common/common/c_smart_ptr.h b/source/common/common/c_smart_ptr.h index 8709e91d340d4..9940bfee673ec 100644 --- a/source/common/common/c_smart_ptr.h +++ b/source/common/common/c_smart_ptr.h @@ -11,4 +11,4 @@ template class CSmartPtr : public std::unique_ptr CSmartPtr() : std::unique_ptr(nullptr, deleter) {} CSmartPtr(T* object) : std::unique_ptr(object, deleter) {} }; -} // Envoy +} // namespace Envoy diff --git a/source/common/common/empty_string.h b/source/common/common/empty_string.h index 572947eb44fae..b9355eae9ab39 100644 --- a/source/common/common/empty_string.h +++ b/source/common/common/empty_string.h @@ -4,4 +4,4 @@ namespace Envoy { static const std::string EMPTY_STRING = ""; -} // Envoy +} // namespace Envoy diff --git a/source/common/common/enum_to_int.h b/source/common/common/enum_to_int.h index 9a0bd9c49185c..a9c77b59419ee 100644 --- a/source/common/common/enum_to_int.h +++ b/source/common/common/enum_to_int.h @@ -7,4 +7,4 @@ namespace Envoy { * Convert an int based enum to an int. */ template uint32_t enumToInt(T val) { return static_cast(val); } -} // Envoy +} // namespace Envoy diff --git a/source/common/common/hex.cc b/source/common/common/hex.cc index 6165f2d927091..c52cc15cdc55a 100644 --- a/source/common/common/hex.cc +++ b/source/common/common/hex.cc @@ -61,4 +61,4 @@ std::string Hex::uint64ToHex(uint64_t value) { return encode(&data[0], data.size()); } -} // Envoy +} // namespace Envoy diff --git a/source/common/common/hex.h b/source/common/common/hex.h index 2c6ab1a2f8c80..328125d8e9c11 100644 --- a/source/common/common/hex.h +++ b/source/common/common/hex.h @@ -40,4 +40,4 @@ class Hex final { */ static std::string uint64ToHex(uint64_t value); }; -} // Envoy +} // namespace Envoy diff --git a/source/common/common/linked_object.h b/source/common/common/linked_object.h index ec8034e3515e5..b2ed96bbdbe53 100644 --- a/source/common/common/linked_object.h +++ b/source/common/common/linked_object.h @@ -83,4 +83,4 @@ template class LinkedObject { bool inserted_; // iterators do not have any "invalid" value so we need this boolean for sanity // checking. }; -} // Envoy +} // namespace Envoy diff --git a/source/common/common/logger.cc b/source/common/common/logger.cc index 8f2110fb64cff..9d0ab9ab01160 100644 --- a/source/common/common/logger.cc +++ b/source/common/common/logger.cc @@ -42,4 +42,4 @@ void Registry::initialize(uint64_t log_level, Thread::BasicLockable& lock) { } } // Logger -} // Envoy +} // namespace Envoy diff --git a/source/common/common/logger.h b/source/common/common/logger.h index 7d02be27fc981..655ee2c4ffc2d 100644 --- a/source/common/common/logger.h +++ b/source/common/common/logger.h @@ -231,4 +231,4 @@ template class Loggable { #define stream_log_info(FORMAT, STREAM, ...) stream_log(log(), info, FORMAT, STREAM, ##__VA_ARGS__) -} // Envoy +} // namespace Envoy diff --git a/source/common/common/non_copyable.h b/source/common/common/non_copyable.h index dfc74027eba81..7c394c41de186 100644 --- a/source/common/common/non_copyable.h +++ b/source/common/common/non_copyable.h @@ -12,4 +12,4 @@ class NonCopyable { NonCopyable(const NonCopyable&); NonCopyable& operator=(const NonCopyable&); }; -} // Envoy +} // namespace Envoy diff --git a/source/common/common/singleton.h b/source/common/common/singleton.h index 3bf52a06c0f8a..99c29f67f0a5a 100644 --- a/source/common/common/singleton.h +++ b/source/common/common/singleton.h @@ -17,4 +17,4 @@ template class ConstSingleton { }; // TODO(htuch): Add a mutable Singleton if there is a need for this. -} // Envoy +} // namespace Envoy diff --git a/source/common/common/stl_helpers.h b/source/common/common/stl_helpers.h index ecdfad6398f6d..5478f89a8658a 100644 --- a/source/common/common/stl_helpers.h +++ b/source/common/common/stl_helpers.h @@ -5,7 +5,8 @@ namespace Envoy { * See if a reference exists within a container of std::reference_wrappers. */ template bool containsReference(const Container& c, const T& t) { - return std::find_if(c.begin(), c.end(), [&](std::reference_wrapper e) - -> bool { return &e.get() == &t; }) != c.end(); + return std::find_if(c.begin(), c.end(), [&](std::reference_wrapper e) -> bool { + return &e.get() == &t; + }) != c.end(); } -} // Envoy +} // namespace Envoy diff --git a/source/common/common/thread.cc b/source/common/common/thread.cc index 8d1ee0d6011eb..719381c981a5a 100644 --- a/source/common/common/thread.cc +++ b/source/common/common/thread.cc @@ -11,10 +11,12 @@ namespace Envoy { namespace Thread { Thread::Thread(std::function thread_routine) : thread_routine_(thread_routine) { - int rc = pthread_create(&thread_id_, nullptr, [](void* arg) -> void* { - static_cast(arg)->thread_routine_(); - return nullptr; - }, this); + int rc = pthread_create(&thread_id_, nullptr, + [](void* arg) -> void* { + static_cast(arg)->thread_routine_(); + return nullptr; + }, + this); RELEASE_ASSERT(rc == 0); UNREFERENCED_PARAMETER(rc); } @@ -27,5 +29,5 @@ void Thread::join() { UNREFERENCED_PARAMETER(rc); } -} // Thread -} // Envoy +} // namespace Thread +} // namespace Envoy diff --git a/source/common/common/thread.h b/source/common/common/thread.h index 82f676ba0a3f9..42542a50f9a63 100644 --- a/source/common/common/thread.h +++ b/source/common/common/thread.h @@ -47,5 +47,5 @@ class MutexBasicLockable : public BasicLockable { std::mutex mutex_; }; -} // Thread -} // Envoy +} // namespace Thread +} // namespace Envoy diff --git a/source/common/common/to_lower_table.cc b/source/common/common/to_lower_table.cc index 94aa29840e30c..e9f194924b54c 100644 --- a/source/common/common/to_lower_table.cc +++ b/source/common/common/to_lower_table.cc @@ -15,4 +15,4 @@ void ToLowerTable::toLowerCase(char* buffer, uint32_t size) const { buffer[i] = table_[static_cast(buffer[i])]; } } -} // Envoy +} // namespace Envoy diff --git a/source/common/common/to_lower_table.h b/source/common/common/to_lower_table.h index a62c124b9ebeb..a5b05fd006dc8 100644 --- a/source/common/common/to_lower_table.h +++ b/source/common/common/to_lower_table.h @@ -27,4 +27,4 @@ class ToLowerTable { private: std::array table_; }; -} // Envoy +} // namespace Envoy diff --git a/source/common/common/utility.cc b/source/common/common/utility.cc index 92cc7baee9abc..c1f737355f5db 100644 --- a/source/common/common/utility.cc +++ b/source/common/common/utility.cc @@ -190,4 +190,4 @@ bool StringUtil::startsWith(const char* source, const std::string& start, bool c return strncasecmp(source, start.c_str(), start.size()) == 0; } } -} // Envoy +} // namespace Envoy diff --git a/source/common/common/utility.h b/source/common/common/utility.h index e06ff3ddc0975..81eda65d80750 100644 --- a/source/common/common/utility.h +++ b/source/common/common/utility.h @@ -172,4 +172,4 @@ class StringUtil { */ static bool startsWith(const char* source, const std::string& start, bool case_sensitive = true); }; -} // Envoy +} // namespace Envoy diff --git a/source/common/common/version.cc b/source/common/common/version.cc index 2d112d1fda919..28d1be754831e 100644 --- a/source/common/common/version.cc +++ b/source/common/common/version.cc @@ -25,6 +25,6 @@ std::string VersionInfo::version() { #else "DEBUG" #endif - ); + ); } -} // Envoy +} // namespace Envoy diff --git a/source/common/common/version.h b/source/common/common/version.h index d864612416fa6..b2d4df551c530 100644 --- a/source/common/common/version.h +++ b/source/common/common/version.h @@ -15,4 +15,4 @@ class VersionInfo { // Repository information and build type. static std::string version(); }; -} // Envoy +} // namespace Envoy diff --git a/source/common/config/grpc_subscription_impl.h b/source/common/config/grpc_subscription_impl.h index 93b2b32b35591..63509c6751915 100644 --- a/source/common/config/grpc_subscription_impl.h +++ b/source/common/config/grpc_subscription_impl.h @@ -19,17 +19,19 @@ class GrpcSubscriptionImpl : public Config::Subscription, const std::string& remote_cluster_name, Event::Dispatcher& dispatcher, const google::protobuf::MethodDescriptor& service_method) : GrpcSubscriptionImpl( - node, std::unique_ptr>( - new Grpc::AsyncClientImpl( - cm, remote_cluster_name)), + node, + std::unique_ptr>( + new Grpc::AsyncClientImpl(cm, + remote_cluster_name)), dispatcher, service_method) {} GrpcSubscriptionImpl( const envoy::api::v2::Node& node, - std::unique_ptr> async_client, + std::unique_ptr< + Grpc::AsyncClient> + async_client, Event::Dispatcher& dispatcher, const google::protobuf::MethodDescriptor& service_method) : async_client_(std::move(async_client)), service_method_(service_method), retry_timer_(dispatcher.createTimer([this]() -> void { establishNewStream(); })) { @@ -112,8 +114,9 @@ class GrpcSubscriptionImpl : public Config::Subscription, const uint32_t RETRY_DELAY_MS = 5000; private: - std::unique_ptr> async_client_; + std::unique_ptr< + Grpc::AsyncClient> + async_client_; const google::protobuf::MethodDescriptor& service_method_; Event::TimerPtr retry_timer_; google::protobuf::RepeatedPtrField resources_; diff --git a/source/common/config/subscription_factory.h b/source/common/config/subscription_factory.h index 1d1823c022e4d..9e24bf53f6037 100644 --- a/source/common/config/subscription_factory.h +++ b/source/common/config/subscription_factory.h @@ -75,5 +75,5 @@ class SubscriptionFactory { } }; -} // Config -} // Envoy +} // namespace Config +} // namespace Envoy diff --git a/source/common/config/utility.h b/source/common/config/utility.h index 591e7447e9ec0..97ad6bd5226e5 100644 --- a/source/common/config/utility.h +++ b/source/common/config/utility.h @@ -51,5 +51,5 @@ class Utility { envoy::api::v2::ConfigSource& eds_config); }; -} // Config -} // Envoy +} // namespace Config +} // namespace Envoy diff --git a/source/common/dynamo/dynamo_filter.cc b/source/common/dynamo/dynamo_filter.cc index 7af351e1e6c8a..6385b900f0a04 100644 --- a/source/common/dynamo/dynamo_filter.cc +++ b/source/common/dynamo/dynamo_filter.cc @@ -172,10 +172,14 @@ void DynamoFilter::chargeStatsPerEntity(const std::string& entity, const std::st Http::CodeUtility::groupStringForResponseCode(static_cast(status)); scope_.counter(fmt::format("{}{}.{}.upstream_rq_total", stat_prefix_, entity_type, entity)).inc(); - scope_.counter(fmt::format("{}{}.{}.upstream_rq_total_{}", stat_prefix_, entity_type, entity, - group_string)).inc(); - scope_.counter(fmt::format("{}{}.{}.upstream_rq_total_{}", stat_prefix_, entity_type, entity, - std::to_string(status))).inc(); + scope_ + .counter(fmt::format("{}{}.{}.upstream_rq_total_{}", stat_prefix_, entity_type, entity, + group_string)) + .inc(); + scope_ + .counter(fmt::format("{}{}.{}.upstream_rq_total_{}", stat_prefix_, entity_type, entity, + std::to_string(status))) + .inc(); scope_.deliverTimingToSinks( fmt::format("{}{}.{}.upstream_rq_time", stat_prefix_, entity_type, entity), latency); @@ -192,8 +196,10 @@ void DynamoFilter::chargeUnProcessedKeysStats(const Json::Object& json_body) { // complete apart of the batch operation. Only the table names will be logged for errors. std::vector unprocessed_tables = RequestParser::parseBatchUnProcessedKeys(json_body); for (const std::string& unprocessed_table : unprocessed_tables) { - scope_.counter(fmt::format("{}error.{}.BatchFailureUnprocessedKeys", stat_prefix_, - unprocessed_table)).inc(); + scope_ + .counter( + fmt::format("{}error.{}.BatchFailureUnprocessedKeys", stat_prefix_, unprocessed_table)) + .inc(); } } @@ -204,8 +210,10 @@ void DynamoFilter::chargeFailureSpecificStats(const Json::Object& json_body) { if (table_descriptor_.table_name.empty()) { scope_.counter(fmt::format("{}error.no_table.{}", stat_prefix_, error_type)).inc(); } else { - scope_.counter(fmt::format("{}error.{}.{}", stat_prefix_, table_descriptor_.table_name, - error_type)).inc(); + scope_ + .counter( + fmt::format("{}error.{}.{}", stat_prefix_, table_descriptor_.table_name, error_type)) + .inc(); } } else { scope_.counter(fmt::format("{}empty_response_body", stat_prefix_)).inc(); @@ -226,5 +234,5 @@ void DynamoFilter::chargeTablePartitionIdStats(const Json::Object& json_body) { } } -} // Dynamo -} // Envoy +} // namespace Dynamo +} // namespace Envoy diff --git a/source/common/dynamo/dynamo_filter.h b/source/common/dynamo/dynamo_filter.h index 9ac395d6503f2..b827fbc402695 100644 --- a/source/common/dynamo/dynamo_filter.h +++ b/source/common/dynamo/dynamo_filter.h @@ -70,5 +70,5 @@ class DynamoFilter : public Http::StreamFilter { Http::StreamEncoderFilterCallbacks* encoder_callbacks_{}; }; -} // Dynamo -} // Envoy +} // namespace Dynamo +} // namespace Envoy diff --git a/source/common/dynamo/dynamo_request_parser.cc b/source/common/dynamo/dynamo_request_parser.cc index 7929749f9ecf2..614b35815bd86 100644 --- a/source/common/dynamo/dynamo_request_parser.cc +++ b/source/common/dynamo/dynamo_request_parser.cc @@ -142,5 +142,5 @@ RequestParser::parsePartitions(const Json::Object& json_data) { return partition_descriptors; } -} // Dynamo -} // Envoy +} // namespace Dynamo +} // namespace Envoy diff --git a/source/common/dynamo/dynamo_request_parser.h b/source/common/dynamo/dynamo_request_parser.h index d012a950d8f4e..1066d89f7ac3e 100644 --- a/source/common/dynamo/dynamo_request_parser.h +++ b/source/common/dynamo/dynamo_request_parser.h @@ -100,5 +100,5 @@ class RequestParser { RequestParser() {} }; -} // Dynamo -} // Envoy +} // namespace Dynamo +} // namespace Envoy diff --git a/source/common/dynamo/dynamo_utility.cc b/source/common/dynamo/dynamo_utility.cc index 9486f136a124f..e2a89e22e4336 100644 --- a/source/common/dynamo/dynamo_utility.cc +++ b/source/common/dynamo/dynamo_utility.cc @@ -29,5 +29,5 @@ std::string Utility::buildPartitionStatString(const std::string& stat_prefix, return fmt::format("{}{}", stats_table_prefix, stats_partition_postfix); } -} // Dynamo -} // Envoy +} // namespace Dynamo +} // namespace Envoy diff --git a/source/common/dynamo/dynamo_utility.h b/source/common/dynamo/dynamo_utility.h index e49d2c6c6789c..dfb120bb91371 100644 --- a/source/common/dynamo/dynamo_utility.h +++ b/source/common/dynamo/dynamo_utility.h @@ -24,5 +24,5 @@ class Utility { const std::string& partition_id); }; -} // Dynamo -} // Envoy +} // namespace Dynamo +} // namespace Envoy diff --git a/source/common/event/dispatched_thread.cc b/source/common/event/dispatched_thread.cc index 564eca4be0607..c9c7c51d30ad6 100644 --- a/source/common/event/dispatched_thread.cc +++ b/source/common/event/dispatched_thread.cc @@ -36,5 +36,5 @@ void DispatchedThreadImpl::threadRoutine(Server::GuardDog& guard_dog) { dispatcher_.reset(); } -} // Event -} // Envoy +} // namespace Event +} // namespace Envoy diff --git a/source/common/event/dispatched_thread.h b/source/common/event/dispatched_thread.h index 186b254ac33e7..01be986d70cfb 100644 --- a/source/common/event/dispatched_thread.h +++ b/source/common/event/dispatched_thread.h @@ -61,5 +61,5 @@ class DispatchedThreadImpl : Logger::Loggable { Thread::ThreadPtr thread_; }; -} // Event -} // Envoy +} // namespace Event +} // namespace Envoy diff --git a/source/common/event/dispatcher_impl.cc b/source/common/event/dispatcher_impl.cc index d5aba5f69767e..8641a52935fa3 100644 --- a/source/common/event/dispatcher_impl.cc +++ b/source/common/event/dispatcher_impl.cc @@ -157,5 +157,5 @@ void DispatcherImpl::runPostCallbacks() { } } -} // Event -} // Envoy +} // namespace Event +} // namespace Envoy diff --git a/source/common/event/dispatcher_impl.h b/source/common/event/dispatcher_impl.h index 44c0a35665d48..7c5a532911105 100644 --- a/source/common/event/dispatcher_impl.h +++ b/source/common/event/dispatcher_impl.h @@ -70,5 +70,5 @@ class DispatcherImpl : Logger::Loggable, public Dispatcher { bool deferred_deleting_{}; }; -} // Event -} // Envoy +} // namespace Event +} // namespace Envoy diff --git a/source/common/event/event_impl_base.cc b/source/common/event/event_impl_base.cc index 56125bd1c2a9a..c14eb1874bc12 100644 --- a/source/common/event/event_impl_base.cc +++ b/source/common/event/event_impl_base.cc @@ -10,5 +10,5 @@ ImplBase::~ImplBase() { event_del(&raw_event_); } -} // Event -} // Envoy +} // namespace Event +} // namespace Envoy diff --git a/source/common/event/event_impl_base.h b/source/common/event/event_impl_base.h index 8643d7f78be69..1b5a341cb3889 100644 --- a/source/common/event/event_impl_base.h +++ b/source/common/event/event_impl_base.h @@ -16,5 +16,5 @@ class ImplBase { event raw_event_; }; -} // Event -} // Envoy +} // namespace Event +} // namespace Envoy diff --git a/source/common/event/file_event_impl.cc b/source/common/event/file_event_impl.cc index 5e5ba81f83724..bc1cf9ad5ab4b 100644 --- a/source/common/event/file_event_impl.cc +++ b/source/common/event/file_event_impl.cc @@ -68,5 +68,5 @@ void FileEventImpl::setEnabled(uint32_t events) { event_add(&raw_event_, nullptr); } -} // Event -} // Envoy +} // namespace Event +} // namespace Envoy diff --git a/source/common/event/file_event_impl.h b/source/common/event/file_event_impl.h index b31865e7d4ec5..feac017b79b92 100644 --- a/source/common/event/file_event_impl.h +++ b/source/common/event/file_event_impl.h @@ -32,5 +32,5 @@ class FileEventImpl : public FileEvent, ImplBase { FileTriggerType trigger_; }; -} // Event -} // Envoy +} // namespace Event +} // namespace Envoy diff --git a/source/common/event/libevent.cc b/source/common/event/libevent.cc index 7703e9a186d80..fb206ce8bee80 100644 --- a/source/common/event/libevent.cc +++ b/source/common/event/libevent.cc @@ -17,6 +17,6 @@ void Global::initialize() { signal(SIGPIPE, SIG_IGN); } -} // Libevent -} // Event -} // Envoy +} // namespace Libevent +} // namespace Event +} // namespace Envoy diff --git a/source/common/event/libevent.h b/source/common/event/libevent.h index 8dd27ac9c4dfa..6e7d68216ee90 100644 --- a/source/common/event/libevent.h +++ b/source/common/event/libevent.h @@ -42,6 +42,6 @@ typedef CSmartPtr BufferPtr; typedef CSmartPtr BufferEventPtr; typedef CSmartPtr ListenerPtr; -} // Libevent -} // Event -} // Envoy +} // namespace Libevent +} // namespace Event +} // namespace Envoy diff --git a/source/common/event/signal_impl.cc b/source/common/event/signal_impl.cc index 4d6de593ec3a8..bfd103f73e9e3 100644 --- a/source/common/event/signal_impl.cc +++ b/source/common/event/signal_impl.cc @@ -9,12 +9,12 @@ namespace Event { SignalEventImpl::SignalEventImpl(DispatcherImpl& dispatcher, int signal_num, SignalCb cb) : cb_(cb) { - evsignal_assign(&raw_event_, &dispatcher.base(), - signal_num, [](evutil_socket_t, short, void* arg) -> void { - static_cast(arg)->cb_(); - }, this); + evsignal_assign( + &raw_event_, &dispatcher.base(), signal_num, + [](evutil_socket_t, short, void* arg) -> void { static_cast(arg)->cb_(); }, + this); evsignal_add(&raw_event_, nullptr); } -} // Event -} // Envoy +} // namespace Event +} // namespace Envoy diff --git a/source/common/event/signal_impl.h b/source/common/event/signal_impl.h index 6b18291346ddb..2e358834b5f31 100644 --- a/source/common/event/signal_impl.h +++ b/source/common/event/signal_impl.h @@ -19,5 +19,5 @@ class SignalEventImpl : public SignalEvent, ImplBase { SignalCb cb_; }; -} // Event -} // Envoy +} // namespace Event +} // namespace Envoy diff --git a/source/common/event/timer_impl.cc b/source/common/event/timer_impl.cc index b98bcd312eb2b..500c42edea6d9 100644 --- a/source/common/event/timer_impl.cc +++ b/source/common/event/timer_impl.cc @@ -12,9 +12,9 @@ namespace Event { TimerImpl::TimerImpl(DispatcherImpl& dispatcher, TimerCb cb) : cb_(cb) { ASSERT(cb_); - evtimer_assign(&raw_event_, &dispatcher.base(), [](evutil_socket_t, short, void* arg) -> void { - static_cast(arg)->cb_(); - }, this); + evtimer_assign( + &raw_event_, &dispatcher.base(), + [](evutil_socket_t, short, void* arg) -> void { static_cast(arg)->cb_(); }, this); } void TimerImpl::disableTimer() { event_del(&raw_event_); } @@ -31,5 +31,5 @@ void TimerImpl::enableTimer(const std::chrono::milliseconds& d) { } } -} // Event -} // Envoy +} // namespace Event +} // namespace Envoy diff --git a/source/common/event/timer_impl.h b/source/common/event/timer_impl.h index 3ec95c7585bbb..a55580653f518 100644 --- a/source/common/event/timer_impl.h +++ b/source/common/event/timer_impl.h @@ -25,5 +25,5 @@ class TimerImpl : public Timer, ImplBase { TimerCb cb_; }; -} // Event -} // Envoy +} // namespace Event +} // namespace Envoy diff --git a/source/common/filesystem/filesystem_impl.cc b/source/common/filesystem/filesystem_impl.cc index 6c8a77569ab32..96650253baa80 100644 --- a/source/common/filesystem/filesystem_impl.cc +++ b/source/common/filesystem/filesystem_impl.cc @@ -194,5 +194,5 @@ void FileImpl::createFlushStructures() { flush_timer_->enableTimer(flush_interval_msec_); } -} // Filesystem -} // Envoy +} // namespace Filesystem +} // namespace Envoy diff --git a/source/common/filesystem/filesystem_impl.h b/source/common/filesystem/filesystem_impl.h index 15e591fb2f4fa..9485bbe75c0b6 100644 --- a/source/common/filesystem/filesystem_impl.h +++ b/source/common/filesystem/filesystem_impl.h @@ -117,5 +117,5 @@ class FileImpl : public File { FileSystemStats stats_; }; -} // Filesystem +} // namespace Filesystem } // Envoy diff --git a/source/common/filesystem/watcher_impl.cc b/source/common/filesystem/watcher_impl.cc index db573f908215f..2ac837273c108 100644 --- a/source/common/filesystem/watcher_impl.cc +++ b/source/common/filesystem/watcher_impl.cc @@ -19,11 +19,14 @@ namespace Filesystem { WatcherImpl::WatcherImpl(Event::Dispatcher& dispatcher) : inotify_fd_(inotify_init1(IN_NONBLOCK)), - inotify_event_(dispatcher.createFileEvent(inotify_fd_, [this](uint32_t events) -> void { - ASSERT(events == Event::FileReadyType::Read); - UNREFERENCED_PARAMETER(events); - onInotifyEvent(); - }, Event::FileTriggerType::Edge, Event::FileReadyType::Read)) {} + inotify_event_(dispatcher.createFileEvent(inotify_fd_, + [this](uint32_t events) -> void { + ASSERT(events == Event::FileReadyType::Read); + UNREFERENCED_PARAMETER(events); + onInotifyEvent(); + }, + Event::FileTriggerType::Edge, + Event::FileReadyType::Read)) {} WatcherImpl::~WatcherImpl() { close(inotify_fd_); } @@ -86,5 +89,5 @@ void WatcherImpl::onInotifyEvent() { } } -} // Filesystem -} // Envoy +} // namespace Filesystem +} // namespace Envoy diff --git a/source/common/filesystem/watcher_impl.h b/source/common/filesystem/watcher_impl.h index 70dd738bac161..bc0482b960d18 100644 --- a/source/common/filesystem/watcher_impl.h +++ b/source/common/filesystem/watcher_impl.h @@ -44,5 +44,5 @@ class WatcherImpl : public Watcher, Logger::Loggable { std::unordered_map callback_map_; }; -} // Filesystem -} // Envoy +} // namespace Filesystem +} // namespace Envoy diff --git a/source/common/filter/auth/client_ssl.cc b/source/common/filter/auth/client_ssl.cc index 40039ca11859a..249061ede439d 100644 --- a/source/common/filter/auth/client_ssl.cc +++ b/source/common/filter/auth/client_ssl.cc @@ -36,8 +36,9 @@ Config::Config(const Json::Object& config, ThreadLocal::Instance& tls, Upstream: } AllowedPrincipalsSharedPtr empty(new AllowedPrincipals()); - tls_.set(tls_slot_, [empty](Event::Dispatcher&) - -> ThreadLocal::ThreadLocalObjectSharedPtr { return empty; }); + tls_.set(tls_slot_, [empty](Event::Dispatcher&) -> ThreadLocal::ThreadLocalObjectSharedPtr { + return empty; + }); } ConfigSharedPtr Config::create(const Json::Object& config, ThreadLocal::Instance& tls, @@ -66,8 +67,10 @@ void Config::parseResponse(const Http::Message& message) { new_principals->add(certificate->getString("fingerprint_sha256")); } - tls_.set(tls_slot_, [new_principals](Event::Dispatcher&) - -> ThreadLocal::ThreadLocalObjectSharedPtr { return new_principals; }); + tls_.set(tls_slot_, + [new_principals](Event::Dispatcher&) -> ThreadLocal::ThreadLocalObjectSharedPtr { + return new_principals; + }); stats_.update_success_.inc(); stats_.total_principals_.set(new_principals->size()); @@ -121,7 +124,7 @@ void Instance::onEvent(uint32_t events) { read_callbacks_->continueReading(); } -} // Client Ssl -} // Auth -} // Filter -} // Envoy +} // namespace ClientSsl +} // namespace Auth +} // namespace Filter +} // namespace Envoy diff --git a/source/common/filter/auth/client_ssl.h b/source/common/filter/auth/client_ssl.h index 00bb74b4721a5..23373715c882d 100644 --- a/source/common/filter/auth/client_ssl.h +++ b/source/common/filter/auth/client_ssl.h @@ -126,6 +126,6 @@ class Instance : public Network::ReadFilter, public Network::ConnectionCallbacks }; } // ClientSsl -} // Auth -} // Filter -} // Envoy +} // namespace Auth +} // namespace Filter +} // namespace Envoy diff --git a/source/common/filter/echo.cc b/source/common/filter/echo.cc index dd358a4a6484e..7383bfc1fd113 100644 --- a/source/common/filter/echo.cc +++ b/source/common/filter/echo.cc @@ -15,5 +15,5 @@ Network::FilterStatus Echo::onData(Buffer::Instance& data) { return Network::FilterStatus::StopIteration; } -} // Filter -} // Envoy +} // namespace Filter +} // namespace Envoy diff --git a/source/common/filter/echo.h b/source/common/filter/echo.h index 9ca9a5eb566d0..da63c9609edbf 100644 --- a/source/common/filter/echo.h +++ b/source/common/filter/echo.h @@ -23,5 +23,5 @@ class Echo : public Network::ReadFilter, Logger::Loggable { Network::ReadFilterCallbacks* read_callbacks_{}; }; -} // Filter -} // Envoy +} // namespace Filter +} // namespace Envoy diff --git a/source/common/filter/ratelimit.cc b/source/common/filter/ratelimit.cc index 26e0220ee0bd6..f0e19b706468c 100644 --- a/source/common/filter/ratelimit.cc +++ b/source/common/filter/ratelimit.cc @@ -98,6 +98,6 @@ void Instance::complete(LimitStatus status) { } } -} // TcpFilter -} // RateLimit -} // Envoy +} // namespace TcpFilter +} // namespace RateLimit +} // namespace Envoy diff --git a/source/common/filter/ratelimit.h b/source/common/filter/ratelimit.h index 58144e5f06d33..ece8d05850e09 100644 --- a/source/common/filter/ratelimit.h +++ b/source/common/filter/ratelimit.h @@ -97,5 +97,5 @@ class Instance : public Network::ReadFilter, }; } // TcpFilter -} // RateLimit -} // Envoy +} // namespace RateLimit +} // namespace Envoy diff --git a/source/common/filter/tcp_proxy.cc b/source/common/filter/tcp_proxy.cc index 847bb6b43475f..da4ec3eb5c30a 100644 --- a/source/common/filter/tcp_proxy.cc +++ b/source/common/filter/tcp_proxy.cc @@ -237,5 +237,5 @@ void TcpProxy::onUpstreamEvent(uint32_t event) { } } -} // Filter -} // Envoy +} // namespace Filter +} // namespace Envoy diff --git a/source/common/filter/tcp_proxy.h b/source/common/filter/tcp_proxy.h index ff1ac045084f3..d981472ea97e4 100644 --- a/source/common/filter/tcp_proxy.h +++ b/source/common/filter/tcp_proxy.h @@ -139,4 +139,4 @@ class TcpProxy : public Network::ReadFilter, Logger::Loggable& output) { } } // namespace Grpc -} // Envoy +} // namespace Envoy diff --git a/source/common/grpc/codec.h b/source/common/grpc/codec.h index 3f8961ba36f7c..6089d5798c45b 100644 --- a/source/common/grpc/codec.h +++ b/source/common/grpc/codec.h @@ -81,5 +81,5 @@ class Decoder { State state_; Frame frame_; }; -} // Grpc -} // Envoy +} // namespace Grpc +} // namespace Envoy diff --git a/source/common/grpc/common.cc b/source/common/grpc/common.cc index 9b9f79985f159..83c773649878c 100644 --- a/source/common/grpc/common.cc +++ b/source/common/grpc/common.cc @@ -185,5 +185,5 @@ void Common::validateResponse(Http::Message& http_response) { } } -} // Grpc -} // Envoy +} // namespace Grpc +} // namespace Envoy diff --git a/source/common/grpc/common.h b/source/common/grpc/common.h index c43d37e14faa3..d664fee3386c1 100644 --- a/source/common/grpc/common.h +++ b/source/common/grpc/common.h @@ -68,12 +68,12 @@ class Common { bool success); /** - * Charge a success/failure stat to a cluster/service/method. - * @param cluster supplies the target cluster. - * @param grpc_service supplies the service name. - * @param grpc_method supplies the method name. - * @param success supplies whether the call succeeded. - */ + * Charge a success/failure stat to a cluster/service/method. + * @param cluster supplies the target cluster. + * @param grpc_service supplies the service name. + * @param grpc_method supplies the method name. + * @param success supplies whether the call succeeded. + */ static void chargeStat(const Upstream::ClusterInfo& cluster, const std::string& grpc_service, const std::string& grpc_method, bool success); @@ -110,5 +110,5 @@ class Common { static void checkForHeaderOnlyError(Http::Message& http_response); }; -} // Grpc -} // Envoy +} // namespace Grpc +} // namespace Envoy diff --git a/source/common/grpc/grpc_web_filter.cc b/source/common/grpc/grpc_web_filter.cc index 9614c3262af0c..749f585edd5fc 100644 --- a/source/common/grpc/grpc_web_filter.cc +++ b/source/common/grpc/grpc_web_filter.cc @@ -143,13 +143,15 @@ Http::FilterTrailersStatus GrpcWebFilter::encodeTrailers(Http::HeaderMap& traile // Trailers are expected to come all in once, and will be encoded into one single trailers frame. // Trailers in the trailers frame are separated by CRLFs. Buffer::OwnedImpl temp; - trailers.iterate([](const Http::HeaderEntry& header, void* context) -> void { - Buffer::Instance* temp = static_cast(context); - temp->add(header.key().c_str(), header.key().size()); - temp->add(":"); - temp->add(header.value().c_str(), header.value().size()); - temp->add("\r\n"); - }, &temp); + trailers.iterate( + [](const Http::HeaderEntry& header, void* context) -> void { + Buffer::Instance* temp = static_cast(context); + temp->add(header.key().c_str(), header.key().size()); + temp->add(":"); + temp->add(header.value().c_str(), header.value().size()); + temp->add("\r\n"); + }, + &temp); Buffer::OwnedImpl buffer; // Adds the trailers frame head. buffer.add(&GRPC_WEB_TRAILER, 1); diff --git a/source/common/grpc/http1_bridge_filter.cc b/source/common/grpc/http1_bridge_filter.cc index cd509dbd41689..b98b3b83a5673 100644 --- a/source/common/grpc/http1_bridge_filter.cc +++ b/source/common/grpc/http1_bridge_filter.cc @@ -100,5 +100,5 @@ void Http1BridgeFilter::setupStatTracking(const Http::HeaderMap& headers) { Common::resolveServiceAndMethod(headers.Path(), &grpc_service_, &grpc_method_); } -} // Grpc -} // Envoy +} // namespace Grpc +} // namespace Envoy diff --git a/source/common/grpc/http1_bridge_filter.h b/source/common/grpc/http1_bridge_filter.h index 0d9fd2c88beff..9345e955f0578 100644 --- a/source/common/grpc/http1_bridge_filter.h +++ b/source/common/grpc/http1_bridge_filter.h @@ -53,5 +53,5 @@ class Http1BridgeFilter : public Http::StreamFilter { std::string grpc_method_; }; -} // Grpc -} // Envoy +} // namespace Grpc +} // namespace Envoy diff --git a/source/common/grpc/json_transcoder_filter.cc b/source/common/grpc/json_transcoder_filter.cc index ee9d7bf9249d8..fa4866ae90a3c 100644 --- a/source/common/grpc/json_transcoder_filter.cc +++ b/source/common/grpc/json_transcoder_filter.cc @@ -28,8 +28,8 @@ using google::protobuf::DescriptorPool; using google::protobuf::FileDescriptor; using google::protobuf::FileDescriptorSet; using google::protobuf::io::ZeroCopyInputStream; -using google::protobuf::util::error::Code; using google::protobuf::util::Status; +using google::protobuf::util::error::Code; namespace Envoy { namespace Grpc { diff --git a/source/common/grpc/rpc_channel_impl.cc b/source/common/grpc/rpc_channel_impl.cc index 06f8abeb39a44..3cfd66fd876ae 100644 --- a/source/common/grpc/rpc_channel_impl.cc +++ b/source/common/grpc/rpc_channel_impl.cc @@ -96,5 +96,5 @@ void RpcChannelImpl::onComplete() { grpc_response_ = nullptr; } -} // Grpc -} // Envoy +} // namespace Grpc +} // namespace Envoy diff --git a/source/common/grpc/rpc_channel_impl.h b/source/common/grpc/rpc_channel_impl.h index 0bb70f829a288..1dfa70eaeb13d 100644 --- a/source/common/grpc/rpc_channel_impl.h +++ b/source/common/grpc/rpc_channel_impl.h @@ -66,5 +66,5 @@ class RpcChannelImpl : public RpcChannel, public Http::AsyncClient::Callbacks { Optional timeout_; }; -} // Grpc -} // Envoy +} // namespace Grpc +} // namespace Envoy diff --git a/source/common/http/access_log/access_log_formatter.cc b/source/common/http/access_log/access_log_formatter.cc index 280833a15cecd..ee3e94dca54fb 100644 --- a/source/common/http/access_log/access_log_formatter.cc +++ b/source/common/http/access_log/access_log_formatter.cc @@ -246,8 +246,9 @@ RequestInfoFormatter::RequestInfoFormatter(const std::string& field_name) { : "0"; }; } else if (field_name == "BYTES_SENT") { - field_extractor_ = - [](const RequestInfo& request_info) { return std::to_string(request_info.bytesSent()); }; + field_extractor_ = [](const RequestInfo& request_info) { + return std::to_string(request_info.bytesSent()); + }; } else if (field_name == "DURATION") { field_extractor_ = [](const RequestInfo& request_info) { return std::to_string(request_info.duration().count()); @@ -337,6 +338,6 @@ std::string RequestHeaderFormatter::format(const Http::HeaderMap& request_header return HeaderFormatter::format(request_headers); } -} // AccessLog -} // Http -} // Envoy +} // namespace AccessLog +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/access_log/access_log_formatter.h b/source/common/http/access_log/access_log_formatter.h index 480950c4634cf..b85c1ece8aceb 100644 --- a/source/common/http/access_log/access_log_formatter.h +++ b/source/common/http/access_log/access_log_formatter.h @@ -146,6 +146,6 @@ class RequestInfoFormatter : public Formatter { std::function field_extractor_; }; -} // AccessLog -} // Http -} // Envoy +} // namespace AccessLog +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/access_log/access_log_impl.cc b/source/common/http/access_log/access_log_impl.cc index 320c369b4d290..0971a8591cf00 100644 --- a/source/common/http/access_log/access_log_impl.cc +++ b/source/common/http/access_log/access_log_impl.cc @@ -199,6 +199,6 @@ void InstanceImpl::log(const HeaderMap* request_headers, const HeaderMap* respon log_file_->write(access_log_line); } -} // AccessLog -} // Http -} // Envoy +} // namespace AccessLog +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/access_log/access_log_impl.h b/source/common/http/access_log/access_log_impl.h index 5fd26d555d806..4e6765fe10485 100644 --- a/source/common/http/access_log/access_log_impl.h +++ b/source/common/http/access_log/access_log_impl.h @@ -148,6 +148,6 @@ class InstanceImpl : public Instance { FormatterPtr formatter_; }; -} // AccessLog -} // Http -} // Envoy +} // namespace AccessLog +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/access_log/request_info_impl.h b/source/common/http/access_log/request_info_impl.h index 64bded206b342..5032c114ccfa1 100644 --- a/source/common/http/access_log/request_info_impl.h +++ b/source/common/http/access_log/request_info_impl.h @@ -56,6 +56,6 @@ struct RequestInfoImpl : public RequestInfo { bool hc_request_{}; }; -} // AccessLog -} // Http -} // Envoy +} // namespace AccessLog +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/async_client_impl.cc b/source/common/http/async_client_impl.cc index 48e5b552e055d..361690a107aee 100644 --- a/source/common/http/async_client_impl.cc +++ b/source/common/http/async_client_impl.cc @@ -73,9 +73,11 @@ AsyncStreamImpl::AsyncStreamImpl(AsyncClientImpl& parent, AsyncClient::StreamCal void AsyncStreamImpl::encodeHeaders(HeaderMapPtr&& headers, bool end_stream) { #ifndef NVLOG ENVOY_LOG(debug, "async http request response headers (end_stream={}):", end_stream); - headers->iterate([](const HeaderEntry& header, void*) -> void { - ENVOY_LOG(debug, " '{}':'{}'", header.key().c_str(), header.value().c_str()); - }, nullptr); + headers->iterate( + [](const HeaderEntry& header, void*) -> void { + ENVOY_LOG(debug, " '{}':'{}'", header.key().c_str(), header.value().c_str()); + }, + nullptr); #endif stream_callbacks_.onHeaders(std::move(headers), end_stream); @@ -92,9 +94,11 @@ void AsyncStreamImpl::encodeData(Buffer::Instance& data, bool end_stream) { void AsyncStreamImpl::encodeTrailers(HeaderMapPtr&& trailers) { #ifndef NVLOG ENVOY_LOG(debug, "async http request response trailers:"); - trailers->iterate([](const HeaderEntry& header, void*) -> void { - ENVOY_LOG(debug, " '{}':'{}'", header.key().c_str(), header.value().c_str()); - }, nullptr); + trailers->iterate( + [](const HeaderEntry& header, void*) -> void { + ENVOY_LOG(debug, " '{}':'{}'", header.key().c_str(), header.value().c_str()); + }, + nullptr); #endif stream_callbacks_.onTrailers(std::move(trailers)); @@ -204,5 +208,5 @@ void AsyncRequestImpl::cancel() { reset(); } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/async_client_impl.h b/source/common/http/async_client_impl.h index a4a84418948f6..b078db0361e95 100644 --- a/source/common/http/async_client_impl.h +++ b/source/common/http/async_client_impl.h @@ -85,7 +85,7 @@ class AsyncStreamImpl : public AsyncClient::Stream, struct NullRateLimitPolicy : public Router::RateLimitPolicy { // Router::RateLimitPolicy const std::vector>& - getApplicableRateLimit(uint64_t) const override { + getApplicableRateLimit(uint64_t) const override { return rate_limit_policy_entry_; } bool empty() const override { return true; } @@ -237,5 +237,5 @@ class AsyncRequestImpl final : public AsyncClient::Request, friend class AsyncClientImpl; }; -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/codec_client.cc b/source/common/http/codec_client.cc index 47166784a2f10..a2013874f0ce3 100644 --- a/source/common/http/codec_client.cc +++ b/source/common/http/codec_client.cc @@ -134,5 +134,5 @@ CodecClientProd::CodecClientProd(Type type, Network::ClientConnectionPtr&& conne } } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/codec_client.h b/source/common/http/codec_client.h index 39abe1792dd8a..a4de637757570 100644 --- a/source/common/http/codec_client.h +++ b/source/common/http/codec_client.h @@ -199,5 +199,5 @@ class CodecClientProd : public CodecClient { Upstream::HostDescriptionConstSharedPtr host); }; -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/codec_helper.h b/source/common/http/codec_helper.h index c3201cbd17494..f73fc95ccfd9c 100644 --- a/source/common/http/codec_helper.h +++ b/source/common/http/codec_helper.h @@ -46,5 +46,5 @@ class StreamCallbackHelper { bool reset_callbacks_run_{}; }; -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/codec_wrappers.h b/source/common/http/codec_wrappers.h index fb94ed8c2fdb3..5b4dca2ea0d61 100644 --- a/source/common/http/codec_wrappers.h +++ b/source/common/http/codec_wrappers.h @@ -93,5 +93,5 @@ class StreamEncoderWrapper : public StreamEncoder { StreamEncoder& inner_; }; -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/codes.cc b/source/common/http/codes.cc index 6e72cedfb91f5..5369db7b39548 100644 --- a/source/common/http/codes.cc +++ b/source/common/http/codes.cc @@ -40,33 +40,43 @@ void CodeUtility::chargeResponseStat(const ResponseStatInfo& info) { // Split stats into external vs. internal. if (info.internal_request_) { - info.cluster_scope_.counter(fmt::format("{}internal.upstream_rq_{}", info.prefix_, - group_string)).inc(); - info.cluster_scope_.counter(fmt::format("{}internal.upstream_rq_{}", info.prefix_, - response_code)).inc(); + info.cluster_scope_ + .counter(fmt::format("{}internal.upstream_rq_{}", info.prefix_, group_string)) + .inc(); + info.cluster_scope_ + .counter(fmt::format("{}internal.upstream_rq_{}", info.prefix_, response_code)) + .inc(); } else { - info.cluster_scope_.counter(fmt::format("{}external.upstream_rq_{}", info.prefix_, - group_string)).inc(); - info.cluster_scope_.counter(fmt::format("{}external.upstream_rq_{}", info.prefix_, - response_code)).inc(); + info.cluster_scope_ + .counter(fmt::format("{}external.upstream_rq_{}", info.prefix_, group_string)) + .inc(); + info.cluster_scope_ + .counter(fmt::format("{}external.upstream_rq_{}", info.prefix_, response_code)) + .inc(); } // Handle request virtual cluster. if (!info.request_vcluster_name_.empty()) { - info.global_scope_.counter(fmt::format("vhost.{}.vcluster.{}.upstream_rq_{}", - info.request_vhost_name_, info.request_vcluster_name_, - group_string)).inc(); - info.global_scope_.counter(fmt::format("vhost.{}.vcluster.{}.upstream_rq_{}", - info.request_vhost_name_, info.request_vcluster_name_, - response_code)).inc(); + info.global_scope_ + .counter(fmt::format("vhost.{}.vcluster.{}.upstream_rq_{}", info.request_vhost_name_, + info.request_vcluster_name_, group_string)) + .inc(); + info.global_scope_ + .counter(fmt::format("vhost.{}.vcluster.{}.upstream_rq_{}", info.request_vhost_name_, + info.request_vcluster_name_, response_code)) + .inc(); } // Handle per zone stats. if (!info.from_zone_.empty() && !info.to_zone_.empty()) { - info.cluster_scope_.counter(fmt::format("{}zone.{}.{}.upstream_rq_{}", info.prefix_, - info.from_zone_, info.to_zone_, group_string)).inc(); - info.cluster_scope_.counter(fmt::format("{}zone.{}.{}.upstream_rq_{}", info.prefix_, - info.from_zone_, info.to_zone_, response_code)).inc(); + info.cluster_scope_ + .counter(fmt::format("{}zone.{}.{}.upstream_rq_{}", info.prefix_, info.from_zone_, + info.to_zone_, group_string)) + .inc(); + info.cluster_scope_ + .counter(fmt::format("{}zone.{}.{}.upstream_rq_{}", info.prefix_, info.from_zone_, + info.to_zone_, response_code)) + .inc(); } } @@ -187,5 +197,5 @@ const char* CodeUtility::toString(Code code) { return "Unknown"; } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/codes.h b/source/common/http/codes.h index 77da3dbff7d73..e698927a43cb3 100644 --- a/source/common/http/codes.h +++ b/source/common/http/codes.h @@ -76,5 +76,5 @@ class CodeUtility { static std::string groupStringForResponseCode(Code response_code); }; -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/conn_manager_impl.cc b/source/common/http/conn_manager_impl.cc index 0f3455e5b81c6..5892b514c67c1 100644 --- a/source/common/http/conn_manager_impl.cc +++ b/source/common/http/conn_manager_impl.cc @@ -399,10 +399,12 @@ void ConnectionManagerImpl::ActiveStream::decodeHeaders(HeaderMapPtr&& headers, request_headers_ = std::move(headers); ENVOY_STREAM_LOG(debug, "request headers complete (end_stream={}):", *this, end_stream); #ifndef NVLOG - request_headers_->iterate([](const HeaderEntry& header, void* context) -> void { - ENVOY_STREAM_LOG(debug, " '{}':'{}'", *static_cast(context), - header.key().c_str(), header.value().c_str()); - }, this); + request_headers_->iterate( + [](const HeaderEntry& header, void* context) -> void { + ENVOY_STREAM_LOG(debug, " '{}':'{}'", *static_cast(context), + header.key().c_str(), header.value().c_str()); + }, + this); #endif connection_manager_.user_agent_.initializeFromHeaders( @@ -710,10 +712,12 @@ void ConnectionManagerImpl::ActiveStream::encodeHeaders(ActiveStreamEncoderFilte ENVOY_STREAM_LOG(debug, "encoding headers via codec (end_stream={}):", *this, end_stream && continue_data_entry == encoder_filters_.end()); #ifndef NVLOG - headers.iterate([](const HeaderEntry& header, void* context) -> void { - ENVOY_STREAM_LOG(debug, " '{}':'{}'", *static_cast(context), - header.key().c_str(), header.value().c_str()); - }, this); + headers.iterate( + [](const HeaderEntry& header, void* context) -> void { + ENVOY_STREAM_LOG(debug, " '{}':'{}'", *static_cast(context), + header.key().c_str(), header.value().c_str()); + }, + this); #endif // Now actually encode via the codec. @@ -789,10 +793,12 @@ void ConnectionManagerImpl::ActiveStream::encodeTrailers(ActiveStreamEncoderFilt ENVOY_STREAM_LOG(debug, "encoding trailers via codec", *this); #ifndef NVLOG - trailers.iterate([](const HeaderEntry& header, void* context) -> void { - ENVOY_STREAM_LOG(debug, " '{}':'{}'", *static_cast(context), - header.key().c_str(), header.value().c_str()); - }, this); + trailers.iterate( + [](const HeaderEntry& header, void* context) -> void { + ENVOY_STREAM_LOG(debug, " '{}':'{}'", *static_cast(context), + header.key().c_str(), header.value().c_str()); + }, + this); #endif response_encoder_->encodeTrailers(trailers); @@ -990,5 +996,5 @@ const std::string& ConnectionManagerImpl::ActiveStreamFilterBase::downstreamAddr return parent_.downstream_address_; } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/conn_manager_impl.h b/source/common/http/conn_manager_impl.h index e05b17aa0b54e..fd370780478a2 100644 --- a/source/common/http/conn_manager_impl.h +++ b/source/common/http/conn_manager_impl.h @@ -100,8 +100,8 @@ struct ConnectionManagerStats { // clang-format on /** -* Wrapper struct for connection manager tracing stats. @see stats_macros.h -*/ + * Wrapper struct for connection manager tracing stats. @see stats_macros.h + */ struct ConnectionManagerTracingStats { CONN_MAN_TRACING_STATS(GENERATE_COUNTER_STRUCT) }; @@ -537,4 +537,4 @@ class ConnectionManagerImpl : Logger::Loggable, }; } // Http -} // Envoy +} // namespace Envoy diff --git a/source/common/http/conn_manager_utility.cc b/source/common/http/conn_manager_utility.cc index 75b4351644902..79ce815bd4dca 100644 --- a/source/common/http/conn_manager_utility.cc +++ b/source/common/http/conn_manager_utility.cc @@ -219,5 +219,5 @@ void ConnectionManagerUtility::mutateResponseHeaders(Http::HeaderMap& response_h } } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/conn_manager_utility.h b/source/common/http/conn_manager_utility.h index fd4f278fa3006..737dc3fc5b7e1 100644 --- a/source/common/http/conn_manager_utility.h +++ b/source/common/http/conn_manager_utility.h @@ -40,5 +40,5 @@ class ConnectionManagerUtility { static std::atomic next_stream_id_; }; -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/date_provider.h b/source/common/http/date_provider.h index c50eb5df28385..8ad7770a361ba 100644 --- a/source/common/http/date_provider.h +++ b/source/common/http/date_provider.h @@ -20,5 +20,5 @@ class DateProvider { virtual void setDateHeader(HeaderMap& headers) PURE; }; -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/date_provider_impl.cc b/source/common/http/date_provider_impl.cc index 8cd3a976c564b..2e0d271330ec0 100644 --- a/source/common/http/date_provider_impl.cc +++ b/source/common/http/date_provider_impl.cc @@ -34,5 +34,5 @@ void SlowDateProviderImpl::setDateHeader(HeaderMap& headers) { headers.insertDate().value(date_formatter_.now()); } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/date_provider_impl.h b/source/common/http/date_provider_impl.h index 1a6d567e33085..f0a438f18036e 100644 --- a/source/common/http/date_provider_impl.h +++ b/source/common/http/date_provider_impl.h @@ -58,5 +58,5 @@ class SlowDateProviderImpl : public DateProviderImplBase { void setDateHeader(HeaderMap& headers) override; }; -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/exception.h b/source/common/http/exception.h index 6fd4014a1f8da..445ef5fb14071 100644 --- a/source/common/http/exception.h +++ b/source/common/http/exception.h @@ -39,5 +39,5 @@ class CodecClientException : public EnvoyException { CodecClientException(const std::string& message) : EnvoyException(message) {} }; -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/filter/buffer_filter.cc b/source/common/http/filter/buffer_filter.cc index 67e7709c214eb..713350016a5a4 100644 --- a/source/common/http/filter/buffer_filter.cc +++ b/source/common/http/filter/buffer_filter.cc @@ -72,5 +72,5 @@ void BufferFilter::setDecoderFilterCallbacks(StreamDecoderFilterCallbacks& callb callbacks_ = &callbacks; } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/filter/buffer_filter.h b/source/common/http/filter/buffer_filter.h index 5fe86c7f845fa..23db7d515097e 100644 --- a/source/common/http/filter/buffer_filter.h +++ b/source/common/http/filter/buffer_filter.h @@ -69,4 +69,4 @@ class BufferFilter : public StreamDecoderFilter { }; } // Http -} // Envoy +} // namespace Envoy diff --git a/source/common/http/filter/fault_filter.cc b/source/common/http/filter/fault_filter.cc index fdff71d773838..4d78f5ea949bb 100644 --- a/source/common/http/filter/fault_filter.cc +++ b/source/common/http/filter/fault_filter.cc @@ -281,5 +281,5 @@ void FaultFilter::setDecoderFilterCallbacks(StreamDecoderFilterCallbacks& callba callbacks_ = &callbacks; } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/filter/fault_filter.h b/source/common/http/filter/fault_filter.h index 439eb3be59500..2055f3b52417e 100644 --- a/source/common/http/filter/fault_filter.h +++ b/source/common/http/filter/fault_filter.h @@ -120,4 +120,4 @@ class FaultFilter : public StreamDecoderFilter { }; } // Http -} // Envoy +} // namespace Envoy diff --git a/source/common/http/filter/ip_tagging_filter.cc b/source/common/http/filter/ip_tagging_filter.cc index f8d292ded42d9..19c21d3e6cdbd 100644 --- a/source/common/http/filter/ip_tagging_filter.cc +++ b/source/common/http/filter/ip_tagging_filter.cc @@ -25,5 +25,5 @@ void IpTaggingFilter::setDecoderFilterCallbacks(StreamDecoderFilterCallbacks& ca callbacks_ = &callbacks; } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/filter/ip_tagging_filter.h b/source/common/http/filter/ip_tagging_filter.h index 13841d6fb1577..7ea058ad3379e 100644 --- a/source/common/http/filter/ip_tagging_filter.h +++ b/source/common/http/filter/ip_tagging_filter.h @@ -71,5 +71,5 @@ class IpTaggingFilter : public StreamDecoderFilter { StreamDecoderFilterCallbacks* callbacks_{}; }; -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/filter/ratelimit.cc b/source/common/http/filter/ratelimit.cc index 7a291709f6e71..cd5c65fe02f6d 100644 --- a/source/common/http/filter/ratelimit.cc +++ b/source/common/http/filter/ratelimit.cc @@ -25,7 +25,7 @@ static const Http::HeaderMap* getTooManyRequestsHeader() { return header_map; } -} // namespace; +} // namespace void Filter::initiateCall(const HeaderMap& headers) { bool is_internal_request = @@ -117,9 +117,16 @@ void Filter::complete(Envoy::RateLimit::LimitStatus status) { break; case Envoy::RateLimit::LimitStatus::OverLimit: cluster_->statsScope().counter("ratelimit.over_limit").inc(); - Http::CodeUtility::ResponseStatInfo info{config_->scope(), cluster_->statsScope(), EMPTY_STRING, - *getTooManyRequestsHeader(), true, EMPTY_STRING, - EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, false}; + Http::CodeUtility::ResponseStatInfo info{config_->scope(), + cluster_->statsScope(), + EMPTY_STRING, + *getTooManyRequestsHeader(), + true, + EMPTY_STRING, + EMPTY_STRING, + EMPTY_STRING, + EMPTY_STRING, + false}; Http::CodeUtility::chargeResponseStat(info); break; } @@ -152,6 +159,6 @@ void Filter::populateRateLimitDescriptors(const Router::RateLimitPolicy& rate_li } } -} // RateLimit -} // Http -} // Envoy +} // namespace RateLimit +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/filter/ratelimit.h b/source/common/http/filter/ratelimit.h index 0c067b7d96181..80d34502875ff 100644 --- a/source/common/http/filter/ratelimit.h +++ b/source/common/http/filter/ratelimit.h @@ -108,6 +108,6 @@ class Filter : public StreamDecoderFilter, public Envoy::RateLimit::RequestCallb Upstream::ClusterInfoConstSharedPtr cluster_; }; -} // RateLimit -} // Http -} // Envoy +} // namespace RateLimit +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/filter_utility.cc b/source/common/http/filter_utility.cc index dfbd2532aa2dd..ab7b5864aae45 100644 --- a/source/common/http/filter_utility.cc +++ b/source/common/http/filter_utility.cc @@ -19,5 +19,5 @@ FilterUtility::resolveClusterInfo(Http::StreamDecoderFilterCallbacks* decoder_ca return cluster->info(); } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/filter_utility.h b/source/common/http/filter_utility.h index 4ffedd6d505dd..e91c60bdfb45e 100644 --- a/source/common/http/filter_utility.h +++ b/source/common/http/filter_utility.h @@ -21,5 +21,5 @@ class FilterUtility { Upstream::ClusterManager& cm); }; -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/header_map_impl.cc b/source/common/http/header_map_impl.cc index d6ba62e858e82..ad59fd3bb12c9 100644 --- a/source/common/http/header_map_impl.cc +++ b/source/common/http/header_map_impl.cc @@ -195,7 +195,7 @@ void HeaderMapImpl::HeaderEntryImpl::value(const HeaderEntry& header) { } #define INLINE_HEADER_STATIC_MAP_ENTRY(name) \ - add(Headers::get().name.get().c_str(), [](HeaderMapImpl & h) -> StaticLookupResponse { \ + add(Headers::get().name.get().c_str(), [](HeaderMapImpl& h) -> StaticLookupResponse { \ return {&h.inline_headers_.name##_, &Headers::get().name}; \ }); @@ -240,16 +240,18 @@ HeaderMapImpl::StaticLookupTable::find(const char* key) const { HeaderMapImpl::HeaderMapImpl() { memset(&inline_headers_, 0, sizeof(inline_headers_)); } HeaderMapImpl::HeaderMapImpl(const HeaderMap& rhs) : HeaderMapImpl() { - rhs.iterate([](const HeaderEntry& header, void* context) -> void { - // TODO(mattklein123) PERF: Avoid copying here is not necessary. - HeaderString key_string; - key_string.setCopy(header.key().c_str(), header.key().size()); - HeaderString value_string; - value_string.setCopy(header.value().c_str(), header.value().size()); - - static_cast(context) - ->addViaMove(std::move(key_string), std::move(value_string)); - }, this); + rhs.iterate( + [](const HeaderEntry& header, void* context) -> void { + // TODO(mattklein123) PERF: Avoid copying here is not necessary. + HeaderString key_string; + key_string.setCopy(header.key().c_str(), header.key().size()); + HeaderString value_string; + value_string.setCopy(header.value().c_str(), header.value().size()); + + static_cast(context)->addViaMove(std::move(key_string), + std::move(value_string)); + }, + this); } HeaderMapImpl::HeaderMapImpl( @@ -401,5 +403,5 @@ void HeaderMapImpl::removeInline(HeaderEntryImpl** ptr_to_entry) { headers_.erase(entry->entry_); } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/header_map_impl.h b/source/common/http/header_map_impl.h index 836a51cbe90f2..4ae1248afbbbc 100644 --- a/source/common/http/header_map_impl.h +++ b/source/common/http/header_map_impl.h @@ -126,4 +126,4 @@ class HeaderMapImpl : public HeaderMap { typedef std::unique_ptr HeaderMapImplPtr; } // Http -} // Envoy +} // namespace Envoy diff --git a/source/common/http/headers.h b/source/common/http/headers.h index 941e29122d872..3570613506fe8 100644 --- a/source/common/http/headers.h +++ b/source/common/http/headers.h @@ -135,5 +135,5 @@ class HeaderValues { typedef ConstSingleton Headers; -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/http1/codec_impl.cc b/source/common/http/http1/codec_impl.cc index 1933a166aad5c..546c11e45d5ae 100644 --- a/source/common/http/http1/codec_impl.cc +++ b/source/common/http/http1/codec_impl.cc @@ -38,23 +38,25 @@ void StreamEncoderImpl::encodeHeader(const char* key, uint32_t key_size, const c void StreamEncoderImpl::encodeHeaders(const HeaderMap& headers, bool end_stream) { bool saw_content_length = false; - headers.iterate([](const HeaderEntry& header, void* context) -> void { - const char* key_to_use = header.key().c_str(); - uint32_t key_size_to_use = header.key().size(); - // Translate :authority -> host so that upper layers do not need to deal with this. - if (key_size_to_use > 1 && key_to_use[0] == ':' && key_to_use[1] == 'a') { - key_to_use = Headers::get().HostLegacy.get().c_str(); - key_size_to_use = Headers::get().HostLegacy.get().size(); - } - - // Skip all headers starting with ':' that make it here. - if (key_to_use[0] == ':') { - return; - } - - static_cast(context) - ->encodeHeader(key_to_use, key_size_to_use, header.value().c_str(), header.value().size()); - }, this); + headers.iterate( + [](const HeaderEntry& header, void* context) -> void { + const char* key_to_use = header.key().c_str(); + uint32_t key_size_to_use = header.key().size(); + // Translate :authority -> host so that upper layers do not need to deal with this. + if (key_size_to_use > 1 && key_to_use[0] == ':' && key_to_use[1] == 'a') { + key_to_use = Headers::get().HostLegacy.get().c_str(); + key_size_to_use = Headers::get().HostLegacy.get().size(); + } + + // Skip all headers starting with ':' that make it here. + if (key_to_use[0] == ':') { + return; + } + + static_cast(context)->encodeHeader( + key_to_use, key_size_to_use, header.value().c_str(), header.value().size()); + }, + this); if (headers.ContentLength()) { saw_content_length = true; @@ -236,8 +238,9 @@ http_parser_settings ConnectionImpl::settings_{ static_cast(parser->data)->onHeaderValue(at, length); return 0; }, - [](http_parser* parser) - -> int { return static_cast(parser->data)->onHeadersCompleteBase(); }, + [](http_parser* parser) -> int { + return static_cast(parser->data)->onHeadersCompleteBase(); + }, [](http_parser* parser, const char* at, size_t length) -> int { static_cast(parser->data)->onBody(at, length); return 0; @@ -564,6 +567,6 @@ void ClientConnectionImpl::onResetStream(StreamResetReason reason) { } } -} // Http1 -} // Http -} // Envoy +} // namespace Http1 +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/http1/codec_impl.h b/source/common/http/http1/codec_impl.h index c7f7409c94fc7..56acfaa6b3c9f 100644 --- a/source/common/http/http1/codec_impl.h +++ b/source/common/http/http1/codec_impl.h @@ -124,8 +124,8 @@ class ConnectionImpl : public virtual Connection, protected Logger::Loggable pending_responses_; }; -} // Http1 -} // Http -} // Envoy +} // namespace Http1 +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/http1/conn_pool.cc b/source/common/http/http1/conn_pool.cc index 68f624505d9a1..e84ffea5a820c 100644 --- a/source/common/http/http1/conn_pool.cc +++ b/source/common/http/http1/conn_pool.cc @@ -308,6 +308,6 @@ CodecClientPtr ConnPoolImplProd::createCodecClient(Upstream::Host::CreateConnect return codec; } -} // Http1 -} // Http -} // Envoy +} // namespace Http1 +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/http1/conn_pool.h b/source/common/http/http1/conn_pool.h index a6d4d9438dcb6..615dc6ef5ab53 100644 --- a/source/common/http/http1/conn_pool.h +++ b/source/common/http/http1/conn_pool.h @@ -137,6 +137,6 @@ class ConnPoolImplProd : public ConnPoolImpl { CodecClientPtr createCodecClient(Upstream::Host::CreateConnectionData& data) override; }; -} // Http1 -} // Http -} // Envoy +} // namespace Http1 +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/http2/codec_impl.cc b/source/common/http/http2/codec_impl.cc index c21da5514d153..ba4a12b3a447a 100644 --- a/source/common/http/http2/codec_impl.cc +++ b/source/common/http/http2/codec_impl.cc @@ -63,23 +63,27 @@ void ConnectionImpl::StreamImpl::buildHeaders(std::vector& final_hea // nghttp2 requires that all ':' headers come before all other headers. To avoid making higher // layers understand that we do two passes here to build the final header list to encode. final_headers.reserve(headers.size()); - headers.iterate([](const HeaderEntry& header, void* context) -> void { - std::vector* final_headers = static_cast*>(context); - if (header.key().c_str()[0] == ':') { - final_headers->push_back({remove_const(header.key().c_str()), - remove_const(header.value().c_str()), header.key().size(), - header.value().size(), 0}); - } - }, &final_headers); - - headers.iterate([](const HeaderEntry& header, void* context) -> void { - std::vector* final_headers = static_cast*>(context); - if (header.key().c_str()[0] != ':') { - final_headers->push_back({remove_const(header.key().c_str()), - remove_const(header.value().c_str()), header.key().size(), - header.value().size(), 0}); - } - }, &final_headers); + headers.iterate( + [](const HeaderEntry& header, void* context) -> void { + std::vector* final_headers = static_cast*>(context); + if (header.key().c_str()[0] == ':') { + final_headers->push_back({remove_const(header.key().c_str()), + remove_const(header.value().c_str()), + header.key().size(), header.value().size(), 0}); + } + }, + &final_headers); + + headers.iterate( + [](const HeaderEntry& header, void* context) -> void { + std::vector* final_headers = static_cast*>(context); + if (header.key().c_str()[0] != ':') { + final_headers->push_back({remove_const(header.key().c_str()), + remove_const(header.value().c_str()), + header.key().size(), header.value().size(), 0}); + } + }, + &final_headers); } void ConnectionImpl::StreamImpl::encodeHeaders(const HeaderMap& headers, bool end_stream) { @@ -89,11 +93,11 @@ void ConnectionImpl::StreamImpl::encodeHeaders(const HeaderMap& headers, bool en nghttp2_data_provider provider; if (!end_stream) { provider.source.ptr = this; - provider.read_callback = - [](nghttp2_session*, int32_t, uint8_t*, size_t length, uint32_t* data_flags, - nghttp2_data_source* source, void*) -> ssize_t { - return static_cast(source->ptr)->onDataSourceRead(length, data_flags); - }; + provider.read_callback = [](nghttp2_session*, int32_t, uint8_t*, size_t length, + uint32_t* data_flags, nghttp2_data_source* source, + void*) -> ssize_t { + return static_cast(source->ptr)->onDataSourceRead(length, data_flags); + }; } local_end_stream_ = end_stream; @@ -576,12 +580,14 @@ ConnectionImpl::Http2Callbacks::Http2Callbacks() { nghttp2_session_callbacks_new(&callbacks_); nghttp2_session_callbacks_set_send_callback( callbacks_, - [](nghttp2_session*, const uint8_t* data, size_t length, int, void* user_data) - -> ssize_t { return static_cast(user_data)->onSend(data, length); }); + [](nghttp2_session*, const uint8_t* data, size_t length, int, void* user_data) -> ssize_t { + return static_cast(user_data)->onSend(data, length); + }); nghttp2_session_callbacks_set_send_data_callback( - callbacks_, [](nghttp2_session*, nghttp2_frame* frame, const uint8_t* framehd, size_t length, - nghttp2_data_source* source, void*) -> int { + callbacks_, + [](nghttp2_session*, nghttp2_frame* frame, const uint8_t* framehd, size_t length, + nghttp2_data_source* source, void*) -> int { ASSERT(frame->data.padlen == 0); UNREFERENCED_PARAMETER(frame); return static_cast(source->ptr)->onDataSourceSend(framehd, length); @@ -602,13 +608,14 @@ ConnectionImpl::Http2Callbacks::Http2Callbacks() { name.setCopy(reinterpret_cast(raw_name), name_length); HeaderString value; value.setCopy(reinterpret_cast(raw_value), value_length); - return static_cast(user_data) - ->onHeader(frame, std::move(name), std::move(value)); + return static_cast(user_data)->onHeader(frame, std::move(name), + std::move(value)); }); nghttp2_session_callbacks_set_on_data_chunk_recv_callback( - callbacks_, [](nghttp2_session*, uint8_t, int32_t stream_id, const uint8_t* data, size_t len, - void* user_data) -> int { + callbacks_, + [](nghttp2_session*, uint8_t, int32_t stream_id, const uint8_t* data, size_t len, + void* user_data) -> int { return static_cast(user_data)->onData(stream_id, data, len); }); @@ -637,8 +644,9 @@ ConnectionImpl::Http2Callbacks::Http2Callbacks() { nghttp2_session_callbacks_set_on_invalid_frame_recv_callback( callbacks_, - [](nghttp2_session*, const nghttp2_frame*, int error_code, void* user_data) - -> int { return static_cast(user_data)->onInvalidFrame(error_code); }); + [](nghttp2_session*, const nghttp2_frame*, int error_code, void* user_data) -> int { + return static_cast(user_data)->onInvalidFrame(error_code); + }); } ConnectionImpl::Http2Callbacks::~Http2Callbacks() { nghttp2_session_callbacks_del(callbacks_); } @@ -731,6 +739,6 @@ int ServerConnectionImpl::onHeader(const nghttp2_frame* frame, HeaderString&& na return saveHeader(frame, std::move(name), std::move(value)); } -} // Http2 -} // Http -} // Envoy +} // namespace Http2 +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/http2/codec_impl.h b/source/common/http/http2/codec_impl.h index e3ef23eb30553..d6c5a83d0004c 100644 --- a/source/common/http/http2/codec_impl.h +++ b/source/common/http/http2/codec_impl.h @@ -258,6 +258,6 @@ class ServerConnectionImpl : public ServerConnection, public ConnectionImpl { ServerConnectionCallbacks& callbacks_; }; -} // Http2 -} // Http -} // Envoy +} // namespace Http2 +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/http2/conn_pool.cc b/source/common/http/http2/conn_pool.cc index 2cd589324b73e..28a59d4b87ec9 100644 --- a/source/common/http/http2/conn_pool.cc +++ b/source/common/http/http2/conn_pool.cc @@ -249,6 +249,6 @@ CodecClientPtr ProdConnPoolImpl::createCodecClient(Upstream::Host::CreateConnect uint32_t ProdConnPoolImpl::maxTotalStreams() { return MAX_STREAMS; } -} // Http2 -} // Http -} // Envoy +} // namespace Http2 +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/http2/conn_pool.h b/source/common/http/http2/conn_pool.h index bb66b5430a4fb..89cd9be9c85b8 100644 --- a/source/common/http/http2/conn_pool.h +++ b/source/common/http/http2/conn_pool.h @@ -99,6 +99,6 @@ class ProdConnPoolImpl : public ConnPoolImpl { static const uint64_t MAX_STREAMS = (1 << 29); }; -} // Http2 -} // Http -} // Envoy +} // namespace Http2 +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/message_impl.cc b/source/common/http/message_impl.cc index edfe5720fb8ed..97c6a8a3e7049 100644 --- a/source/common/http/message_impl.cc +++ b/source/common/http/message_impl.cc @@ -19,5 +19,5 @@ std::string MessageImpl::bodyAsString() const { return ret; } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/message_impl.h b/source/common/http/message_impl.h index 308586a21a9b2..cda0a341af0b3 100644 --- a/source/common/http/message_impl.h +++ b/source/common/http/message_impl.h @@ -44,5 +44,5 @@ class ResponseMessageImpl : public MessageImpl { ResponseMessageImpl(HeaderMapPtr&& headers) : MessageImpl(std::move(headers)) {} }; -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/rest_api_fetcher.cc b/source/common/http/rest_api_fetcher.cc index 3f892341caf81..6b3b976e2d96a 100644 --- a/source/common/http/rest_api_fetcher.cc +++ b/source/common/http/rest_api_fetcher.cc @@ -67,5 +67,5 @@ void RestApiFetcher::requestComplete() { refresh_timer_->enableTimer(final_delay); } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/rest_api_fetcher.h b/source/common/http/rest_api_fetcher.h index 562736eb546fe..8c62e6f5aeb0c 100644 --- a/source/common/http/rest_api_fetcher.h +++ b/source/common/http/rest_api_fetcher.h @@ -67,5 +67,5 @@ class RestApiFetcher : public Http::AsyncClient::Callbacks { Http::AsyncClient::Request* active_request_{}; }; -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/user_agent.cc b/source/common/http/user_agent.cc index 82077807d2fed..b781785d2d431 100644 --- a/source/common/http/user_agent.cc +++ b/source/common/http/user_agent.cc @@ -57,5 +57,5 @@ void UserAgent::onConnectionDestroy(uint32_t events, bool active_streams) { } } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/user_agent.h b/source/common/http/user_agent.h index 082f30f14e4ee..1849ef69a61c0 100644 --- a/source/common/http/user_agent.h +++ b/source/common/http/user_agent.h @@ -63,5 +63,5 @@ class UserAgent { std::string prefix_; }; -} // Http +} // namespace Http } // Envoy diff --git a/source/common/http/utility.cc b/source/common/http/utility.cc index 2fe313e2929dd..0548edcf8c113 100644 --- a/source/common/http/utility.cc +++ b/source/common/http/utility.cc @@ -82,36 +82,38 @@ std::string Utility::parseCookieValue(const HeaderMap& headers, const std::strin State state; state.key_ = key; - headers.iterate([](const HeaderEntry& header, void* context) -> void { - // Find the cookie headers in the request (typically, there's only one). - if (header.key() == Http::Headers::get().Cookie.get().c_str()) { - // Split the cookie header into individual cookies. - for (const std::string& s : StringUtil::split(std::string{header.value().c_str()}, ';')) { - // Find the key part of the cookie (i.e. the name of the cookie). - size_t first_non_space = s.find_first_not_of(" "); - size_t equals_index = s.find('='); - if (equals_index == std::string::npos) { - // The cookie is malformed if it does not have an `=`. Continue - // checking other cookies in this header. - continue; - } - std::string k = s.substr(first_non_space, equals_index - first_non_space); - State* state = static_cast(context); - // If the key matches, parse the value from the rest of the cookie string. - if (k == state->key_) { - std::string v = s.substr(equals_index + 1, s.size() - 1); - - // Cookie values may be wrapped in double quotes. - // https://tools.ietf.org/html/rfc6265#section-4.1.1 - if (v.size() >= 2 && v.back() == '"' && v[0] == '"') { - v = v.substr(1, v.size() - 2); + headers.iterate( + [](const HeaderEntry& header, void* context) -> void { + // Find the cookie headers in the request (typically, there's only one). + if (header.key() == Http::Headers::get().Cookie.get().c_str()) { + // Split the cookie header into individual cookies. + for (const std::string& s : StringUtil::split(std::string{header.value().c_str()}, ';')) { + // Find the key part of the cookie (i.e. the name of the cookie). + size_t first_non_space = s.find_first_not_of(" "); + size_t equals_index = s.find('='); + if (equals_index == std::string::npos) { + // The cookie is malformed if it does not have an `=`. Continue + // checking other cookies in this header. + continue; + } + std::string k = s.substr(first_non_space, equals_index - first_non_space); + State* state = static_cast(context); + // If the key matches, parse the value from the rest of the cookie string. + if (k == state->key_) { + std::string v = s.substr(equals_index + 1, s.size() - 1); + + // Cookie values may be wrapped in double quotes. + // https://tools.ietf.org/html/rfc6265#section-4.1.1 + if (v.size() >= 2 && v.back() == '"' && v[0] == '"') { + v = v.substr(1, v.size() - 2); + } + state->ret_ = v; + return; + } } - state->ret_ = v; - return; } - } - } - }, &state); + }, + &state); return state.ret_; } @@ -210,5 +212,5 @@ std::string Utility::getLastAddressFromXFF(const Http::HeaderMap& request_header return xff_address_list.back(); } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/http/utility.h b/source/common/http/utility.h index e7d16d8aaaae9..02db49dc46067 100644 --- a/source/common/http/utility.h +++ b/source/common/http/utility.h @@ -94,5 +94,5 @@ class Utility { static std::string getLastAddressFromXFF(const Http::HeaderMap& request_headers); }; -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/common/json/config_schemas.cc b/source/common/json/config_schemas.cc index dc92faf799a84..cdec4ae59f727 100644 --- a/source/common/json/config_schemas.cc +++ b/source/common/json/config_schemas.cc @@ -1440,4 +1440,4 @@ const std::string Json::Schema::SDS_SCHEMA(R"EOF( "required" : ["hosts"] } )EOF"); -} // Envoy +} // namespace Envoy diff --git a/source/common/json/config_schemas.h b/source/common/json/config_schemas.h index 414a9044b192d..9996a0511fbd7 100644 --- a/source/common/json/config_schemas.h +++ b/source/common/json/config_schemas.h @@ -50,5 +50,5 @@ class Schema { static const std::string REDIS_CONN_POOL_SCHEMA; }; -} // Json -} // Envoy +} // namespace Json +} // namespace Envoy diff --git a/source/common/json/json_loader.cc b/source/common/json/json_loader.cc index dfdb0158d45c3..fdce6c3a32e47 100644 --- a/source/common/json/json_loader.cc +++ b/source/common/json/json_loader.cc @@ -693,5 +693,5 @@ const std::string Factory::listAsJsonString(const std::list& items) return writer_string_buffer.GetString(); } -} // Json -} // Envoy +} // namespace Json +} // namespace Envoy diff --git a/source/common/json/json_loader.h b/source/common/json/json_loader.h index 27019c9559649..9a576e79314c1 100644 --- a/source/common/json/json_loader.h +++ b/source/common/json/json_loader.h @@ -23,5 +23,5 @@ class Factory { static const std::string listAsJsonString(const std::list& items); }; -} // Json -} // Envoy +} // namespace Json +} // namespace Envoy diff --git a/source/common/json/json_validator.h b/source/common/json/json_validator.h index 0d22ed173da77..b906eb23b3cdc 100644 --- a/source/common/json/json_validator.h +++ b/source/common/json/json_validator.h @@ -17,5 +17,5 @@ class Validator { } }; -} // Json -} // Envoy +} // namespace Json +} // namespace Envoy diff --git a/source/common/local_info/local_info_impl.h b/source/common/local_info/local_info_impl.h index 4d2042c9f9311..1189c19e6e312 100644 --- a/source/common/local_info/local_info_impl.h +++ b/source/common/local_info/local_info_impl.h @@ -26,5 +26,5 @@ class LocalInfoImpl : public LocalInfo { const std::string node_name_; }; -} // LocalInfo -} // Envoy +} // namespace LocalInfo +} // namespace Envoy diff --git a/source/common/memory/stats.cc b/source/common/memory/stats.cc index d111deb2ad883..38fc68fe6dee6 100644 --- a/source/common/memory/stats.cc +++ b/source/common/memory/stats.cc @@ -21,8 +21,8 @@ uint64_t Stats::totalCurrentlyReserved() { return value; } -} // Memory -} // Envoy +} // namespace Memory +} // namespace Envoy #else @@ -32,7 +32,7 @@ namespace Memory { uint64_t Stats::totalCurrentlyAllocated() { return 0; } uint64_t Stats::totalCurrentlyReserved() { return 0; } -} // Memory -} // Envoy +} // namespace Memory +} // namespace Envoy #endif // #ifdef TCMALLOC diff --git a/source/common/memory/stats.h b/source/common/memory/stats.h index 46abc777022da..7dba0850e337a 100644 --- a/source/common/memory/stats.h +++ b/source/common/memory/stats.h @@ -22,5 +22,5 @@ class Stats { static uint64_t totalCurrentlyReserved(); }; -} // Memory -} // Envoy +} // namespace Memory +} // namespace Envoy diff --git a/source/common/mongo/bson_impl.cc b/source/common/mongo/bson_impl.cc index 515bcb2384a8d..eaadc2952d20b 100644 --- a/source/common/mongo/bson_impl.cc +++ b/source/common/mongo/bson_impl.cc @@ -551,5 +551,5 @@ const Field* DocumentImpl::find(const std::string& name, Field::Type type) const return nullptr; } -} // Bson -} // Envoy +} // namespace Bson +} // namespace Envoy diff --git a/source/common/mongo/bson_impl.h b/source/common/mongo/bson_impl.h index 9a0492b2f2b36..3857112355a1e 100644 --- a/source/common/mongo/bson_impl.h +++ b/source/common/mongo/bson_impl.h @@ -261,5 +261,5 @@ class DocumentImpl : public Document, std::list fields_; }; -} // Bson -} // Envoy +} // namespace Bson +} // namespace Envoy diff --git a/source/common/mongo/codec_impl.cc b/source/common/mongo/codec_impl.cc index f5f06f3e68282..074219865f7ae 100644 --- a/source/common/mongo/codec_impl.cc +++ b/source/common/mongo/codec_impl.cc @@ -393,5 +393,5 @@ void EncoderImpl::encodeReply(const ReplyMessage& message) { } } -} // Mongo -} // Envoy +} // namespace Mongo +} // namespace Envoy diff --git a/source/common/mongo/codec_impl.h b/source/common/mongo/codec_impl.h index cc3526d5f33db..da3030e6eb547 100644 --- a/source/common/mongo/codec_impl.h +++ b/source/common/mongo/codec_impl.h @@ -215,5 +215,5 @@ class EncoderImpl : public Encoder, Logger::Loggable { Buffer::Instance& output_; }; -} // Mongo -} // Envoy +} // namespace Mongo +} // namespace Envoy diff --git a/source/common/mongo/proxy.cc b/source/common/mongo/proxy.cc index b046c03ddf5f5..92c84bdb16b15 100644 --- a/source/common/mongo/proxy.cc +++ b/source/common/mongo/proxy.cc @@ -241,5 +241,5 @@ DecoderPtr ProdProxyFilter::createDecoder(DecoderCallbacks& callbacks) { return DecoderPtr{new DecoderImpl(callbacks)}; } -} // Envoy -} // Mongo +} // namespace Mongo +} // namespace Envoy diff --git a/source/common/mongo/proxy.h b/source/common/mongo/proxy.h index 9354ee3b569e1..8be56ff6e87eb 100644 --- a/source/common/mongo/proxy.h +++ b/source/common/mongo/proxy.h @@ -158,4 +158,4 @@ class ProdProxyFilter : public ProxyFilter { }; } // Mongo -} // Envoy +} // namespace Envoy diff --git a/source/common/mongo/utility.cc b/source/common/mongo/utility.cc index 48874522581b7..e0d3c941d97d0 100644 --- a/source/common/mongo/utility.cc +++ b/source/common/mongo/utility.cc @@ -135,5 +135,5 @@ void QueryMessageInfo::parseFindCommand(const Bson::Document& command) { } } -} // Mongo -} // Envoy +} // namespace Mongo +} // namespace Envoy diff --git a/source/common/mongo/utility.h b/source/common/mongo/utility.h index d3f5e7118de6f..f54fcb22123fa 100644 --- a/source/common/mongo/utility.h +++ b/source/common/mongo/utility.h @@ -68,5 +68,5 @@ class QueryMessageInfo { std::string command_; }; -} // Mongo -} // Envoy +} // namespace Mongo +} // namespace Envoy diff --git a/source/common/network/address_impl.cc b/source/common/network/address_impl.cc index f909c805bc11d..155d86c1b035c 100644 --- a/source/common/network/address_impl.cc +++ b/source/common/network/address_impl.cc @@ -221,6 +221,6 @@ int PipeInstance::socket(SocketType type) const { return ::socket(AF_UNIX, flagsFromSocketType(type), 0); } -} // Address -} // Network -} // Envoy +} // namespace Address +} // namespace Network +} // namespace Envoy diff --git a/source/common/network/address_impl.h b/source/common/network/address_impl.h index 07a6225e24196..0654eea40f27f 100644 --- a/source/common/network/address_impl.h +++ b/source/common/network/address_impl.h @@ -198,6 +198,6 @@ class PipeInstance : public InstanceBase { sockaddr_un address_; }; -} // Address -} // Network -} // Envoy +} // namespace Address +} // namespace Network +} // namespace Envoy diff --git a/source/common/network/cidr_range.cc b/source/common/network/cidr_range.cc index 80ecbeeaf4c5a..d6bd2318657c2 100644 --- a/source/common/network/cidr_range.cc +++ b/source/common/network/cidr_range.cc @@ -248,6 +248,6 @@ IpList::IpList(const Json::Object& config, const std::string& member_name) : IpList(config.hasObject(member_name) ? config.getStringArray(member_name) : std::vector()) {} -} // Address -} // Network -} // Envoy +} // namespace Address +} // namespace Network +} // namespace Envoy diff --git a/source/common/network/cidr_range.h b/source/common/network/cidr_range.h index 848d04c60ec1a..014ab8d0d0c0c 100644 --- a/source/common/network/cidr_range.h +++ b/source/common/network/cidr_range.h @@ -136,6 +136,6 @@ class IpList { std::vector ip_list_; }; -} // Address -} // Network -} // Envoy +} // namespace Address +} // namespace Network +} // namespace Envoy diff --git a/source/common/network/connection_impl.cc b/source/common/network/connection_impl.cc index 71dd1a992ab0f..b376a36534982 100644 --- a/source/common/network/connection_impl.cc +++ b/source/common/network/connection_impl.cc @@ -66,9 +66,9 @@ ConnectionImpl::ConnectionImpl(Event::DispatcherImpl& dispatcher, int fd, // We never ask for both early close and read at the same time. If we are reading, we want to // consume all available data. - file_event_ = dispatcher_.createFileEvent(fd_, [this](uint32_t events) -> void { - onFileEvent(events); - }, Event::FileTriggerType::Edge, Event::FileReadyType::Read | Event::FileReadyType::Write); + file_event_ = dispatcher_.createFileEvent( + fd_, [this](uint32_t events) -> void { onFileEvent(events); }, Event::FileTriggerType::Edge, + Event::FileReadyType::Read | Event::FileReadyType::Write); } ConnectionImpl::~ConnectionImpl() { @@ -463,5 +463,5 @@ ClientConnectionImpl::ClientConnectionImpl(Event::DispatcherImpl& dispatcher, : ConnectionImpl(dispatcher, address->socket(Address::SocketType::Stream), address, getNullLocalAddress(*address)) {} -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/source/common/network/connection_impl.h b/source/common/network/connection_impl.h index 7570a805f45b5..a3a81a76199c5 100644 --- a/source/common/network/connection_impl.h +++ b/source/common/network/connection_impl.h @@ -151,5 +151,5 @@ class ClientConnectionImpl : public ConnectionImpl, virtual public ClientConnect void connect() override { doConnect(); } }; -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/source/common/network/dns_impl.cc b/source/common/network/dns_impl.cc index 3d35479efb26e..900f9485e251e 100644 --- a/source/common/network/dns_impl.cc +++ b/source/common/network/dns_impl.cc @@ -153,9 +153,9 @@ void DnsResolverImpl::onAresSocketStateChange(int fd, int read, int write) { // If we weren't tracking the fd before, create a new FileEvent. if (it == events_.end()) { - events_[fd] = dispatcher_.createFileEvent(fd, [this, fd](uint32_t events) { - onEventCallback(fd, events); - }, Event::FileTriggerType::Level, Event::FileReadyType::Read | Event::FileReadyType::Write); + events_[fd] = dispatcher_.createFileEvent( + fd, [this, fd](uint32_t events) { onEventCallback(fd, events); }, + Event::FileTriggerType::Level, Event::FileReadyType::Read | Event::FileReadyType::Write); } events_[fd]->setEnabled((read ? Event::FileReadyType::Read : 0) | (write ? Event::FileReadyType::Write : 0)); @@ -194,12 +194,13 @@ ActiveDnsQuery* DnsResolverImpl::resolve(const std::string& dns_name, } void DnsResolverImpl::PendingResolution::getHostByName(int family) { - ares_gethostbyname(channel_, dns_name_.c_str(), - family, [](void* arg, int status, int timeouts, hostent* hostent) { - static_cast(arg) - ->onAresHostCallback(status, timeouts, hostent); - }, this); + ares_gethostbyname(channel_, dns_name_.c_str(), family, + [](void* arg, int status, int timeouts, hostent* hostent) { + static_cast(arg)->onAresHostCallback(status, timeouts, + hostent); + }, + this); } -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/source/common/network/dns_impl.h b/source/common/network/dns_impl.h index 8096b9d015e00..b10fd067d8d21 100644 --- a/source/common/network/dns_impl.h +++ b/source/common/network/dns_impl.h @@ -93,5 +93,5 @@ class DnsResolverImpl : public DnsResolver, protected Logger::Loggable events_; }; -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/source/common/network/filter_impl.h b/source/common/network/filter_impl.h index a934481fa123e..345c81c8652a8 100644 --- a/source/common/network/filter_impl.h +++ b/source/common/network/filter_impl.h @@ -21,5 +21,5 @@ class FilterBaseImpl : public Filter { Network::FilterStatus onNewConnection() override { return Network::FilterStatus::Continue; } }; -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/source/common/network/filter_manager_impl.cc b/source/common/network/filter_manager_impl.cc index 20b79c5683d5d..7f9faddb72180 100644 --- a/source/common/network/filter_manager_impl.cc +++ b/source/common/network/filter_manager_impl.cc @@ -82,5 +82,5 @@ FilterStatus FilterManagerImpl::onWrite() { return FilterStatus::Continue; } -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/source/common/network/filter_manager_impl.h b/source/common/network/filter_manager_impl.h index c3c54a7efec16..6f2bca0615c41 100644 --- a/source/common/network/filter_manager_impl.h +++ b/source/common/network/filter_manager_impl.h @@ -74,5 +74,5 @@ class FilterManagerImpl { std::list downstream_filters_; }; -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/source/common/network/listen_socket_impl.cc b/source/common/network/listen_socket_impl.cc index 9435c138718fa..7d2dae864b2b2 100644 --- a/source/common/network/listen_socket_impl.cc +++ b/source/common/network/listen_socket_impl.cc @@ -57,5 +57,5 @@ UdsListenSocket::UdsListenSocket(const std::string& uds_path) { doBind(); } -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/source/common/network/listen_socket_impl.h b/source/common/network/listen_socket_impl.h index cbbae660a9e8e..e525b17e0c872 100644 --- a/source/common/network/listen_socket_impl.h +++ b/source/common/network/listen_socket_impl.h @@ -50,5 +50,5 @@ class UdsListenSocket : public ListenSocketImpl { UdsListenSocket(const std::string& uds_path); }; -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/source/common/network/listener_impl.cc b/source/common/network/listener_impl.cc index 3744375665a51..13499b8d36893 100644 --- a/source/common/network/listener_impl.cc +++ b/source/common/network/listener_impl.cc @@ -114,5 +114,5 @@ void SslListenerImpl::newConnection(int fd, Address::InstanceConstSharedPtr remo cb_.onNewConnection(std::move(new_connection)); } -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/source/common/network/listener_impl.h b/source/common/network/listener_impl.h index 942617f920554..45a5a0134c5df 100644 --- a/source/common/network/listener_impl.h +++ b/source/common/network/listener_impl.h @@ -70,5 +70,5 @@ class SslListenerImpl : public ListenerImpl { Ssl::Context& ssl_ctx_; }; -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/source/common/network/proxy_protocol.cc b/source/common/network/proxy_protocol.cc index 4df8dab042e3a..c08a557f9ac5d 100644 --- a/source/common/network/proxy_protocol.cc +++ b/source/common/network/proxy_protocol.cc @@ -32,11 +32,14 @@ ProxyProtocol::ActiveConnection::ActiveConnection(ProxyProtocol& parent, Event::Dispatcher& dispatcher, int fd, ListenerImpl& listener) : parent_(parent), fd_(fd), listener_(listener), search_index_(1) { - file_event_ = dispatcher.createFileEvent(fd, [this](uint32_t events) { - ASSERT(events == Event::FileReadyType::Read); - UNREFERENCED_PARAMETER(events); - onRead(); - }, Event::FileTriggerType::Edge, Event::FileReadyType::Read); + file_event_ = + dispatcher.createFileEvent(fd, + [this](uint32_t events) { + ASSERT(events == Event::FileReadyType::Read); + UNREFERENCED_PARAMETER(events); + onRead(); + }, + Event::FileTriggerType::Edge, Event::FileReadyType::Read); } ProxyProtocol::ActiveConnection::~ActiveConnection() { @@ -157,5 +160,5 @@ bool ProxyProtocol::ActiveConnection::readLine(int fd, std::string& s) { throw EnvoyException("failed to read proxy protocol"); } -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/source/common/network/proxy_protocol.h b/source/common/network/proxy_protocol.h index db83b2282bcc8..4e4babab5dd8e 100644 --- a/source/common/network/proxy_protocol.h +++ b/source/common/network/proxy_protocol.h @@ -79,5 +79,5 @@ class ProxyProtocol { std::list> connections_; }; -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/source/common/network/utility.cc b/source/common/network/utility.cc index 9942cc23fa48b..c882e8dac9518 100644 --- a/source/common/network/utility.cc +++ b/source/common/network/utility.cc @@ -318,5 +318,5 @@ bool Utility::portInRangeList(const Address::Instance& address, const std::list< return false; } -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/source/common/network/utility.h b/source/common/network/utility.h index 6d3390df31855..baf05d6f286ca 100644 --- a/source/common/network/utility.h +++ b/source/common/network/utility.h @@ -56,21 +56,21 @@ class Utility { static uint32_t portFromTcpUrl(const std::string& url); /** - * Parse an internet host address (IPv4 or IPv6) and create an Instance from it. The address must - * not include a port number. Throws EnvoyException if unable to parse the address. - * @param ip_address string to be parsed as an internet address. - * @return pointer to the Instance, or nullptr if unable to parse the address. - */ + * Parse an internet host address (IPv4 or IPv6) and create an Instance from it. The address must + * not include a port number. Throws EnvoyException if unable to parse the address. + * @param ip_address string to be parsed as an internet address. + * @return pointer to the Instance, or nullptr if unable to parse the address. + */ static Address::InstanceConstSharedPtr parseInternetAddress(const std::string& ip_address); /** - * Parse an internet host address (IPv4 or IPv6) AND port, and create an Instance from it. Throws - * EnvoyException if unable to parse the address. - * @param ip_addr string to be parsed as an internet address and port. Examples: - * - "1.2.3.4:80" - * - "[1234:5678::9]:443" - * @return pointer to the Instance. - */ + * Parse an internet host address (IPv4 or IPv6) AND port, and create an Instance from it. Throws + * EnvoyException if unable to parse the address. + * @param ip_addr string to be parsed as an internet address and port. Examples: + * - "1.2.3.4:80" + * - "[1234:5678::9]:443" + * @return pointer to the Instance. + */ static Address::InstanceConstSharedPtr parseInternetAddressAndPort(const std::string& ip_address); /** @@ -161,5 +161,5 @@ class Utility { static void throwWithMalformedIp(const std::string& ip_address); }; -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/source/common/profiler/profiler.cc b/source/common/profiler/profiler.cc index 3022cadece7c0..d99fe81532eff 100644 --- a/source/common/profiler/profiler.cc +++ b/source/common/profiler/profiler.cc @@ -25,8 +25,8 @@ void Heap::forceLink() { HeapProfilerDump(""); } -} // Profiler -} // Envoy +} // namespace Profiler +} // namespace Envoy #else @@ -37,7 +37,7 @@ bool Cpu::profilerEnabled() { return false; } bool Cpu::startProfiler(const std::string&) { return false; } void Cpu::stopProfiler() {} -} // Profiler -} // Envoy +} // namespace Profiler +} // namespace Envoy #endif // #ifdef TCMALLOC diff --git a/source/common/profiler/profiler.h b/source/common/profiler/profiler.h index f5c8746d9b853..9d49122bd827f 100644 --- a/source/common/profiler/profiler.h +++ b/source/common/profiler/profiler.h @@ -35,5 +35,5 @@ class Heap { static void forceLink(); }; -} // Profiler -} // Envoy +} // namespace Profiler +} // namespace Envoy diff --git a/source/common/ratelimit/ratelimit_impl.cc b/source/common/ratelimit/ratelimit_impl.cc index a2c4222ce5565..b4c8862c4f098 100644 --- a/source/common/ratelimit/ratelimit_impl.cc +++ b/source/common/ratelimit/ratelimit_impl.cc @@ -97,5 +97,5 @@ Grpc::RpcChannelPtr GrpcFactoryImpl::create(Grpc::RpcChannelCallbacks& callbacks return Grpc::RpcChannelPtr{new Grpc::RpcChannelImpl(cm_, cluster_name_, callbacks, timeout)}; } -} // RateLimit -} // Envoy +} // namespace RateLimit +} // namespace Envoy diff --git a/source/common/ratelimit/ratelimit_impl.h b/source/common/ratelimit/ratelimit_impl.h index 94c45363910c3..968c81b6768c0 100644 --- a/source/common/ratelimit/ratelimit_impl.h +++ b/source/common/ratelimit/ratelimit_impl.h @@ -78,5 +78,5 @@ class NullFactoryImpl : public ClientFactory { } }; -} // RateLimit -} // Envoy +} // namespace RateLimit +} // namespace Envoy diff --git a/source/common/redis/codec_impl.cc b/source/common/redis/codec_impl.cc index 66f53cf87fea8..e5e9c5b722792 100644 --- a/source/common/redis/codec_impl.cc +++ b/source/common/redis/codec_impl.cc @@ -418,5 +418,5 @@ void EncoderImpl::encodeSimpleString(const std::string& string, Buffer::Instance out.add("\r\n", 2); } -} // Redis -} // Envoy +} // namespace Redis +} // namespace Envoy diff --git a/source/common/redis/codec_impl.h b/source/common/redis/codec_impl.h index 17c46cc173178..53f2d9b4474b0 100644 --- a/source/common/redis/codec_impl.h +++ b/source/common/redis/codec_impl.h @@ -89,5 +89,5 @@ class EncoderImpl : public Encoder { void encodeSimpleString(const std::string& string, Buffer::Instance& out); }; -} // Redis -} // Envoy +} // namespace Redis +} // namespace Envoy diff --git a/source/common/redis/command_splitter_impl.cc b/source/common/redis/command_splitter_impl.cc index 4bbf38e20640e..be6fac731c33d 100644 --- a/source/common/redis/command_splitter_impl.cc +++ b/source/common/redis/command_splitter_impl.cc @@ -143,8 +143,8 @@ void MGETCommandHandler::SplitRequestImpl::onFailure(uint32_t index) { InstanceImpl::InstanceImpl(ConnPool::InstancePtr&& conn_pool, Stats::Scope& scope, const std::string& stat_prefix) : conn_pool_(std::move(conn_pool)), all_to_one_handler_(*conn_pool_), - mget_handler_(*conn_pool_), - stats_{ALL_COMMAND_SPLITTER_STATS(POOL_COUNTER_PREFIX(scope, stat_prefix + "splitter."))} { + mget_handler_(*conn_pool_), stats_{ALL_COMMAND_SPLITTER_STATS( + POOL_COUNTER_PREFIX(scope, stat_prefix + "splitter."))} { // TODO(mattklein123) PERF: Make this a trie (like in header_map_impl). for (const std::string& command : Commands::allToOneCommands()) { addHandler(scope, stat_prefix, command, all_to_one_handler_); @@ -197,6 +197,6 @@ void InstanceImpl::addHandler(Stats::Scope& scope, const std::string& stat_prefi handler}); } -} // CommandSplitter -} // Redis -} // Envoy +} // namespace CommandSplitter +} // namespace Redis +} // namespace Envoy diff --git a/source/common/redis/command_splitter_impl.h b/source/common/redis/command_splitter_impl.h index 6b7251ddecd01..d2e284ebb958c 100644 --- a/source/common/redis/command_splitter_impl.h +++ b/source/common/redis/command_splitter_impl.h @@ -161,6 +161,6 @@ class InstanceImpl : public Instance, Logger::Loggable { const ToLowerTable to_lower_table_; }; -} // CommandSplitter -} // Redis -} // Envoy +} // namespace CommandSplitter +} // namespace Redis +} // namespace Envoy diff --git a/source/common/redis/conn_pool_impl.cc b/source/common/redis/conn_pool_impl.cc index b431c5e076fba..6ad207db4fd13 100644 --- a/source/common/redis/conn_pool_impl.cc +++ b/source/common/redis/conn_pool_impl.cc @@ -179,10 +179,11 @@ InstanceImpl::InstanceImpl(const std::string& cluster_name, Upstream::ClusterMan const Json::Object& config) : cm_(cm), client_factory_(client_factory), tls_(tls), tls_slot_(tls.allocateSlot()), config_(config) { - tls.set(tls_slot_, [this, cluster_name]( - Event::Dispatcher& dispatcher) -> ThreadLocal::ThreadLocalObjectSharedPtr { - return std::make_shared(*this, dispatcher, cluster_name); - }); + tls.set(tls_slot_, + [this, + cluster_name](Event::Dispatcher& dispatcher) -> ThreadLocal::ThreadLocalObjectSharedPtr { + return std::make_shared(*this, dispatcher, cluster_name); + }); } PoolRequest* InstanceImpl::makeRequest(const std::string& hash_key, const RespValue& value, @@ -196,8 +197,9 @@ InstanceImpl::ThreadLocalPool::ThreadLocalPool(InstanceImpl& parent, Event::Disp cluster_->hostSet().addMemberUpdateCb( [this](const std::vector&, - const std::vector& hosts_removed) - -> void { onHostsRemoved(hosts_removed); }); + const std::vector& hosts_removed) -> void { + onHostsRemoved(hosts_removed); + }); } void InstanceImpl::ThreadLocalPool::onHostsRemoved( @@ -248,6 +250,6 @@ void InstanceImpl::ThreadLocalPool::shutdown() { } } -} // ConnPool -} // Redis -} // Envoy +} // namespace ConnPool +} // namespace Redis +} // namespace Envoy diff --git a/source/common/redis/conn_pool_impl.h b/source/common/redis/conn_pool_impl.h index 664146e308939..5937ebd00e874 100644 --- a/source/common/redis/conn_pool_impl.h +++ b/source/common/redis/conn_pool_impl.h @@ -166,6 +166,6 @@ class InstanceImpl : public Instance { ConfigImpl config_; }; -} // ConnPool -} // Redis -} // Envoy +} // namespace ConnPool +} // namespace Redis +} // namespace Envoy diff --git a/source/common/redis/proxy_filter.cc b/source/common/redis/proxy_filter.cc index 9466aec1d8afb..c2d268641ef92 100644 --- a/source/common/redis/proxy_filter.cc +++ b/source/common/redis/proxy_filter.cc @@ -115,5 +115,5 @@ ProxyFilter::PendingRequest::~PendingRequest() { parent_.config_->stats().downstream_rq_active_.dec(); } -} // Redis -} // Envoy +} // namespace Redis +} // namespace Envoy diff --git a/source/common/redis/proxy_filter.h b/source/common/redis/proxy_filter.h index abc262d9bce99..c8437891d5d7e 100644 --- a/source/common/redis/proxy_filter.h +++ b/source/common/redis/proxy_filter.h @@ -109,4 +109,4 @@ class ProxyFilter : public Network::ReadFilter, }; } // Redis -} // Envoy +} // namespace Envoy diff --git a/source/common/router/config_impl.cc b/source/common/router/config_impl.cc index b8e3620843631..e49cc158553e1 100644 --- a/source/common/router/config_impl.cc +++ b/source/common/router/config_impl.cc @@ -638,5 +638,5 @@ ConfigImpl::ConfigImpl(const Json::Object& config, Runtime::Loader& runtime, } } -} // Router -} // Envoy +} // namespace Router +} // namespace Envoy diff --git a/source/common/router/config_impl.h b/source/common/router/config_impl.h index 89202f008a8f1..da9ef24672b86 100644 --- a/source/common/router/config_impl.h +++ b/source/common/router/config_impl.h @@ -469,5 +469,5 @@ class NullConfigImpl : public Config { std::list response_headers_to_remove_; }; -} // Router -} // Envoy +} // namespace Router +} // namespace Envoy diff --git a/source/common/router/config_utility.cc b/source/common/router/config_utility.cc index 34c7572bca6ea..c3f41c6b4bffb 100644 --- a/source/common/router/config_utility.cc +++ b/source/common/router/config_utility.cc @@ -43,5 +43,5 @@ bool ConfigUtility::matchHeaders(const Http::HeaderMap& request_headers, return matches; } -} // Router -} // Envoy +} // namespace Router +} // namespace Envoy diff --git a/source/common/router/config_utility.h b/source/common/router/config_utility.h index 92af4753e4024..21e0232ab39a6 100644 --- a/source/common/router/config_utility.h +++ b/source/common/router/config_utility.h @@ -52,5 +52,5 @@ class ConfigUtility { const std::vector& request_headers); }; -} // Router -} // Envoy +} // namespace Router +} // namespace Envoy diff --git a/source/common/router/rds_impl.cc b/source/common/router/rds_impl.cc index 44ae3ee6a894d..59872742b7d96 100644 --- a/source/common/router/rds_impl.cc +++ b/source/common/router/rds_impl.cc @@ -129,5 +129,5 @@ void RdsRouteConfigProviderImpl::registerInitTarget(Init::Manager& init_manager) init_manager.registerTarget(*this); } -} // Router -} // Envoy +} // namespace Router +} // namespace Envoy diff --git a/source/common/router/rds_impl.h b/source/common/router/rds_impl.h index 0aac2dbc95f45..611b3ae201006 100644 --- a/source/common/router/rds_impl.h +++ b/source/common/router/rds_impl.h @@ -122,5 +122,5 @@ class RdsRouteConfigProviderImpl : public RouteConfigProvider, friend class RouteConfigProviderUtil; }; -} // Router -} // Envoy +} // namespace Router +} // namespace Envoy diff --git a/source/common/router/retry_state_impl.cc b/source/common/router/retry_state_impl.cc index d1c16a534a5d1..583f750a61ea1 100644 --- a/source/common/router/retry_state_impl.cc +++ b/source/common/router/retry_state_impl.cc @@ -213,5 +213,5 @@ bool RetryStateImpl::wouldRetry(const Http::HeaderMap* response_headers, return false; } -} // Router -} // Envoy +} // namespace Router +} // namespace Envoy diff --git a/source/common/router/retry_state_impl.h b/source/common/router/retry_state_impl.h index e4133f7e7178b..298db6dd064c6 100644 --- a/source/common/router/retry_state_impl.h +++ b/source/common/router/retry_state_impl.h @@ -59,5 +59,5 @@ class RetryStateImpl : public RetryState { Upstream::ResourcePriority priority_; }; -} // Router -} // Envoy +} // namespace Router +} // namespace Envoy diff --git a/source/common/router/router.cc b/source/common/router/router.cc index 3ae929fc2d37f..9a70e67c7291e 100644 --- a/source/common/router/router.cc +++ b/source/common/router/router.cc @@ -112,19 +112,31 @@ void Filter::chargeUpstreamCode(const Http::HeaderMap& response_headers, (upstream_host ? upstream_host->canary() : false); bool internal_request = internal_request_header && internal_request_header->value() == "true"; - Http::CodeUtility::ResponseStatInfo info{ - config_.scope_, cluster_->statsScope(), EMPTY_STRING, response_headers, internal_request, - route_entry_->virtualHost().name(), - request_vcluster_ ? request_vcluster_->name() : EMPTY_STRING, - config_.local_info_.zoneName(), upstreamZone(upstream_host), is_canary}; + Http::CodeUtility::ResponseStatInfo info{config_.scope_, + cluster_->statsScope(), + EMPTY_STRING, + response_headers, + internal_request, + route_entry_->virtualHost().name(), + request_vcluster_ ? request_vcluster_->name() + : EMPTY_STRING, + config_.local_info_.zoneName(), + upstreamZone(upstream_host), + is_canary}; Http::CodeUtility::chargeResponseStat(info); if (!alt_stat_prefix_.empty()) { - Http::CodeUtility::ResponseStatInfo info{ - config_.scope_, cluster_->statsScope(), alt_stat_prefix_, response_headers, - internal_request, EMPTY_STRING, EMPTY_STRING, config_.local_info_.zoneName(), - upstreamZone(upstream_host), is_canary}; + Http::CodeUtility::ResponseStatInfo info{config_.scope_, + cluster_->statsScope(), + alt_stat_prefix_, + response_headers, + internal_request, + EMPTY_STRING, + EMPTY_STRING, + config_.local_info_.zoneName(), + upstreamZone(upstream_host), + is_canary}; Http::CodeUtility::chargeResponseStat(info); } @@ -232,11 +244,13 @@ Http::FilterHeadersStatus Filter::decodeHeaders(Http::HeaderMap& headers, bool e callbacks_->streamId()); #ifndef NVLOG - headers.iterate([](const Http::HeaderEntry& header, void* context) -> void { - ENVOY_STREAM_LOG(debug, " '{}':'{}'", - *static_cast(context), - header.key().c_str(), header.value().c_str()); - }, callbacks_); + headers.iterate( + [](const Http::HeaderEntry& header, void* context) -> void { + ENVOY_STREAM_LOG(debug, " '{}':'{}'", + *static_cast(context), + header.key().c_str(), header.value().c_str()); + }, + callbacks_); #endif // Do a common header check. We make sure that all outgoing requests have all HTTP/2 headers. @@ -517,19 +531,31 @@ void Filter::onUpstreamComplete() { const Http::HeaderEntry* internal_request_header = downstream_headers_->EnvoyInternalRequest(); bool internal_request = internal_request_header && internal_request_header->value() == "true"; - Http::CodeUtility::ResponseTimingInfo info{ - config_.scope_, cluster_->statsScope(), EMPTY_STRING, response_time, - upstream_request_->upstream_canary_, internal_request, route_entry_->virtualHost().name(), - request_vcluster_ ? request_vcluster_->name() : EMPTY_STRING, - config_.local_info_.zoneName(), upstreamZone(upstream_request_->upstream_host_)}; + Http::CodeUtility::ResponseTimingInfo info{config_.scope_, + cluster_->statsScope(), + EMPTY_STRING, + response_time, + upstream_request_->upstream_canary_, + internal_request, + route_entry_->virtualHost().name(), + request_vcluster_ ? request_vcluster_->name() + : EMPTY_STRING, + config_.local_info_.zoneName(), + upstreamZone(upstream_request_->upstream_host_)}; Http::CodeUtility::chargeResponseTiming(info); if (!alt_stat_prefix_.empty()) { - Http::CodeUtility::ResponseTimingInfo info{ - config_.scope_, cluster_->statsScope(), alt_stat_prefix_, response_time, - upstream_request_->upstream_canary_, internal_request, EMPTY_STRING, EMPTY_STRING, - config_.local_info_.zoneName(), upstreamZone(upstream_request_->upstream_host_)}; + Http::CodeUtility::ResponseTimingInfo info{config_.scope_, + cluster_->statsScope(), + alt_stat_prefix_, + response_time, + upstream_request_->upstream_canary_, + internal_request, + EMPTY_STRING, + EMPTY_STRING, + config_.local_info_.zoneName(), + upstreamZone(upstream_request_->upstream_host_)}; Http::CodeUtility::chargeResponseTiming(info); } @@ -750,5 +776,5 @@ ProdFilter::createRetryState(const RetryPolicy& policy, Http::HeaderMap& request priority); } -} // Router -} // Envoy +} // namespace Router +} // namespace Envoy diff --git a/source/common/router/router.h b/source/common/router/router.h index 61c5f4b6ab9e8..8c6f3de5215fd 100644 --- a/source/common/router/router.h +++ b/source/common/router/router.h @@ -81,8 +81,8 @@ class FilterConfig { Stats::Scope& scope, Upstream::ClusterManager& cm, Runtime::Loader& runtime, Runtime::RandomGenerator& random, ShadowWriterPtr&& shadow_writer, bool emit_dynamic_stats) - : scope_(scope), local_info_(local_info), cm_(cm), runtime_(runtime), random_(random), - stats_{ALL_ROUTER_STATS(POOL_COUNTER_PREFIX(scope, stat_prefix))}, + : scope_(scope), local_info_(local_info), cm_(cm), runtime_(runtime), + random_(random), stats_{ALL_ROUTER_STATS(POOL_COUNTER_PREFIX(scope, stat_prefix))}, emit_dynamic_stats_(emit_dynamic_stats), shadow_writer_(std::move(shadow_writer)) {} ShadowWriter& shadowWriter() { return *shadow_writer_; } @@ -251,4 +251,4 @@ class ProdFilter : public Filter { }; } // Router -} // Envoy +} // namespace Envoy diff --git a/source/common/router/router_ratelimit.cc b/source/common/router/router_ratelimit.cc index 4eeaf5958e5c6..c58533f7e6c1b 100644 --- a/source/common/router/router_ratelimit.cc +++ b/source/common/router/router_ratelimit.cc @@ -114,9 +114,8 @@ void RateLimitPolicyEntryImpl::populateDescriptors(const Router::RouteEntry& rou RateLimit::Descriptor descriptor; bool result = true; for (const RateLimitActionPtr& action : actions_) { - result = result && - action->populateDescriptor(route, descriptor, local_service_cluster, headers, - remote_address); + result = result && action->populateDescriptor(route, descriptor, local_service_cluster, headers, + remote_address); if (!result) { break; } @@ -147,5 +146,5 @@ RateLimitPolicyImpl::getApplicableRateLimit(uint64_t stage) const { return rate_limit_entries_reference_[stage]; } -} // Router -} // Envoy +} // namespace Router +} // namespace Envoy diff --git a/source/common/router/router_ratelimit.h b/source/common/router/router_ratelimit.h index ab7ea917ae15b..aa5313aef5e9d 100644 --- a/source/common/router/router_ratelimit.h +++ b/source/common/router/router_ratelimit.h @@ -38,8 +38,8 @@ class DestinationClusterAction : public RateLimitAction { }; /** -* Action for request headers rate limiting. -*/ + * Action for request headers rate limiting. + */ class RequestHeadersAction : public RateLimitAction { public: RequestHeadersAction(const Json::Object& action) @@ -145,5 +145,5 @@ class RateLimitPolicyImpl : public RateLimitPolicy { static const uint64_t MAX_STAGE_NUMBER; }; -} // Router -} // Envoy +} // namespace Router +} // namespace Envoy diff --git a/source/common/router/shadow_writer_impl.cc b/source/common/router/shadow_writer_impl.cc index 01d089e30f382..c494e1ef6b6b4 100644 --- a/source/common/router/shadow_writer_impl.cc +++ b/source/common/router/shadow_writer_impl.cc @@ -20,9 +20,9 @@ void ShadowWriterImpl::shadow(const std::string& cluster, Http::MessagePtr&& req // Configuration should guarantee that cluster exists before calling here. This is basically // fire and forget. We don't handle cancelling. - cm_.httpAsyncClientForCluster(cluster) - .send(std::move(request), *this, Optional(timeout)); + cm_.httpAsyncClientForCluster(cluster).send(std::move(request), *this, + Optional(timeout)); } -} // Router -} // Envoy +} // namespace Router +} // namespace Envoy diff --git a/source/common/router/shadow_writer_impl.h b/source/common/router/shadow_writer_impl.h index 5302b8321644f..3724795b5b3e9 100644 --- a/source/common/router/shadow_writer_impl.h +++ b/source/common/router/shadow_writer_impl.h @@ -29,5 +29,5 @@ class ShadowWriterImpl : public ShadowWriter, public Http::AsyncClient::Callback Upstream::ClusterManager& cm_; }; -} // Router -} // Envoy +} // namespace Router +} // namespace Envoy diff --git a/source/common/runtime/runtime_impl.cc b/source/common/runtime/runtime_impl.cc index 44f448228ea23..0b8f3b27b3784 100644 --- a/source/common/runtime/runtime_impl.cc +++ b/source/common/runtime/runtime_impl.cc @@ -148,11 +148,12 @@ RuntimeStats LoaderImpl::generateStats(Stats::Store& store) { void LoaderImpl::onSymlinkSwap() { current_snapshot_.reset(new SnapshotImpl(root_path_, override_path_, stats_, generator_)); ThreadLocal::ThreadLocalObjectSharedPtr ptr_copy = current_snapshot_; - tls_.set(tls_slot_, [ptr_copy](Event::Dispatcher&) - -> ThreadLocal::ThreadLocalObjectSharedPtr { return ptr_copy; }); + tls_.set(tls_slot_, [ptr_copy](Event::Dispatcher&) -> ThreadLocal::ThreadLocalObjectSharedPtr { + return ptr_copy; + }); } Snapshot& LoaderImpl::snapshot() { return tls_.getTyped(tls_slot_); } -} // Runtime -} // Envoy +} // namespace Runtime +} // namespace Envoy diff --git a/source/common/runtime/runtime_impl.h b/source/common/runtime/runtime_impl.h index 76ed5504c314f..14cdf96d3134a 100644 --- a/source/common/runtime/runtime_impl.h +++ b/source/common/runtime/runtime_impl.h @@ -207,5 +207,5 @@ class NullLoaderImpl : public Loader { NullSnapshotImpl snapshot_; }; -} // Runtime -} // Envoy +} // namespace Runtime +} // namespace Envoy diff --git a/source/common/runtime/uuid_util.cc b/source/common/runtime/uuid_util.cc index 887f71a7b3eb3..fa59e758cf542 100644 --- a/source/common/runtime/uuid_util.cc +++ b/source/common/runtime/uuid_util.cc @@ -60,4 +60,4 @@ bool UuidUtils::setTraceableUuid(std::string& uuid, UuidTraceStatus trace_status return true; } -} // Envoy +} // namespace Envoy diff --git a/source/common/runtime/uuid_util.h b/source/common/runtime/uuid_util.h index 902dfd9826790..f13e03e0a3251 100644 --- a/source/common/runtime/uuid_util.h +++ b/source/common/runtime/uuid_util.h @@ -50,4 +50,4 @@ class UuidUtils { // Initial value for freshly generated uuid4. static const char NO_TRACE = '4'; }; -} // Envoy +} // namespace Envoy diff --git a/source/common/ssl/connection_impl.cc b/source/common/ssl/connection_impl.cc index 3c975495f7969..c2c9716dda3a9 100644 --- a/source/common/ssl/connection_impl.cc +++ b/source/common/ssl/connection_impl.cc @@ -314,5 +314,5 @@ std::string ConnectionImpl::nextProtocol() { return std::string(reinterpret_cast(proto), proto_len); } -} // Ssl -} // Envoy +} // namespace Ssl +} // namespace Envoy diff --git a/source/common/ssl/connection_impl.h b/source/common/ssl/connection_impl.h index 7e6af6b91983c..44002752ec36d 100644 --- a/source/common/ssl/connection_impl.h +++ b/source/common/ssl/connection_impl.h @@ -55,5 +55,5 @@ class ClientConnectionImpl final : public ConnectionImpl, public Network::Client void connect() override; }; -} // Ssl -} // Envoy +} // namespace Ssl +} // namespace Envoy diff --git a/source/common/ssl/context_config_impl.cc b/source/common/ssl/context_config_impl.cc index a3b8a271d9aa6..199fff72e81f0 100644 --- a/source/common/ssl/context_config_impl.cc +++ b/source/common/ssl/context_config_impl.cc @@ -44,5 +44,5 @@ ContextConfigImpl::ContextConfigImpl(const Json::Object& config) { server_name_indication_ = config.getString("sni", ""); } -} // Ssl -} // Envoy +} // namespace Ssl +} // namespace Envoy diff --git a/source/common/ssl/context_config_impl.h b/source/common/ssl/context_config_impl.h index 6d763da0a0527..b8a4984e2db75 100644 --- a/source/common/ssl/context_config_impl.h +++ b/source/common/ssl/context_config_impl.h @@ -44,5 +44,5 @@ class ContextConfigImpl final : public Ssl::ContextConfig { std::string server_name_indication_; }; -} // Ssl -} // Envoy +} // namespace Ssl +} // namespace Envoy diff --git a/source/common/ssl/context_impl.cc b/source/common/ssl/context_impl.cc index 4dd9f96ede822..73fd51b2c3a73 100644 --- a/source/common/ssl/context_impl.cc +++ b/source/common/ssl/context_impl.cc @@ -336,12 +336,12 @@ ServerContextImpl::ServerContextImpl(ContextManagerImpl& parent, Stats::Scope& s SSL_CTX_set_alpn_select_cb(ctx_.get(), [](SSL*, const unsigned char** out, unsigned char* outlen, const unsigned char* in, unsigned int inlen, void* arg) -> int { - return static_cast(arg) - ->alpnSelectCallback(out, outlen, in, inlen); + return static_cast(arg)->alpnSelectCallback( + out, outlen, in, inlen); }, this); } } -} // Ssl -} // Envoy +} // namespace Ssl +} // namespace Envoy diff --git a/source/common/ssl/context_manager_impl.cc b/source/common/ssl/context_manager_impl.cc index 48f906e0e190e..28b8dc7782718 100644 --- a/source/common/ssl/context_manager_impl.cc +++ b/source/common/ssl/context_manager_impl.cc @@ -50,5 +50,5 @@ void ContextManagerImpl::iterateContexts(std::function callback) } } -} // Ssl -} // Envoy +} // namespace Ssl +} // namespace Envoy diff --git a/source/common/ssl/context_manager_impl.h b/source/common/ssl/context_manager_impl.h index 1d5e1c2070876..3675925c45ffc 100644 --- a/source/common/ssl/context_manager_impl.h +++ b/source/common/ssl/context_manager_impl.h @@ -41,5 +41,5 @@ class ContextManagerImpl final : public ContextManager { std::mutex contexts_lock_; }; -} // Ssl -} // Envoy +} // namespace Ssl +} // namespace Envoy diff --git a/source/common/stats/stats_impl.cc b/source/common/stats/stats_impl.cc index 7c6d79f791b5c..aa07373366c73 100644 --- a/source/common/stats/stats_impl.cc +++ b/source/common/stats/stats_impl.cc @@ -42,5 +42,5 @@ bool RawStatData::matches(const std::string& name) { return 0 == strcmp(name.substr(0, MAX_NAME_SIZE).c_str(), name_); } -} // Stats -} // Envoy +} // namespace Stats +} // namespace Envoy diff --git a/source/common/stats/stats_impl.h b/source/common/stats/stats_impl.h index 0d2b7ba940c5f..3dfbaa64d7e94 100644 --- a/source/common/stats/stats_impl.h +++ b/source/common/stats/stats_impl.h @@ -206,12 +206,14 @@ template class IsolatedStatsCache { class IsolatedStoreImpl : public Store { public: IsolatedStoreImpl() - : counters_([this](const std::string& name) - -> CounterImpl* { return new CounterImpl(*alloc_.alloc(name), alloc_); }), - gauges_([this](const std::string& name) - -> GaugeImpl* { return new GaugeImpl(*alloc_.alloc(name), alloc_); }), - timers_([this](const std::string& name) - -> TimerImpl* { return new TimerImpl(name, *this); }) {} + : counters_([this](const std::string& name) -> CounterImpl* { + return new CounterImpl(*alloc_.alloc(name), alloc_); + }), + gauges_([this](const std::string& name) -> GaugeImpl* { + return new GaugeImpl(*alloc_.alloc(name), alloc_); + }), + timers_( + [this](const std::string& name) -> TimerImpl* { return new TimerImpl(name, *this); }) {} // Stats::Scope Counter& counter(const std::string& name) override { return counters_.get(name); } @@ -249,5 +251,5 @@ class IsolatedStoreImpl : public Store { IsolatedStatsCache timers_; }; -} // Stats -} // Envoy +} // namespace Stats +} // namespace Envoy diff --git a/source/common/stats/statsd.cc b/source/common/stats/statsd.cc index 05ba4ac7ffba2..feb697beda4f2 100644 --- a/source/common/stats/statsd.cc +++ b/source/common/stats/statsd.cc @@ -178,6 +178,6 @@ void TcpStatsdSink::TlsSink::write(const std::string& stat) { connection_->write(buffer); } -} // Statsd -} // Stats -} // Envoy +} // namespace Statsd +} // namespace Stats +} // namespace Envoy diff --git a/source/common/stats/statsd.h b/source/common/stats/statsd.h index ccba6e8997181..36d925319909a 100644 --- a/source/common/stats/statsd.h +++ b/source/common/stats/statsd.h @@ -120,6 +120,6 @@ class TcpStatsdSink : public Sink { Stats::Counter& cx_overflow_stat_; }; -} // Statsd -} // Stats -} // Envoy +} // namespace Statsd +} // namespace Stats +} // namespace Envoy diff --git a/source/common/stats/thread_local_store.cc b/source/common/stats/thread_local_store.cc index 9a3b25fcddb99..16be756339438 100644 --- a/source/common/stats/thread_local_store.cc +++ b/source/common/stats/thread_local_store.cc @@ -220,5 +220,5 @@ Timer& ThreadLocalStoreImpl::ScopeImpl::timer(const std::string& name) { return *central_ref; } -} // Stats -} // Envoy +} // namespace Stats +} // namespace Envoy diff --git a/source/common/stats/thread_local_store.h b/source/common/stats/thread_local_store.h index 61e21ea9920d0..e34fbf0bea41a 100644 --- a/source/common/stats/thread_local_store.h +++ b/source/common/stats/thread_local_store.h @@ -125,5 +125,5 @@ class ThreadLocalStoreImpl : public StoreRoot { HeapRawStatDataAllocator heap_allocator_; }; -} // Stats -} // Envoy +} // namespace Stats +} // namespace Envoy diff --git a/source/common/thread_local/thread_local_impl.cc b/source/common/thread_local/thread_local_impl.cc index 9b2ade07564a9..f1ef279365141 100644 --- a/source/common/thread_local/thread_local_impl.cc +++ b/source/common/thread_local/thread_local_impl.cc @@ -75,5 +75,5 @@ void InstanceImpl::reset() { registered_threads_.clear(); } -} // ThreadLocal -} // Envoy +} // namespace ThreadLocal +} // namespace Envoy diff --git a/source/common/thread_local/thread_local_impl.h b/source/common/thread_local/thread_local_impl.h index be1f9a49e2d94..1655dd3724151 100644 --- a/source/common/thread_local/thread_local_impl.h +++ b/source/common/thread_local/thread_local_impl.h @@ -43,5 +43,5 @@ class InstanceImpl : Logger::Loggable, public Instance { Event::Dispatcher* main_thread_dispatcher_{}; }; -} // ThreadLocal -} // Envoy +} // namespace ThreadLocal +} // namespace Envoy diff --git a/source/common/tracing/http_tracer_impl.cc b/source/common/tracing/http_tracer_impl.cc index 6c9150242175b..b000059d22da2 100644 --- a/source/common/tracing/http_tracer_impl.cc +++ b/source/common/tracing/http_tracer_impl.cc @@ -179,5 +179,5 @@ SpanPtr HttpTracerImpl::startSpan(const Config& config, Http::HeaderMap& request return active_span; } -} // Tracing -} // Envoy +} // namespace Tracing +} // namespace Envoy diff --git a/source/common/tracing/http_tracer_impl.h b/source/common/tracing/http_tracer_impl.h index 61ebcb09cf39b..af1e6ab318f53 100644 --- a/source/common/tracing/http_tracer_impl.h +++ b/source/common/tracing/http_tracer_impl.h @@ -114,5 +114,5 @@ class HttpTracerImpl : public HttpTracer { const LocalInfo::LocalInfo& local_info_; }; -} // Tracing -} // Envoy +} // namespace Tracing +} // namespace Envoy diff --git a/source/common/tracing/lightstep_tracer_impl.cc b/source/common/tracing/lightstep_tracer_impl.cc index 0a998d73f6e9c..7d9e717ec3da4 100644 --- a/source/common/tracing/lightstep_tracer_impl.cc +++ b/source/common/tracing/lightstep_tracer_impl.cc @@ -110,8 +110,8 @@ LightStepDriver::LightStepDriver(const Json::Object& config, Upstream::ClusterManager& cluster_manager, Stats::Store& stats, ThreadLocal::Instance& tls, Runtime::Loader& runtime, std::unique_ptr options) - : cm_(cluster_manager), - tracer_stats_{LIGHTSTEP_TRACER_STATS(POOL_COUNTER_PREFIX(stats, "tracing.lightstep."))}, + : cm_(cluster_manager), tracer_stats_{LIGHTSTEP_TRACER_STATS( + POOL_COUNTER_PREFIX(stats, "tracing.lightstep."))}, tls_(tls), runtime_(runtime), options_(std::move(options)), tls_slot_(tls.allocateSlot()) { Upstream::ThreadLocalCluster* cluster = cm_.get(config.getString("collector_cluster")); if (!cluster) { @@ -180,5 +180,5 @@ void LightStepRecorder::onSuccess(Http::MessagePtr&& msg) { } } -} // Tracing -} // Envoy +} // namespace Tracing +} // namespace Envoy diff --git a/source/common/tracing/lightstep_tracer_impl.h b/source/common/tracing/lightstep_tracer_impl.h index 3f9b4521acca2..b0942f840447c 100644 --- a/source/common/tracing/lightstep_tracer_impl.h +++ b/source/common/tracing/lightstep_tracer_impl.h @@ -113,4 +113,4 @@ class LightStepRecorder : public lightstep::Recorder, Http::AsyncClient::Callbac }; } // Tracing -} // Envoy +} // namespace Envoy diff --git a/source/common/tracing/zipkin/span_buffer.cc b/source/common/tracing/zipkin/span_buffer.cc index d887547c77718..cff07425f616e 100644 --- a/source/common/tracing/zipkin/span_buffer.cc +++ b/source/common/tracing/zipkin/span_buffer.cc @@ -29,5 +29,5 @@ std::string SpanBuffer::toStringifiedJsonArray() { return stringified_json_array; } -} // Zipkin -} // Envoy +} // namespace Zipkin +} // namespace Envoy diff --git a/source/common/tracing/zipkin/span_buffer.h b/source/common/tracing/zipkin/span_buffer.h index b9874fa1f88d4..cfe09662e046b 100644 --- a/source/common/tracing/zipkin/span_buffer.h +++ b/source/common/tracing/zipkin/span_buffer.h @@ -61,5 +61,5 @@ class SpanBuffer { // We use a pre-allocated vector to improve performance std::vector span_buffer_; }; -} // Zipkin -} // Envoy +} // namespace Zipkin +} // namespace Envoy diff --git a/source/common/tracing/zipkin/span_context.cc b/source/common/tracing/zipkin/span_context.cc index 0b5a8cd5e8d6b..480253268ef21 100644 --- a/source/common/tracing/zipkin/span_context.cc +++ b/source/common/tracing/zipkin/span_context.cc @@ -150,5 +150,5 @@ void SpanContext::populateFromString(const std::string& span_context_str) { is_initialized_ = false; } } -} // Zipkin -} // Envoy +} // namespace Zipkin +} // namespace Envoy diff --git a/source/common/tracing/zipkin/span_context.h b/source/common/tracing/zipkin/span_context.h index 0fcb514a3a120..319d93aab59b5 100644 --- a/source/common/tracing/zipkin/span_context.h +++ b/source/common/tracing/zipkin/span_context.h @@ -117,5 +117,5 @@ class SpanContext { AnnotationSet annotation_values_; bool is_initialized_; }; -} // Zipkin -} // Envoy +} // namespace Zipkin +} // namespace Envoy diff --git a/source/common/tracing/zipkin/tracer.cc b/source/common/tracing/zipkin/tracer.cc index 55538ecf8bf1b..f7caa12f936b5 100644 --- a/source/common/tracing/zipkin/tracer.cc +++ b/source/common/tracing/zipkin/tracer.cc @@ -26,7 +26,8 @@ SpanPtr Tracer::startSpan(const std::string& span_name, SystemTime timestamp) { span_ptr->setTraceId(random_number); int64_t start_time_micro = std::chrono::duration_cast( - ProdMonotonicTimeSource::instance_.currentTime().time_since_epoch()).count(); + ProdMonotonicTimeSource::instance_.currentTime().time_since_epoch()) + .count(); span_ptr->setStartTime(start_time_micro); // Set the timestamp globally for the span and also for the CS annotation @@ -97,7 +98,8 @@ SpanPtr Tracer::startSpan(const std::string& span_name, SystemTime timestamp, int64_t start_time_micro = std::chrono::duration_cast( - ProdMonotonicTimeSource::instance_.currentTime().time_since_epoch()).count(); + ProdMonotonicTimeSource::instance_.currentTime().time_since_epoch()) + .count(); span_ptr->setStartTime(start_time_micro); span_ptr->setTracer(this); @@ -113,5 +115,5 @@ void Tracer::reportSpan(Span&& span) { void Tracer::setReporter(ReporterPtr reporter) { reporter_ = std::move(reporter); } -} // Zipkin -} // Envoy +} // namespace Zipkin +} // namespace Envoy diff --git a/source/common/tracing/zipkin/tracer.h b/source/common/tracing/zipkin/tracer.h index ca9b4d2335438..5c4809ff9f139 100644 --- a/source/common/tracing/zipkin/tracer.h +++ b/source/common/tracing/zipkin/tracer.h @@ -110,5 +110,5 @@ class Tracer : public TracerInterface { typedef std::unique_ptr TracerPtr; -} // Zipkin -} // Envoy +} // namespace Zipkin +} // namespace Envoy diff --git a/source/common/tracing/zipkin/tracer_interface.h b/source/common/tracing/zipkin/tracer_interface.h index fc76dc828598e..fe6d72bc90046 100644 --- a/source/common/tracing/zipkin/tracer_interface.h +++ b/source/common/tracing/zipkin/tracer_interface.h @@ -28,5 +28,5 @@ class TracerInterface { */ virtual void reportSpan(Span&& span) PURE; }; -} // Zipkin -} // Envoy +} // namespace Zipkin +} // namespace Envoy diff --git a/source/common/tracing/zipkin/util.cc b/source/common/tracing/zipkin/util.cc index 331c8bd2905fc..95b3d2d530318 100644 --- a/source/common/tracing/zipkin/util.cc +++ b/source/common/tracing/zipkin/util.cc @@ -49,9 +49,10 @@ void Util::addArrayToJson(std::string& target, const std::vector& j uint64_t Util::generateRandom64() { uint64_t seed = std::chrono::duration_cast( - ProdSystemTimeSource::instance_.currentTime().time_since_epoch()).count(); + ProdSystemTimeSource::instance_.currentTime().time_since_epoch()) + .count(); std::mt19937_64 rand_64(seed); return rand_64(); } -} // Zipkin -} // Envoy +} // namespace Zipkin +} // namespace Envoy diff --git a/source/common/tracing/zipkin/util.h b/source/common/tracing/zipkin/util.h index 1dfbf22859973..a988b250502c1 100644 --- a/source/common/tracing/zipkin/util.h +++ b/source/common/tracing/zipkin/util.h @@ -45,5 +45,5 @@ class Util { */ static uint64_t generateRandom64(); }; -} // Zipkin -} // Envoy +} // namespace Zipkin +} // namespace Envoy diff --git a/source/common/tracing/zipkin/zipkin_core_constants.h b/source/common/tracing/zipkin/zipkin_core_constants.h index e01f6f516db8d..61696a26c981b 100644 --- a/source/common/tracing/zipkin/zipkin_core_constants.h +++ b/source/common/tracing/zipkin/zipkin_core_constants.h @@ -41,5 +41,5 @@ class ZipkinCoreConstantValues { typedef ConstSingleton ZipkinCoreConstants; -} // Zipkin -} // Envoy +} // namespace Zipkin +} // namespace Envoy diff --git a/source/common/tracing/zipkin/zipkin_core_types.cc b/source/common/tracing/zipkin/zipkin_core_types.cc index 946761725c651..63da04a3cde2b 100644 --- a/source/common/tracing/zipkin/zipkin_core_types.cc +++ b/source/common/tracing/zipkin/zipkin_core_types.cc @@ -225,7 +225,8 @@ void Span::finish() { Annotation ss; ss.setEndpoint(annotations_[0].endpoint()); ss.setTimestamp(std::chrono::duration_cast( - ProdSystemTimeSource::instance_.currentTime().time_since_epoch()).count()); + ProdSystemTimeSource::instance_.currentTime().time_since_epoch()) + .count()); ss.setValue(ZipkinCoreConstants::get().SERVER_SEND); annotations_.push_back(std::move(ss)); } else if (context.annotationSet().cs_ && !context.annotationSet().cr_) { @@ -233,14 +234,16 @@ void Span::finish() { Annotation cr; const uint64_t stop_timestamp = std::chrono::duration_cast( - ProdSystemTimeSource::instance_.currentTime().time_since_epoch()).count(); + ProdSystemTimeSource::instance_.currentTime().time_since_epoch()) + .count(); cr.setEndpoint(annotations_[0].endpoint()); cr.setTimestamp(stop_timestamp); cr.setValue(ZipkinCoreConstants::get().CLIENT_RECV); annotations_.push_back(std::move(cr)); const int64_t monotonic_stop_time = std::chrono::duration_cast( - ProdMonotonicTimeSource::instance_.currentTime().time_since_epoch()).count(); + ProdMonotonicTimeSource::instance_.currentTime().time_since_epoch()) + .count(); setDuration(monotonic_stop_time - monotonic_start_time_); } @@ -254,5 +257,5 @@ void Span::setTag(const std::string& name, const std::string& value) { addBinaryAnnotation(BinaryAnnotation(name, value)); } } -} // Zipkin -} // Envoy +} // namespace Zipkin +} // namespace Envoy diff --git a/source/common/tracing/zipkin/zipkin_core_types.h b/source/common/tracing/zipkin/zipkin_core_types.h index 091ee48824cd1..b0ba07ace4549 100644 --- a/source/common/tracing/zipkin/zipkin_core_types.h +++ b/source/common/tracing/zipkin/zipkin_core_types.h @@ -488,12 +488,12 @@ class Span : public ZipkinBase { void setServiceName(const std::string& service_name); /** - * Serializes the span as a Zipkin-compliant JSON representation as a string. - * The resulting JSON string can be used as part of an HTTP POST call to - * send the span to Zipkin. - * - * @return a stringified JSON. - */ + * Serializes the span as a Zipkin-compliant JSON representation as a string. + * The resulting JSON string can be used as part of an HTTP POST call to + * send the span to Zipkin. + * + * @return a stringified JSON. + */ const std::string toJson() override; /** @@ -543,5 +543,5 @@ class Span : public ZipkinBase { int64_t monotonic_start_time_; TracerInterface* tracer_; }; -} // Zipkin -} // Envoy +} // namespace Zipkin +} // namespace Envoy diff --git a/source/common/tracing/zipkin/zipkin_json_field_names.h b/source/common/tracing/zipkin/zipkin_json_field_names.h index fadb1964c5794..9ffb92886be0d 100644 --- a/source/common/tracing/zipkin/zipkin_json_field_names.h +++ b/source/common/tracing/zipkin/zipkin_json_field_names.h @@ -34,5 +34,5 @@ class ZipkinJsonFieldNameValues { typedef ConstSingleton ZipkinJsonFieldNames; -} // Zipkin -} // Envoy +} // namespace Zipkin +} // namespace Envoy diff --git a/source/common/tracing/zipkin/zipkin_tracer_impl.cc b/source/common/tracing/zipkin/zipkin_tracer_impl.cc index 576d5f43c03ae..bd993656c4d1d 100644 --- a/source/common/tracing/zipkin/zipkin_tracer_impl.cc +++ b/source/common/tracing/zipkin/zipkin_tracer_impl.cc @@ -63,9 +63,9 @@ Driver::TlsTracer::TlsTracer(TracerPtr&& tracer, Driver& driver) Driver::Driver(const Json::Object& config, Upstream::ClusterManager& cluster_manager, Stats::Store& stats, ThreadLocal::Instance& tls, Runtime::Loader& runtime, const LocalInfo::LocalInfo& local_info, Runtime::RandomGenerator& random_generator) - : cm_(cluster_manager), - tracer_stats_{ZIPKIN_TRACER_STATS(POOL_COUNTER_PREFIX(stats, "tracing.zipkin."))}, tls_(tls), - runtime_(runtime), local_info_(local_info), tls_slot_(tls.allocateSlot()) { + : cm_(cluster_manager), tracer_stats_{ZIPKIN_TRACER_STATS( + POOL_COUNTER_PREFIX(stats, "tracing.zipkin."))}, + tls_(tls), runtime_(runtime), local_info_(local_info), tls_slot_(tls.allocateSlot()) { Upstream::ThreadLocalCluster* cluster = cm_.get(config.getString("collector_cluster")); if (!cluster) { @@ -77,15 +77,16 @@ Driver::Driver(const Json::Object& config, Upstream::ClusterManager& cluster_man const std::string collector_endpoint = config.getString("collector_endpoint", ZipkinCoreConstants::get().DEFAULT_COLLECTOR_ENDPOINT); - tls_.set(tls_slot_, [this, collector_endpoint, &random_generator](Event::Dispatcher& dispatcher) - -> ThreadLocal::ThreadLocalObjectSharedPtr { - TracerPtr tracer(new Tracer(local_info_.clusterName(), - local_info_.address(), random_generator)); - tracer->setReporter(ReporterImpl::NewInstance( - std::ref(*this), std::ref(dispatcher), collector_endpoint)); - return ThreadLocal::ThreadLocalObjectSharedPtr{ - new TlsTracer(std::move(tracer), *this)}; - }); + tls_.set( + tls_slot_, + [this, collector_endpoint, &random_generator]( + Event::Dispatcher& dispatcher) -> ThreadLocal::ThreadLocalObjectSharedPtr { + TracerPtr tracer( + new Tracer(local_info_.clusterName(), local_info_.address(), random_generator)); + tracer->setReporter( + ReporterImpl::NewInstance(std::ref(*this), std::ref(dispatcher), collector_endpoint)); + return ThreadLocal::ThreadLocalObjectSharedPtr{new TlsTracer(std::move(tracer), *this)}; + }); } Tracing::SpanPtr Driver::startSpan(Http::HeaderMap& request_headers, const std::string&, @@ -200,5 +201,5 @@ void ReporterImpl::onSuccess(Http::MessagePtr&& http_response) { driver_.tracerStats().reports_sent_.inc(); } } -} // Zipkin -} // Envoy +} // namespace Zipkin +} // namespace Envoy diff --git a/source/common/tracing/zipkin/zipkin_tracer_impl.h b/source/common/tracing/zipkin/zipkin_tracer_impl.h index 7cbe01df461e1..c72defd11916f 100644 --- a/source/common/tracing/zipkin/zipkin_tracer_impl.h +++ b/source/common/tracing/zipkin/zipkin_tracer_impl.h @@ -207,4 +207,4 @@ class ReporterImpl : public Reporter, Http::AsyncClient::Callbacks { const std::string collector_endpoint_; }; } // Zipkin -} // Envoy +} // namespace Envoy diff --git a/source/common/upstream/cds_api_impl.cc b/source/common/upstream/cds_api_impl.cc index 8fc8cdfa9f3f9..b3919c72ac292 100644 --- a/source/common/upstream/cds_api_impl.cc +++ b/source/common/upstream/cds_api_impl.cc @@ -86,5 +86,5 @@ void CdsApiImpl::onFetchFailure(const EnvoyException* e) { } } -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/source/common/upstream/cds_api_impl.h b/source/common/upstream/cds_api_impl.h index 2cdf94517577f..9d6f6feba277c 100644 --- a/source/common/upstream/cds_api_impl.h +++ b/source/common/upstream/cds_api_impl.h @@ -61,4 +61,4 @@ class CdsApiImpl : public CdsApi, Http::RestApiFetcher, Logger::Loggable ThreadLocal::ThreadLocalObjectSharedPtr { - return ThreadLocal::ThreadLocalObjectSharedPtr{ - new ThreadLocalClusterManagerImpl(*this, dispatcher, local_cluster_name)}; - }); + [this, local_cluster_name]( + Event::Dispatcher& dispatcher) -> ThreadLocal::ThreadLocalObjectSharedPtr { + return ThreadLocal::ThreadLocalObjectSharedPtr{ + new ThreadLocalClusterManagerImpl(*this, dispatcher, local_cluster_name)}; + }); // To avoid threading issues, for those clusters that start with hosts already in them (like the // static cluster), we need to post an update onto each thread to notify them of the update. We @@ -591,5 +591,5 @@ CdsApiPtr ProdClusterManagerFactory::createCds(const Json::Object& config, Clust return CdsApiImpl::create(config, cm, primary_dispatcher_, random_, local_info_, stats_); } -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/source/common/upstream/cluster_manager_impl.h b/source/common/upstream/cluster_manager_impl.h index 5621aed13b934..71582fc518821 100644 --- a/source/common/upstream/cluster_manager_impl.h +++ b/source/common/upstream/cluster_manager_impl.h @@ -237,5 +237,5 @@ class ClusterManagerImpl : public ClusterManager { ClusterManagerInitHelper init_helper_; }; -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/source/common/upstream/eds.cc b/source/common/upstream/eds.cc index ba1850aa71c67..5ea3a17d0b878 100644 --- a/source/common/upstream/eds.cc +++ b/source/common/upstream/eds.cc @@ -23,10 +23,10 @@ EdsClusterImpl::EdsClusterImpl(const Json::Object& config, Runtime::Loader& runt subscription_ = Config::SubscriptionFactory::subscriptionFromConfigSource< envoy::api::v2::ClusterLoadAssignment>( eds_config, node, dispatcher, cm, random, - [this, &eds_config, &cm, &dispatcher, &random]() - -> Config::Subscription* { - return new SdsSubscription(info_->stats(), eds_config, cm, dispatcher, random); - }, + [this, &eds_config, &cm, &dispatcher, + &random]() -> Config::Subscription* { + return new SdsSubscription(info_->stats(), eds_config, cm, dispatcher, random); + }, "envoy.api.v2.EndpointDiscoveryService.FetchEndpoints", "envoy.api.v2.EndpointDiscoveryService.StreamEndpoints"); } @@ -48,9 +48,10 @@ void EdsClusterImpl::onConfigUpdate(const ResourceVector& resources) { for (const auto& lb_endpoint : locality_lb_endpoint.lb_endpoints()) { new_hosts.emplace_back(new HostImpl( - info_, "", Network::Address::InstanceConstSharedPtr{new Network::Address::Ipv4Instance( - lb_endpoint.endpoint().address().socket_address().ip_address(), - lb_endpoint.endpoint().address().socket_address().port().value())}, + info_, "", + Network::Address::InstanceConstSharedPtr{new Network::Address::Ipv4Instance( + lb_endpoint.endpoint().address().socket_address().ip_address(), + lb_endpoint.endpoint().address().socket_address().port().value())}, lb_endpoint.canary().value(), lb_endpoint.load_balancing_weight().value(), zone)); } } @@ -117,5 +118,5 @@ void EdsClusterImpl::runInitializeCallbackIfAny() { } } -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/source/common/upstream/eds.h b/source/common/upstream/eds.h index fc5f469e4ad84..08991f4fdaf1a 100644 --- a/source/common/upstream/eds.h +++ b/source/common/upstream/eds.h @@ -40,5 +40,5 @@ class EdsClusterImpl : public BaseDynamicClusterImpl, uint64_t pending_health_checks_{}; }; -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/source/common/upstream/health_checker_impl.cc b/source/common/upstream/health_checker_impl.cc index 0fff27dd556f7..68216d049e0a7 100644 --- a/source/common/upstream/health_checker_impl.cc +++ b/source/common/upstream/health_checker_impl.cc @@ -62,8 +62,9 @@ HealthCheckerImplBase::HealthCheckerImplBase(const Cluster& cluster, const Json: interval_(config.getInteger("interval_ms")), interval_jitter_(config.getInteger("interval_jitter_ms", 0)) { cluster_.addMemberUpdateCb([this](const std::vector& hosts_added, - const std::vector& hosts_removed) - -> void { onClusterMemberUpdate(hosts_added, hosts_removed); }); + const std::vector& hosts_removed) -> void { + onClusterMemberUpdate(hosts_added, hosts_removed); + }); } void HealthCheckerImplBase::decHealthy() { @@ -523,5 +524,5 @@ RedisHealthCheckerImpl::HealthCheckRequest::HealthCheckRequest() { request_.asArray().swap(values); } -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/source/common/upstream/health_checker_impl.h b/source/common/upstream/health_checker_impl.h index 5fe7c81d65d8e..ab700c6cc411e 100644 --- a/source/common/upstream/health_checker_impl.h +++ b/source/common/upstream/health_checker_impl.h @@ -376,5 +376,5 @@ class RedisHealthCheckerImpl : public HealthCheckerImplBase { Redis::ConnPool::ClientFactory& client_factory_; }; -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/source/common/upstream/host_utility.cc b/source/common/upstream/host_utility.cc index f271df1185741..c224f1322c3f6 100644 --- a/source/common/upstream/host_utility.cc +++ b/source/common/upstream/host_utility.cc @@ -22,5 +22,5 @@ std::string HostUtility::healthFlagsToString(const Host& host) { return ret; } -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/source/common/upstream/host_utility.h b/source/common/upstream/host_utility.h index 6b2e0fa14bc97..74bc26587c122 100644 --- a/source/common/upstream/host_utility.h +++ b/source/common/upstream/host_utility.h @@ -18,5 +18,5 @@ class HostUtility { static std::string healthFlagsToString(const Host& host); }; -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/source/common/upstream/load_balancer_impl.cc b/source/common/upstream/load_balancer_impl.cc index df1c25985e608..a8d0491aee09e 100644 --- a/source/common/upstream/load_balancer_impl.cc +++ b/source/common/upstream/load_balancer_impl.cc @@ -24,11 +24,13 @@ LoadBalancerBase::LoadBalancerBase(const HostSet& host_set, const HostSet* local local_host_set_(local_host_set) { if (local_host_set_) { host_set_.addMemberUpdateCb( - [this](const std::vector&, const std::vector&) - -> void { regenerateZoneRoutingStructures(); }); + [this](const std::vector&, const std::vector&) -> void { + regenerateZoneRoutingStructures(); + }); local_host_set_->addMemberUpdateCb( - [this](const std::vector&, const std::vector&) - -> void { regenerateZoneRoutingStructures(); }); + [this](const std::vector&, const std::vector&) -> void { + regenerateZoneRoutingStructures(); + }); } } @@ -297,5 +299,5 @@ HostConstSharedPtr RandomLoadBalancer::chooseHost(const LoadBalancerContext*) { return hosts_to_use[random_.random() % hosts_to_use.size()]; } -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/source/common/upstream/load_balancer_impl.h b/source/common/upstream/load_balancer_impl.h index 27e75b2c7f722..f27d3462e2426 100644 --- a/source/common/upstream/load_balancer_impl.h +++ b/source/common/upstream/load_balancer_impl.h @@ -132,5 +132,5 @@ class RandomLoadBalancer : public LoadBalancer, LoadBalancerBase { HostConstSharedPtr chooseHost(const LoadBalancerContext* context) override; }; -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/source/common/upstream/logical_dns_cluster.cc b/source/common/upstream/logical_dns_cluster.cc index f6e891aca2ca2..0cf76f71c7d6c 100644 --- a/source/common/upstream/logical_dns_cluster.cc +++ b/source/common/upstream/logical_dns_cluster.cc @@ -60,8 +60,8 @@ void LogicalDnsCluster::startResolve() { active_dns_query_ = dns_resolver_->resolve( dns_address, dns_lookup_family_, - [this, dns_address]( - std::list&& address_list) -> void { + [this, + dns_address](std::list&& address_list) -> void { active_dns_query_ = nullptr; ENVOY_LOG(debug, "async DNS resolution complete for {}", dns_address); info_->stats().update_success_.inc(); @@ -123,5 +123,5 @@ LogicalDnsCluster::LogicalHost::createConnection(Event::Dispatcher& dispatcher) new RealHostDescription(data.current_resolved_address_, shared_from_this())}}; } -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/source/common/upstream/logical_dns_cluster.h b/source/common/upstream/logical_dns_cluster.h index d218112c6e3ec..a24a1ea34e8ea 100644 --- a/source/common/upstream/logical_dns_cluster.h +++ b/source/common/upstream/logical_dns_cluster.h @@ -103,5 +103,5 @@ class LogicalDnsCluster : public ClusterImplBase { Network::ActiveDnsQuery* active_dns_query_{}; }; -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/source/common/upstream/outlier_detection_impl.cc b/source/common/upstream/outlier_detection_impl.cc index 4fa1ed8b78212..acb86ed76804a 100644 --- a/source/common/upstream/outlier_detection_impl.cc +++ b/source/common/upstream/outlier_detection_impl.cc @@ -469,6 +469,6 @@ Optional SuccessRateAccumulator::getSuccessRate(uint64_t success_rate_re backup_success_rate_bucket_->total_request_counter_); } -} // Outlier -} // Upstream -} // Envoy +} // namespace Outlier +} // namespace Upstream +} // namespace Envoy diff --git a/source/common/upstream/outlier_detection_impl.h b/source/common/upstream/outlier_detection_impl.h index 8f8ea83407a04..3019d0df02f86 100644 --- a/source/common/upstream/outlier_detection_impl.h +++ b/source/common/upstream/outlier_detection_impl.h @@ -280,6 +280,6 @@ class Utility { double success_rate_stdev_factor); }; -} // Outlier -} // Upstream -} // Envoy +} // namespace Outlier +} // namespace Upstream +} // namespace Envoy diff --git a/source/common/upstream/resource_manager_impl.h b/source/common/upstream/resource_manager_impl.h index 37ce05574a4ae..a666edf917099 100644 --- a/source/common/upstream/resource_manager_impl.h +++ b/source/common/upstream/resource_manager_impl.h @@ -67,5 +67,5 @@ class ResourceManagerImpl : public ResourceManager { typedef std::unique_ptr ResourceManagerImplPtr; -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/source/common/upstream/ring_hash_lb.cc b/source/common/upstream/ring_hash_lb.cc index c545ccf92bf9b..ffebc0fae16ac 100644 --- a/source/common/upstream/ring_hash_lb.cc +++ b/source/common/upstream/ring_hash_lb.cc @@ -113,8 +113,9 @@ void RingHashLoadBalancer::Ring::create(Runtime::Loader& runtime, } } - std::sort(ring_.begin(), ring_.end(), [](const RingEntry& lhs, const RingEntry& rhs) - -> bool { return lhs.hash_ < rhs.hash_; }); + std::sort(ring_.begin(), ring_.end(), [](const RingEntry& lhs, const RingEntry& rhs) -> bool { + return lhs.hash_ < rhs.hash_; + }); #ifndef NVLOG for (auto entry : ring_) { ENVOY_LOG(trace, "ring hash: host={} hash={}", entry.host_->address()->asString(), entry.hash_); @@ -127,5 +128,5 @@ void RingHashLoadBalancer::refresh() { healthy_hosts_ring_.create(runtime_, host_set_.healthyHosts()); } -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/source/common/upstream/ring_hash_lb.h b/source/common/upstream/ring_hash_lb.h index eca6d9dc93309..660f8487d6956 100644 --- a/source/common/upstream/ring_hash_lb.h +++ b/source/common/upstream/ring_hash_lb.h @@ -52,5 +52,5 @@ class RingHashLoadBalancer : public LoadBalancer, Logger::Loggable void { - ASSERT(events == Event::FileReadyType::Read); - UNREFERENCED_PARAMETER(events); - onSocketEvent(); - }, Event::FileTriggerType::Edge, Event::FileReadyType::Read); + socket_event_ = + dispatcher.createFileEvent(my_domain_socket_, + [this](uint32_t events) -> void { + ASSERT(events == Event::FileReadyType::Read); + UNREFERENCED_PARAMETER(events); + onSocketEvent(); + }, + Event::FileTriggerType::Edge, Event::FileReadyType::Read); server_ = &server; } @@ -432,5 +435,5 @@ void HotRestartImpl::shutdown() { socket_event_.reset(); } std::string HotRestartImpl::version() { return SharedMemory::version(); } -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/source/exe/hot_restart.h b/source/exe/hot_restart.h index 3d39b0aa82fe5..a653928fff8ef 100644 --- a/source/exe/hot_restart.h +++ b/source/exe/hot_restart.h @@ -201,5 +201,5 @@ class HotRestartImpl : public HotRestart, bool parent_terminated_{}; }; -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/source/exe/main_common.cc b/source/exe/main_common.cc index 44b1706f4cdba..fb7b89622b8e6 100644 --- a/source/exe/main_common.cc +++ b/source/exe/main_common.cc @@ -35,7 +35,7 @@ class ProdComponentFactory : public ComponentFactory { } }; -} // Server +} // namespace Server int main_common(OptionsImpl& options, Server::HotRestartImpl& restarter) { Event::Libevent::Global::initialize(); @@ -65,4 +65,4 @@ int main_common(OptionsImpl& options, Server::HotRestartImpl& restarter) { return 0; } -} // Envoy +} // namespace Envoy diff --git a/source/exe/main_common.h b/source/exe/main_common.h index 809c41b49f53f..9b7c27a09275c 100644 --- a/source/exe/main_common.h +++ b/source/exe/main_common.h @@ -15,4 +15,4 @@ namespace Envoy { */ int main_common(Envoy::OptionsImpl& options, Envoy::Server::HotRestartImpl& restarter); -} // Envoy +} // namespace Envoy diff --git a/source/exe/signal_action.cc b/source/exe/signal_action.cc index 7a3d11b89bdf0..0494c595356ae 100644 --- a/source/exe/signal_action.cc +++ b/source/exe/signal_action.cc @@ -97,4 +97,4 @@ void SignalAction::tryEvilAccessForTest(bool end) { *(altaltstack + guard_size_ - 1) = 43; } } -} // Envoy +} // namespace Envoy diff --git a/source/exe/signal_action.h b/source/exe/signal_action.h index de7eae41d0d87..fa54b58bed6ff 100644 --- a/source/exe/signal_action.h +++ b/source/exe/signal_action.h @@ -125,4 +125,4 @@ class SignalAction : NonCopyable { std::array previous_handlers_; stack_t previous_altstack_; }; -} // Envoy +} // namespace Envoy diff --git a/source/server/config/http/buffer.cc b/source/server/config/http/buffer.cc index 95c7156c43288..78facea48e6fc 100644 --- a/source/server/config/http/buffer.cc +++ b/source/server/config/http/buffer.cc @@ -33,6 +33,6 @@ HttpFilterFactoryCb BufferFilterConfig::createFilterFactory(const Json::Object& */ static Registry::RegisterFactory register_; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/http/buffer.h b/source/server/config/http/buffer.h index e05b23fc654fd..bf4d5bb364b5d 100644 --- a/source/server/config/http/buffer.h +++ b/source/server/config/http/buffer.h @@ -20,6 +20,6 @@ class BufferFilterConfig : public NamedHttpFilterConfigFactory { HttpFilterType type() override { return HttpFilterType::Decoder; } }; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/http/dynamo.cc b/source/server/config/http/dynamo.cc index 5e27fdf0aede5..d282b89996bf7 100644 --- a/source/server/config/http/dynamo.cc +++ b/source/server/config/http/dynamo.cc @@ -24,6 +24,6 @@ HttpFilterFactoryCb DynamoFilterConfig::createFilterFactory(const Json::Object&, */ static Registry::RegisterFactory register_; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/http/dynamo.h b/source/server/config/http/dynamo.h index 7b6dc0699fe84..54eed0c6c67d0 100644 --- a/source/server/config/http/dynamo.h +++ b/source/server/config/http/dynamo.h @@ -19,6 +19,6 @@ class DynamoFilterConfig : public NamedHttpFilterConfigFactory { HttpFilterType type() override { return HttpFilterType::Both; } }; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/http/fault.cc b/source/server/config/http/fault.cc index 4b0a2a5b6811e..1e12750024909 100644 --- a/source/server/config/http/fault.cc +++ b/source/server/config/http/fault.cc @@ -27,6 +27,6 @@ HttpFilterFactoryCb FaultFilterConfig::createFilterFactory(const Json::Object& j */ static Registry::RegisterFactory register_; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/http/fault.h b/source/server/config/http/fault.h index 40cc339f0fe4c..58da2a1b3d430 100644 --- a/source/server/config/http/fault.h +++ b/source/server/config/http/fault.h @@ -20,6 +20,6 @@ class FaultFilterConfig : public NamedHttpFilterConfigFactory { HttpFilterType type() override { return HttpFilterType::Decoder; } }; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/http/grpc_http1_bridge.cc b/source/server/config/http/grpc_http1_bridge.cc index 1981147b7580f..76c1b6e8c4d35 100644 --- a/source/server/config/http/grpc_http1_bridge.cc +++ b/source/server/config/http/grpc_http1_bridge.cc @@ -25,6 +25,6 @@ HttpFilterFactoryCb GrpcHttp1BridgeFilterConfig::createFilterFactory(const Json: static Registry::RegisterFactory register_; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/http/grpc_http1_bridge.h b/source/server/config/http/grpc_http1_bridge.h index d05b8749b4b0d..de274b8a3edb7 100644 --- a/source/server/config/http/grpc_http1_bridge.h +++ b/source/server/config/http/grpc_http1_bridge.h @@ -19,6 +19,6 @@ class GrpcHttp1BridgeFilterConfig : public NamedHttpFilterConfigFactory { HttpFilterType type() override { return HttpFilterType::Both; } }; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/http/grpc_json_transcoder.cc b/source/server/config/http/grpc_json_transcoder.cc index 52cfd00011815..0beb4e5bead1d 100644 --- a/source/server/config/http/grpc_json_transcoder.cc +++ b/source/server/config/http/grpc_json_transcoder.cc @@ -25,6 +25,6 @@ GrpcJsonTranscoderFilterConfig::createFilterFactory(const Json::Object& config_j static Registry::RegisterFactory register_; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/http/grpc_json_transcoder.h b/source/server/config/http/grpc_json_transcoder.h index c1fb19e596634..fb7ad2af633df 100644 --- a/source/server/config/http/grpc_json_transcoder.h +++ b/source/server/config/http/grpc_json_transcoder.h @@ -21,6 +21,6 @@ class GrpcJsonTranscoderFilterConfig : public NamedHttpFilterConfigFactory { HttpFilterType type() override { return HttpFilterType::Both; } }; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/http/ip_tagging.cc b/source/server/config/http/ip_tagging.cc index 611cbc0179721..d4405a8a756cb 100644 --- a/source/server/config/http/ip_tagging.cc +++ b/source/server/config/http/ip_tagging.cc @@ -26,6 +26,6 @@ HttpFilterFactoryCb IpTaggingFilterConfig::createFilterFactory(const Json::Objec */ static Registry::RegisterFactory register_; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/http/ip_tagging.h b/source/server/config/http/ip_tagging.h index 87f63830e5a4d..ca2792bafdf74 100644 --- a/source/server/config/http/ip_tagging.h +++ b/source/server/config/http/ip_tagging.h @@ -20,6 +20,6 @@ class IpTaggingFilterConfig : public NamedHttpFilterConfigFactory { HttpFilterType type() override { return HttpFilterType::Decoder; } }; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/http/lightstep_http_tracer.cc b/source/server/config/http/lightstep_http_tracer.cc index 35d5e945b7695..363c08339cc58 100644 --- a/source/server/config/http/lightstep_http_tracer.cc +++ b/source/server/config/http/lightstep_http_tracer.cc @@ -43,6 +43,6 @@ std::string LightstepHttpTracerFactory::name() { return "lightstep"; } */ static Registry::RegisterFactory register_; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/http/lightstep_http_tracer.h b/source/server/config/http/lightstep_http_tracer.h index 721ea74580256..4ff1c0f054425 100644 --- a/source/server/config/http/lightstep_http_tracer.h +++ b/source/server/config/http/lightstep_http_tracer.h @@ -22,6 +22,6 @@ class LightstepHttpTracerFactory : public HttpTracerFactory { std::string name() override; }; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/http/ratelimit.cc b/source/server/config/http/ratelimit.cc index 0ac46c339e416..90130675e804d 100644 --- a/source/server/config/http/ratelimit.cc +++ b/source/server/config/http/ratelimit.cc @@ -27,6 +27,6 @@ HttpFilterFactoryCb RateLimitFilterConfig::createFilterFactory(const Json::Objec */ static Registry::RegisterFactory register_; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/http/ratelimit.h b/source/server/config/http/ratelimit.h index e01fef89b3651..a5b3bd28c7d87 100644 --- a/source/server/config/http/ratelimit.h +++ b/source/server/config/http/ratelimit.h @@ -19,6 +19,6 @@ class RateLimitFilterConfig : public NamedHttpFilterConfigFactory { HttpFilterType type() override { return HttpFilterType::Decoder; } }; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/http/router.cc b/source/server/config/http/router.cc index b6928b71264a2..6ded51d73b7dc 100644 --- a/source/server/config/http/router.cc +++ b/source/server/config/http/router.cc @@ -23,8 +23,9 @@ HttpFilterFactoryCb RouterFilterConfig::createFilterFactory(const Json::Object& Router::ShadowWriterPtr{new Router::ShadowWriterImpl(context.clusterManager())}, json_config.getBoolean("dynamic_stats", true))); - return [config](Http::FilterChainFactoryCallbacks& callbacks) - -> void { callbacks.addStreamDecoderFilter(std::make_shared(*config)); }; + return [config](Http::FilterChainFactoryCallbacks& callbacks) -> void { + callbacks.addStreamDecoderFilter(std::make_shared(*config)); + }; } /** @@ -32,6 +33,6 @@ HttpFilterFactoryCb RouterFilterConfig::createFilterFactory(const Json::Object& */ static Registry::RegisterFactory register_; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/http/router.h b/source/server/config/http/router.h index 4c10b772844b9..1b409a41bc001 100644 --- a/source/server/config/http/router.h +++ b/source/server/config/http/router.h @@ -20,6 +20,6 @@ class RouterFilterConfig : public NamedHttpFilterConfigFactory { HttpFilterType type() override { return HttpFilterType::Decoder; } }; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/http/zipkin_http_tracer.cc b/source/server/config/http/zipkin_http_tracer.cc index a9faaf6f0eaf3..817cf377c6537 100644 --- a/source/server/config/http/zipkin_http_tracer.cc +++ b/source/server/config/http/zipkin_http_tracer.cc @@ -33,6 +33,6 @@ std::string ZipkinHttpTracerFactory::name() { return "zipkin"; } */ static Registry::RegisterFactory register_; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/http/zipkin_http_tracer.h b/source/server/config/http/zipkin_http_tracer.h index fc464f6c99f0d..52ec9c63cdb87 100644 --- a/source/server/config/http/zipkin_http_tracer.h +++ b/source/server/config/http/zipkin_http_tracer.h @@ -21,6 +21,6 @@ class ZipkinHttpTracerFactory : public HttpTracerFactory { std::string name() override; }; -} // Configuration -} // Server -} // Envoy \ No newline at end of file +} // namespace Configuration +} // namespace Server +} // namespace Envoy \ No newline at end of file diff --git a/source/server/config/network/client_ssl_auth.cc b/source/server/config/network/client_ssl_auth.cc index 9b1df2727ef2a..87cd67475c49a 100644 --- a/source/server/config/network/client_ssl_auth.cc +++ b/source/server/config/network/client_ssl_auth.cc @@ -29,6 +29,6 @@ ClientSslAuthConfigFactory::createFilterFactory(const Json::Object& json_config, static Registry::RegisterFactory registered_; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/network/client_ssl_auth.h b/source/server/config/network/client_ssl_auth.h index 3086e138d4b07..2df5c3dc90e5c 100644 --- a/source/server/config/network/client_ssl_auth.h +++ b/source/server/config/network/client_ssl_auth.h @@ -20,6 +20,6 @@ class ClientSslAuthConfigFactory : public NamedNetworkFilterConfigFactory { NetworkFilterType type() override { return NetworkFilterType::Read; } }; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/network/echo.cc b/source/server/config/network/echo.cc index 7adf39cc521bd..967660e32de79 100644 --- a/source/server/config/network/echo.cc +++ b/source/server/config/network/echo.cc @@ -16,8 +16,9 @@ class EchoConfigFactory : public NamedNetworkFilterConfigFactory { public: // NamedNetworkFilterConfigFactory NetworkFilterFactoryCb createFilterFactory(const Json::Object&, FactoryContext&) override { - return [](Network::FilterManager& filter_manager) - -> void { filter_manager.addReadFilter(Network::ReadFilterSharedPtr{new Filter::Echo()}); }; + return [](Network::FilterManager& filter_manager) -> void { + filter_manager.addReadFilter(Network::ReadFilterSharedPtr{new Filter::Echo()}); + }; } std::string name() override { return "echo"; } @@ -29,6 +30,6 @@ class EchoConfigFactory : public NamedNetworkFilterConfigFactory { */ static Registry::RegisterFactory registered_; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/network/http_connection_manager.cc b/source/server/config/network/http_connection_manager.cc index f8d3cdf329342..63fa6f3b9508b 100644 --- a/source/server/config/network/http_connection_manager.cc +++ b/source/server/config/network/http_connection_manager.cc @@ -42,7 +42,8 @@ HttpConnectionManagerFilterConfigFactory::createFilterFactory(const Json::Object * Static registration for the HTTP connection manager filter. */ static Registry::RegisterFactory registered_; + NamedNetworkFilterConfigFactory> + registered_; std::string HttpConnectionManagerConfigUtility::determineNextProtocol(Network::Connection& connection, @@ -54,9 +55,8 @@ HttpConnectionManagerConfigUtility::determineNextProtocol(Network::Connection& c // See if the data we have so far shows the HTTP/2 prefix. We ignore the case where someone sends // us the first few bytes of the HTTP/2 prefix since in all public cases we use SSL/ALPN. For // internal cases this should practically never happen. - if (-1 != - data.search(Http::Http2::CLIENT_MAGIC_PREFIX.c_str(), Http::Http2::CLIENT_MAGIC_PREFIX.size(), - 0)) { + if (-1 != data.search(Http::Http2::CLIENT_MAGIC_PREFIX.c_str(), + Http::Http2::CLIENT_MAGIC_PREFIX.size(), 0)) { return Http::Http2::ALPN_STRING; } @@ -248,6 +248,6 @@ const Network::Address::Instance& HttpConnectionManagerConfig::localAddress() { return *context_.localInfo().address(); } -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/network/http_connection_manager.h b/source/server/config/network/http_connection_manager.h index 5e7fa16d074fe..a5a6a8b7600a0 100644 --- a/source/server/config/network/http_connection_manager.h +++ b/source/server/config/network/http_connection_manager.h @@ -164,6 +164,6 @@ template class RegisterHttpFilterConfigFactory { } }; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/network/mongo_proxy.cc b/source/server/config/network/mongo_proxy.cc index 2ea18f9d9f9fb..ab1673718758e 100644 --- a/source/server/config/network/mongo_proxy.cc +++ b/source/server/config/network/mongo_proxy.cc @@ -36,6 +36,6 @@ MongoProxyFilterConfigFactory::createFilterFactory(const Json::Object& config, static Registry::RegisterFactory registered_; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/network/mongo_proxy.h b/source/server/config/network/mongo_proxy.h index 42cd370cf8e29..c98bdb2dbbbfd 100644 --- a/source/server/config/network/mongo_proxy.h +++ b/source/server/config/network/mongo_proxy.h @@ -21,6 +21,6 @@ class MongoProxyFilterConfigFactory : public NamedNetworkFilterConfigFactory { NetworkFilterType type() override { return NetworkFilterType::Both; } }; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/network/ratelimit.cc b/source/server/config/network/ratelimit.cc index 4a57dad1939f4..127e07bd9e396 100644 --- a/source/server/config/network/ratelimit.cc +++ b/source/server/config/network/ratelimit.cc @@ -28,6 +28,6 @@ NetworkFilterFactoryCb RateLimitConfigFactory::createFilterFactory(const Json::O static Registry::RegisterFactory registered_; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/network/ratelimit.h b/source/server/config/network/ratelimit.h index a9849fc5b8dca..3ac43f695214d 100644 --- a/source/server/config/network/ratelimit.h +++ b/source/server/config/network/ratelimit.h @@ -20,6 +20,6 @@ class RateLimitConfigFactory : public NamedNetworkFilterConfigFactory { NetworkFilterType type() override { return NetworkFilterType::Read; } }; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/network/redis_proxy.cc b/source/server/config/network/redis_proxy.cc index a2e4945aab3d6..d3043abe86b5c 100644 --- a/source/server/config/network/redis_proxy.cc +++ b/source/server/config/network/redis_proxy.cc @@ -39,6 +39,6 @@ RedisProxyFilterConfigFactory::createFilterFactory(const Json::Object& config, static Registry::RegisterFactory registered_; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/network/redis_proxy.h b/source/server/config/network/redis_proxy.h index a7517655ad83c..f0a59c686b115 100644 --- a/source/server/config/network/redis_proxy.h +++ b/source/server/config/network/redis_proxy.h @@ -20,6 +20,6 @@ class RedisProxyFilterConfigFactory : public NamedNetworkFilterConfigFactory { NetworkFilterType type() override { return NetworkFilterType::Read; } }; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/network/tcp_proxy.cc b/source/server/config/network/tcp_proxy.cc index 2fcba169afda2..8f99595602ff4 100644 --- a/source/server/config/network/tcp_proxy.cc +++ b/source/server/config/network/tcp_proxy.cc @@ -27,6 +27,6 @@ NetworkFilterFactoryCb TcpProxyConfigFactory::createFilterFactory(const Json::Ob static Registry::RegisterFactory registered_; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config/network/tcp_proxy.h b/source/server/config/network/tcp_proxy.h index 1838387541c6e..7bde8d73fb398 100644 --- a/source/server/config/network/tcp_proxy.h +++ b/source/server/config/network/tcp_proxy.h @@ -20,6 +20,6 @@ class TcpProxyConfigFactory : public NamedNetworkFilterConfigFactory { NetworkFilterType type() override { return NetworkFilterType::Read; } }; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/config_validation/api.cc b/source/server/config_validation/api.cc index b859694080318..f83d46a984105 100644 --- a/source/server/config_validation/api.cc +++ b/source/server/config_validation/api.cc @@ -12,5 +12,5 @@ Event::DispatcherPtr ValidationImpl::allocateDispatcher() { return Event::DispatcherPtr{new Event::ValidationDispatcher()}; } -} // Api -} // Envoy +} // namespace Api +} // namespace Envoy diff --git a/source/server/config_validation/api.h b/source/server/config_validation/api.h index 969541a2a0f26..710b775e16ae0 100644 --- a/source/server/config_validation/api.h +++ b/source/server/config_validation/api.h @@ -19,5 +19,5 @@ class ValidationImpl : public Impl { Event::DispatcherPtr allocateDispatcher() override; }; -} // Api -} // Envoy +} // namespace Api +} // namespace Envoy diff --git a/source/server/config_validation/async_client.cc b/source/server/config_validation/async_client.cc index 71f4f6433084e..0c09531457b46 100644 --- a/source/server/config_validation/async_client.cc +++ b/source/server/config_validation/async_client.cc @@ -13,5 +13,5 @@ AsyncClient::Stream* ValidationAsyncClient::start(StreamCallbacks&, return nullptr; } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/server/config_validation/async_client.h b/source/server/config_validation/async_client.h index 4f1267eb4ad94..993c1238e69e1 100644 --- a/source/server/config_validation/async_client.h +++ b/source/server/config_validation/async_client.h @@ -21,5 +21,5 @@ class ValidationAsyncClient : public AsyncClient { AsyncClient::Stream* start(StreamCallbacks&, const Optional&) override; }; -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/source/server/config_validation/cluster_manager.cc b/source/server/config_validation/cluster_manager.cc index 40a29e70f41df..c421e803a1c80 100644 --- a/source/server/config_validation/cluster_manager.cc +++ b/source/server/config_validation/cluster_manager.cc @@ -47,5 +47,5 @@ Http::AsyncClient& ValidationClusterManager::httpAsyncClientForCluster(const std return async_client_; } -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/source/server/config_validation/cluster_manager.h b/source/server/config_validation/cluster_manager.h index 61ecdab4f876d..654e8330e0037 100644 --- a/source/server/config_validation/cluster_manager.h +++ b/source/server/config_validation/cluster_manager.h @@ -56,5 +56,5 @@ class ValidationClusterManager : public ClusterManagerImpl { Http::ValidationAsyncClient async_client_; }; -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/source/server/config_validation/dispatcher.cc b/source/server/config_validation/dispatcher.cc index 82e3372e8013c..d1cadae299670 100644 --- a/source/server/config_validation/dispatcher.cc +++ b/source/server/config_validation/dispatcher.cc @@ -6,7 +6,7 @@ namespace Envoy { namespace Event { Network::ClientConnectionPtr - ValidationDispatcher::createClientConnection(Network::Address::InstanceConstSharedPtr) { +ValidationDispatcher::createClientConnection(Network::Address::InstanceConstSharedPtr) { NOT_IMPLEMENTED; } @@ -36,5 +36,5 @@ ValidationDispatcher::createSslListener(Network::ConnectionHandler&, Ssl::Server NOT_IMPLEMENTED; } -} // Event -} // Envoy +} // namespace Event +} // namespace Envoy diff --git a/source/server/config_validation/dispatcher.h b/source/server/config_validation/dispatcher.h index eba17834b517e..9095d7e7877ca 100644 --- a/source/server/config_validation/dispatcher.h +++ b/source/server/config_validation/dispatcher.h @@ -28,5 +28,5 @@ class ValidationDispatcher : public DispatcherImpl { Stats::Scope&, const Network::ListenerOptions&) override; }; -} // Event -} // Envoy +} // namespace Event +} // namespace Envoy diff --git a/source/server/config_validation/dns.cc b/source/server/config_validation/dns.cc index 222f9c19d6bd8..178e41df18e14 100644 --- a/source/server/config_validation/dns.cc +++ b/source/server/config_validation/dns.cc @@ -9,5 +9,5 @@ ActiveDnsQuery* ValidationDnsResolver::resolve(const std::string&, DnsLookupFami return nullptr; } -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/source/server/config_validation/dns.h b/source/server/config_validation/dns.h index c15bb3a725d5d..d07ca22c95f3d 100644 --- a/source/server/config_validation/dns.h +++ b/source/server/config_validation/dns.h @@ -19,5 +19,5 @@ class ValidationDnsResolver : public DnsResolver { ResolveCb callback) override; }; -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/source/server/config_validation/server.cc b/source/server/config_validation/server.cc index a1010cd20a270..01ee699215ad4 100644 --- a/source/server/config_validation/server.cc +++ b/source/server/config_validation/server.cc @@ -62,8 +62,8 @@ void ValidationInstance::initialize(Options& options, ComponentFactory& componen config_.reset(main_config); main_config->initialize(*config_json, *this, *cluster_manager_factory_); - clusterManager().setInitializedCb([this]() - -> void { init_manager_.initialize([]() -> void {}); }); + clusterManager().setInitializedCb( + [this]() -> void { init_manager_.initialize([]() -> void {}); }); } void ValidationInstance::shutdown() { @@ -74,5 +74,5 @@ void ValidationInstance::shutdown() { thread_local_.shutdownThread(); } -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/source/server/config_validation/server.h b/source/server/config_validation/server.h index af2ffdc4917d2..451c9c3ebfd01 100644 --- a/source/server/config_validation/server.h +++ b/source/server/config_validation/server.h @@ -127,5 +127,5 @@ class ValidationInstance : Logger::Loggable, ListenerManagerImpl listener_manager_; }; -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/source/server/configuration_impl.cc b/source/server/configuration_impl.cc index 03b4255e88a30..124eb27eed213 100644 --- a/source/server/configuration_impl.cc +++ b/source/server/configuration_impl.cc @@ -147,6 +147,6 @@ InitialImpl::InitialImpl(const Json::Object& json) { } } -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/configuration_impl.h b/source/server/configuration_impl.h index 7d9aceed35921..d135b3f307b34 100644 --- a/source/server/configuration_impl.h +++ b/source/server/configuration_impl.h @@ -47,21 +47,21 @@ class HttpTracerFactory { virtual ~HttpTracerFactory() {} /** - * Create a particular HttpTracer implementation. If the implementation is unable to produce an - * HttpTracer with the provided parameters, it should throw an EnvoyException in the case of - * general error or a Json::Exception if the json configuration is erroneous. The returned pointer - * should always be valid. - * @param json_config supplies the general json configuration for the HttpTracer - * @param server supplies the server instance - * @param cluster_manager supplies the cluster_manager instance - */ + * Create a particular HttpTracer implementation. If the implementation is unable to produce an + * HttpTracer with the provided parameters, it should throw an EnvoyException in the case of + * general error or a Json::Exception if the json configuration is erroneous. The returned + * pointer should always be valid. + * @param json_config supplies the general json configuration for the HttpTracer + * @param server supplies the server instance + * @param cluster_manager supplies the cluster_manager instance + */ virtual Tracing::HttpTracerPtr createHttpTracer(const Json::Object& json_config, Instance& server, Upstream::ClusterManager& cluster_manager) PURE; /** - * Returns the identifying name for a particular implementation of HttpTracer produced by the - * factory. - */ + * Returns the identifying name for a particular implementation of HttpTracer produced by the + * factory. + */ virtual std::string name() PURE; }; @@ -212,6 +212,6 @@ class InitialImpl : public Initial { std::unique_ptr runtime_; }; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/source/server/connection_handler_impl.cc b/source/server/connection_handler_impl.cc index b20ba61c9df02..12ff693c60759 100644 --- a/source/server/connection_handler_impl.cc +++ b/source/server/connection_handler_impl.cc @@ -89,8 +89,9 @@ ConnectionHandlerImpl::SslActiveListener::SslActiveListener( ConnectionHandlerImpl& parent, Ssl::ServerContext& ssl_ctx, Network::ListenSocket& socket, Network::FilterChainFactory& factory, Stats::Scope& scope, uint64_t listener_tag, const Network::ListenerOptions& listener_options) - : ActiveListener(parent, parent.dispatcher_.createSslListener(parent, ssl_ctx, socket, *this, - scope, listener_options), + : ActiveListener(parent, + parent.dispatcher_.createSslListener(parent, ssl_ctx, socket, *this, scope, + listener_options), factory, scope, listener_tag) {} Network::Listener* @@ -165,5 +166,5 @@ ListenerStats ConnectionHandlerImpl::generateStats(Stats::Scope& scope) { return {ALL_LISTENER_STATS(POOL_COUNTER(scope), POOL_GAUGE(scope), POOL_TIMER(scope))}; } -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/source/server/connection_handler_impl.h b/source/server/connection_handler_impl.h index 9387431984b58..09cd27d5b2568 100644 --- a/source/server/connection_handler_impl.h +++ b/source/server/connection_handler_impl.h @@ -136,4 +136,4 @@ class ConnectionHandlerImpl : public Network::ConnectionHandler, NonCopyable { }; } // Server -} // Envoy +} // namespace Envoy diff --git a/source/server/drain_manager_impl.cc b/source/server/drain_manager_impl.cc index 0ae3e21b5ae08..25a44e3c744e3 100644 --- a/source/server/drain_manager_impl.cc +++ b/source/server/drain_manager_impl.cc @@ -58,5 +58,5 @@ void DrainManagerImpl::startParentShutdownSequence() { server_.options().parentShutdownTime())); } -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/source/server/drain_manager_impl.h b/source/server/drain_manager_impl.h index 2db944cc3dfe7..c39eb7465c446 100644 --- a/source/server/drain_manager_impl.h +++ b/source/server/drain_manager_impl.h @@ -35,5 +35,5 @@ class DrainManagerImpl : Logger::Loggable, public DrainManager Event::TimerPtr parent_shutdown_timer_; }; -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/source/server/guarddog_impl.cc b/source/server/guarddog_impl.cc index 190c74ee7ceac..8fd82f41b3f72 100644 --- a/source/server/guarddog_impl.cc +++ b/source/server/guarddog_impl.cc @@ -133,5 +133,5 @@ void GuardDogImpl::stop() { } } -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/source/server/guarddog_impl.h b/source/server/guarddog_impl.h index d5dbe09b043a4..f9b6b3d0ac67a 100644 --- a/source/server/guarddog_impl.h +++ b/source/server/guarddog_impl.h @@ -91,5 +91,5 @@ class GuardDogImpl : public GuardDog { std::condition_variable_any force_checked_event_; }; -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/source/server/http/admin.cc b/source/server/http/admin.cc index c12dc081d9959..c2daa1a7f37e7 100644 --- a/source/server/http/admin.cc +++ b/source/server/http/admin.cc @@ -425,4 +425,4 @@ const Network::Address::Instance& AdminImpl::localAddress() { } } // Server -} // Envoy +} // namespace Envoy diff --git a/source/server/http/admin.h b/source/server/http/admin.h index b0ecac7768649..a0632aa8f2188 100644 --- a/source/server/http/admin.h +++ b/source/server/http/admin.h @@ -171,5 +171,5 @@ class AdminFilter : public Http::StreamDecoderFilter, Logger::Loggable void { + return [&context, pass_through_mode, cache_manager, + hc_endpoint](Http::FilterChainFactoryCallbacks& callbacks) -> void { callbacks.addStreamFilter(Http::StreamFilterSharedPtr{ new HealthCheckFilter(context, pass_through_mode, cache_manager, hc_endpoint)}); }; @@ -57,8 +57,8 @@ HttpFilterFactoryCb HealthCheckFilterConfig::createFilterFactory(const Json::Obj */ static Registry::RegisterFactory register_; -} // Configuration -} // Server +} // namespace Configuration +} // namespace Server HealthCheckCacheManager::HealthCheckCacheManager(Event::Dispatcher& dispatcher, std::chrono::milliseconds timeout) @@ -149,4 +149,4 @@ void HealthCheckFilter::onComplete() { callbacks_->encodeHeaders(std::move(headers), true); } -} // Envoy +} // namespace Envoy diff --git a/source/server/http/health_check.h b/source/server/http/health_check.h index 4f175fcf81004..06d099d232c7c 100644 --- a/source/server/http/health_check.h +++ b/source/server/http/health_check.h @@ -21,8 +21,8 @@ class HealthCheckFilterConfig : public NamedHttpFilterConfigFactory { HttpFilterType type() override { return HttpFilterType::Both; } }; -} // Configuration -} // Server +} // namespace Configuration +} // namespace Server /** * Shared cache manager used by all instances of a health check filter configuration as well as @@ -95,4 +95,4 @@ class HealthCheckFilter : public Http::StreamFilter { HealthCheckCacheManagerSharedPtr cache_manager_{}; const std::string endpoint_; }; -} // Envoy +} // namespace Envoy diff --git a/source/server/init_manager_impl.cc b/source/server/init_manager_impl.cc index 83c0368a21651..14c963e68c292 100644 --- a/source/server/init_manager_impl.cc +++ b/source/server/init_manager_impl.cc @@ -42,5 +42,5 @@ void InitManagerImpl::registerTarget(Init::Target& target) { } } -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/source/server/init_manager_impl.h b/source/server/init_manager_impl.h index 5f1ec4a487fff..bc953dada2afd 100644 --- a/source/server/init_manager_impl.h +++ b/source/server/init_manager_impl.h @@ -27,5 +27,5 @@ class InitManagerImpl : public Init::Manager { std::function callback_; }; -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/source/server/listener_manager_impl.cc b/source/server/listener_manager_impl.cc index fb99753a49f3e..9463adae01bfb 100644 --- a/source/server/listener_manager_impl.cc +++ b/source/server/listener_manager_impl.cc @@ -171,5 +171,5 @@ void ListenerManagerImpl::stopWorkers() { } } -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/source/server/listener_manager_impl.h b/source/server/listener_manager_impl.h index dc460fa0fcf74..9ee3aa2892436 100644 --- a/source/server/listener_manager_impl.h +++ b/source/server/listener_manager_impl.h @@ -126,5 +126,5 @@ class ListenerManagerImpl : public ListenerManager { std::list workers_; }; -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/source/server/options_impl.cc b/source/server/options_impl.cc index 12d00925c2993..a313b58d488b9 100644 --- a/source/server/options_impl.cc +++ b/source/server/options_impl.cc @@ -113,4 +113,4 @@ OptionsImpl::OptionsImpl(int argc, char** argv, const std::string& hot_restart_v drain_time_ = std::chrono::seconds(drain_time_s.getValue()); parent_shutdown_time_ = std::chrono::seconds(parent_shutdown_time_s.getValue()); } -} // Envoy +} // namespace Envoy diff --git a/source/server/options_impl.h b/source/server/options_impl.h index 89f9abe51de7e..15be994d829fc 100644 --- a/source/server/options_impl.h +++ b/source/server/options_impl.h @@ -50,4 +50,4 @@ class OptionsImpl : public Server::Options { std::chrono::seconds parent_shutdown_time_; Server::Mode mode_; }; -} // Envoy +} // namespace Envoy diff --git a/source/server/server.cc b/source/server/server.cc index 3064a12479e9d..7a51028ac3120 100644 --- a/source/server/server.cc +++ b/source/server/server.cc @@ -37,8 +37,9 @@ InstanceImpl::InstanceImpl(Options& options, TestHooks& hooks, HotRestart& resta ComponentFactory& component_factory, const LocalInfo::LocalInfo& local_info) : options_(options), restarter_(restarter), start_time_(time(nullptr)), - original_start_time_(start_time_), stats_store_(store), - server_stats_{ALL_SERVER_STATS(POOL_GAUGE_PREFIX(stats_store_, "server."))}, + original_start_time_(start_time_), + stats_store_(store), server_stats_{ALL_SERVER_STATS( + POOL_GAUGE_PREFIX(stats_store_, "server."))}, api_(new Api::Impl(options.fileFlushIntervalMsec())), dispatcher_(api_->allocateDispatcher()), handler_(new ConnectionHandlerImpl(log(), *dispatcher_)), listener_component_factory_(*this), worker_factory_(thread_local_, *api_), dns_resolver_(dispatcher_->createDnsResolver({})), @@ -336,5 +337,5 @@ void InstanceImpl::shutdownAdmin() { restarter_.terminateParent(); } -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/source/server/server.h b/source/server/server.h index 9b317825b66a7..3a811cac7b3c2 100644 --- a/source/server/server.h +++ b/source/server/server.h @@ -168,4 +168,4 @@ class InstanceImpl : Logger::Loggable, public Instance { }; } // Server -} // Envoy +} // namespace Envoy diff --git a/source/server/test_hooks.h b/source/server/test_hooks.h index d78bb4f18c638..c3f3fff1e6f1c 100644 --- a/source/server/test_hooks.h +++ b/source/server/test_hooks.h @@ -23,4 +23,4 @@ class DefaultTestHooks : public TestHooks { // TestHooks void onServerInitialized() override {} }; -} // Envoy +} // namespace Envoy diff --git a/source/server/watchdog_impl.cc b/source/server/watchdog_impl.cc index 32014e82a7e66..8a7e53b7880c3 100644 --- a/source/server/watchdog_impl.cc +++ b/source/server/watchdog_impl.cc @@ -15,5 +15,5 @@ void WatchDogImpl::startWatchdog(Event::Dispatcher& dispatcher) { timer_->enableTimer(timer_interval_); } -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/source/server/watchdog_impl.h b/source/server/watchdog_impl.h index 2b3a59602e8b3..68d06690eb005 100644 --- a/source/server/watchdog_impl.h +++ b/source/server/watchdog_impl.h @@ -45,4 +45,4 @@ class WatchDogImpl : public WatchDog { }; } // namespace Server -} // Envoy +} // namespace Envoy diff --git a/source/server/worker_impl.cc b/source/server/worker_impl.cc index 165a6eee865fb..026ebfdf645db 100644 --- a/source/server/worker_impl.cc +++ b/source/server/worker_impl.cc @@ -114,5 +114,5 @@ void WorkerImpl::threadRoutine(GuardDog& guard_dog) { watchdog.reset(); } -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/source/server/worker_impl.h b/source/server/worker_impl.h index 80689f03f4e23..62d2762ea363e 100644 --- a/source/server/worker_impl.h +++ b/source/server/worker_impl.h @@ -54,5 +54,5 @@ class WorkerImpl : public Worker, Logger::Loggable { Thread::ThreadPtr thread_; }; -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/test/common/access_log/access_log_manager_impl_test.cc b/test/common/access_log/access_log_manager_impl_test.cc index eb452c4e16dba..a296247d75b25 100644 --- a/test/common/access_log/access_log_manager_impl_test.cc +++ b/test/common/access_log/access_log_manager_impl_test.cc @@ -12,8 +12,8 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::Return; +using testing::_; namespace AccessLog { @@ -40,5 +40,5 @@ TEST(AccessLogManagerImpl, reopenAllFiles) { access_log_manager.reopen(); } -} // AccessLog -} // Envoy +} // namespace AccessLog +} // namespace Envoy diff --git a/test/common/api/api_impl_test.cc b/test/common/api/api_impl_test.cc index 5313299a5b8f4..51a53436931ed 100644 --- a/test/common/api/api_impl_test.cc +++ b/test/common/api/api_impl_test.cc @@ -32,5 +32,5 @@ TEST(ApiImplTest, fileExists) { EXPECT_FALSE(api.fileExists("/dev/blahblahblah")); } -} // Api -} // Envoy +} // namespace Api +} // namespace Envoy diff --git a/test/common/common/base64_test.cc b/test/common/common/base64_test.cc index 2ce791da41ef9..2701cc04917af 100644 --- a/test/common/common/base64_test.cc +++ b/test/common/common/base64_test.cc @@ -95,4 +95,4 @@ TEST(Base64Test, BinaryBufferEncode) { EXPECT_EQ("AAECAwgKCQCqvA==", Base64::encode(buffer, 10)); EXPECT_EQ("AAECAwgKCQCqvN4=", Base64::encode(buffer, 30)); } -} // Envoy +} // namespace Envoy diff --git a/test/common/common/hex_test.cc b/test/common/common/hex_test.cc index f5d5135f09ff5..50ee7d2bb80df 100644 --- a/test/common/common/hex_test.cc +++ b/test/common/common/hex_test.cc @@ -34,4 +34,4 @@ TEST(Hex, UIntToHex) { EXPECT_EQ("25c6f38dd0600e78", base16_string); EXPECT_EQ("0000000000000000", Hex::uint64ToHex(0ULL)); } -} // Envoy +} // namespace Envoy diff --git a/test/common/common/log_macros_test.cc b/test/common/common/log_macros_test.cc index fcc9d40828287..ab5781f718ee5 100644 --- a/test/common/common/log_macros_test.cc +++ b/test/common/common/log_macros_test.cc @@ -44,4 +44,4 @@ TEST(Logger, All) { // Misc logging with no facility. ENVOY_LOG_MISC(info, "fake message"); } -} // Envoy \ No newline at end of file +} // namespace Envoy \ No newline at end of file diff --git a/test/common/common/optional_test.cc b/test/common/common/optional_test.cc index 9bd42818481e3..d8c7d5e49578f 100644 --- a/test/common/common/optional_test.cc +++ b/test/common/common/optional_test.cc @@ -20,4 +20,4 @@ TEST(Optional, All) { EXPECT_TRUE(optional_const_2.valid()); EXPECT_EQ(10, optional_const_2.value()); } -} // Envoy +} // namespace Envoy diff --git a/test/common/common/to_lower_table_test.cc b/test/common/common/to_lower_table_test.cc index bc447de60cb6c..3004f852aa200 100644 --- a/test/common/common/to_lower_table_test.cc +++ b/test/common/common/to_lower_table_test.cc @@ -27,4 +27,4 @@ TEST(ToLowerTableTest, All) { EXPECT_EQ(input, "\x90hello\x90"); } } -} // Envoy +} // namespace Envoy diff --git a/test/common/common/utility_test.cc b/test/common/common/utility_test.cc index b7d2e4c31b56d..babe8ab92f7e4 100644 --- a/test/common/common/utility_test.cc +++ b/test/common/common/utility_test.cc @@ -179,4 +179,4 @@ TEST(StringUtil, escape) { EXPECT_EQ(StringUtil::escape("\t\nworld\r\n"), "\\t\\nworld\\r\\n"); EXPECT_EQ(StringUtil::escape("{\"linux\": \"penguin\"}"), "{\\\"linux\\\": \\\"penguin\\\"}"); } -} // Envoy +} // namespace Envoy diff --git a/test/common/config/filesystem_subscription_test_harness.h b/test/common/config/filesystem_subscription_test_harness.h index 10fee325db99e..ab40f164def52 100644 --- a/test/common/config/filesystem_subscription_test_harness.h +++ b/test/common/config/filesystem_subscription_test_harness.h @@ -12,8 +12,8 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -using testing::_; using testing::Return; +using testing::_; namespace Envoy { namespace Config { @@ -67,7 +67,8 @@ class FilesystemSubscriptionTestHarness : public SubscriptionTestHarness { EXPECT_CALL(callbacks_, onConfigUpdate(RepeatedProtoEq( Config::Utility::getTypedResources( - response_pb)))).WillOnce(ThrowOnRejectedConfig(accept)); + response_pb)))) + .WillOnce(ThrowOnRejectedConfig(accept)); if (!accept) { EXPECT_CALL(callbacks_, onConfigUpdateFailed(_)); } diff --git a/test/common/config/grpc_subscription_test_harness.h b/test/common/config/grpc_subscription_test_harness.h index 0768c7d09f0b2..3065f50dfa665 100644 --- a/test/common/config/grpc_subscription_test_harness.h +++ b/test/common/config/grpc_subscription_test_harness.h @@ -13,11 +13,11 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -using testing::_; using testing::Invoke; +using testing::Mock; using testing::NiceMock; using testing::Return; -using testing::Mock; +using testing::_; namespace Envoy { namespace Config { @@ -33,11 +33,10 @@ class GrpcSubscriptionTestHarness : public SubscriptionTestHarness { "envoy.api.v2.EndpointDiscoveryService.StreamEndpoints")), async_client_(new SubscriptionMockAsyncClient()), timer_(new Event::MockTimer()) { node_.set_id("fo0"); - EXPECT_CALL(dispatcher_, createTimer_(_)) - .WillOnce(Invoke([this](Event::TimerCb timer_cb) { - timer_cb_ = timer_cb; - return timer_; - })); + EXPECT_CALL(dispatcher_, createTimer_(_)).WillOnce(Invoke([this](Event::TimerCb timer_cb) { + timer_cb_ = timer_cb; + return timer_; + })); subscription_.reset(new GrpcEdsSubscriptionImpl( node_, std::unique_ptr(async_client_), dispatcher_, *method_descriptor_)); diff --git a/test/common/config/http_subscription_test_harness.h b/test/common/config/http_subscription_test_harness.h index 7476b59777aa0..0596ad0081381 100644 --- a/test/common/config/http_subscription_test_harness.h +++ b/test/common/config/http_subscription_test_harness.h @@ -17,9 +17,9 @@ #include "google/protobuf/util/json_util.h" #include "gtest/gtest.h" -using testing::_; using testing::Invoke; using testing::Return; +using testing::_; namespace Envoy { namespace Config { @@ -33,11 +33,10 @@ class HttpSubscriptionTestHarness : public SubscriptionTestHarness { "envoy.api.v2.EndpointDiscoveryService.FetchEndpoints")), timer_(new Event::MockTimer()), http_request_(&cm_.async_client_) { node_.set_id("fo0"); - EXPECT_CALL(dispatcher_, createTimer_(_)) - .WillOnce(Invoke([this](Event::TimerCb timer_cb) { - timer_cb_ = timer_cb; - return timer_; - })); + EXPECT_CALL(dispatcher_, createTimer_(_)).WillOnce(Invoke([this](Event::TimerCb timer_cb) { + timer_cb_ = timer_cb; + return timer_; + })); subscription_.reset(new HttpEdsSubscriptionImpl(node_, cm_, "eds_cluster", dispatcher_, random_gen_, std::chrono::milliseconds(1), *method_descriptor_)); @@ -55,8 +54,8 @@ class HttpSubscriptionTestHarness : public SubscriptionTestHarness { EXPECT_CALL(cm_, httpAsyncClientForCluster("eds_cluster")); EXPECT_CALL(cm_.async_client_, send_(_, _, _)) .WillOnce(Invoke([this, cluster_names, version]( - Http::MessagePtr& request, Http::AsyncClient::Callbacks& callbacks, - const Optional& timeout) { + Http::MessagePtr& request, Http::AsyncClient::Callbacks& callbacks, + const Optional& timeout) { http_callbacks_ = &callbacks; UNREFERENCED_PARAMETER(timeout); EXPECT_EQ("POST", std::string(request->headers().Method()->value().c_str())); @@ -111,7 +110,8 @@ class HttpSubscriptionTestHarness : public SubscriptionTestHarness { EXPECT_CALL(callbacks_, onConfigUpdate(RepeatedProtoEq( Config::Utility::getTypedResources( - response_pb)))).WillOnce(ThrowOnRejectedConfig(accept)); + response_pb)))) + .WillOnce(ThrowOnRejectedConfig(accept)); if (!accept) { EXPECT_CALL(callbacks_, onConfigUpdateFailed(_)); } diff --git a/test/common/config/subscription_factory_test.cc b/test/common/config/subscription_factory_test.cc index 05502749cc447..25c25562cc56e 100644 --- a/test/common/config/subscription_factory_test.cc +++ b/test/common/config/subscription_factory_test.cc @@ -13,9 +13,9 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -using ::testing::_; using ::testing::Invoke; using ::testing::Return; +using ::testing::_; namespace Envoy { namespace Config { diff --git a/test/common/dynamo/dynamo_filter_test.cc b/test/common/dynamo/dynamo_filter_test.cc index 729d52f0d8672..3ff5289b5094e 100644 --- a/test/common/dynamo/dynamo_filter_test.cc +++ b/test/common/dynamo/dynamo_filter_test.cc @@ -15,10 +15,10 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::NiceMock; using testing::Return; using testing::ReturnRef; +using testing::_; namespace Dynamo { @@ -628,5 +628,5 @@ TEST_F(DynamoFilterTest, PartitionIdStatsForSingleTableBatchOperation) { EXPECT_EQ(Http::FilterDataStatus::Continue, filter_->encodeData(empty_data, true)); } -} // Dynamo -} // Envoy +} // namespace Dynamo +} // namespace Envoy diff --git a/test/common/dynamo/dynamo_request_parser_test.cc b/test/common/dynamo/dynamo_request_parser_test.cc index 7b5d8ade42a62..82ad8b9b20e20 100644 --- a/test/common/dynamo/dynamo_request_parser_test.cc +++ b/test/common/dynamo/dynamo_request_parser_test.cc @@ -72,20 +72,16 @@ TEST(DynamoRequestParser, parseTableNameSingleOperation) { TEST(DynamoRequestParser, parseErrorType) { { - EXPECT_EQ( - "ResourceNotFoundException", - RequestParser::parseErrorType( - *Json::Factory::loadFromString( - "{\"__type\":\"com.amazonaws.dynamodb.v20120810#ResourceNotFoundException\"}"))); + EXPECT_EQ("ResourceNotFoundException", + RequestParser::parseErrorType(*Json::Factory::loadFromString( + "{\"__type\":\"com.amazonaws.dynamodb.v20120810#ResourceNotFoundException\"}"))); } { - EXPECT_EQ( - "ResourceNotFoundException", - RequestParser::parseErrorType( - *Json::Factory::loadFromString( - "{\"__type\":\"com.amazonaws.dynamodb.v20120810#ResourceNotFoundException\"," - "\"message\":\"Requested resource not found: Table: tablename not found\"}"))); + EXPECT_EQ("ResourceNotFoundException", + RequestParser::parseErrorType(*Json::Factory::loadFromString( + "{\"__type\":\"com.amazonaws.dynamodb.v20120810#ResourceNotFoundException\"," + "\"message\":\"Requested resource not found: Table: tablename not found\"}"))); } { @@ -265,5 +261,5 @@ TEST(DynamoRequestParser, parsePartitionIds) { } } -} // Dynamo -} // Envoy +} // namespace Dynamo +} // namespace Envoy diff --git a/test/common/dynamo/dynamo_utility_test.cc b/test/common/dynamo/dynamo_utility_test.cc index 5ec2e0f024709..089e35423ff0c 100644 --- a/test/common/dynamo/dynamo_utility_test.cc +++ b/test/common/dynamo/dynamo_utility_test.cc @@ -56,5 +56,5 @@ TEST(DynamoUtility, PartitionIdStatString) { } } -} // Dynamo -} // Envoy +} // namespace Dynamo +} // namespace Envoy diff --git a/test/common/event/dispatched_thread_impl_test.cc b/test/common/event/dispatched_thread_impl_test.cc index 59105726c5acb..a177dcb6bd796 100644 --- a/test/common/event/dispatched_thread_impl_test.cc +++ b/test/common/event/dispatched_thread_impl_test.cc @@ -41,5 +41,5 @@ TEST_F(DispatchedThreadTest, PostCallbackTest) { thread_.exit(); } -} // Event -} // Envoy +} // namespace Event +} // namespace Envoy diff --git a/test/common/event/dispatcher_impl_test.cc b/test/common/event/dispatcher_impl_test.cc index f720e43d264f1..2c9ee6db86851 100644 --- a/test/common/event/dispatcher_impl_test.cc +++ b/test/common/event/dispatcher_impl_test.cc @@ -51,5 +51,5 @@ TEST(DispatcherImplTest, DeferredDelete) { dispatcher.clearDeferredDeleteList(); } -} // Event -} // Envoy +} // namespace Event +} // namespace Envoy diff --git a/test/common/event/file_event_impl_test.cc b/test/common/event/file_event_impl_test.cc index 3bd4afb3cd48d..e6b0566ca35c3 100644 --- a/test/common/event/file_event_impl_test.cc +++ b/test/common/event/file_event_impl_test.cc @@ -53,19 +53,22 @@ TEST_P(FileEventImplActivateTest, Activate) { ReadyWatcher closed_event; EXPECT_CALL(closed_event, ready()).Times(1); - Event::FileEventPtr file_event = dispatcher.createFileEvent(fd, [&](uint32_t events) -> void { - if (events & FileReadyType::Read) { - read_event.ready(); - } + Event::FileEventPtr file_event = dispatcher.createFileEvent( + fd, + [&](uint32_t events) -> void { + if (events & FileReadyType::Read) { + read_event.ready(); + } - if (events & FileReadyType::Write) { - write_event.ready(); - } + if (events & FileReadyType::Write) { + write_event.ready(); + } - if (events & FileReadyType::Closed) { - closed_event.ready(); - } - }, FileTriggerType::Edge, FileReadyType::Read | FileReadyType::Write | FileReadyType::Closed); + if (events & FileReadyType::Closed) { + closed_event.ready(); + } + }, + FileTriggerType::Edge, FileReadyType::Read | FileReadyType::Write | FileReadyType::Closed); file_event->activate(FileReadyType::Read | FileReadyType::Write | FileReadyType::Closed); dispatcher.run(Event::Dispatcher::RunType::NonBlock); @@ -81,15 +84,17 @@ TEST_F(FileEventImplTest, EdgeTrigger) { EXPECT_CALL(write_event, ready()).Times(1); Event::FileEventPtr file_event = - dispatcher.createFileEvent(fds_[0], [&](uint32_t events) -> void { - if (events & FileReadyType::Read) { - read_event.ready(); - } - - if (events & FileReadyType::Write) { - write_event.ready(); - } - }, FileTriggerType::Edge, FileReadyType::Read | FileReadyType::Write); + dispatcher.createFileEvent(fds_[0], + [&](uint32_t events) -> void { + if (events & FileReadyType::Read) { + read_event.ready(); + } + + if (events & FileReadyType::Write) { + write_event.ready(); + } + }, + FileTriggerType::Edge, FileReadyType::Read | FileReadyType::Write); dispatcher.run(Event::Dispatcher::RunType::NonBlock); } @@ -102,8 +107,9 @@ TEST_F(FileEventImplTest, LevelTrigger) { EXPECT_CALL(write_event, ready()).Times(2); int count = 2; - Event::FileEventPtr file_event = - dispatcher.createFileEvent(fds_[0], [&](uint32_t events) -> void { + Event::FileEventPtr file_event = dispatcher.createFileEvent( + fds_[0], + [&](uint32_t events) -> void { if (count-- == 0) { dispatcher.exit(); return; @@ -115,7 +121,8 @@ TEST_F(FileEventImplTest, LevelTrigger) { if (events & FileReadyType::Write) { write_event.ready(); } - }, FileTriggerType::Level, FileReadyType::Read | FileReadyType::Write); + }, + FileTriggerType::Level, FileReadyType::Read | FileReadyType::Write); dispatcher.run(Event::Dispatcher::RunType::Block); } @@ -128,15 +135,17 @@ TEST_F(FileEventImplTest, SetEnabled) { EXPECT_CALL(write_event, ready()).Times(2); Event::FileEventPtr file_event = - dispatcher.createFileEvent(fds_[0], [&](uint32_t events) -> void { - if (events & FileReadyType::Read) { - read_event.ready(); - } - - if (events & FileReadyType::Write) { - write_event.ready(); - } - }, FileTriggerType::Edge, FileReadyType::Read | FileReadyType::Write); + dispatcher.createFileEvent(fds_[0], + [&](uint32_t events) -> void { + if (events & FileReadyType::Read) { + read_event.ready(); + } + + if (events & FileReadyType::Write) { + write_event.ready(); + } + }, + FileTriggerType::Edge, FileReadyType::Read | FileReadyType::Write); file_event->setEnabled(FileReadyType::Read); dispatcher.run(Event::Dispatcher::RunType::NonBlock); @@ -151,5 +160,5 @@ TEST_F(FileEventImplTest, SetEnabled) { dispatcher.run(Event::Dispatcher::RunType::NonBlock); } -} // Event -} // Envoy +} // namespace Event +} // namespace Envoy diff --git a/test/common/filesystem/filesystem_impl_test.cc b/test/common/filesystem/filesystem_impl_test.cc index 6084ad5b931b9..c94c20ecd546a 100644 --- a/test/common/filesystem/filesystem_impl_test.cc +++ b/test/common/filesystem/filesystem_impl_test.cc @@ -15,7 +15,6 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::InSequence; using testing::Invoke; using testing::NiceMock; @@ -23,6 +22,7 @@ using testing::Return; using testing::SaveArg; using testing::Sequence; using testing::Throw; +using testing::_; TEST(FileSystemImpl, BadFile) { Event::MockDispatcher dispatcher; @@ -277,4 +277,4 @@ TEST(FilesystemImpl, bigDataChunkShouldBeFlushedWithoutTimer) { } } } -} // Envoy +} // namespace Envoy diff --git a/test/common/filesystem/watcher_impl_test.cc b/test/common/filesystem/watcher_impl_test.cc index e897e916ff7f2..4ccab40225889 100644 --- a/test/common/filesystem/watcher_impl_test.cc +++ b/test/common/filesystem/watcher_impl_test.cc @@ -59,5 +59,5 @@ TEST(WatcherImplTest, All) { dispatcher.run(Event::Dispatcher::RunType::Block); } -} // Filesystem -} // Envoy +} // namespace Filesystem +} // namespace Envoy diff --git a/test/common/filter/auth/client_ssl_test.cc b/test/common/filter/auth/client_ssl_test.cc index 4afc4a8a944f4..e2d60dc3a62c5 100644 --- a/test/common/filter/auth/client_ssl_test.cc +++ b/test/common/filter/auth/client_ssl_test.cc @@ -20,13 +20,13 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::InSequence; using testing::Invoke; using testing::Return; using testing::ReturnNew; using testing::ReturnRef; using testing::WithArg; +using testing::_; namespace Filter { namespace Auth { @@ -250,7 +250,7 @@ TEST_F(ClientSslAuthFilterTest, Ssl) { EXPECT_EQ(4U, stats_store_.counter("auth.clientssl.vpn.update_failure").value()); } -} // ClientSsl -} // Auth -} // Filter -} // Envoy +} // namespace ClientSsl +} // namespace Auth +} // namespace Filter +} // namespace Envoy diff --git a/test/common/filter/ratelimit_test.cc b/test/common/filter/ratelimit_test.cc index 02dc7207a612c..cf70df5d300b5 100644 --- a/test/common/filter/ratelimit_test.cc +++ b/test/common/filter/ratelimit_test.cc @@ -16,12 +16,12 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::InSequence; using testing::Invoke; using testing::NiceMock; using testing::Return; using testing::WithArgs; +using testing::_; namespace RateLimit { namespace TcpFilter { @@ -84,10 +84,10 @@ TEST_F(RateLimitFilterTest, BadRatelimitConfig) { TEST_F(RateLimitFilterTest, OK) { InSequence s; - EXPECT_CALL(*client_, - limit(_, "foo", testing::ContainerEq(std::vector{ + EXPECT_CALL(*client_, limit(_, "foo", + testing::ContainerEq(std::vector{ {{{"hello", "world"}, {"foo", "bar"}}}, {{{"foo2", "bar2"}}}}), - Tracing::EMPTY_CONTEXT)) + Tracing::EMPTY_CONTEXT)) .WillOnce(WithArgs<0>( Invoke([&](RequestCallbacks& callbacks) -> void { request_callbacks_ = &callbacks; }))); @@ -200,8 +200,8 @@ TEST_F(RateLimitFilterTest, ImmediateOK) { EXPECT_CALL(filter_callbacks_, continueReading()).Times(0); EXPECT_CALL(*client_, limit(_, "foo", _, _)) - .WillOnce(WithArgs<0>(Invoke([&](RequestCallbacks& callbacks) - -> void { callbacks.complete(LimitStatus::OK); }))); + .WillOnce(WithArgs<0>(Invoke( + [&](RequestCallbacks& callbacks) -> void { callbacks.complete(LimitStatus::OK); }))); EXPECT_EQ(Network::FilterStatus::Continue, filter_->onNewConnection()); Buffer::OwnedImpl data("hello"); @@ -227,6 +227,6 @@ TEST_F(RateLimitFilterTest, RuntimeDisable) { EXPECT_EQ(Network::FilterStatus::Continue, filter_->onData(data)); } -} // TcpFilter -} // RateLimit -} // Envoy +} // namespace TcpFilter +} // namespace RateLimit +} // namespace Envoy diff --git a/test/common/filter/tcp_proxy_test.cc b/test/common/filter/tcp_proxy_test.cc index 07cf2c7d425ee..dfb01f690623a 100644 --- a/test/common/filter/tcp_proxy_test.cc +++ b/test/common/filter/tcp_proxy_test.cc @@ -19,11 +19,11 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::NiceMock; using testing::Return; using testing::ReturnRef; using testing::SaveArg; +using testing::_; namespace Filter { @@ -590,5 +590,5 @@ TEST_F(TcpProxyRoutingTest, RoutableConnection) { EXPECT_EQ(non_routable_cx, config_->stats().downstream_cx_no_route_.value()); } -} // Filter -} // Envoy +} // namespace Filter +} // namespace Envoy diff --git a/test/common/grpc/async_client_impl_test.cc b/test/common/grpc/async_client_impl_test.cc index 66b039fd41f56..7c957bae86cc9 100644 --- a/test/common/grpc/async_client_impl_test.cc +++ b/test/common/grpc/async_client_impl_test.cc @@ -10,12 +10,12 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -using testing::_; using testing::Invoke; +using testing::Mock; using testing::NiceMock; using testing::Return; using testing::ReturnRef; -using testing::Mock; +using testing::_; namespace Envoy { namespace Grpc { diff --git a/test/common/grpc/codec_test.cc b/test/common/grpc/codec_test.cc index 01bcc7a8ca89d..65d52be4b5369 100644 --- a/test/common/grpc/codec_test.cc +++ b/test/common/grpc/codec_test.cc @@ -164,5 +164,5 @@ TEST(GrpcCodecTest, decodeMultipleFrame) { } } -} // Grpc -} // Envoy +} // namespace Grpc +} // namespace Envoy diff --git a/test/common/grpc/common_test.cc b/test/common/grpc/common_test.cc index 6da1b59640d6d..8fbdabc1f9641 100644 --- a/test/common/grpc/common_test.cc +++ b/test/common/grpc/common_test.cc @@ -87,5 +87,5 @@ TEST(GrpcCommonTest, resolveServiceAndMethod) { EXPECT_FALSE(Common::resolveServiceAndMethod(&path, &service, &method)); } -} // Grpc -} // Envoy +} // namespace Grpc +} // namespace Envoy diff --git a/test/common/grpc/grpc_web_filter_test.cc b/test/common/grpc/grpc_web_filter_test.cc index 6703d3e33e12b..3950edab86c27 100644 --- a/test/common/grpc/grpc_web_filter_test.cc +++ b/test/common/grpc/grpc_web_filter_test.cc @@ -12,12 +12,12 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -using testing::_; using testing::Combine; using testing::Invoke; using testing::NiceMock; using testing::Return; using testing::Values; +using testing::_; namespace Envoy { namespace Grpc { @@ -241,8 +241,9 @@ TEST_P(GrpcWebFilterTest, Unary) { // Tests response trailers. Buffer::OwnedImpl trailers_buffer; - EXPECT_CALL(encoder_callbacks_, addEncodedData(_)) - .WillOnce(Invoke([&](Buffer::Instance& data) { trailers_buffer.move(data); })); + EXPECT_CALL(encoder_callbacks_, addEncodedData(_)).WillOnce(Invoke([&](Buffer::Instance& data) { + trailers_buffer.move(data); + })); Http::TestHeaderMapImpl response_trailers; response_trailers.addViaCopy(Http::Headers::get().GrpcStatus, "0"); response_trailers.addViaCopy(Http::Headers::get().GrpcMessage, "ok"); diff --git a/test/common/grpc/http1_bridge_filter_test.cc b/test/common/grpc/http1_bridge_filter_test.cc index f321155e6bdf0..ac8c1aa01902b 100644 --- a/test/common/grpc/http1_bridge_filter_test.cc +++ b/test/common/grpc/http1_bridge_filter_test.cc @@ -11,11 +11,11 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::NiceMock; using testing::Return; using testing::ReturnPointee; using testing::ReturnRef; +using testing::_; namespace Grpc { @@ -178,5 +178,5 @@ TEST_F(GrpcHttp1BridgeFilterTest, HandlingBadGrpcStatus) { EXPECT_EQ("foo", response_headers.get_("grpc-message")); } -} // Grpc -} // Envoy +} // namespace Grpc +} // namespace Envoy diff --git a/test/common/grpc/json_transcoder_filter_test.cc b/test/common/grpc/json_transcoder_filter_test.cc index 02ec3ccb7291f..c00c29f82173b 100644 --- a/test/common/grpc/json_transcoder_filter_test.cc +++ b/test/common/grpc/json_transcoder_filter_test.cc @@ -15,12 +15,12 @@ #include "google/protobuf/util/message_differencer.h" #include "gtest/gtest.h" -using testing::_; using testing::Invoke; using testing::NiceMock; using testing::Return; using testing::ReturnPointee; using testing::ReturnRef; +using testing::_; using google::protobuf::util::MessageDifferencer; using google::protobuf::util::Status; diff --git a/test/common/grpc/rpc_channel_impl_test.cc b/test/common/grpc/rpc_channel_impl_test.cc index 5e7dd426bf2c8..b4f9aea49e775 100644 --- a/test/common/grpc/rpc_channel_impl_test.cc +++ b/test/common/grpc/rpc_channel_impl_test.cc @@ -16,9 +16,9 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::Invoke; using testing::Return; +using testing::_; namespace Grpc { @@ -61,8 +61,8 @@ TEST_F(GrpcRequestImplTest, NoError) { Http::LowerCaseString header_key("foo"); std::string header_value("bar"); EXPECT_CALL(grpc_callbacks_, onPreRequestCustomizeHeaders(_)) - .WillOnce(Invoke([&](Http::HeaderMap& headers) - -> void { headers.addStatic(header_key, header_value); })); + .WillOnce(Invoke( + [&](Http::HeaderMap& headers) -> void { headers.addStatic(header_key, header_value); })); service_.SayHello(nullptr, &request, &response, nullptr); Http::TestHeaderMapImpl expected_request_headers{{":method", "POST"}, @@ -323,5 +323,5 @@ TEST_F(GrpcRequestImplTest, RequestTimeoutSet) { http_callbacks_->onSuccess(std::move(response_http_message)); } -} // Grpc -} // Envoy +} // namespace Grpc +} // namespace Envoy diff --git a/test/common/http/access_log/access_log_formatter_test.cc b/test/common/http/access_log/access_log_formatter_test.cc index 344dac2babb41..f96381fe628f5 100644 --- a/test/common/http/access_log/access_log_formatter_test.cc +++ b/test/common/http/access_log/access_log_formatter_test.cc @@ -16,10 +16,10 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::NiceMock; using testing::Return; using testing::ReturnRef; +using testing::_; namespace Http { namespace AccessLog { @@ -251,16 +251,28 @@ TEST(AccessLogFormatterTest, ParserFailures) { AccessLogFormatParser parser; std::vector test_cases = { - "{{%PROTOCOL%}} ++ %REQ(FIRST?SECOND)% %RESP(FIRST?SECOND)", "%REQ(FIRST?SECOND)T%", - "RESP(FIRST)%", "%REQ(valid)% %NOT_VALID%", "%REQ(FIRST?SECOND%", "%%", "%protocol%", - "%REQ(TEST):%", "%REQ(TEST):3q4%", "%RESP(TEST):%", "%RESP(X?Y):%", "%RESP(X?Y):343o24%", - "%REQ(TEST):10", "REQ(:TEST):10%", "%REQ(TEST:10%", "%REQ("}; + "{{%PROTOCOL%}} ++ %REQ(FIRST?SECOND)% %RESP(FIRST?SECOND)", + "%REQ(FIRST?SECOND)T%", + "RESP(FIRST)%", + "%REQ(valid)% %NOT_VALID%", + "%REQ(FIRST?SECOND%", + "%%", + "%protocol%", + "%REQ(TEST):%", + "%REQ(TEST):3q4%", + "%RESP(TEST):%", + "%RESP(X?Y):%", + "%RESP(X?Y):343o24%", + "%REQ(TEST):10", + "REQ(:TEST):10%", + "%REQ(TEST:10%", + "%REQ("}; for (const std::string& test_case : test_cases) { EXPECT_THROW(parser.parse(test_case), EnvoyException); } } -} // AccessLog -} // Http -} // Envoy +} // namespace AccessLog +} // namespace Http +} // namespace Envoy diff --git a/test/common/http/access_log/access_log_impl_test.cc b/test/common/http/access_log/access_log_impl_test.cc index 1ac269c32121b..54e24b5c7e956 100644 --- a/test/common/http/access_log/access_log_impl_test.cc +++ b/test/common/http/access_log/access_log_impl_test.cc @@ -28,10 +28,10 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::NiceMock; using testing::Return; using testing::SaveArg; +using testing::_; namespace Http { namespace AccessLog { @@ -525,6 +525,6 @@ TEST(AccessLogFilterTest, StatusCodeWithRuntimeKey) { EXPECT_FALSE(filter.evaluate(info, request_headers)); } -} // AccessLog -} // Http -} // Envoy +} // namespace AccessLog +} // namespace Http +} // namespace Envoy diff --git a/test/common/http/async_client_impl_test.cc b/test/common/http/async_client_impl_test.cc index cb34a0e04ae56..d51fa1bdf229f 100644 --- a/test/common/http/async_client_impl_test.cc +++ b/test/common/http/async_client_impl_test.cc @@ -22,12 +22,12 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::Invoke; using testing::NiceMock; using testing::Ref; using testing::Return; using testing::ReturnRef; +using testing::_; namespace Http { @@ -44,10 +44,9 @@ class AsyncClientImplTest : public testing::Test { } void expectSuccess(uint64_t code) { - EXPECT_CALL(callbacks_, onSuccess_(_)) - .WillOnce(Invoke([code](Message* response) -> void { - EXPECT_EQ(code, Utility::getResponseStatus(response->headers())); - })); + EXPECT_CALL(callbacks_, onSuccess_(_)).WillOnce(Invoke([code](Message* response) -> void { + EXPECT_EQ(code, Utility::getResponseStatus(response->headers())); + })); } void expectResponseHeaders(MockAsyncClientStreamCallbacks& callbacks, uint64_t code, @@ -77,12 +76,12 @@ TEST_F(AsyncClientImplTest, BasicStream) { Buffer::InstancePtr body{new Buffer::OwnedImpl("test body")}; EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) - .WillOnce(Invoke([&](StreamDecoder& decoder, ConnectionPool::Callbacks& callbacks) - -> ConnectionPool::Cancellable* { - callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); - response_decoder_ = &decoder; - return nullptr; - })); + .WillOnce(Invoke([&](StreamDecoder& decoder, + ConnectionPool::Callbacks& callbacks) -> ConnectionPool::Cancellable* { + callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); + response_decoder_ = &decoder; + return nullptr; + })); TestHeaderMapImpl headers; HttpTestUtility::addDefaultHeaders(headers); @@ -104,12 +103,12 @@ TEST_F(AsyncClientImplTest, BasicStream) { response_decoder_->decodeHeaders(HeaderMapPtr(new TestHeaderMapImpl{{":status", "200"}}), false); response_decoder_->decodeData(*body, true); - EXPECT_EQ(1UL, cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_200") - .value()); EXPECT_EQ( 1UL, - cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("internal.upstream_rq_200") - .value()); + cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_200").value()); + EXPECT_EQ(1UL, cm_.thread_local_cluster_.cluster_.info_->stats_store_ + .counter("internal.upstream_rq_200") + .value()); } TEST_F(AsyncClientImplTest, Basic) { @@ -117,12 +116,12 @@ TEST_F(AsyncClientImplTest, Basic) { Buffer::Instance& data = *message_->body(); EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) - .WillOnce(Invoke([&](StreamDecoder& decoder, ConnectionPool::Callbacks& callbacks) - -> ConnectionPool::Cancellable* { - callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); - response_decoder_ = &decoder; - return nullptr; - })); + .WillOnce(Invoke([&](StreamDecoder& decoder, + ConnectionPool::Callbacks& callbacks) -> ConnectionPool::Cancellable* { + callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); + response_decoder_ = &decoder; + return nullptr; + })); TestHeaderMapImpl copy(message_->headers()); copy.addViaCopy("x-envoy-internal", "true"); @@ -139,12 +138,12 @@ TEST_F(AsyncClientImplTest, Basic) { response_decoder_->decodeHeaders(std::move(response_headers), false); response_decoder_->decodeData(data, true); - EXPECT_EQ(1UL, cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_200") - .value()); EXPECT_EQ( 1UL, - cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("internal.upstream_rq_200") - .value()); + cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_200").value()); + EXPECT_EQ(1UL, cm_.thread_local_cluster_.cluster_.info_->stats_store_ + .counter("internal.upstream_rq_200") + .value()); } TEST_F(AsyncClientImplTest, Retry) { @@ -156,12 +155,12 @@ TEST_F(AsyncClientImplTest, Retry) { Buffer::Instance& data = *message_->body(); EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) - .WillOnce(Invoke([&](StreamDecoder& decoder, ConnectionPool::Callbacks& callbacks) - -> ConnectionPool::Cancellable* { - callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); - response_decoder_ = &decoder; - return nullptr; - })); + .WillOnce(Invoke([&](StreamDecoder& decoder, + ConnectionPool::Callbacks& callbacks) -> ConnectionPool::Cancellable* { + callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); + response_decoder_ = &decoder; + return nullptr; + })); EXPECT_CALL(stream_encoder_, encodeHeaders(HeaderMapEqualRef(&message_->headers()), false)); EXPECT_CALL(stream_encoder_, encodeData(BufferEqual(&data), true)); @@ -176,12 +175,12 @@ TEST_F(AsyncClientImplTest, Retry) { // Retry request. EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) - .WillOnce(Invoke([&](StreamDecoder& decoder, ConnectionPool::Callbacks& callbacks) - -> ConnectionPool::Cancellable* { - callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); - response_decoder_ = &decoder; - return nullptr; - })); + .WillOnce(Invoke([&](StreamDecoder& decoder, + ConnectionPool::Callbacks& callbacks) -> ConnectionPool::Cancellable* { + callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); + response_decoder_ = &decoder; + return nullptr; + })); EXPECT_CALL(stream_encoder_, encodeHeaders(HeaderMapEqualRef(&message_copy->headers()), false)); EXPECT_CALL(stream_encoder_, encodeData(BufferEqual(&data), true)); @@ -199,12 +198,12 @@ TEST_F(AsyncClientImplTest, NoRetryWithStream) { Buffer::InstancePtr body{new Buffer::OwnedImpl("test body")}; EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) - .WillOnce(Invoke([&](StreamDecoder& decoder, ConnectionPool::Callbacks& callbacks) - -> ConnectionPool::Cancellable* { - callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); - response_decoder_ = &decoder; - return nullptr; - })); + .WillOnce(Invoke([&](StreamDecoder& decoder, + ConnectionPool::Callbacks& callbacks) -> ConnectionPool::Cancellable* { + callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); + response_decoder_ = &decoder; + return nullptr; + })); TestHeaderMapImpl headers; HttpTestUtility::addDefaultHeaders(headers); @@ -231,12 +230,12 @@ TEST_F(AsyncClientImplTest, MultipleStreams) { Buffer::InstancePtr body{new Buffer::OwnedImpl("test body")}; EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) - .WillOnce(Invoke([&](StreamDecoder& decoder, ConnectionPool::Callbacks& callbacks) - -> ConnectionPool::Cancellable* { - callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); - response_decoder_ = &decoder; - return nullptr; - })); + .WillOnce(Invoke([&](StreamDecoder& decoder, + ConnectionPool::Callbacks& callbacks) -> ConnectionPool::Cancellable* { + callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); + response_decoder_ = &decoder; + return nullptr; + })); TestHeaderMapImpl headers(message_->headers()); EXPECT_CALL(stream_encoder_, encodeHeaders(HeaderMapEqualRef(&headers), false)); @@ -257,12 +256,12 @@ TEST_F(AsyncClientImplTest, MultipleStreams) { MockAsyncClientStreamCallbacks stream_callbacks2; EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) - .WillOnce(Invoke([&](StreamDecoder& decoder, ConnectionPool::Callbacks& callbacks) - -> ConnectionPool::Cancellable* { - callbacks.onPoolReady(stream_encoder2, cm_.conn_pool_.host_); - response_decoder2 = &decoder; - return nullptr; - })); + .WillOnce(Invoke([&](StreamDecoder& decoder, + ConnectionPool::Callbacks& callbacks) -> ConnectionPool::Cancellable* { + callbacks.onPoolReady(stream_encoder2, cm_.conn_pool_.host_); + response_decoder2 = &decoder; + return nullptr; + })); TestHeaderMapImpl headers2(message_->headers()); EXPECT_CALL(stream_encoder2, encodeHeaders(HeaderMapEqualRef(&headers2), false)); @@ -291,12 +290,12 @@ TEST_F(AsyncClientImplTest, MultipleRequests) { Buffer::Instance& data = *message_->body(); EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) - .WillOnce(Invoke([&](StreamDecoder& decoder, ConnectionPool::Callbacks& callbacks) - -> ConnectionPool::Cancellable* { - callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); - response_decoder_ = &decoder; - return nullptr; - })); + .WillOnce(Invoke([&](StreamDecoder& decoder, + ConnectionPool::Callbacks& callbacks) -> ConnectionPool::Cancellable* { + callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); + response_decoder_ = &decoder; + return nullptr; + })); EXPECT_CALL(stream_encoder_, encodeHeaders(HeaderMapEqualRef(&message_->headers()), false)); EXPECT_CALL(stream_encoder_, encodeData(BufferEqual(&data), true)); @@ -310,12 +309,12 @@ TEST_F(AsyncClientImplTest, MultipleRequests) { StreamDecoder* response_decoder2{}; MockAsyncClientCallbacks callbacks2; EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) - .WillOnce(Invoke([&](StreamDecoder& decoder, ConnectionPool::Callbacks& callbacks) - -> ConnectionPool::Cancellable* { - callbacks.onPoolReady(stream_encoder2, cm_.conn_pool_.host_); - response_decoder2 = &decoder; - return nullptr; - })); + .WillOnce(Invoke([&](StreamDecoder& decoder, + ConnectionPool::Callbacks& callbacks) -> ConnectionPool::Cancellable* { + callbacks.onPoolReady(stream_encoder2, cm_.conn_pool_.host_); + response_decoder2 = &decoder; + return nullptr; + })); EXPECT_CALL(stream_encoder2, encodeHeaders(HeaderMapEqualRef(&message2->headers()), true)); client_.send(std::move(message2), callbacks2, Optional()); @@ -337,12 +336,12 @@ TEST_F(AsyncClientImplTest, StreamAndRequest) { Buffer::Instance& data = *message_->body(); EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) - .WillOnce(Invoke([&](StreamDecoder& decoder, ConnectionPool::Callbacks& callbacks) - -> ConnectionPool::Cancellable* { - callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); - response_decoder_ = &decoder; - return nullptr; - })); + .WillOnce(Invoke([&](StreamDecoder& decoder, + ConnectionPool::Callbacks& callbacks) -> ConnectionPool::Cancellable* { + callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); + response_decoder_ = &decoder; + return nullptr; + })); EXPECT_CALL(stream_encoder_, encodeHeaders(HeaderMapEqualRef(&message_->headers()), false)); EXPECT_CALL(stream_encoder_, encodeData(BufferEqual(&data), true)); @@ -355,12 +354,12 @@ TEST_F(AsyncClientImplTest, StreamAndRequest) { StreamDecoder* response_decoder2{}; EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) - .WillOnce(Invoke([&](StreamDecoder& decoder, ConnectionPool::Callbacks& callbacks) - -> ConnectionPool::Cancellable* { - callbacks.onPoolReady(stream_encoder2, cm_.conn_pool_.host_); - response_decoder2 = &decoder; - return nullptr; - })); + .WillOnce(Invoke([&](StreamDecoder& decoder, + ConnectionPool::Callbacks& callbacks) -> ConnectionPool::Cancellable* { + callbacks.onPoolReady(stream_encoder2, cm_.conn_pool_.host_); + response_decoder2 = &decoder; + return nullptr; + })); TestHeaderMapImpl headers; HttpTestUtility::addDefaultHeaders(headers); @@ -394,12 +393,12 @@ TEST_F(AsyncClientImplTest, StreamWithTrailers) { TestHeaderMapImpl trailers{{"some", "request_trailer"}}; EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) - .WillOnce(Invoke([&](StreamDecoder& decoder, ConnectionPool::Callbacks& callbacks) - -> ConnectionPool::Cancellable* { - callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); - response_decoder_ = &decoder; - return nullptr; - })); + .WillOnce(Invoke([&](StreamDecoder& decoder, + ConnectionPool::Callbacks& callbacks) -> ConnectionPool::Cancellable* { + callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); + response_decoder_ = &decoder; + return nullptr; + })); EXPECT_CALL(stream_encoder_, encodeHeaders(HeaderMapEqualRef(&headers), false)); EXPECT_CALL(stream_encoder_, encodeData(BufferEqual(body.get()), false)); @@ -427,12 +426,12 @@ TEST_F(AsyncClientImplTest, Trailers) { Buffer::Instance& data = *message_->body(); EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) - .WillOnce(Invoke([&](StreamDecoder& decoder, ConnectionPool::Callbacks& callbacks) - -> ConnectionPool::Cancellable* { - callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); - response_decoder_ = &decoder; - return nullptr; - })); + .WillOnce(Invoke([&](StreamDecoder& decoder, + ConnectionPool::Callbacks& callbacks) -> ConnectionPool::Cancellable* { + callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); + response_decoder_ = &decoder; + return nullptr; + })); EXPECT_CALL(stream_encoder_, encodeHeaders(HeaderMapEqualRef(&message_->headers()), false)); EXPECT_CALL(stream_encoder_, encodeData(BufferEqual(&data), true)); @@ -447,11 +446,11 @@ TEST_F(AsyncClientImplTest, Trailers) { TEST_F(AsyncClientImplTest, ImmediateReset) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) - .WillOnce(Invoke([&](StreamDecoder&, ConnectionPool::Callbacks& callbacks) - -> ConnectionPool::Cancellable* { - callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); - return nullptr; - })); + .WillOnce(Invoke([&](StreamDecoder&, + ConnectionPool::Callbacks& callbacks) -> ConnectionPool::Cancellable* { + callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); + return nullptr; + })); EXPECT_CALL(stream_encoder_, encodeHeaders(HeaderMapEqualRef(&message_->headers()), true)); expectSuccess(503); @@ -459,20 +458,21 @@ TEST_F(AsyncClientImplTest, ImmediateReset) { client_.send(std::move(message_), callbacks_, Optional()); stream_encoder_.getStream().resetStream(StreamResetReason::RemoteReset); - EXPECT_EQ(1UL, cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_503") - .value()); + EXPECT_EQ( + 1UL, + cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_503").value()); } TEST_F(AsyncClientImplTest, LocalResetAfterStreamStart) { Buffer::InstancePtr body{new Buffer::OwnedImpl("test body")}; EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) - .WillOnce(Invoke([&](StreamDecoder& decoder, ConnectionPool::Callbacks& callbacks) - -> ConnectionPool::Cancellable* { - callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); - response_decoder_ = &decoder; - return nullptr; - })); + .WillOnce(Invoke([&](StreamDecoder& decoder, + ConnectionPool::Callbacks& callbacks) -> ConnectionPool::Cancellable* { + callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); + response_decoder_ = &decoder; + return nullptr; + })); TestHeaderMapImpl headers; HttpTestUtility::addDefaultHeaders(headers); @@ -503,12 +503,12 @@ TEST_F(AsyncClientImplTest, RemoteResetAfterStreamStart) { Buffer::InstancePtr body{new Buffer::OwnedImpl("test body")}; EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) - .WillOnce(Invoke([&](StreamDecoder& decoder, ConnectionPool::Callbacks& callbacks) - -> ConnectionPool::Cancellable* { - callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); - response_decoder_ = &decoder; - return nullptr; - })); + .WillOnce(Invoke([&](StreamDecoder& decoder, + ConnectionPool::Callbacks& callbacks) -> ConnectionPool::Cancellable* { + callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); + response_decoder_ = &decoder; + return nullptr; + })); TestHeaderMapImpl headers; HttpTestUtility::addDefaultHeaders(headers); @@ -537,12 +537,12 @@ TEST_F(AsyncClientImplTest, RemoteResetAfterStreamStart) { TEST_F(AsyncClientImplTest, ResetAfterResponseStart) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) - .WillOnce(Invoke([&](StreamDecoder& decoder, ConnectionPool::Callbacks& callbacks) - -> ConnectionPool::Cancellable* { - callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); - response_decoder_ = &decoder; - return nullptr; - })); + .WillOnce(Invoke([&](StreamDecoder& decoder, + ConnectionPool::Callbacks& callbacks) -> ConnectionPool::Cancellable* { + callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); + response_decoder_ = &decoder; + return nullptr; + })); EXPECT_CALL(stream_encoder_, encodeHeaders(HeaderMapEqualRef(&message_->headers()), true)); EXPECT_CALL(callbacks_, onFailure(_)); @@ -555,11 +555,11 @@ TEST_F(AsyncClientImplTest, ResetAfterResponseStart) { TEST_F(AsyncClientImplTest, ResetStream) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) - .WillOnce(Invoke([&](StreamDecoder&, ConnectionPool::Callbacks& callbacks) - -> ConnectionPool::Cancellable* { - callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); - return nullptr; - })); + .WillOnce(Invoke([&](StreamDecoder&, + ConnectionPool::Callbacks& callbacks) -> ConnectionPool::Cancellable* { + callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); + return nullptr; + })); EXPECT_CALL(stream_encoder_, encodeHeaders(HeaderMapEqualRef(&message_->headers()), true)); EXPECT_CALL(stream_encoder_.stream_, resetStream(_)); @@ -573,11 +573,11 @@ TEST_F(AsyncClientImplTest, ResetStream) { TEST_F(AsyncClientImplTest, CancelRequest) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) - .WillOnce(Invoke([&](StreamDecoder&, ConnectionPool::Callbacks& callbacks) - -> ConnectionPool::Cancellable* { - callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); - return nullptr; - })); + .WillOnce(Invoke([&](StreamDecoder&, + ConnectionPool::Callbacks& callbacks) -> ConnectionPool::Cancellable* { + callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); + return nullptr; + })); EXPECT_CALL(stream_encoder_, encodeHeaders(HeaderMapEqualRef(&message_->headers()), true)); EXPECT_CALL(stream_encoder_.stream_, resetStream(_)); @@ -589,11 +589,11 @@ TEST_F(AsyncClientImplTest, CancelRequest) { TEST_F(AsyncClientImplTest, DestroyWithActiveStream) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) - .WillOnce(Invoke([&](StreamDecoder&, ConnectionPool::Callbacks& callbacks) - -> ConnectionPool::Cancellable* { - callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); - return nullptr; - })); + .WillOnce(Invoke([&](StreamDecoder&, + ConnectionPool::Callbacks& callbacks) -> ConnectionPool::Cancellable* { + callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); + return nullptr; + })); EXPECT_CALL(stream_encoder_, encodeHeaders(HeaderMapEqualRef(&message_->headers()), false)); EXPECT_CALL(stream_encoder_.stream_, resetStream(_)); @@ -605,11 +605,11 @@ TEST_F(AsyncClientImplTest, DestroyWithActiveStream) { TEST_F(AsyncClientImplTest, DestroyWithActiveRequest) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) - .WillOnce(Invoke([&](StreamDecoder&, ConnectionPool::Callbacks& callbacks) - -> ConnectionPool::Cancellable* { - callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); - return nullptr; - })); + .WillOnce(Invoke([&](StreamDecoder&, + ConnectionPool::Callbacks& callbacks) -> ConnectionPool::Cancellable* { + callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); + return nullptr; + })); EXPECT_CALL(stream_encoder_, encodeHeaders(HeaderMapEqualRef(&message_->headers()), true)); EXPECT_CALL(stream_encoder_.stream_, resetStream(_)); @@ -629,8 +629,9 @@ TEST_F(AsyncClientImplTest, PoolFailure) { EXPECT_EQ(nullptr, client_.send(std::move(message_), callbacks_, Optional())); - EXPECT_EQ(1UL, cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_503") - .value()); + EXPECT_EQ( + 1UL, + cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_503").value()); } TEST_F(AsyncClientImplTest, PoolFailureWithBody) { @@ -646,17 +647,18 @@ TEST_F(AsyncClientImplTest, PoolFailureWithBody) { EXPECT_EQ(nullptr, client_.send(std::move(message_), callbacks_, Optional())); - EXPECT_EQ(1UL, cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_503") - .value()); + EXPECT_EQ( + 1UL, + cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_503").value()); } TEST_F(AsyncClientImplTest, StreamTimeout) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) - .WillOnce(Invoke([&](StreamDecoder&, ConnectionPool::Callbacks& callbacks) - -> ConnectionPool::Cancellable* { - callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); - return nullptr; - })); + .WillOnce(Invoke([&](StreamDecoder&, + ConnectionPool::Callbacks& callbacks) -> ConnectionPool::Cancellable* { + callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); + return nullptr; + })); EXPECT_CALL(stream_encoder_, encodeHeaders(HeaderMapEqualRef(&message_->headers()), true)); timer_ = new NiceMock(&dispatcher_); @@ -676,17 +678,18 @@ TEST_F(AsyncClientImplTest, StreamTimeout) { cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_timeout") .value()); EXPECT_EQ(1UL, cm_.conn_pool_.host_->stats().rq_timeout_.value()); - EXPECT_EQ(1UL, cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_504") - .value()); + EXPECT_EQ( + 1UL, + cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_504").value()); } TEST_F(AsyncClientImplTest, RequestTimeout) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) - .WillOnce(Invoke([&](StreamDecoder&, ConnectionPool::Callbacks& callbacks) - -> ConnectionPool::Cancellable* { - callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); - return nullptr; - })); + .WillOnce(Invoke([&](StreamDecoder&, + ConnectionPool::Callbacks& callbacks) -> ConnectionPool::Cancellable* { + callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); + return nullptr; + })); EXPECT_CALL(stream_encoder_, encodeHeaders(HeaderMapEqualRef(&message_->headers()), true)); expectSuccess(504); @@ -700,17 +703,18 @@ TEST_F(AsyncClientImplTest, RequestTimeout) { cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_timeout") .value()); EXPECT_EQ(1UL, cm_.conn_pool_.host_->stats().rq_timeout_.value()); - EXPECT_EQ(1UL, cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_504") - .value()); + EXPECT_EQ( + 1UL, + cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_504").value()); } TEST_F(AsyncClientImplTest, DisableTimer) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) - .WillOnce(Invoke([&](StreamDecoder&, ConnectionPool::Callbacks& callbacks) - -> ConnectionPool::Cancellable* { - callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); - return nullptr; - })); + .WillOnce(Invoke([&](StreamDecoder&, + ConnectionPool::Callbacks& callbacks) -> ConnectionPool::Cancellable* { + callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); + return nullptr; + })); EXPECT_CALL(stream_encoder_, encodeHeaders(HeaderMapEqualRef(&message_->headers()), true)); timer_ = new NiceMock(&dispatcher_); @@ -724,11 +728,11 @@ TEST_F(AsyncClientImplTest, DisableTimer) { TEST_F(AsyncClientImplTest, DisableTimerWithStream) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) - .WillOnce(Invoke([&](StreamDecoder&, ConnectionPool::Callbacks& callbacks) - -> ConnectionPool::Cancellable* { - callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); - return nullptr; - })); + .WillOnce(Invoke([&](StreamDecoder&, + ConnectionPool::Callbacks& callbacks) -> ConnectionPool::Cancellable* { + callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); + return nullptr; + })); EXPECT_CALL(stream_encoder_, encodeHeaders(HeaderMapEqualRef(&message_->headers()), true)); timer_ = new NiceMock(&dispatcher_); @@ -747,12 +751,12 @@ TEST_F(AsyncClientImplTest, MultipleDataStream) { Buffer::InstancePtr body2{new Buffer::OwnedImpl("test body2")}; EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) - .WillOnce(Invoke([&](StreamDecoder& decoder, ConnectionPool::Callbacks& callbacks) - -> ConnectionPool::Cancellable* { - callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); - response_decoder_ = &decoder; - return nullptr; - })); + .WillOnce(Invoke([&](StreamDecoder& decoder, + ConnectionPool::Callbacks& callbacks) -> ConnectionPool::Cancellable* { + callbacks.onPoolReady(stream_encoder_, cm_.conn_pool_.host_); + response_decoder_ = &decoder; + return nullptr; + })); TestHeaderMapImpl headers; HttpTestUtility::addDefaultHeaders(headers); @@ -781,13 +785,13 @@ TEST_F(AsyncClientImplTest, MultipleDataStream) { stream->sendData(*body2, true); response_decoder_->decodeData(*body2, true); - EXPECT_EQ(1UL, cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_200") - .value()); EXPECT_EQ( 1UL, - cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("internal.upstream_rq_200") - .value()); + cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_200").value()); + EXPECT_EQ(1UL, cm_.thread_local_cluster_.cluster_.info_->stats_store_ + .counter("internal.upstream_rq_200") + .value()); } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/test/common/http/codec_client_test.cc b/test/common/http/codec_client_test.cc index 448fe04a0cfa0..0969f61056c8e 100644 --- a/test/common/http/codec_client_test.cc +++ b/test/common/http/codec_client_test.cc @@ -19,7 +19,6 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::Invoke; using testing::NiceMock; using testing::Pointee; @@ -27,6 +26,7 @@ using testing::Ref; using testing::Return; using testing::SaveArg; using testing::Throw; +using testing::_; namespace Http { @@ -131,11 +131,10 @@ TEST_F(CodecClientTest, ProtocolError) { } TEST_F(CodecClientTest, 408Response) { - EXPECT_CALL(*codec_, dispatch(_)) - .WillOnce(Invoke([](Buffer::Instance&) -> void { - Http::HeaderMapPtr response_headers{new TestHeaderMapImpl{{":status", "408"}}}; - throw PrematureResponseException(std::move(response_headers)); - })); + EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([](Buffer::Instance&) -> void { + Http::HeaderMapPtr response_headers{new TestHeaderMapImpl{{":status", "408"}}}; + throw PrematureResponseException(std::move(response_headers)); + })); EXPECT_CALL(*connection_, close(Network::ConnectionCloseType::NoFlush)); @@ -146,11 +145,10 @@ TEST_F(CodecClientTest, 408Response) { } TEST_F(CodecClientTest, PrematureResponse) { - EXPECT_CALL(*codec_, dispatch(_)) - .WillOnce(Invoke([](Buffer::Instance&) -> void { - Http::HeaderMapPtr response_headers{new TestHeaderMapImpl{{":status", "200"}}}; - throw PrematureResponseException(std::move(response_headers)); - })); + EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([](Buffer::Instance&) -> void { + Http::HeaderMapPtr response_headers{new TestHeaderMapImpl{{":status", "200"}}}; + throw PrematureResponseException(std::move(response_headers)); + })); EXPECT_CALL(*connection_, close(Network::ConnectionCloseType::NoFlush)); @@ -160,5 +158,5 @@ TEST_F(CodecClientTest, PrematureResponse) { EXPECT_EQ(1U, cluster_->stats_.upstream_cx_protocol_error_.value()); } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/test/common/http/codes_test.cc b/test/common/http/codes_test.cc index 0e5a091a79416..bb04e7d063768 100644 --- a/test/common/http/codes_test.cc +++ b/test/common/http/codes_test.cc @@ -29,9 +29,9 @@ class CodeUtilityTest : public testing::Test { const std::string& to_az = EMPTY_STRING) { TestHeaderMapImpl headers{{":status", std::to_string(code)}}; - CodeUtility::ResponseStatInfo info{global_store_, cluster_scope_, "prefix.", headers, - internal_request, request_vhost_name, request_vcluster_name, - from_az, to_az, canary}; + CodeUtility::ResponseStatInfo info{ + global_store_, cluster_scope_, "prefix.", headers, internal_request, + request_vhost_name, request_vcluster_name, from_az, to_az, canary}; CodeUtility::chargeResponseStat(info); } @@ -93,8 +93,10 @@ TEST_F(CodeUtilityTest, Canary) { TEST_F(CodeUtilityTest, All) { std::vector> testSet = { - std::make_pair(Code::Continue, "Continue"), std::make_pair(Code::OK, "OK"), - std::make_pair(Code::Created, "Created"), std::make_pair(Code::Accepted, "Accepted"), + std::make_pair(Code::Continue, "Continue"), + std::make_pair(Code::OK, "OK"), + std::make_pair(Code::Created, "Created"), + std::make_pair(Code::Accepted, "Accepted"), std::make_pair(Code::NonAuthoritativeInformation, "Non-Authoritative Information"), std::make_pair(Code::NoContent, "No Content"), std::make_pair(Code::ResetContent, "Reset Content"), @@ -104,7 +106,8 @@ TEST_F(CodeUtilityTest, All) { std::make_pair(Code::IMUsed, "IM Used"), std::make_pair(Code::MultipleChoices, "Multiple Choices"), std::make_pair(Code::MovedPermanently, "Moved Permanently"), - std::make_pair(Code::Found, "Found"), std::make_pair(Code::SeeOther, "See Other"), + std::make_pair(Code::Found, "Found"), + std::make_pair(Code::SeeOther, "See Other"), std::make_pair(Code::NotModified, "Not Modified"), std::make_pair(Code::UseProxy, "Use Proxy"), std::make_pair(Code::TemporaryRedirect, "Temporary Redirect"), @@ -112,12 +115,14 @@ TEST_F(CodeUtilityTest, All) { std::make_pair(Code::BadRequest, "Bad Request"), std::make_pair(Code::Unauthorized, "Unauthorized"), std::make_pair(Code::PaymentRequired, "Payment Required"), - std::make_pair(Code::Forbidden, "Forbidden"), std::make_pair(Code::NotFound, "Not Found"), + std::make_pair(Code::Forbidden, "Forbidden"), + std::make_pair(Code::NotFound, "Not Found"), std::make_pair(Code::MethodNotAllowed, "Method Not Allowed"), std::make_pair(Code::NotAcceptable, "Not Acceptable"), std::make_pair(Code::ProxyAuthenticationRequired, "Proxy Authentication Required"), std::make_pair(Code::RequestTimeout, "Request Timeout"), - std::make_pair(Code::Conflict, "Conflict"), std::make_pair(Code::Gone, "Gone"), + std::make_pair(Code::Conflict, "Conflict"), + std::make_pair(Code::Gone, "Gone"), std::make_pair(Code::LengthRequired, "Length Required"), std::make_pair(Code::PreconditionFailed, "Precondition Failed"), std::make_pair(Code::PayloadTooLarge, "Payload Too Large"), @@ -173,9 +178,10 @@ TEST(CodeUtilityResponseTimingTest, All) { Stats::MockStore global_store; Stats::MockStore cluster_scope; - CodeUtility::ResponseTimingInfo info{global_store, cluster_scope, "prefix.", - std::chrono::milliseconds(5), true, true, "vhost_name", - "req_vcluster_name", "from_az", "to_az"}; + CodeUtility::ResponseTimingInfo info{ + global_store, cluster_scope, "prefix.", std::chrono::milliseconds(5), + true, true, "vhost_name", "req_vcluster_name", + "from_az", "to_az"}; EXPECT_CALL(cluster_scope, deliverTimingToSinks("prefix.upstream_rq_time", std::chrono::milliseconds(5))); @@ -191,5 +197,5 @@ TEST(CodeUtilityResponseTimingTest, All) { CodeUtility::chargeResponseTiming(info); } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/test/common/http/common.cc b/test/common/http/common.cc index 2f6f0a95d095f..07628caf9661e 100644 --- a/test/common/http/common.cc +++ b/test/common/http/common.cc @@ -11,4 +11,4 @@ void HttpTestUtility::addDefaultHeaders(Http::HeaderMap& headers) { headers.insertHost().value(std::string("host")); headers.insertPath().value(std::string("/")); } -} // Envoy +} // namespace Envoy diff --git a/test/common/http/common.h b/test/common/http/common.h index 98e056c500ae1..b3f83347c6f71 100644 --- a/test/common/http/common.h +++ b/test/common/http/common.h @@ -65,4 +65,4 @@ class HttpTestUtility { public: static void addDefaultHeaders(Http::HeaderMap& headers); }; -} // Envoy +} // namespace Envoy diff --git a/test/common/http/conn_manager_impl_test.cc b/test/common/http/conn_manager_impl_test.cc index 45c8af21cc617..033154b9dd067 100644 --- a/test/common/http/conn_manager_impl_test.cc +++ b/test/common/http/conn_manager_impl_test.cc @@ -35,7 +35,6 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::AtLeast; using testing::InSequence; using testing::Invoke; @@ -46,6 +45,7 @@ using testing::Return; using testing::ReturnRef; using testing::Sequence; using testing::Test; +using testing::_; namespace Http { @@ -107,8 +107,8 @@ class HttpConnectionManagerImplTest : public Test, public ConnectionManagerConfi } EXPECT_CALL(filter_factory_, createFilterChain(_)) - .WillOnce(Invoke([num_decoder_filters, num_encoder_filters, this]( - FilterChainFactoryCallbacks& callbacks) -> void { + .WillOnce(Invoke([num_decoder_filters, num_encoder_filters, + this](FilterChainFactoryCallbacks& callbacks) -> void { for (int i = 0; i < num_decoder_filters; i++) { callbacks.addStreamDecoderFilter(StreamDecoderFilterSharedPtr{decoder_filters_[i]}); } @@ -219,8 +219,9 @@ TEST_F(HttpConnectionManagerImplTest, HeaderOnlyRequestAndResponse) { EXPECT_CALL(filter_factory_, createFilterChain(_)) .Times(2) - .WillRepeatedly(Invoke([&](FilterChainFactoryCallbacks& callbacks) - -> void { callbacks.addStreamDecoderFilter(filter); })); + .WillRepeatedly(Invoke([&](FilterChainFactoryCallbacks& callbacks) -> void { + callbacks.addStreamDecoderFilter(filter); + })); EXPECT_CALL(filter_callbacks_.connection_.dispatcher_, deferredDelete_(_)).Times(2); @@ -261,27 +262,28 @@ TEST_F(HttpConnectionManagerImplTest, InvalidPathWithDualFilter) { InSequence s; setup(false, ""); - EXPECT_CALL(*codec_, dispatch(_)) - .WillOnce(Invoke([&](Buffer::Instance& data) -> void { - StreamDecoder* decoder = &conn_manager_->newStream(response_encoder_); - HeaderMapPtr headers{ - new TestHeaderMapImpl{{":authority", "host"}, {":path", "http://api.lyft.com/"}}}; - decoder->decodeHeaders(std::move(headers), true); - data.drain(4); - })); + EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance& data) -> void { + StreamDecoder* decoder = &conn_manager_->newStream(response_encoder_); + HeaderMapPtr headers{ + new TestHeaderMapImpl{{":authority", "host"}, {":path", "http://api.lyft.com/"}}}; + decoder->decodeHeaders(std::move(headers), true); + data.drain(4); + })); // This test also verifies that decoder/encoder filters have onDestroy() called only once. MockStreamFilter* filter = new MockStreamFilter(); EXPECT_CALL(filter_factory_, createFilterChain(_)) - .WillOnce(Invoke([&](FilterChainFactoryCallbacks& callbacks) - -> void { callbacks.addStreamFilter(StreamFilterSharedPtr{filter}); })); + .WillOnce(Invoke([&](FilterChainFactoryCallbacks& callbacks) -> void { + callbacks.addStreamFilter(StreamFilterSharedPtr{filter}); + })); EXPECT_CALL(*filter, setDecoderFilterCallbacks(_)); EXPECT_CALL(*filter, setEncoderFilterCallbacks(_)); EXPECT_CALL(*filter, encodeHeaders(_, true)); EXPECT_CALL(response_encoder_, encodeHeaders(_, true)) - .WillOnce(Invoke([](const HeaderMap& headers, bool) - -> void { EXPECT_STREQ("404", headers.Status()->value().c_str()); })); + .WillOnce(Invoke([](const HeaderMap& headers, bool) -> void { + EXPECT_STREQ("404", headers.Status()->value().c_str()); + })); EXPECT_CALL(*filter, onDestroy()); Buffer::OwnedImpl fake_input("1234"); @@ -313,28 +315,28 @@ TEST_F(HttpConnectionManagerImplTest, StartAndFinishSpanNormalFlow) { std::shared_ptr filter(new NiceMock()); EXPECT_CALL(filter_factory_, createFilterChain(_)) - .WillRepeatedly(Invoke([&](FilterChainFactoryCallbacks& callbacks) - -> void { callbacks.addStreamDecoderFilter(filter); })); + .WillRepeatedly(Invoke([&](FilterChainFactoryCallbacks& callbacks) -> void { + callbacks.addStreamDecoderFilter(filter); + })); StreamDecoder* decoder = nullptr; NiceMock encoder; - EXPECT_CALL(*codec_, dispatch(_)) - .WillRepeatedly(Invoke([&](Buffer::Instance& data) -> void { - decoder = &conn_manager_->newStream(encoder); + EXPECT_CALL(*codec_, dispatch(_)).WillRepeatedly(Invoke([&](Buffer::Instance& data) -> void { + decoder = &conn_manager_->newStream(encoder); - HeaderMapPtr headers{ - new TestHeaderMapImpl{{":method", "GET"}, - {":authority", "host"}, - {":path", "/"}, - {"x-request-id", "125a4afb-6f55-a4ba-ad80-413f09f48a28"}}}; - decoder->decodeHeaders(std::move(headers), true); + HeaderMapPtr headers{ + new TestHeaderMapImpl{{":method", "GET"}, + {":authority", "host"}, + {":path", "/"}, + {"x-request-id", "125a4afb-6f55-a4ba-ad80-413f09f48a28"}}}; + decoder->decodeHeaders(std::move(headers), true); - HeaderMapPtr response_headers{new TestHeaderMapImpl{{":status", "200"}}}; - filter->callbacks_->encodeHeaders(std::move(response_headers), true); - filter->callbacks_->activeSpan().setTag("service-cluster", "scoobydoo"); + HeaderMapPtr response_headers{new TestHeaderMapImpl{{":status", "200"}}}; + filter->callbacks_->encodeHeaders(std::move(response_headers), true); + filter->callbacks_->activeSpan().setTag("service-cluster", "scoobydoo"); - data.drain(4); - })); + data.drain(4); + })); Buffer::OwnedImpl fake_input("1234"); conn_manager_->onData(fake_input); @@ -364,22 +366,21 @@ TEST_F(HttpConnectionManagerImplTest, TestAccessLog) { StreamDecoder* decoder = nullptr; NiceMock encoder; - EXPECT_CALL(*codec_, dispatch(_)) - .WillRepeatedly(Invoke([&](Buffer::Instance& data) -> void { - decoder = &conn_manager_->newStream(encoder); + EXPECT_CALL(*codec_, dispatch(_)).WillRepeatedly(Invoke([&](Buffer::Instance& data) -> void { + decoder = &conn_manager_->newStream(encoder); - HeaderMapPtr headers{ - new TestHeaderMapImpl{{":method", "GET"}, - {":authority", "host"}, - {":path", "/"}, - {"x-request-id", "125a4afb-6f55-a4ba-ad80-413f09f48a28"}}}; - decoder->decodeHeaders(std::move(headers), true); + HeaderMapPtr headers{ + new TestHeaderMapImpl{{":method", "GET"}, + {":authority", "host"}, + {":path", "/"}, + {"x-request-id", "125a4afb-6f55-a4ba-ad80-413f09f48a28"}}}; + decoder->decodeHeaders(std::move(headers), true); - HeaderMapPtr response_headers{new TestHeaderMapImpl{{":status", "200"}}}; - filter->callbacks_->encodeHeaders(std::move(response_headers), true); + HeaderMapPtr response_headers{new TestHeaderMapImpl{{":status", "200"}}}; + filter->callbacks_->encodeHeaders(std::move(response_headers), true); - data.drain(4); - })); + data.drain(4); + })); Buffer::OwnedImpl fake_input("1234"); conn_manager_->onData(fake_input); @@ -398,27 +399,27 @@ TEST_F(HttpConnectionManagerImplTest, DoNotStartSpanIfTracingIsNotEnabled) { std::shared_ptr filter(new NiceMock()); EXPECT_CALL(filter_factory_, createFilterChain(_)) - .WillRepeatedly(Invoke([&](FilterChainFactoryCallbacks& callbacks) - -> void { callbacks.addStreamDecoderFilter(filter); })); + .WillRepeatedly(Invoke([&](FilterChainFactoryCallbacks& callbacks) -> void { + callbacks.addStreamDecoderFilter(filter); + })); StreamDecoder* decoder = nullptr; NiceMock encoder; - EXPECT_CALL(*codec_, dispatch(_)) - .WillRepeatedly(Invoke([&](Buffer::Instance& data) -> void { - decoder = &conn_manager_->newStream(encoder); + EXPECT_CALL(*codec_, dispatch(_)).WillRepeatedly(Invoke([&](Buffer::Instance& data) -> void { + decoder = &conn_manager_->newStream(encoder); - HeaderMapPtr headers{ - new TestHeaderMapImpl{{":method", "GET"}, - {":authority", "host"}, - {":path", "/"}, - {"x-request-id", "125a4afb-6f55-a4ba-ad80-413f09f48a28"}}}; - decoder->decodeHeaders(std::move(headers), true); + HeaderMapPtr headers{ + new TestHeaderMapImpl{{":method", "GET"}, + {":authority", "host"}, + {":path", "/"}, + {"x-request-id", "125a4afb-6f55-a4ba-ad80-413f09f48a28"}}}; + decoder->decodeHeaders(std::move(headers), true); - HeaderMapPtr response_headers{new TestHeaderMapImpl{{":status", "200"}}}; - filter->callbacks_->encodeHeaders(std::move(response_headers), true); + HeaderMapPtr response_headers{new TestHeaderMapImpl{{":status", "200"}}}; + filter->callbacks_->encodeHeaders(std::move(response_headers), true); - data.drain(4); - })); + data.drain(4); + })); Buffer::OwnedImpl fake_input("1234"); conn_manager_->onData(fake_input); @@ -438,8 +439,9 @@ TEST_F(HttpConnectionManagerImplTest, StartSpanOnlyHealthCheckRequest) { std::shared_ptr filter(new NiceMock()); EXPECT_CALL(filter_factory_, createFilterChain(_)) - .WillRepeatedly(Invoke([&](FilterChainFactoryCallbacks& callbacks) - -> void { callbacks.addStreamDecoderFilter(filter); })); + .WillRepeatedly(Invoke([&](FilterChainFactoryCallbacks& callbacks) -> void { + callbacks.addStreamDecoderFilter(filter); + })); EXPECT_CALL(*filter, decodeHeaders(_, true)) .WillOnce(Invoke([&](HeaderMap&, bool) -> FilterHeadersStatus { @@ -449,22 +451,21 @@ TEST_F(HttpConnectionManagerImplTest, StartSpanOnlyHealthCheckRequest) { StreamDecoder* decoder = nullptr; NiceMock encoder; - EXPECT_CALL(*codec_, dispatch(_)) - .WillRepeatedly(Invoke([&](Buffer::Instance& data) -> void { - decoder = &conn_manager_->newStream(encoder); + EXPECT_CALL(*codec_, dispatch(_)).WillRepeatedly(Invoke([&](Buffer::Instance& data) -> void { + decoder = &conn_manager_->newStream(encoder); - HeaderMapPtr headers{ - new TestHeaderMapImpl{{":method", "GET"}, - {":authority", "host"}, - {":path", "/healthcheck"}, - {"x-request-id", "125a4afb-6f55-94ba-ad80-413f09f48a28"}}}; - decoder->decodeHeaders(std::move(headers), true); + HeaderMapPtr headers{ + new TestHeaderMapImpl{{":method", "GET"}, + {":authority", "host"}, + {":path", "/healthcheck"}, + {"x-request-id", "125a4afb-6f55-94ba-ad80-413f09f48a28"}}}; + decoder->decodeHeaders(std::move(headers), true); - HeaderMapPtr response_headers{new TestHeaderMapImpl{{":status", "200"}}}; - filter->callbacks_->encodeHeaders(std::move(response_headers), true); + HeaderMapPtr response_headers{new TestHeaderMapImpl{{":status", "200"}}}; + filter->callbacks_->encodeHeaders(std::move(response_headers), true); - data.drain(4); - })); + data.drain(4); + })); Buffer::OwnedImpl fake_input("1234"); conn_manager_->onData(fake_input); @@ -483,17 +484,17 @@ TEST_F(HttpConnectionManagerImplTest, NoPath) { StreamDecoder* decoder = nullptr; NiceMock encoder; - EXPECT_CALL(*codec_, dispatch(_)) - .WillOnce(Invoke([&](Buffer::Instance& data) -> void { - decoder = &conn_manager_->newStream(encoder); - HeaderMapPtr headers{new TestHeaderMapImpl{{":authority", "host"}, {":method", "CONNECT"}}}; - decoder->decodeHeaders(std::move(headers), true); - data.drain(4); - })); + EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance& data) -> void { + decoder = &conn_manager_->newStream(encoder); + HeaderMapPtr headers{new TestHeaderMapImpl{{":authority", "host"}, {":method", "CONNECT"}}}; + decoder->decodeHeaders(std::move(headers), true); + data.drain(4); + })); EXPECT_CALL(encoder, encodeHeaders(_, true)) - .WillOnce(Invoke([](const HeaderMap& headers, bool) - -> void { EXPECT_STREQ("404", headers.Status()->value().c_str()); })); + .WillOnce(Invoke([](const HeaderMap& headers, bool) -> void { + EXPECT_STREQ("404", headers.Status()->value().c_str()); + })); Buffer::OwnedImpl fake_input("1234"); conn_manager_->onData(fake_input); @@ -517,12 +518,11 @@ TEST_F(HttpConnectionManagerImplTest, DrainClose) { StreamDecoder* decoder = nullptr; NiceMock encoder; - EXPECT_CALL(*codec_, dispatch(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - decoder = &conn_manager_->newStream(encoder); - HeaderMapPtr headers{new TestHeaderMapImpl{{":authority", "host"}, {":path", "/"}}}; - decoder->decodeHeaders(std::move(headers), true); - })); + EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + decoder = &conn_manager_->newStream(encoder); + HeaderMapPtr headers{new TestHeaderMapImpl{{":authority", "host"}, {":path", "/"}}}; + decoder->decodeHeaders(std::move(headers), true); + })); Buffer::OwnedImpl fake_input; conn_manager_->onData(fake_input); @@ -548,12 +548,11 @@ TEST_F(HttpConnectionManagerImplTest, ResponseBeforeRequestComplete) { InSequence s; setup(false, "envoy-server-test"); - EXPECT_CALL(*codec_, dispatch(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - StreamDecoder* decoder = &conn_manager_->newStream(response_encoder_); - HeaderMapPtr headers{new TestHeaderMapImpl{{":authority", "host"}, {":path", "/"}}}; - decoder->decodeHeaders(std::move(headers), false); - })); + EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + StreamDecoder* decoder = &conn_manager_->newStream(response_encoder_); + HeaderMapPtr headers{new TestHeaderMapImpl{{":authority", "host"}, {":path", "/"}}}; + decoder->decodeHeaders(std::move(headers), false); + })); setupFilterChain(1, 0); @@ -592,12 +591,11 @@ TEST_F(HttpConnectionManagerImplTest, ResponseStartBeforeRequestComplete) { // Start the request StreamDecoder* decoder = nullptr; NiceMock encoder; - EXPECT_CALL(*codec_, dispatch(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - decoder = &conn_manager_->newStream(encoder); - HeaderMapPtr headers{new TestHeaderMapImpl{{":authority", "host"}, {":path", "/"}}}; - decoder->decodeHeaders(std::move(headers), false); - })); + EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + decoder = &conn_manager_->newStream(encoder); + HeaderMapPtr headers{new TestHeaderMapImpl{{":authority", "host"}, {":path", "/"}}}; + decoder->decodeHeaders(std::move(headers), false); + })); Buffer::OwnedImpl fake_input("hello"); conn_manager_->onData(fake_input); @@ -613,8 +611,9 @@ TEST_F(HttpConnectionManagerImplTest, ResponseStartBeforeRequestComplete) { // Finish the request. EXPECT_CALL(*filter, decodeData(_, true)); - EXPECT_CALL(*codec_, dispatch(_)) - .WillOnce(Invoke([&](Buffer::Instance& data) -> void { decoder->decodeData(data, true); })); + EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance& data) -> void { + decoder->decodeData(data, true); + })); conn_manager_->onData(fake_input); @@ -631,11 +630,10 @@ TEST_F(HttpConnectionManagerImplTest, DownstreamDisconnect) { setup(false, ""); NiceMock encoder; - EXPECT_CALL(*codec_, dispatch(_)) - .WillOnce(Invoke([&](Buffer::Instance& data) -> void { - conn_manager_->newStream(encoder); - data.drain(2); - })); + EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance& data) -> void { + conn_manager_->newStream(encoder); + data.drain(2); + })); setupFilterChain(1, 0); @@ -652,11 +650,10 @@ TEST_F(HttpConnectionManagerImplTest, DownstreamProtocolError) { InSequence s; setup(false, ""); - EXPECT_CALL(*codec_, dispatch(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - conn_manager_->newStream(response_encoder_); - throw CodecProtocolException("protocol error"); - })); + EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + conn_manager_->newStream(response_encoder_); + throw CodecProtocolException("protocol error"); + })); setupFilterChain(1, 0); @@ -699,15 +696,14 @@ TEST_F(HttpConnectionManagerImplTest, IdleTimeout) { NiceMock encoder; StreamDecoder* decoder = nullptr; - EXPECT_CALL(*codec_, dispatch(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - decoder = &conn_manager_->newStream(encoder); - HeaderMapPtr headers{new TestHeaderMapImpl{{":authority", "host"}, {":path", "/"}}}; - decoder->decodeHeaders(std::move(headers), false); + EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + decoder = &conn_manager_->newStream(encoder); + HeaderMapPtr headers{new TestHeaderMapImpl{{":authority", "host"}, {":path", "/"}}}; + decoder->decodeHeaders(std::move(headers), false); - Buffer::OwnedImpl fake_data("hello"); - decoder->decodeData(fake_data, true); - })); + Buffer::OwnedImpl fake_data("hello"); + decoder->decodeData(fake_data, true); + })); EXPECT_CALL(*idle_timer, disableTimer()); EXPECT_CALL(*filter, decodeHeaders(_, false)) @@ -740,15 +736,14 @@ TEST_F(HttpConnectionManagerImplTest, IntermediateBufferingEarlyResponse) { InSequence s; setup(false, ""); - EXPECT_CALL(*codec_, dispatch(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - StreamDecoder* decoder = &conn_manager_->newStream(response_encoder_); - HeaderMapPtr headers{new TestHeaderMapImpl{{":authority", "host"}, {":path", "/"}}}; - decoder->decodeHeaders(std::move(headers), false); + EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + StreamDecoder* decoder = &conn_manager_->newStream(response_encoder_); + HeaderMapPtr headers{new TestHeaderMapImpl{{":authority", "host"}, {":path", "/"}}}; + decoder->decodeHeaders(std::move(headers), false); - Buffer::OwnedImpl fake_data("hello"); - decoder->decodeData(fake_data, true); - })); + Buffer::OwnedImpl fake_data("hello"); + decoder->decodeData(fake_data, true); + })); setupFilterChain(2, 0); @@ -785,13 +780,12 @@ TEST_F(HttpConnectionManagerImplTest, DoubleBuffering) { // The data will get moved so we need to have a copy to compare against. Buffer::OwnedImpl fake_data("hello"); Buffer::OwnedImpl fake_data_copy("hello"); - EXPECT_CALL(*codec_, dispatch(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - StreamDecoder* decoder = &conn_manager_->newStream(response_encoder_); - HeaderMapPtr headers{new TestHeaderMapImpl{{":authority", "host"}, {":path", "/"}}}; - decoder->decodeHeaders(std::move(headers), false); - decoder->decodeData(fake_data, true); - })); + EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + StreamDecoder* decoder = &conn_manager_->newStream(response_encoder_); + HeaderMapPtr headers{new TestHeaderMapImpl{{":authority", "host"}, {":path", "/"}}}; + decoder->decodeHeaders(std::move(headers), false); + decoder->decodeData(fake_data, true); + })); setupFilterChain(3, 0); @@ -825,12 +819,11 @@ TEST_F(HttpConnectionManagerImplTest, ZeroByteDataFiltering) { setup(false, ""); StreamDecoder* decoder = nullptr; - EXPECT_CALL(*codec_, dispatch(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - decoder = &conn_manager_->newStream(response_encoder_); - HeaderMapPtr headers{new TestHeaderMapImpl{{":authority", "host"}, {":path", "/"}}}; - decoder->decodeHeaders(std::move(headers), false); - })); + EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + decoder = &conn_manager_->newStream(response_encoder_); + HeaderMapPtr headers{new TestHeaderMapImpl{{":authority", "host"}, {":path", "/"}}}; + decoder->decodeHeaders(std::move(headers), false); + })); setupFilterChain(2, 0); @@ -862,18 +855,17 @@ TEST_F(HttpConnectionManagerImplTest, FilterAddBodyInTrailersCallback) { InSequence s; setup(false, ""); - EXPECT_CALL(*codec_, dispatch(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - StreamDecoder* decoder = &conn_manager_->newStream(response_encoder_); - HeaderMapPtr headers{new TestHeaderMapImpl{{":authority", "host"}, {":path", "/"}}}; - decoder->decodeHeaders(std::move(headers), false); + EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + StreamDecoder* decoder = &conn_manager_->newStream(response_encoder_); + HeaderMapPtr headers{new TestHeaderMapImpl{{":authority", "host"}, {":path", "/"}}}; + decoder->decodeHeaders(std::move(headers), false); - Buffer::OwnedImpl fake_data("hello"); - decoder->decodeData(fake_data, false); + Buffer::OwnedImpl fake_data("hello"); + decoder->decodeData(fake_data, false); - HeaderMapPtr trailers{new TestHeaderMapImpl{{"foo", "bar"}}}; - decoder->decodeTrailers(std::move(trailers)); - })); + HeaderMapPtr trailers{new TestHeaderMapImpl{{"foo", "bar"}}}; + decoder->decodeTrailers(std::move(trailers)); + })); setupFilterChain(2, 2); @@ -938,12 +930,11 @@ TEST_F(HttpConnectionManagerImplTest, FilterAddBodyInline) { InSequence s; setup(false, ""); - EXPECT_CALL(*codec_, dispatch(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - StreamDecoder* decoder = &conn_manager_->newStream(response_encoder_); - HeaderMapPtr headers{new TestHeaderMapImpl{{":authority", "host"}, {":path", "/"}}}; - decoder->decodeHeaders(std::move(headers), true); - })); + EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + StreamDecoder* decoder = &conn_manager_->newStream(response_encoder_); + HeaderMapPtr headers{new TestHeaderMapImpl{{":authority", "host"}, {":path", "/"}}}; + decoder->decodeHeaders(std::move(headers), true); + })); setupFilterChain(2, 2); @@ -985,12 +976,11 @@ TEST_F(HttpConnectionManagerImplTest, FilterAddBodyContinuation) { InSequence s; setup(false, ""); - EXPECT_CALL(*codec_, dispatch(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - StreamDecoder* decoder = &conn_manager_->newStream(response_encoder_); - HeaderMapPtr headers{new TestHeaderMapImpl{{":authority", "host"}, {":path", "/"}}}; - decoder->decodeHeaders(std::move(headers), true); - })); + EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + StreamDecoder* decoder = &conn_manager_->newStream(response_encoder_); + HeaderMapPtr headers{new TestHeaderMapImpl{{":authority", "host"}, {":path", "/"}}}; + decoder->decodeHeaders(std::move(headers), true); + })); setupFilterChain(2, 2); @@ -1033,18 +1023,17 @@ TEST_F(HttpConnectionManagerImplTest, MultipleFilters) { InSequence s; setup(false, ""); - EXPECT_CALL(*codec_, dispatch(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - StreamDecoder* decoder = &conn_manager_->newStream(response_encoder_); - HeaderMapPtr headers{new TestHeaderMapImpl{{":authority", "host"}, {":path", "/"}}}; - decoder->decodeHeaders(std::move(headers), false); + EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + StreamDecoder* decoder = &conn_manager_->newStream(response_encoder_); + HeaderMapPtr headers{new TestHeaderMapImpl{{":authority", "host"}, {":path", "/"}}}; + decoder->decodeHeaders(std::move(headers), false); - Buffer::OwnedImpl fake_data("hello"); - decoder->decodeData(fake_data, false); + Buffer::OwnedImpl fake_data("hello"); + decoder->decodeData(fake_data, false); - Buffer::OwnedImpl fake_data2("world"); - decoder->decodeData(fake_data2, true); - })); + Buffer::OwnedImpl fake_data2("world"); + decoder->decodeData(fake_data2, true); + })); setupFilterChain(3, 2); @@ -1132,5 +1121,5 @@ TEST(HttpConnectionManagerTracingStatsTest, verifyTracingStats) { EXPECT_EQ(1UL, tracing_stats.not_traceable_.value()); } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/test/common/http/conn_manager_utility_test.cc b/test/common/http/conn_manager_utility_test.cc index e9a118f850fdf..d19dcd27c3dac 100644 --- a/test/common/http/conn_manager_utility_test.cc +++ b/test/common/http/conn_manager_utility_test.cc @@ -19,12 +19,12 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::InSequence; using testing::NiceMock; using testing::Return; using testing::ReturnRef; using testing::ReturnRefOfCopy; +using testing::_; namespace Http { @@ -605,5 +605,5 @@ TEST_F(ConnectionManagerUtilityTest, NonTlsAlwaysForwardClientCert) { EXPECT_EQ("By=test://foo.com/fe;SAN=test://bar.com/be", headers.get_("x-forwarded-client-cert")); } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/test/common/http/date_provider_impl_test.cc b/test/common/http/date_provider_impl_test.cc index 5693ae882a938..29df9ff7e6145 100644 --- a/test/common/http/date_provider_impl_test.cc +++ b/test/common/http/date_provider_impl_test.cc @@ -34,5 +34,5 @@ TEST(DateProviderImplTest, All) { EXPECT_NE(nullptr, headers.Date()); } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/test/common/http/filter/buffer_filter_test.cc b/test/common/http/filter/buffer_filter_test.cc index f2f9895b7f673..405e3d05d289b 100644 --- a/test/common/http/filter/buffer_filter_test.cc +++ b/test/common/http/filter/buffer_filter_test.cc @@ -15,12 +15,12 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::DoAll; using testing::InSequence; using testing::NiceMock; using testing::Return; using testing::SaveArg; +using testing::_; namespace Http { @@ -118,5 +118,5 @@ TEST_F(BufferFilterTest, TxResetAfterEndStream) { filter_.onDestroy(); } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/test/common/http/filter/fault_filter_test.cc b/test/common/http/filter/fault_filter_test.cc index a01fd96cfd8d1..4bb1b006e7e95 100644 --- a/test/common/http/filter/fault_filter_test.cc +++ b/test/common/http/filter/fault_filter_test.cc @@ -22,13 +22,13 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::DoAll; using testing::Invoke; using testing::NiceMock; using testing::Return; using testing::ReturnRef; using testing::WithArgs; +using testing::_; namespace Http { @@ -254,7 +254,8 @@ TEST_F(FaultFilterTest, AbortWithHttpStatus) { EXPECT_CALL(runtime_.snapshot_, getInteger("fault.http.delay.fixed_duration_ms", _)).Times(0); EXPECT_CALL(filter_callbacks_, continueDecoding()).Times(0); EXPECT_CALL(filter_callbacks_.request_info_, - setResponseFlag(Http::AccessLog::ResponseFlag::DelayInjected)).Times(0); + setResponseFlag(Http::AccessLog::ResponseFlag::DelayInjected)) + .Times(0); // Abort related calls EXPECT_CALL(runtime_.snapshot_, featureEnabled("fault.http.abort.abort_percent", 100)) @@ -331,7 +332,8 @@ TEST_F(FaultFilterTest, FixedDelayNonZeroDuration) { EXPECT_CALL(runtime_.snapshot_, getInteger("fault.http.abort.http_status", _)).Times(0); EXPECT_CALL(filter_callbacks_, encodeHeaders_(_, _)).Times(0); EXPECT_CALL(filter_callbacks_.request_info_, - setResponseFlag(Http::AccessLog::ResponseFlag::FaultInjected)).Times(0); + setResponseFlag(Http::AccessLog::ResponseFlag::FaultInjected)) + .Times(0); EXPECT_CALL(filter_callbacks_, continueDecoding()); EXPECT_EQ(FilterDataStatus::StopIterationAndBuffer, filter_->decodeData(data_, false)); @@ -350,8 +352,9 @@ TEST_F(FaultFilterTest, DelayForDownstreamCluster) { // Delay related calls. EXPECT_CALL(runtime_.snapshot_, featureEnabled("fault.http.delay.fixed_delay_percent", 100)) .WillOnce(Return(false)); - EXPECT_CALL(runtime_.snapshot_, featureEnabled("fault.http.cluster.delay.fixed_delay_percent", - 100)).WillOnce(Return(true)); + EXPECT_CALL(runtime_.snapshot_, + featureEnabled("fault.http.cluster.delay.fixed_delay_percent", 100)) + .WillOnce(Return(true)); EXPECT_CALL(runtime_.snapshot_, getInteger("fault.http.delay.fixed_duration_ms", 5000)) .WillOnce(Return(125UL)); @@ -374,7 +377,8 @@ TEST_F(FaultFilterTest, DelayForDownstreamCluster) { EXPECT_CALL(runtime_.snapshot_, getInteger("fault.http.abort.http_status", _)).Times(0); EXPECT_CALL(filter_callbacks_, encodeHeaders_(_, _)).Times(0); EXPECT_CALL(filter_callbacks_.request_info_, - setResponseFlag(Http::AccessLog::ResponseFlag::FaultInjected)).Times(0); + setResponseFlag(Http::AccessLog::ResponseFlag::FaultInjected)) + .Times(0); EXPECT_CALL(filter_callbacks_, continueDecoding()); EXPECT_EQ(FilterDataStatus::StopIterationAndBuffer, filter_->decodeData(data_, false)); @@ -396,8 +400,9 @@ TEST_F(FaultFilterTest, FixedDelayAndAbortDownstream) { // Delay related calls. EXPECT_CALL(runtime_.snapshot_, featureEnabled("fault.http.delay.fixed_delay_percent", 100)) .WillOnce(Return(false)); - EXPECT_CALL(runtime_.snapshot_, featureEnabled("fault.http.cluster.delay.fixed_delay_percent", - 100)).WillOnce(Return(true)); + EXPECT_CALL(runtime_.snapshot_, + featureEnabled("fault.http.cluster.delay.fixed_delay_percent", 100)) + .WillOnce(Return(true)); EXPECT_CALL(runtime_.snapshot_, getInteger("fault.http.delay.fixed_duration_ms", 5000)) .WillOnce(Return(125UL)); @@ -620,7 +625,8 @@ TEST_F(FaultFilterTest, TimerResetAfterStreamReset) { EXPECT_CALL(runtime_.snapshot_, getInteger("fault.http.abort.http_status", _)).Times(0); EXPECT_CALL(filter_callbacks_, encodeHeaders_(_, _)).Times(0); EXPECT_CALL(filter_callbacks_.request_info_, - setResponseFlag(Http::AccessLog::ResponseFlag::FaultInjected)).Times(0); + setResponseFlag(Http::AccessLog::ResponseFlag::FaultInjected)) + .Times(0); EXPECT_CALL(filter_callbacks_, continueDecoding()).Times(0); EXPECT_EQ(0UL, config_->stats().aborts_injected_.value()); @@ -658,7 +664,8 @@ TEST_F(FaultFilterTest, FaultWithTargetClusterMatchSuccess) { EXPECT_CALL(runtime_.snapshot_, getInteger("fault.http.abort.http_status", _)).Times(0); EXPECT_CALL(filter_callbacks_, encodeHeaders_(_, _)).Times(0); EXPECT_CALL(filter_callbacks_.request_info_, - setResponseFlag(Http::AccessLog::ResponseFlag::FaultInjected)).Times(0); + setResponseFlag(Http::AccessLog::ResponseFlag::FaultInjected)) + .Times(0); EXPECT_CALL(filter_callbacks_, continueDecoding()); timer_->callback_(); @@ -714,5 +721,5 @@ TEST_F(FaultFilterTest, FaultWithTargetClusterNullRoute) { EXPECT_EQ(0UL, config_->stats().aborts_injected_.value()); } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/test/common/http/filter/ip_tagging_filter_test.cc b/test/common/http/filter/ip_tagging_filter_test.cc index cd7068c170271..3e62ff6ad03ed 100644 --- a/test/common/http/filter/ip_tagging_filter_test.cc +++ b/test/common/http/filter/ip_tagging_filter_test.cc @@ -9,8 +9,8 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -using testing::_; using testing::Return; +using testing::_; namespace Envoy { namespace Http { @@ -91,5 +91,5 @@ TEST_F(IpTaggingFilterTest, BothRequest) { EXPECT_EQ(FilterTrailersStatus::Continue, filter_->decodeTrailers(request_headers_)); } -} // Http -} // Envoy \ No newline at end of file +} // namespace Http +} // namespace Envoy \ No newline at end of file diff --git a/test/common/http/filter/ratelimit_test.cc b/test/common/http/filter/ratelimit_test.cc index 1393abc40f53e..f3f8fd0d3dd79 100644 --- a/test/common/http/filter/ratelimit_test.cc +++ b/test/common/http/filter/ratelimit_test.cc @@ -20,7 +20,6 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::InSequence; using testing::Invoke; using testing::NiceMock; @@ -28,6 +27,7 @@ using testing::Return; using testing::ReturnRef; using testing::SetArgReferee; using testing::WithArgs; +using testing::_; namespace Http { namespace RateLimit { @@ -155,15 +155,17 @@ TEST_F(HttpRateLimitFilterTest, OkResponse) { .WillOnce(SetArgReferee<1>(descriptor_)); EXPECT_CALL(filter_callbacks_.route_->route_entry_.virtual_host_.rate_limit_policy_, - getApplicableRateLimit(0)).Times(1); + getApplicableRateLimit(0)) + .Times(1); Tracing::TransportContext context{"requestid", "context"}; - EXPECT_CALL(*client_, - limit(_, "foo", testing::ContainerEq(std::vector{ + EXPECT_CALL(*client_, limit(_, "foo", + testing::ContainerEq(std::vector{ {{{"descriptor_key", "descriptor_value"}}}}), - context)) - .WillOnce(WithArgs<0>(Invoke([&](Envoy::RateLimit::RequestCallbacks& callbacks) - -> void { request_callbacks_ = &callbacks; }))); + context)) + .WillOnce(WithArgs<0>(Invoke([&](Envoy::RateLimit::RequestCallbacks& callbacks) -> void { + request_callbacks_ = &callbacks; + }))); request_headers_.addViaCopy(Http::Headers::get().RequestId, "requestid"); request_headers_.addViaCopy(Http::Headers::get().OtSpanContext, "context"); @@ -173,7 +175,8 @@ TEST_F(HttpRateLimitFilterTest, OkResponse) { EXPECT_CALL(filter_callbacks_, continueDecoding()); EXPECT_CALL(filter_callbacks_.request_info_, - setResponseFlag(Http::AccessLog::ResponseFlag::RateLimited)).Times(0); + setResponseFlag(Http::AccessLog::ResponseFlag::RateLimited)) + .Times(0); request_callbacks_->complete(Envoy::RateLimit::LimitStatus::OK); EXPECT_EQ(1U, @@ -187,10 +190,10 @@ TEST_F(HttpRateLimitFilterTest, ImmediateOkResponse) { EXPECT_CALL(vh_rate_limit_, populateDescriptors(_, _, _, _, _)) .WillOnce(SetArgReferee<1>(descriptor_)); - EXPECT_CALL(*client_, - limit(_, "foo", testing::ContainerEq(std::vector{ + EXPECT_CALL(*client_, limit(_, "foo", + testing::ContainerEq(std::vector{ {{{"descriptor_key", "descriptor_value"}}}}), - Tracing::EMPTY_CONTEXT)) + Tracing::EMPTY_CONTEXT)) .WillOnce(WithArgs<0>(Invoke([&](Envoy::RateLimit::RequestCallbacks& callbacks) -> void { callbacks.complete(Envoy::RateLimit::LimitStatus::OK); }))); @@ -211,8 +214,9 @@ TEST_F(HttpRateLimitFilterTest, ErrorResponse) { EXPECT_CALL(route_rate_limit_, populateDescriptors(_, _, _, _, _)) .WillOnce(SetArgReferee<1>(descriptor_)); EXPECT_CALL(*client_, limit(_, _, _, _)) - .WillOnce(WithArgs<0>(Invoke([&](Envoy::RateLimit::RequestCallbacks& callbacks) - -> void { request_callbacks_ = &callbacks; }))); + .WillOnce(WithArgs<0>(Invoke([&](Envoy::RateLimit::RequestCallbacks& callbacks) -> void { + request_callbacks_ = &callbacks; + }))); EXPECT_EQ(FilterHeadersStatus::StopIteration, filter_->decodeHeaders(request_headers_, false)); @@ -222,10 +226,12 @@ TEST_F(HttpRateLimitFilterTest, ErrorResponse) { EXPECT_EQ(FilterDataStatus::Continue, filter_->decodeData(data_, false)); EXPECT_EQ(FilterTrailersStatus::Continue, filter_->decodeTrailers(request_headers_)); EXPECT_CALL(filter_callbacks_.request_info_, - setResponseFlag(Http::AccessLog::ResponseFlag::RateLimited)).Times(0); + setResponseFlag(Http::AccessLog::ResponseFlag::RateLimited)) + .Times(0); - EXPECT_EQ(1U, cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("ratelimit.error") - .value()); + EXPECT_EQ( + 1U, + cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("ratelimit.error").value()); } TEST_F(HttpRateLimitFilterTest, LimitResponse) { @@ -235,8 +241,9 @@ TEST_F(HttpRateLimitFilterTest, LimitResponse) { EXPECT_CALL(route_rate_limit_, populateDescriptors(_, _, _, _, _)) .WillOnce(SetArgReferee<1>(descriptor_)); EXPECT_CALL(*client_, limit(_, _, _, _)) - .WillOnce(WithArgs<0>(Invoke([&](Envoy::RateLimit::RequestCallbacks& callbacks) - -> void { request_callbacks_ = &callbacks; }))); + .WillOnce(WithArgs<0>(Invoke([&](Envoy::RateLimit::RequestCallbacks& callbacks) -> void { + request_callbacks_ = &callbacks; + }))); EXPECT_EQ(FilterHeadersStatus::StopIteration, filter_->decodeHeaders(request_headers_, false)); @@ -251,10 +258,12 @@ TEST_F(HttpRateLimitFilterTest, LimitResponse) { EXPECT_EQ(1U, cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("ratelimit.over_limit") .value()); - EXPECT_EQ(1U, cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_4xx") - .value()); - EXPECT_EQ(1U, cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_429") - .value()); + EXPECT_EQ( + 1U, + cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_4xx").value()); + EXPECT_EQ( + 1U, + cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_429").value()); } TEST_F(HttpRateLimitFilterTest, LimitResponseRuntimeDisabled) { @@ -264,8 +273,9 @@ TEST_F(HttpRateLimitFilterTest, LimitResponseRuntimeDisabled) { EXPECT_CALL(route_rate_limit_, populateDescriptors(_, _, _, _, _)) .WillOnce(SetArgReferee<1>(descriptor_)); EXPECT_CALL(*client_, limit(_, _, _, _)) - .WillOnce(WithArgs<0>(Invoke([&](Envoy::RateLimit::RequestCallbacks& callbacks) - -> void { request_callbacks_ = &callbacks; }))); + .WillOnce(WithArgs<0>(Invoke([&](Envoy::RateLimit::RequestCallbacks& callbacks) -> void { + request_callbacks_ = &callbacks; + }))); EXPECT_EQ(FilterHeadersStatus::StopIteration, filter_->decodeHeaders(request_headers_, false)); @@ -280,10 +290,12 @@ TEST_F(HttpRateLimitFilterTest, LimitResponseRuntimeDisabled) { EXPECT_EQ(1U, cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("ratelimit.over_limit") .value()); - EXPECT_EQ(1U, cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_4xx") - .value()); - EXPECT_EQ(1U, cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_429") - .value()); + EXPECT_EQ( + 1U, + cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_4xx").value()); + EXPECT_EQ( + 1U, + cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_429").value()); } TEST_F(HttpRateLimitFilterTest, ResetDuringCall) { @@ -293,8 +305,9 @@ TEST_F(HttpRateLimitFilterTest, ResetDuringCall) { EXPECT_CALL(route_rate_limit_, populateDescriptors(_, _, _, _, _)) .WillOnce(SetArgReferee<1>(descriptor_)); EXPECT_CALL(*client_, limit(_, _, _, _)) - .WillOnce(WithArgs<0>(Invoke([&](Envoy::RateLimit::RequestCallbacks& callbacks) - -> void { request_callbacks_ = &callbacks; }))); + .WillOnce(WithArgs<0>(Invoke([&](Envoy::RateLimit::RequestCallbacks& callbacks) -> void { + request_callbacks_ = &callbacks; + }))); EXPECT_EQ(FilterHeadersStatus::StopIteration, filter_->decodeHeaders(request_headers_, false)); @@ -383,12 +396,13 @@ TEST_F(HttpRateLimitFilterTest, InternalRequestType) { .WillOnce(SetArgReferee<1>(descriptor_)); EXPECT_CALL(filter_callbacks_.route_->route_entry_.virtual_host_.rate_limit_policy_, - getApplicableRateLimit(0)).Times(1); + getApplicableRateLimit(0)) + .Times(1); - EXPECT_CALL(*client_, - limit(_, "foo", testing::ContainerEq(std::vector{ + EXPECT_CALL(*client_, limit(_, "foo", + testing::ContainerEq(std::vector{ {{{"descriptor_key", "descriptor_value"}}}}), - Tracing::EMPTY_CONTEXT)) + Tracing::EMPTY_CONTEXT)) .WillOnce(WithArgs<0>(Invoke([&](Envoy::RateLimit::RequestCallbacks& callbacks) -> void { callbacks.complete(Envoy::RateLimit::LimitStatus::OK); }))); @@ -421,12 +435,13 @@ TEST_F(HttpRateLimitFilterTest, ExternalRequestType) { .WillOnce(SetArgReferee<1>(descriptor_)); EXPECT_CALL(filter_callbacks_.route_->route_entry_.virtual_host_.rate_limit_policy_, - getApplicableRateLimit(0)).Times(1); + getApplicableRateLimit(0)) + .Times(1); - EXPECT_CALL(*client_, - limit(_, "foo", testing::ContainerEq(std::vector{ + EXPECT_CALL(*client_, limit(_, "foo", + testing::ContainerEq(std::vector{ {{{"descriptor_key", "descriptor_value"}}}}), - Tracing::EMPTY_CONTEXT)) + Tracing::EMPTY_CONTEXT)) .WillOnce(WithArgs<0>(Invoke([&](Envoy::RateLimit::RequestCallbacks& callbacks) -> void { callbacks.complete(Envoy::RateLimit::LimitStatus::OK); }))); @@ -456,12 +471,13 @@ TEST_F(HttpRateLimitFilterTest, ExcludeVirtualHost) { EXPECT_CALL(filter_callbacks_.route_->route_entry_, includeVirtualHostRateLimits()) .WillOnce(Return(false)); EXPECT_CALL(filter_callbacks_.route_->route_entry_.virtual_host_.rate_limit_policy_, - getApplicableRateLimit(0)).Times(0); + getApplicableRateLimit(0)) + .Times(0); - EXPECT_CALL(*client_, - limit(_, "foo", testing::ContainerEq(std::vector{ + EXPECT_CALL(*client_, limit(_, "foo", + testing::ContainerEq(std::vector{ {{{"descriptor_key", "descriptor_value"}}}}), - Tracing::EMPTY_CONTEXT)) + Tracing::EMPTY_CONTEXT)) .WillOnce(WithArgs<0>(Invoke([&](Envoy::RateLimit::RequestCallbacks& callbacks) -> void { callbacks.complete(Envoy::RateLimit::LimitStatus::OK); }))); @@ -505,6 +521,6 @@ TEST_F(HttpRateLimitFilterTest, DefaultConfigValueTest) { EXPECT_EQ(FilterRequestType::Both, config_->requestType()); } -} // RateLimit -} // Http -} // Envoy +} // namespace RateLimit +} // namespace Http +} // namespace Envoy diff --git a/test/common/http/header_map_impl_test.cc b/test/common/http/header_map_impl_test.cc index 519ec3dfcd5ff..d6548daaa79c7 100644 --- a/test/common/http/header_map_impl_test.cc +++ b/test/common/http/header_map_impl_test.cc @@ -319,5 +319,5 @@ TEST(HeaderMapImplTest, LargeCharInHeader) { EXPECT_STREQ("value", headers.get(static_key)->value().c_str()); } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/test/common/http/http1/codec_impl_test.cc b/test/common/http/http1/codec_impl_test.cc index d0269b5f1c3ab..2881efc3c949c 100644 --- a/test/common/http/http1/codec_impl_test.cc +++ b/test/common/http/http1/codec_impl_test.cc @@ -17,11 +17,11 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::InSequence; using testing::Invoke; using testing::NiceMock; using testing::ReturnRef; +using testing::_; namespace Http { namespace Http1 { @@ -126,8 +126,9 @@ TEST_F(Http1ServerConnectionImplTest, CloseDuringHeadersComplete) { TestHeaderMapImpl expected_headers{{"content-length", "5"}, {":path", "/"}, {":method", "POST"}}; EXPECT_CALL(decoder, decodeHeaders_(HeaderMapEqual(&expected_headers), false)) - .WillOnce(Invoke([&](Http::HeaderMapPtr&, bool) - -> void { connection_.state_ = Network::Connection::State::Closing; })); + .WillOnce(Invoke([&](Http::HeaderMapPtr&, bool) -> void { + connection_.state_ = Network::Connection::State::Closing; + })); EXPECT_CALL(decoder, decodeData(_, _)).Times(0); Buffer::OwnedImpl buffer("POST / HTTP/1.1\r\ncontent-length: 5\r\n\r\n12345"); @@ -453,6 +454,6 @@ TEST_F(Http1ClientConnectionImplTest, GiantPath) { codec_->dispatch(response); } -} // Http1 -} // Http -} // Envoy +} // namespace Http1 +} // namespace Http +} // namespace Envoy diff --git a/test/common/http/http1/conn_pool_test.cc b/test/common/http/http1/conn_pool_test.cc index ebbf36e72d4f7..fbabd622c4be8 100644 --- a/test/common/http/http1/conn_pool_test.cc +++ b/test/common/http/http1/conn_pool_test.cc @@ -21,7 +21,6 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::DoAll; using testing::InSequence; using testing::Invoke; @@ -29,6 +28,7 @@ using testing::NiceMock; using testing::Return; using testing::ReturnRef; using testing::SaveArg; +using testing::_; namespace Http { namespace Http1 { @@ -78,16 +78,18 @@ class ConnPoolImplForTest : public ConnPoolImpl { test_client.connect_timer_ = new NiceMock(&mock_dispatcher_); Network::ClientConnectionPtr connection{test_client.connection_}; - test_client.codec_client_ = new CodecClientForTest( - std::move(connection), test_client.codec_, [this](CodecClient* codec_client) -> void { - for (auto i = test_clients_.begin(); i != test_clients_.end(); i++) { - if (i->codec_client_ == codec_client) { - onClientDestroy(); - test_clients_.erase(i); - return; - } - } - }, nullptr); + test_client.codec_client_ = new CodecClientForTest(std::move(connection), test_client.codec_, + [this](CodecClient* codec_client) -> void { + for (auto i = test_clients_.begin(); + i != test_clients_.end(); i++) { + if (i->codec_client_ == codec_client) { + onClientDestroy(); + test_clients_.erase(i); + return; + } + } + }, + nullptr); EXPECT_CALL(mock_dispatcher_, createClientConnection_(_)) .WillOnce(Return(test_client.connection_)); @@ -305,11 +307,10 @@ TEST_F(Http1ConnPoolImplTest, ConnectTimeout) { NiceMock outer_decoder2; ConnPoolCallbacks callbacks2; - EXPECT_CALL(callbacks1.pool_failure_, ready()) - .WillOnce(Invoke([&]() -> void { - conn_pool_.expectClientCreate(); - EXPECT_NE(nullptr, conn_pool_.newStream(outer_decoder2, callbacks2)); - })); + EXPECT_CALL(callbacks1.pool_failure_, ready()).WillOnce(Invoke([&]() -> void { + conn_pool_.expectClientCreate(); + EXPECT_NE(nullptr, conn_pool_.newStream(outer_decoder2, callbacks2)); + })); conn_pool_.test_clients_[0].connect_timer_->callback_(); @@ -580,6 +581,6 @@ TEST_F(Http1ConnPoolImplTest, RemoteCloseToCompleteResponse) { dispatcher_.clearDeferredDeleteList(); } -} // Http1 -} // Http -} // Envoy +} // namespace Http1 +} // namespace Http +} // namespace Envoy diff --git a/test/common/http/http2/codec_impl_test.cc b/test/common/http/http2/codec_impl_test.cc index 78de060fd33a9..9692631885eb9 100644 --- a/test/common/http/http2/codec_impl_test.cc +++ b/test/common/http/http2/codec_impl_test.cc @@ -15,12 +15,12 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -using testing::_; using testing::AtLeast; using testing::InSequence; using testing::Invoke; using testing::InvokeWithoutArgs; using testing::NiceMock; +using testing::_; namespace Envoy { namespace Http { @@ -38,7 +38,7 @@ Http2Settings Http2SettingsFromTuple(const Http2SettingsTuple& tp) { ret.initial_connection_window_size_ = ::testing::get<3>(tp); return ret; } -} +} // namespace class Http2CodecImplTest : public testing::TestWithParam { public: @@ -75,12 +75,12 @@ class Http2CodecImplTest : public testing::TestWithParam } void setupDefaultConnectionMocks() { - ON_CALL(client_connection_, write(_)) - .WillByDefault(Invoke([&](Buffer::Instance& data) - -> void { server_wrapper_.dispatch(data, server_); })); - ON_CALL(server_connection_, write(_)) - .WillByDefault(Invoke([&](Buffer::Instance& data) - -> void { client_wrapper_.dispatch(data, client_); })); + ON_CALL(client_connection_, write(_)).WillByDefault(Invoke([&](Buffer::Instance& data) -> void { + server_wrapper_.dispatch(data, server_); + })); + ON_CALL(server_connection_, write(_)).WillByDefault(Invoke([&](Buffer::Instance& data) -> void { + client_wrapper_.dispatch(data, client_); + })); } Stats::IsolatedStoreImpl stats_store_; @@ -174,9 +174,9 @@ TEST_P(Http2CodecImplTest, RefusedStreamReset) { } TEST_P(Http2CodecImplTest, InvalidFrame) { - ON_CALL(client_connection_, write(_)) - .WillByDefault( - Invoke([&](Buffer::Instance& data) -> void { server_wrapper_.buffer_.add(data); })); + ON_CALL(client_connection_, write(_)).WillByDefault(Invoke([&](Buffer::Instance& data) -> void { + server_wrapper_.buffer_.add(data); + })); request_encoder_.encodeHeaders(TestHeaderMapImpl{}, true); EXPECT_THROW(server_wrapper_.dispatch(Buffer::OwnedImpl(), server_), CodecProtocolException); } @@ -204,9 +204,9 @@ TEST_P(Http2CodecImplTest, TrailingHeaders) { TEST_P(Http2CodecImplTest, TrailingHeadersLargeBody) { // Buffer server data so we can make sure we don't get any window updates. - ON_CALL(client_connection_, write(_)) - .WillByDefault( - Invoke([&](Buffer::Instance& data) -> void { server_wrapper_.buffer_.add(data); })); + ON_CALL(client_connection_, write(_)).WillByDefault(Invoke([&](Buffer::Instance& data) -> void { + server_wrapper_.buffer_.add(data); + })); TestHeaderMapImpl request_headers; HttpTestUtility::addDefaultHeaders(request_headers); @@ -243,9 +243,9 @@ TEST_P(Http2CodecImplDeferredResetTest, DeferredResetClient) { // Do a request, but pause server dispatch so we don't send window updates. This will result in a // deferred reset, followed by a pending frames flush which will cause the stream to actually // be reset immediately since we are outside of dispatch context. - ON_CALL(client_connection_, write(_)) - .WillByDefault( - Invoke([&](Buffer::Instance& data) -> void { server_wrapper_.buffer_.add(data); })); + ON_CALL(client_connection_, write(_)).WillByDefault(Invoke([&](Buffer::Instance& data) -> void { + server_wrapper_.buffer_.add(data); + })); TestHeaderMapImpl request_headers; HttpTestUtility::addDefaultHeaders(request_headers); request_encoder_.encodeHeaders(request_headers, false); @@ -256,14 +256,13 @@ TEST_P(Http2CodecImplDeferredResetTest, DeferredResetClient) { // Dispatch server. We expect to see some data. EXPECT_CALL(response_decoder_, decodeHeaders_(_, _)).Times(0); - EXPECT_CALL(request_decoder_, decodeHeaders_(_, false)) - .WillOnce(InvokeWithoutArgs([&]() -> void { - // Start a response inside the headers callback. This should not result in the client - // seeing any headers as the stream should already be reset on the other side, even though - // we don't know about it yet. - TestHeaderMapImpl response_headers{{":status", "200"}}; - response_encoder_->encodeHeaders(response_headers, false); - })); + EXPECT_CALL(request_decoder_, decodeHeaders_(_, false)).WillOnce(InvokeWithoutArgs([&]() -> void { + // Start a response inside the headers callback. This should not result in the client + // seeing any headers as the stream should already be reset on the other side, even though + // we don't know about it yet. + TestHeaderMapImpl response_headers{{":status", "200"}}; + response_encoder_->encodeHeaders(response_headers, false); + })); EXPECT_CALL(request_decoder_, decodeData(_, false)).Times(AtLeast(1)); EXPECT_CALL(server_stream_callbacks_, onResetStream(StreamResetReason::RemoteReset)); @@ -280,9 +279,9 @@ TEST_P(Http2CodecImplDeferredResetTest, DeferredResetServer) { request_encoder_.encodeHeaders(request_headers, false); // In this case we do the same thing as DeferredResetClient but on the server side. - ON_CALL(server_connection_, write(_)) - .WillByDefault( - Invoke([&](Buffer::Instance& data) -> void { client_wrapper_.buffer_.add(data); })); + ON_CALL(server_connection_, write(_)).WillByDefault(Invoke([&](Buffer::Instance& data) -> void { + client_wrapper_.buffer_.add(data); + })); TestHeaderMapImpl response_headers{{":status", "200"}}; response_encoder_->encodeHeaders(response_headers, false); Buffer::OwnedImpl body(std::string(1024 * 1024, 'a')); @@ -368,6 +367,6 @@ TEST(Http2CodecUtility, reconstituteCrumbledCookies) { } } -} // Http2 -} // Http -} // Envoy +} // namespace Http2 +} // namespace Http +} // namespace Envoy diff --git a/test/common/http/http2/conn_pool_test.cc b/test/common/http/http2/conn_pool_test.cc index c31cdacd344c9..ea4e8ab40952e 100644 --- a/test/common/http/http2/conn_pool_test.cc +++ b/test/common/http/http2/conn_pool_test.cc @@ -18,14 +18,14 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::DoAll; -using testing::Invoke; using testing::InSequence; +using testing::Invoke; using testing::NiceMock; using testing::Return; using testing::ReturnRef; using testing::SaveArg; +using testing::_; namespace Http { namespace Http2 { @@ -80,8 +80,9 @@ class Http2ConnPoolImplTest : public testing::Test { EXPECT_CALL(dispatcher_, createClientConnection_(_)).WillOnce(Return(test_client.connection_)); EXPECT_CALL(pool_, createCodecClient_(_)) - .WillOnce(Invoke([this](Upstream::Host::CreateConnectionData&) - -> CodecClient* { return test_clients_.back().codec_client_; })); + .WillOnce(Invoke([this](Upstream::Host::CreateConnectionData&) -> CodecClient* { + return test_clients_.back().codec_client_; + })); EXPECT_CALL(*test_client.connect_timer_, enableTimer(_)); } @@ -404,6 +405,6 @@ TEST_F(Http2ConnPoolImplTest, GoAway) { EXPECT_EQ(1U, cluster_->stats_.upstream_cx_close_notify_.value()); } -} // Http2 -} // Http -} // Envoy +} // namespace Http2 +} // namespace Http +} // namespace Envoy diff --git a/test/common/http/user_agent_test.cc b/test/common/http/user_agent_test.cc index 4457fab542796..719c19d1b3a7d 100644 --- a/test/common/http/user_agent_test.cc +++ b/test/common/http/user_agent_test.cc @@ -56,5 +56,5 @@ TEST(UserAgentTest, All) { } } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/test/common/http/utility_test.cc b/test/common/http/utility_test.cc index b70152abbab43..cfd3d650559b1 100644 --- a/test/common/http/utility_test.cc +++ b/test/common/http/utility_test.cc @@ -9,8 +9,8 @@ #include "test/test_common/printers.h" #include "test/test_common/utility.h" -#include "gtest/gtest.h" #include "spdlog/spdlog.h" +#include "gtest/gtest.h" namespace Envoy { namespace Http { @@ -209,5 +209,5 @@ TEST(HttpUtility, TestParseCookieWithQuotes) { EXPECT_EQ(Utility::parseCookieValue(headers, "leadingdquote"), "\"foobar"); } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/test/common/json/config_schemas_test.cc b/test/common/json/config_schemas_test.cc index 13dd421ed004d..0f86827964824 100644 --- a/test/common/json/config_schemas_test.cc +++ b/test/common/json/config_schemas_test.cc @@ -8,8 +8,8 @@ #include "test/test_common/utility.h" #include "gmock/gmock.h" -#include "gtest/gtest.h" #include "spdlog/spdlog.h" +#include "gtest/gtest.h" namespace Envoy { using testing::_; @@ -59,5 +59,5 @@ TEST_P(ConfigSchemasTest, CheckValidationExpectation) { } INSTANTIATE_TEST_CASE_P(Default, ConfigSchemasTest, testing::ValuesIn(generateTestInputs())); -} -} // Envoy +} // namespace Json +} // namespace Envoy diff --git a/test/common/json/json_loader_test.cc b/test/common/json/json_loader_test.cc index 49f30fcccfa6e..9e69b5da0055e 100644 --- a/test/common/json/json_loader_test.cc +++ b/test/common/json/json_loader_test.cc @@ -386,5 +386,5 @@ TEST(JsonLoaderTest, ListAsString) { } } -} // Json -} // Envoy +} // namespace Json +} // namespace Envoy diff --git a/test/common/mongo/bson_impl_test.cc b/test/common/mongo/bson_impl_test.cc index 5d5450465797a..43af7b7178dae 100644 --- a/test/common/mongo/bson_impl_test.cc +++ b/test/common/mongo/bson_impl_test.cc @@ -59,5 +59,5 @@ TEST(BufferHelperTest, InvalidSize) { EXPECT_THROW(BufferHelper::removeString(buffer), EnvoyException); } -} // Bson -} // Envoy +} // namespace Bson +} // namespace Envoy diff --git a/test/common/mongo/codec_impl_test.cc b/test/common/mongo/codec_impl_test.cc index 2e4b478f81be0..0d6e4a94b2abb 100644 --- a/test/common/mongo/codec_impl_test.cc +++ b/test/common/mongo/codec_impl_test.cc @@ -332,5 +332,5 @@ TEST_F(MongoCodecImplTest, QueryToStringWithEscape) { EXPECT_NO_THROW(Json::Factory::loadFromString(query.toString(false))); } -} // Mongo -} // Envoy +} // namespace Mongo +} // namespace Envoy diff --git a/test/common/mongo/proxy_test.cc b/test/common/mongo/proxy_test.cc index 5ede6d188c6e2..562b26b2208a4 100644 --- a/test/common/mongo/proxy_test.cc +++ b/test/common/mongo/proxy_test.cc @@ -19,11 +19,11 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::AtLeast; using testing::Invoke; using testing::NiceMock; using testing::Return; +using testing::_; namespace Mongo { @@ -83,29 +83,27 @@ class MongoProxyFilterTest : public testing::Test { TEST_F(MongoProxyFilterTest, Stats) { EXPECT_CALL(*file_, write(_)).Times(AtLeast(1)); - EXPECT_CALL(*filter_->decoder_, onData(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - QueryMessagePtr message(new QueryMessageImpl(0, 0)); - message->fullCollectionName("db.test"); - message->flags(0b1110010); - message->query(Bson::DocumentImpl::create()); - filter_->callbacks_->decodeQuery(std::move(message)); - })); + EXPECT_CALL(*filter_->decoder_, onData(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + QueryMessagePtr message(new QueryMessageImpl(0, 0)); + message->fullCollectionName("db.test"); + message->flags(0b1110010); + message->query(Bson::DocumentImpl::create()); + filter_->callbacks_->decodeQuery(std::move(message)); + })); filter_->onData(fake_data_); EXPECT_CALL(store_, deliverHistogramToSinks("test.collection.test.query.reply_num_docs", 1)); EXPECT_CALL(store_, deliverHistogramToSinks("test.collection.test.query.reply_size", 22)); EXPECT_CALL(store_, deliverTimingToSinks("test.collection.test.query.reply_time_ms", _)); - EXPECT_CALL(*filter_->decoder_, onData(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - ReplyMessagePtr message(new ReplyMessageImpl(0, 0)); - message->flags(0b11); - message->cursorId(1); - message->documents().push_back(Bson::DocumentImpl::create()->addString("hello", "world")); - filter_->callbacks_->decodeReply(std::move(message)); + EXPECT_CALL(*filter_->decoder_, onData(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + ReplyMessagePtr message(new ReplyMessageImpl(0, 0)); + message->flags(0b11); + message->cursorId(1); + message->documents().push_back(Bson::DocumentImpl::create()->addString("hello", "world")); + filter_->callbacks_->decodeReply(std::move(message)); - })); + })); filter_->onWrite(fake_data_); EXPECT_EQ(1U, store_.counter("test.op_query").value()); @@ -124,31 +122,28 @@ TEST_F(MongoProxyFilterTest, Stats) { EXPECT_EQ(1U, store_.counter("test.op_reply_query_failure").value()); EXPECT_EQ(1U, store_.counter("test.op_reply_valid_cursor").value()); - EXPECT_CALL(*filter_->decoder_, onData(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - GetMoreMessagePtr message(new GetMoreMessageImpl(0, 0)); - message->fullCollectionName("db.test"); - message->cursorId(1); - filter_->callbacks_->decodeGetMore(std::move(message)); - })); + EXPECT_CALL(*filter_->decoder_, onData(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + GetMoreMessagePtr message(new GetMoreMessageImpl(0, 0)); + message->fullCollectionName("db.test"); + message->cursorId(1); + filter_->callbacks_->decodeGetMore(std::move(message)); + })); filter_->onData(fake_data_); - EXPECT_CALL(*filter_->decoder_, onData(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - InsertMessagePtr message(new InsertMessageImpl(0, 0)); - message->fullCollectionName("db.test"); - message->documents().push_back(Bson::DocumentImpl::create()); - filter_->callbacks_->decodeInsert(std::move(message)); - })); + EXPECT_CALL(*filter_->decoder_, onData(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + InsertMessagePtr message(new InsertMessageImpl(0, 0)); + message->fullCollectionName("db.test"); + message->documents().push_back(Bson::DocumentImpl::create()); + filter_->callbacks_->decodeInsert(std::move(message)); + })); filter_->onData(fake_data_); - EXPECT_CALL(*filter_->decoder_, onData(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - KillCursorsMessagePtr message(new KillCursorsMessageImpl(0, 0)); - message->numberOfCursorIds(1); - message->cursorIds({1}); - filter_->callbacks_->decodeKillCursors(std::move(message)); - })); + EXPECT_CALL(*filter_->decoder_, onData(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + KillCursorsMessagePtr message(new KillCursorsMessageImpl(0, 0)); + message->numberOfCursorIds(1); + message->cursorIds({1}); + filter_->callbacks_->decodeKillCursors(std::move(message)); + })); filter_->onData(fake_data_); EXPECT_EQ(1U, store_.counter("test.op_get_more").value()); @@ -157,28 +152,26 @@ TEST_F(MongoProxyFilterTest, Stats) { } TEST_F(MongoProxyFilterTest, CommandStats) { - EXPECT_CALL(*filter_->decoder_, onData(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - QueryMessagePtr message(new QueryMessageImpl(0, 0)); - message->fullCollectionName("db.$cmd"); - message->flags(0b1110010); - message->query(Bson::DocumentImpl::create()->addString("foo", "bar")); - filter_->callbacks_->decodeQuery(std::move(message)); - })); + EXPECT_CALL(*filter_->decoder_, onData(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + QueryMessagePtr message(new QueryMessageImpl(0, 0)); + message->fullCollectionName("db.$cmd"); + message->flags(0b1110010); + message->query(Bson::DocumentImpl::create()->addString("foo", "bar")); + filter_->callbacks_->decodeQuery(std::move(message)); + })); filter_->onData(fake_data_); EXPECT_CALL(store_, deliverHistogramToSinks("test.cmd.foo.reply_num_docs", 1)); EXPECT_CALL(store_, deliverHistogramToSinks("test.cmd.foo.reply_size", 22)); EXPECT_CALL(store_, deliverTimingToSinks("test.cmd.foo.reply_time_ms", _)); - EXPECT_CALL(*filter_->decoder_, onData(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - ReplyMessagePtr message(new ReplyMessageImpl(0, 0)); - message->flags(0b11); - message->cursorId(1); - message->documents().push_back(Bson::DocumentImpl::create()->addString("hello", "world")); - filter_->callbacks_->decodeReply(std::move(message)); - })); + EXPECT_CALL(*filter_->decoder_, onData(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + ReplyMessagePtr message(new ReplyMessageImpl(0, 0)); + message->flags(0b11); + message->cursorId(1); + message->documents().push_back(Bson::DocumentImpl::create()->addString("hello", "world")); + filter_->callbacks_->decodeReply(std::move(message)); + })); filter_->onWrite(fake_data_); EXPECT_EQ(1U, store_.counter("test.cmd.foo.total").value()); @@ -193,14 +186,13 @@ TEST_F(MongoProxyFilterTest, CallingFunctionStats) { } )EOF"; - EXPECT_CALL(*filter_->decoder_, onData(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - QueryMessagePtr message(new QueryMessageImpl(0, 0)); - message->fullCollectionName("db.test"); - message->flags(0b1110010); - message->query(Bson::DocumentImpl::create()->addString("$comment", std::move(json))); - filter_->callbacks_->decodeQuery(std::move(message)); - })); + EXPECT_CALL(*filter_->decoder_, onData(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + QueryMessagePtr message(new QueryMessageImpl(0, 0)); + message->fullCollectionName("db.test"); + message->flags(0b1110010); + message->query(Bson::DocumentImpl::create()->addString("$comment", std::move(json))); + filter_->callbacks_->decodeQuery(std::move(message)); + })); filter_->onData(fake_data_); EXPECT_EQ(1U, store_.counter("test.collection.test.query.total").value()); @@ -219,28 +211,26 @@ TEST_F(MongoProxyFilterTest, CallingFunctionStats) { EXPECT_CALL(store_, deliverTimingToSinks( "test.collection.test.callsite.getByMongoId.query.reply_time_ms", _)); - EXPECT_CALL(*filter_->decoder_, onData(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - ReplyMessagePtr message(new ReplyMessageImpl(0, 0)); - message->flags(0b11); - message->cursorId(1); - message->documents().push_back(Bson::DocumentImpl::create()->addString("hello", "world")); - filter_->callbacks_->decodeReply(std::move(message)); + EXPECT_CALL(*filter_->decoder_, onData(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + ReplyMessagePtr message(new ReplyMessageImpl(0, 0)); + message->flags(0b11); + message->cursorId(1); + message->documents().push_back(Bson::DocumentImpl::create()->addString("hello", "world")); + filter_->callbacks_->decodeReply(std::move(message)); - })); + })); filter_->onWrite(fake_data_); } TEST_F(MongoProxyFilterTest, MultiGet) { - EXPECT_CALL(*filter_->decoder_, onData(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - QueryMessagePtr message(new QueryMessageImpl(0, 0)); - message->fullCollectionName("db.test"); - message->flags(0b1110010); - message->query(Bson::DocumentImpl::create()->addDocument( - "_id", Bson::DocumentImpl::create()->addArray("$in", Bson::DocumentImpl::create()))); - filter_->callbacks_->decodeQuery(std::move(message)); - })); + EXPECT_CALL(*filter_->decoder_, onData(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + QueryMessagePtr message(new QueryMessageImpl(0, 0)); + message->fullCollectionName("db.test"); + message->flags(0b1110010); + message->query(Bson::DocumentImpl::create()->addDocument( + "_id", Bson::DocumentImpl::create()->addArray("$in", Bson::DocumentImpl::create()))); + filter_->callbacks_->decodeQuery(std::move(message)); + })); filter_->onData(fake_data_); EXPECT_EQ(1U, store_.counter("test.op_query_multi_get").value()); @@ -248,22 +238,22 @@ TEST_F(MongoProxyFilterTest, MultiGet) { } TEST_F(MongoProxyFilterTest, MaxTime) { - EXPECT_CALL(*filter_->decoder_, onData(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - QueryMessagePtr message(new QueryMessageImpl(0, 0)); - message->fullCollectionName("db.test"); - message->flags(0b1110010); - message->query(Bson::DocumentImpl::create()->addInt32("$maxTimeMS", 100)); - filter_->callbacks_->decodeQuery(std::move(message)); - })); + EXPECT_CALL(*filter_->decoder_, onData(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + QueryMessagePtr message(new QueryMessageImpl(0, 0)); + message->fullCollectionName("db.test"); + message->flags(0b1110010); + message->query(Bson::DocumentImpl::create()->addInt32("$maxTimeMS", 100)); + filter_->callbacks_->decodeQuery(std::move(message)); + })); filter_->onData(fake_data_); EXPECT_EQ(0U, store_.counter("test.op_query_no_max_time").value()); } TEST_F(MongoProxyFilterTest, DecodeError) { - EXPECT_CALL(*filter_->decoder_, onData(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { throw EnvoyException("bad decode"); })); + EXPECT_CALL(*filter_->decoder_, onData(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + throw EnvoyException("bad decode"); + })); filter_->onData(fake_data_); // Should not call decode again. @@ -273,60 +263,56 @@ TEST_F(MongoProxyFilterTest, DecodeError) { } TEST_F(MongoProxyFilterTest, ConcurrentQuery) { - EXPECT_CALL(*filter_->decoder_, onData(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - QueryMessagePtr message(new QueryMessageImpl(1, 0)); - message->fullCollectionName("db.test"); - message->flags(0b1110010); - message->query(Bson::DocumentImpl::create()); - filter_->callbacks_->decodeQuery(std::move(message)); - - message.reset(new QueryMessageImpl(2, 0)); - message->fullCollectionName("db.test"); - message->flags(0b1110010); - message->query(Bson::DocumentImpl::create()); - filter_->callbacks_->decodeQuery(std::move(message)); - })); + EXPECT_CALL(*filter_->decoder_, onData(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + QueryMessagePtr message(new QueryMessageImpl(1, 0)); + message->fullCollectionName("db.test"); + message->flags(0b1110010); + message->query(Bson::DocumentImpl::create()); + filter_->callbacks_->decodeQuery(std::move(message)); + + message.reset(new QueryMessageImpl(2, 0)); + message->fullCollectionName("db.test"); + message->flags(0b1110010); + message->query(Bson::DocumentImpl::create()); + filter_->callbacks_->decodeQuery(std::move(message)); + })); filter_->onData(fake_data_); EXPECT_EQ(2U, store_.gauge("test.op_query_active").value()); - EXPECT_CALL(*filter_->decoder_, onData(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - ReplyMessagePtr message(new ReplyMessageImpl(0, 1)); - message->flags(0b11); - message->cursorId(1); - message->documents().push_back(Bson::DocumentImpl::create()->addString("hello", "world")); - filter_->callbacks_->decodeReply(std::move(message)); - - message.reset(new ReplyMessageImpl(0, 2)); - message->flags(0b11); - message->cursorId(1); - message->documents().push_back(Bson::DocumentImpl::create()->addString("hello", "world")); - filter_->callbacks_->decodeReply(std::move(message)); - })); + EXPECT_CALL(*filter_->decoder_, onData(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + ReplyMessagePtr message(new ReplyMessageImpl(0, 1)); + message->flags(0b11); + message->cursorId(1); + message->documents().push_back(Bson::DocumentImpl::create()->addString("hello", "world")); + filter_->callbacks_->decodeReply(std::move(message)); + + message.reset(new ReplyMessageImpl(0, 2)); + message->flags(0b11); + message->cursorId(1); + message->documents().push_back(Bson::DocumentImpl::create()->addString("hello", "world")); + filter_->callbacks_->decodeReply(std::move(message)); + })); filter_->onWrite(fake_data_); EXPECT_EQ(0U, store_.gauge("test.op_query_active").value()); } TEST_F(MongoProxyFilterTest, EmptyActiveQueryList) { - EXPECT_CALL(*filter_->decoder_, onData(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - QueryMessagePtr message(new QueryMessageImpl(0, 0)); - message->fullCollectionName("db.$cmd"); - message->flags(0b1110010); - message->query(Bson::DocumentImpl::create()->addString("foo", "bar")); - filter_->callbacks_->decodeQuery(std::move(message)); - })); + EXPECT_CALL(*filter_->decoder_, onData(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + QueryMessagePtr message(new QueryMessageImpl(0, 0)); + message->fullCollectionName("db.$cmd"); + message->flags(0b1110010); + message->query(Bson::DocumentImpl::create()->addString("foo", "bar")); + filter_->callbacks_->decodeQuery(std::move(message)); + })); filter_->onData(fake_data_); - EXPECT_CALL(*filter_->decoder_, onData(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - ReplyMessagePtr message(new ReplyMessageImpl(0, 0)); - message->flags(0b11); - message->cursorId(1); - message->documents().push_back(Bson::DocumentImpl::create()->addString("hello", "world")); - filter_->callbacks_->decodeReply(std::move(message)); - })); + EXPECT_CALL(*filter_->decoder_, onData(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + ReplyMessagePtr message(new ReplyMessageImpl(0, 0)); + message->flags(0b11); + message->cursorId(1); + message->documents().push_back(Bson::DocumentImpl::create()->addString("hello", "world")); + filter_->callbacks_->decodeReply(std::move(message)); + })); filter_->onWrite(fake_data_); read_filter_callbacks_.connection_.raiseEvents(Network::ConnectionEvent::RemoteClose); EXPECT_EQ(0U, store_.counter("test.cx_destroy_local_with_active_rq").value()); @@ -334,15 +320,14 @@ TEST_F(MongoProxyFilterTest, EmptyActiveQueryList) { } TEST_F(MongoProxyFilterTest, ConnectionDestroyLocal) { - EXPECT_CALL(*filter_->decoder_, onData(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - QueryMessagePtr message(new QueryMessageImpl(0, 0)); - message->fullCollectionName("db.test"); - message->flags(0b1110010); - message->query(Bson::DocumentImpl::create()->addDocument( - "_id", Bson::DocumentImpl::create()->addArray("$in", Bson::DocumentImpl::create()))); - filter_->callbacks_->decodeQuery(std::move(message)); - })); + EXPECT_CALL(*filter_->decoder_, onData(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + QueryMessagePtr message(new QueryMessageImpl(0, 0)); + message->fullCollectionName("db.test"); + message->flags(0b1110010); + message->query(Bson::DocumentImpl::create()->addDocument( + "_id", Bson::DocumentImpl::create()->addArray("$in", Bson::DocumentImpl::create()))); + filter_->callbacks_->decodeQuery(std::move(message)); + })); filter_->onData(fake_data_); read_filter_callbacks_.connection_.raiseEvents(Network::ConnectionEvent::RemoteClose); @@ -351,15 +336,14 @@ TEST_F(MongoProxyFilterTest, ConnectionDestroyLocal) { } TEST_F(MongoProxyFilterTest, ConnectionDestroyRemote) { - EXPECT_CALL(*filter_->decoder_, onData(_)) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - QueryMessagePtr message(new QueryMessageImpl(0, 0)); - message->fullCollectionName("db.test"); - message->flags(0b1110010); - message->query(Bson::DocumentImpl::create()->addDocument( - "_id", Bson::DocumentImpl::create()->addArray("$in", Bson::DocumentImpl::create()))); - filter_->callbacks_->decodeQuery(std::move(message)); - })); + EXPECT_CALL(*filter_->decoder_, onData(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { + QueryMessagePtr message(new QueryMessageImpl(0, 0)); + message->fullCollectionName("db.test"); + message->flags(0b1110010); + message->query(Bson::DocumentImpl::create()->addDocument( + "_id", Bson::DocumentImpl::create()->addArray("$in", Bson::DocumentImpl::create()))); + filter_->callbacks_->decodeQuery(std::move(message)); + })); filter_->onData(fake_data_); read_filter_callbacks_.connection_.raiseEvents(Network::ConnectionEvent::LocalClose); @@ -367,5 +351,5 @@ TEST_F(MongoProxyFilterTest, ConnectionDestroyRemote) { EXPECT_EQ(0U, store_.counter("test.cx_destroy_local_with_active_rq").value()); } -} // Mongo -} // Envoy +} // namespace Mongo +} // namespace Envoy diff --git a/test/common/mongo/utility_test.cc b/test/common/mongo/utility_test.cc index 40a333663f47c..08a2a3dc636ad 100644 --- a/test/common/mongo/utility_test.cc +++ b/test/common/mongo/utility_test.cc @@ -189,5 +189,5 @@ TEST(QueryMessageInfoTest, Command) { } } -} // Mongo -} // Envoy +} // namespace Mongo +} // namespace Envoy diff --git a/test/common/network/address_impl_test.cc b/test/common/network/address_impl_test.cc index 680cb446d2272..a5c1dfc834f9d 100644 --- a/test/common/network/address_impl_test.cc +++ b/test/common/network/address_impl_test.cc @@ -263,6 +263,6 @@ TEST(AddressFromSockAddr, Pipe) { EnvoyException); } -} // Address -} // Network -} // Envoy +} // namespace Address +} // namespace Network +} // namespace Envoy diff --git a/test/common/network/cidr_range_test.cc b/test/common/network/cidr_range_test.cc index 91f68f1f6b262..01f87b710b6f6 100644 --- a/test/common/network/cidr_range_test.cc +++ b/test/common/network/cidr_range_test.cc @@ -10,8 +10,8 @@ #include "common/network/cidr_range.h" #include "common/network/utility.h" -#include "gtest/gtest.h" #include "spdlog/spdlog.h" +#include "gtest/gtest.h" // We are adding things into the std namespace. // Note that this is technically undefined behavior! @@ -23,7 +23,7 @@ std::ostream& operator<<(std::ostream& out, const std::pair& p) { return out << '(' << p.first << ", " << p.second << ')'; } -} // std +} // namespace std namespace Envoy { @@ -573,6 +573,6 @@ TEST(IpListTest, MatchAnyAll) { EXPECT_FALSE(wl.contains(Address::PipeInstance("foo"))); } -} // Address -} // Network -} // Envoy +} // namespace Address +} // namespace Network +} // namespace Envoy diff --git a/test/common/network/connection_impl_test.cc b/test/common/network/connection_impl_test.cc index b5821870a1215..405835b8d59b9 100644 --- a/test/common/network/connection_impl_test.cc +++ b/test/common/network/connection_impl_test.cc @@ -22,13 +22,13 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; -using testing::Sequence; using testing::InSequence; using testing::Invoke; using testing::Return; +using testing::Sequence; using testing::StrictMock; using testing::Test; +using testing::_; namespace Network { @@ -90,8 +90,8 @@ TEST_P(ConnectionImplTest, CloseDuringConnectCallback) { client_connection->connect(); EXPECT_CALL(client_callbacks, onEvent(ConnectionEvent::Connected)) - .WillOnce(Invoke([&](uint32_t) - -> void { client_connection->close(ConnectionCloseType::NoFlush); })); + .WillOnce(Invoke( + [&](uint32_t) -> void { client_connection->close(ConnectionCloseType::NoFlush); })); EXPECT_CALL(client_callbacks, onEvent(ConnectionEvent::LocalClose)); Network::ConnectionPtr server_connection; @@ -173,12 +173,11 @@ TEST_P(ConnectionImplTest, BufferStats) { EXPECT_CALL(server_callbacks, onEvent(ConnectionEvent::LocalClose)).InSequence(s2); EXPECT_CALL(*read_filter, onNewConnection()); - EXPECT_CALL(*read_filter, onData(_)) - .WillOnce(Invoke([&](Buffer::Instance& data) -> FilterStatus { - data.drain(data.length()); - server_connection->close(ConnectionCloseType::FlushWrite); - return FilterStatus::StopIteration; - })); + EXPECT_CALL(*read_filter, onData(_)).WillOnce(Invoke([&](Buffer::Instance& data) -> FilterStatus { + data.drain(data.length()); + server_connection->close(ConnectionCloseType::FlushWrite); + return FilterStatus::StopIteration; + })); EXPECT_CALL(client_callbacks, onEvent(ConnectionEvent::RemoteClose)) .WillOnce(Invoke([&](uint32_t) -> void { dispatcher.exit(); })); @@ -288,5 +287,5 @@ TEST_P(TcpClientConnectionImplTest, BadConnectConnRefused) { dispatcher.run(Event::Dispatcher::RunType::Block); } -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/test/common/network/dns_impl_test.cc b/test/common/network/dns_impl_test.cc index c83f547e6d77f..8f775eef0fe77 100644 --- a/test/common/network/dns_impl_test.cc +++ b/test/common/network/dns_impl_test.cc @@ -28,11 +28,11 @@ #include "ares_dns.h" #include "gtest/gtest.h" -using testing::_; using testing::InSequence; using testing::Mock; using testing::NiceMock; using testing::Return; +using testing::_; namespace Envoy { namespace Network { @@ -356,9 +356,11 @@ TEST_P(DnsImplTest, LocalLookup) { EXPECT_TRUE(address_list.empty()); if (GetParam() == Address::IpVersion::v4) { - EXPECT_EQ(nullptr, resolver_->resolve("localhost", DnsLookupFamily::V4Only, - [&](std::list&& results) - -> void { address_list = results; })); + EXPECT_EQ(nullptr, + resolver_->resolve("localhost", DnsLookupFamily::V4Only, + [&](std::list&& results) -> void { + address_list = results; + })); EXPECT_TRUE(hasAddress(address_list, "127.0.0.1")); EXPECT_FALSE(hasAddress(address_list, "::1")); } @@ -367,16 +369,20 @@ TEST_P(DnsImplTest, LocalLookup) { const std::string error_msg = "Synchronous DNS IPv6 localhost resolution failed. Please verify localhost resolves to ::1 " "in /etc/hosts, since this misconfiguration is a common cause of these failures."; - EXPECT_EQ(nullptr, resolver_->resolve("localhost", DnsLookupFamily::V6Only, - [&](std::list&& results) - -> void { address_list = results; })) + EXPECT_EQ(nullptr, + resolver_->resolve("localhost", DnsLookupFamily::V6Only, + [&](std::list&& results) -> void { + address_list = results; + })) << error_msg; EXPECT_TRUE(hasAddress(address_list, "::1")) << error_msg; EXPECT_FALSE(hasAddress(address_list, "127.0.0.1")); - EXPECT_EQ(nullptr, resolver_->resolve("localhost", DnsLookupFamily::Auto, - [&](std::list&& results) - -> void { address_list = results; })) + EXPECT_EQ(nullptr, + resolver_->resolve("localhost", DnsLookupFamily::Auto, + [&](std::list&& results) -> void { + address_list = results; + })) << error_msg; EXPECT_FALSE(hasAddress(address_list, "127.0.0.1")); EXPECT_TRUE(hasAddress(address_list, "::1")) << error_msg; @@ -541,7 +547,7 @@ TEST_P(DnsImplTest, Cancel) { ActiveDnsQuery* query = resolver_->resolve("some.domain", DnsLookupFamily::Auto, - [](std::list && ) -> void { FAIL(); }); + [](std::list &&) -> void { FAIL(); }); std::list address_list; EXPECT_NE(nullptr, @@ -599,5 +605,5 @@ TEST(DnsImplUnitTest, PendingTimerEnable) { })); } -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/test/common/network/filter_manager_impl_test.cc b/test/common/network/filter_manager_impl_test.cc index 75d4b392e228e..49fa3fc6631a2 100644 --- a/test/common/network/filter_manager_impl_test.cc +++ b/test/common/network/filter_manager_impl_test.cc @@ -21,12 +21,12 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::InSequence; using testing::Invoke; using testing::NiceMock; using testing::Return; using testing::WithArgs; +using testing::_; namespace Network { @@ -144,11 +144,13 @@ TEST_F(NetworkFilterManagerTest, RateLimitAndTcpProxy) { manager.addReadFilter(ReadFilterSharedPtr{new Envoy::Filter::TcpProxy(tcp_proxy_config, cm)}); RateLimit::RequestCallbacks* request_callbacks{}; - EXPECT_CALL(*rl_client, limit(_, "foo", testing::ContainerEq(std::vector{ - {{{"hello", "world"}}}}), + EXPECT_CALL(*rl_client, limit(_, "foo", + testing::ContainerEq( + std::vector{{{{"hello", "world"}}}}), Tracing::EMPTY_CONTEXT)) - .WillOnce(WithArgs<0>(Invoke([&](RateLimit::RequestCallbacks& callbacks) - -> void { request_callbacks = &callbacks; }))); + .WillOnce(WithArgs<0>(Invoke([&](RateLimit::RequestCallbacks& callbacks) -> void { + request_callbacks = &callbacks; + }))); EXPECT_EQ(manager.initializeReadFilters(), true); @@ -171,5 +173,5 @@ TEST_F(NetworkFilterManagerTest, RateLimitAndTcpProxy) { manager.onRead(); } -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/test/common/network/listen_socket_impl_test.cc b/test/common/network/listen_socket_impl_test.cc index 82f5cc842a902..b40281f970cac 100644 --- a/test/common/network/listen_socket_impl_test.cc +++ b/test/common/network/listen_socket_impl_test.cc @@ -59,5 +59,5 @@ TEST_P(ListenSocketImplTest, BindPortZero) { EXPECT_GT(socket.localAddress()->ip()->port(), 0U); } -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/test/common/network/listener_impl_test.cc b/test/common/network/listener_impl_test.cc index ce3be1a1ddd1b..b7f5b31216890 100644 --- a/test/common/network/listener_impl_test.cc +++ b/test/common/network/listener_impl_test.cc @@ -12,11 +12,11 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::ByRef; using testing::Eq; using testing::Invoke; using testing::Return; +using testing::_; namespace Network { @@ -100,10 +100,11 @@ TEST_P(ListenerImplTest, NormalRedirect) { Network::MockConnectionHandler connection_handler; // The traffic should redirect from binding listener to the virtual listener. Network::TestListenerImpl listener(connection_handler, dispatcher, socket, listener_callbacks1, - stats_store, {.bind_to_port_ = true, - .use_proxy_proto_ = false, - .use_original_dst_ = true, - .per_connection_buffer_limit_bytes_ = 0}); + stats_store, + {.bind_to_port_ = true, + .use_proxy_proto_ = false, + .use_original_dst_ = true, + .per_connection_buffer_limit_bytes_ = 0}); Network::MockListenerCallbacks listener_callbacks2; Network::TestListenerImpl listenerDst(connection_handler, dispatcher, socketDst, listener_callbacks2, stats_store, @@ -139,10 +140,11 @@ TEST_P(ListenerImplTest, FallbackToWildcardListener) { Network::MockConnectionHandler connection_handler; // The virtual listener of exact address does not exist, fall back to wild card virtual listener. Network::TestListenerImpl listener(connection_handler, dispatcher, socket, listener_callbacks1, - stats_store, {.bind_to_port_ = true, - .use_proxy_proto_ = false, - .use_original_dst_ = true, - .per_connection_buffer_limit_bytes_ = 0}); + stats_store, + {.bind_to_port_ = true, + .use_proxy_proto_ = false, + .use_original_dst_ = true, + .per_connection_buffer_limit_bytes_ = 0}); Network::MockListenerCallbacks listener_callbacks2; Network::TestListenerImpl listenerDst(connection_handler, dispatcher, socketDst, listener_callbacks2, stats_store, @@ -177,10 +179,11 @@ TEST_P(ListenerImplTest, UseActualDst) { Network::MockConnectionHandler connection_handler; // Do not redirect since use_original_dst is false. Network::TestListenerImpl listener(connection_handler, dispatcher, socket, listener_callbacks1, - stats_store, {.bind_to_port_ = true, - .use_proxy_proto_ = false, - .use_original_dst_ = false, - .per_connection_buffer_limit_bytes_ = 0}); + stats_store, + {.bind_to_port_ = true, + .use_proxy_proto_ = false, + .use_original_dst_ = false, + .per_connection_buffer_limit_bytes_ = 0}); Network::MockListenerCallbacks listener_callbacks2; Network::TestListenerImpl listenerDst(connection_handler, dispatcher, socketDst, listener_callbacks2, stats_store, @@ -206,5 +209,5 @@ TEST_P(ListenerImplTest, UseActualDst) { dispatcher.run(Event::Dispatcher::RunType::Block); } -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/test/common/network/proxy_protocol_test.cc b/test/common/network/proxy_protocol_test.cc index 24b3c5f614f87..2b56a080b2f4c 100644 --- a/test/common/network/proxy_protocol_test.cc +++ b/test/common/network/proxy_protocol_test.cc @@ -18,9 +18,9 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::Invoke; using testing::NiceMock; +using testing::_; namespace Network { @@ -64,12 +64,11 @@ TEST_P(ProxyProtocolTest, Basic) { ConnectionPtr accepted_connection; - EXPECT_CALL(callbacks_, onNewConnection_(_)) - .WillOnce(Invoke([&](ConnectionPtr& conn) -> void { - ASSERT_EQ("1.2.3.4", conn->remoteAddress().ip()->addressAsString()); - conn->addReadFilter(read_filter_); - accepted_connection = std::move(conn); - })); + EXPECT_CALL(callbacks_, onNewConnection_(_)).WillOnce(Invoke([&](ConnectionPtr& conn) -> void { + ASSERT_EQ("1.2.3.4", conn->remoteAddress().ip()->addressAsString()); + conn->addReadFilter(read_filter_); + accepted_connection = std::move(conn); + })); read_filter_.reset(new MockReadFilter()); EXPECT_CALL(*read_filter_, onNewConnection()); @@ -86,12 +85,11 @@ TEST_P(ProxyProtocolTest, BasicV6) { ConnectionPtr accepted_connection; - EXPECT_CALL(callbacks_, onNewConnection_(_)) - .WillOnce(Invoke([&](ConnectionPtr& conn) -> void { - ASSERT_EQ("1:2:3::4", conn->remoteAddress().ip()->addressAsString()); - conn->addReadFilter(read_filter_); - accepted_connection = std::move(conn); - })); + EXPECT_CALL(callbacks_, onNewConnection_(_)).WillOnce(Invoke([&](ConnectionPtr& conn) -> void { + ASSERT_EQ("1:2:3::4", conn->remoteAddress().ip()->addressAsString()); + conn->addReadFilter(read_filter_); + accepted_connection = std::move(conn); + })); read_filter_.reset(new MockReadFilter()); EXPECT_CALL(*read_filter_, onNewConnection()); @@ -110,13 +108,12 @@ TEST_P(ProxyProtocolTest, Fragmented) { write(".3.4 65535"); write(" 1234\r\n"); - EXPECT_CALL(callbacks_, onNewConnection_(_)) - .WillOnce(Invoke([&](ConnectionPtr& conn) -> void { - ASSERT_EQ("255.255.255.255", conn->remoteAddress().ip()->addressAsString()); - read_filter_.reset(new MockReadFilter()); - conn->addReadFilter(read_filter_); - conn->close(ConnectionCloseType::NoFlush); - })); + EXPECT_CALL(callbacks_, onNewConnection_(_)).WillOnce(Invoke([&](ConnectionPtr& conn) -> void { + ASSERT_EQ("255.255.255.255", conn->remoteAddress().ip()->addressAsString()); + read_filter_.reset(new MockReadFilter()); + conn->addReadFilter(read_filter_); + conn->close(ConnectionCloseType::NoFlush); + })); dispatcher_.run(Event::Dispatcher::RunType::NonBlock); } @@ -126,13 +123,12 @@ TEST_P(ProxyProtocolTest, PartialRead) { write("PROXY TCP4"); write(" 255.255.2"); - EXPECT_CALL(callbacks_, onNewConnection_(_)) - .WillOnce(Invoke([&](ConnectionPtr& conn) -> void { - ASSERT_EQ("255.255.255.255", conn->remoteAddress().ip()->addressAsString()); - read_filter_.reset(new MockReadFilter()); - conn->addReadFilter(read_filter_); - conn->close(ConnectionCloseType::NoFlush); - })); + EXPECT_CALL(callbacks_, onNewConnection_(_)).WillOnce(Invoke([&](ConnectionPtr& conn) -> void { + ASSERT_EQ("255.255.255.255", conn->remoteAddress().ip()->addressAsString()); + read_filter_.reset(new MockReadFilter()); + conn->addReadFilter(read_filter_); + conn->close(ConnectionCloseType::NoFlush); + })); dispatcher_.run(Event::Dispatcher::RunType::NonBlock); @@ -200,5 +196,5 @@ TEST_P(ProxyProtocolTest, AddressVersionsNotMatch) { dispatcher_.run(Event::Dispatcher::RunType::NonBlock); } -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/test/common/network/utility_test.cc b/test/common/network/utility_test.cc index c51fbff885f18..d36be7ebce49f 100644 --- a/test/common/network/utility_test.cc +++ b/test/common/network/utility_test.cc @@ -270,5 +270,5 @@ TEST(PortRangeListTest, Normal) { } } -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/test/common/ratelimit/ratelimit_impl_test.cc b/test/common/ratelimit/ratelimit_impl_test.cc index 326f4f140cf65..3bc643789216a 100644 --- a/test/common/ratelimit/ratelimit_impl_test.cc +++ b/test/common/ratelimit/ratelimit_impl_test.cc @@ -14,11 +14,11 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::AtLeast; using testing::Invoke; using testing::Return; using testing::WithArg; +using testing::_; namespace RateLimit { @@ -93,8 +93,9 @@ TEST_F(RateLimitGrpcClientTest, Basic) { { pb::lyft::ratelimit::RateLimitRequest request; - GrpcClientImpl::createRequest(request, "foo", {{{{"foo", "bar"}, {"bar", "baz"}}}, - {{{"foo2", "bar2"}, {"bar2", "baz2"}}}}); + GrpcClientImpl::createRequest( + request, "foo", + {{{{"foo", "bar"}, {"bar", "baz"}}}, {{{"foo2", "bar2"}, {"bar2", "baz2"}}}}); EXPECT_CALL(*channel_, CallMethod(_, _, ProtoMessageEqual(&request), _, nullptr)) .WillOnce(WithArg<3>(Invoke([&](::google::protobuf::Message* raw_response) -> void { response = dynamic_cast(raw_response); @@ -162,5 +163,5 @@ TEST(RateLimitNullFactoryTest, Basic) { client->cancel(); } -} // RateLimit -} // Envoy +} // namespace RateLimit +} // namespace Envoy diff --git a/test/common/redis/codec_impl_test.cc b/test/common/redis/codec_impl_test.cc index b05602923d971..765ec3fdc403f 100644 --- a/test/common/redis/codec_impl_test.cc +++ b/test/common/redis/codec_impl_test.cc @@ -186,5 +186,5 @@ TEST_F(RedisEncoderDecoderImplTest, InvalidBulkStringExpectLF) { EXPECT_THROW(decoder_.decode(buffer_), ProtocolError); } -} // Redis -} // Envoy +} // namespace Redis +} // namespace Envoy diff --git a/test/common/redis/command_splitter_impl_test.cc b/test/common/redis/command_splitter_impl_test.cc index bf16c68026d2b..df95f9d20aea8 100644 --- a/test/common/redis/command_splitter_impl_test.cc +++ b/test/common/redis/command_splitter_impl_test.cc @@ -14,7 +14,6 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::ByRef; using testing::DoAll; using testing::Eq; @@ -22,6 +21,7 @@ using testing::InSequence; using testing::Ref; using testing::Return; using testing::WithArg; +using testing::_; namespace Redis { namespace CommandSplitter { @@ -384,6 +384,6 @@ TEST_F(RedisMGETCommandHandlerTest, Cancel) { handle_->cancel(); }; -} // CommandSplitter -} // Redis -} // Envoy +} // namespace CommandSplitter +} // namespace Redis +} // namespace Envoy diff --git a/test/common/redis/conn_pool_impl_test.cc b/test/common/redis/conn_pool_impl_test.cc index af79c16c5e8b9..5792ee07eb644 100644 --- a/test/common/redis/conn_pool_impl_test.cc +++ b/test/common/redis/conn_pool_impl_test.cc @@ -15,7 +15,6 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::Eq; using testing::InSequence; using testing::Invoke; @@ -23,6 +22,7 @@ using testing::Ref; using testing::Return; using testing::ReturnRef; using testing::SaveArg; +using testing::_; namespace Redis { namespace ConnPool { @@ -116,20 +116,19 @@ TEST_F(RedisClientImplTest, Basic) { EXPECT_EQ(2UL, host_->stats_.rq_active_.value()); Buffer::OwnedImpl fake_data; - EXPECT_CALL(*decoder_, decode(Ref(fake_data))) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - InSequence s; - RespValuePtr response1(new RespValue()); - EXPECT_CALL(callbacks1, onResponse_(Ref(response1))); - EXPECT_CALL(host_->outlier_detector_, putHttpResponseCode(200)); - callbacks_->onRespValue(std::move(response1)); - - RespValuePtr response2(new RespValue()); - EXPECT_CALL(callbacks2, onResponse_(Ref(response2))); - EXPECT_CALL(*connect_or_op_timer_, disableTimer()); - EXPECT_CALL(host_->outlier_detector_, putHttpResponseCode(200)); - callbacks_->onRespValue(std::move(response2)); - })); + EXPECT_CALL(*decoder_, decode(Ref(fake_data))).WillOnce(Invoke([&](Buffer::Instance&) -> void { + InSequence s; + RespValuePtr response1(new RespValue()); + EXPECT_CALL(callbacks1, onResponse_(Ref(response1))); + EXPECT_CALL(host_->outlier_detector_, putHttpResponseCode(200)); + callbacks_->onRespValue(std::move(response1)); + + RespValuePtr response2(new RespValue()); + EXPECT_CALL(callbacks2, onResponse_(Ref(response2))); + EXPECT_CALL(*connect_or_op_timer_, disableTimer()); + EXPECT_CALL(host_->outlier_detector_, putHttpResponseCode(200)); + callbacks_->onRespValue(std::move(response2)); + })); upstream_read_filter_->onData(fake_data); EXPECT_CALL(*upstream_connection_, close(Network::ConnectionCloseType::NoFlush)); @@ -160,21 +159,20 @@ TEST_F(RedisClientImplTest, Cancel) { handle1->cancel(); Buffer::OwnedImpl fake_data; - EXPECT_CALL(*decoder_, decode(Ref(fake_data))) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - InSequence s; - - RespValuePtr response1(new RespValue()); - EXPECT_CALL(callbacks1, onResponse_(_)).Times(0); - EXPECT_CALL(host_->outlier_detector_, putHttpResponseCode(200)); - callbacks_->onRespValue(std::move(response1)); - - RespValuePtr response2(new RespValue()); - EXPECT_CALL(callbacks2, onResponse_(Ref(response2))); - EXPECT_CALL(*connect_or_op_timer_, disableTimer()); - EXPECT_CALL(host_->outlier_detector_, putHttpResponseCode(200)); - callbacks_->onRespValue(std::move(response2)); - })); + EXPECT_CALL(*decoder_, decode(Ref(fake_data))).WillOnce(Invoke([&](Buffer::Instance&) -> void { + InSequence s; + + RespValuePtr response1(new RespValue()); + EXPECT_CALL(callbacks1, onResponse_(_)).Times(0); + EXPECT_CALL(host_->outlier_detector_, putHttpResponseCode(200)); + callbacks_->onRespValue(std::move(response1)); + + RespValuePtr response2(new RespValue()); + EXPECT_CALL(callbacks2, onResponse_(Ref(response2))); + EXPECT_CALL(*connect_or_op_timer_, disableTimer()); + EXPECT_CALL(host_->outlier_detector_, putHttpResponseCode(200)); + callbacks_->onRespValue(std::move(response2)); + })); upstream_read_filter_->onData(fake_data); EXPECT_CALL(*upstream_connection_, close(Network::ConnectionCloseType::NoFlush)); @@ -251,8 +249,9 @@ TEST_F(RedisClientImplTest, ProtocolError) { onConnected(); Buffer::OwnedImpl fake_data; - EXPECT_CALL(*decoder_, decode(Ref(fake_data))) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { throw ProtocolError("error"); })); + EXPECT_CALL(*decoder_, decode(Ref(fake_data))).WillOnce(Invoke([&](Buffer::Instance&) -> void { + throw ProtocolError("error"); + })); EXPECT_CALL(host_->outlier_detector_, putHttpResponseCode(500)); EXPECT_CALL(*upstream_connection_, close(Network::ConnectionCloseType::NoFlush)); EXPECT_CALL(callbacks1, onFailure()); @@ -457,6 +456,6 @@ TEST_F(RedisConnPoolImplTest, RemoteClose) { tls_.shutdownThread(); } -} // ConnPool -} // Redis -} // Envoy +} // namespace ConnPool +} // namespace Redis +} // namespace Envoy diff --git a/test/common/redis/proxy_filter_test.cc b/test/common/redis/proxy_filter_test.cc index 89d968e5eca4f..3c61b8e502881 100644 --- a/test/common/redis/proxy_filter_test.cc +++ b/test/common/redis/proxy_filter_test.cc @@ -13,7 +13,6 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::ByRef; using testing::DoAll; using testing::Eq; @@ -23,6 +22,7 @@ using testing::NiceMock; using testing::Ref; using testing::Return; using testing::WithArg; +using testing::_; namespace Redis { @@ -124,20 +124,17 @@ TEST_F(RedisProxyFilterTest, OutOfOrderResponse) { CommandSplitter::SplitCallbacks* request_callbacks1; CommandSplitter::MockSplitRequest* request_handle2 = new CommandSplitter::MockSplitRequest(); CommandSplitter::SplitCallbacks* request_callbacks2; - EXPECT_CALL(*decoder_, decode(Ref(fake_data))) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - RespValuePtr request1(new RespValue()); - EXPECT_CALL(splitter_, makeRequest_(Ref(*request1), _)) - .WillOnce( - DoAll(WithArg<1>(SaveArgAddress(&request_callbacks1)), Return(request_handle1))); - decoder_callbacks_->onRespValue(std::move(request1)); - - RespValuePtr request2(new RespValue()); - EXPECT_CALL(splitter_, makeRequest_(Ref(*request2), _)) - .WillOnce( - DoAll(WithArg<1>(SaveArgAddress(&request_callbacks2)), Return(request_handle2))); - decoder_callbacks_->onRespValue(std::move(request2)); - })); + EXPECT_CALL(*decoder_, decode(Ref(fake_data))).WillOnce(Invoke([&](Buffer::Instance&) -> void { + RespValuePtr request1(new RespValue()); + EXPECT_CALL(splitter_, makeRequest_(Ref(*request1), _)) + .WillOnce(DoAll(WithArg<1>(SaveArgAddress(&request_callbacks1)), Return(request_handle1))); + decoder_callbacks_->onRespValue(std::move(request1)); + + RespValuePtr request2(new RespValue()); + EXPECT_CALL(splitter_, makeRequest_(Ref(*request2), _)) + .WillOnce(DoAll(WithArg<1>(SaveArgAddress(&request_callbacks2)), Return(request_handle2))); + decoder_callbacks_->onRespValue(std::move(request2)); + })); EXPECT_EQ(Network::FilterStatus::Continue, filter_->onData(fake_data)); EXPECT_EQ(2UL, config_->stats().downstream_rq_total_.value()); @@ -162,14 +159,12 @@ TEST_F(RedisProxyFilterTest, DownstreamDisconnectWithActive) { Buffer::OwnedImpl fake_data; CommandSplitter::MockSplitRequest* request_handle1 = new CommandSplitter::MockSplitRequest(); CommandSplitter::SplitCallbacks* request_callbacks1; - EXPECT_CALL(*decoder_, decode(Ref(fake_data))) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { - RespValuePtr request1(new RespValue()); - EXPECT_CALL(splitter_, makeRequest_(Ref(*request1), _)) - .WillOnce( - DoAll(WithArg<1>(SaveArgAddress(&request_callbacks1)), Return(request_handle1))); - decoder_callbacks_->onRespValue(std::move(request1)); - })); + EXPECT_CALL(*decoder_, decode(Ref(fake_data))).WillOnce(Invoke([&](Buffer::Instance&) -> void { + RespValuePtr request1(new RespValue()); + EXPECT_CALL(splitter_, makeRequest_(Ref(*request1), _)) + .WillOnce(DoAll(WithArg<1>(SaveArgAddress(&request_callbacks1)), Return(request_handle1))); + decoder_callbacks_->onRespValue(std::move(request1)); + })); EXPECT_EQ(Network::FilterStatus::Continue, filter_->onData(fake_data)); EXPECT_CALL(*request_handle1, cancel()); @@ -181,20 +176,21 @@ TEST_F(RedisProxyFilterTest, ImmediateResponse) { Buffer::OwnedImpl fake_data; RespValuePtr request1(new RespValue()); - EXPECT_CALL(*decoder_, decode(Ref(fake_data))) - .WillOnce(Invoke([&](Buffer::Instance&) - -> void { decoder_callbacks_->onRespValue(std::move(request1)); })); + EXPECT_CALL(*decoder_, decode(Ref(fake_data))).WillOnce(Invoke([&](Buffer::Instance&) -> void { + decoder_callbacks_->onRespValue(std::move(request1)); + })); EXPECT_CALL(splitter_, makeRequest_(Ref(*request1), _)) - .WillOnce(Invoke([&](const RespValue&, CommandSplitter::SplitCallbacks& callbacks) - -> CommandSplitter::SplitRequest* { - RespValuePtr error(new RespValue()); - error->type(RespType::Error); - error->asString() = "no healthy upstream"; - EXPECT_CALL(*encoder_, encode(Eq(ByRef(*error)), _)); - EXPECT_CALL(filter_callbacks_.connection_, write(_)); - callbacks.onResponse(std::move(error)); - return nullptr; - })); + .WillOnce( + Invoke([&](const RespValue&, + CommandSplitter::SplitCallbacks& callbacks) -> CommandSplitter::SplitRequest* { + RespValuePtr error(new RespValue()); + error->type(RespType::Error); + error->asString() = "no healthy upstream"; + EXPECT_CALL(*encoder_, encode(Eq(ByRef(*error)), _)); + EXPECT_CALL(filter_callbacks_.connection_, write(_)); + callbacks.onResponse(std::move(error)); + return nullptr; + })); EXPECT_EQ(Network::FilterStatus::Continue, filter_->onData(fake_data)); filter_callbacks_.connection_.raiseEvents(Network::ConnectionEvent::RemoteClose); @@ -204,8 +200,9 @@ TEST_F(RedisProxyFilterTest, ProtocolError) { InSequence s; Buffer::OwnedImpl fake_data; - EXPECT_CALL(*decoder_, decode(Ref(fake_data))) - .WillOnce(Invoke([&](Buffer::Instance&) -> void { throw ProtocolError("error"); })); + EXPECT_CALL(*decoder_, decode(Ref(fake_data))).WillOnce(Invoke([&](Buffer::Instance&) -> void { + throw ProtocolError("error"); + })); RespValue error; error.type(RespType::Error); @@ -218,5 +215,5 @@ TEST_F(RedisProxyFilterTest, ProtocolError) { EXPECT_EQ(1UL, store_.counter("redis.foo.downstream_cx_protocol_error").value()); } -} // Redis -} // Envoy +} // namespace Redis +} // namespace Envoy diff --git a/test/common/router/config_impl_test.cc b/test/common/router/config_impl_test.cc index 6e5e45114fdab..4d9b82c517a9b 100644 --- a/test/common/router/config_impl_test.cc +++ b/test/common/router/config_impl_test.cc @@ -18,12 +18,12 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::ContainerEq; using testing::NiceMock; using testing::Return; using testing::ReturnRef; using testing::StrNe; +using testing::_; namespace Router { @@ -1104,10 +1104,11 @@ TEST(RouteMatcherTest, Retry) { EXPECT_FALSE(config.usesRuntime()); - EXPECT_EQ(std::chrono::milliseconds(0), config.route(genHeaders("www.lyft.com", "/foo", "GET"), 0) - ->routeEntry() - ->retryPolicy() - .perTryTimeout()); + EXPECT_EQ(std::chrono::milliseconds(0), + config.route(genHeaders("www.lyft.com", "/foo", "GET"), 0) + ->routeEntry() + ->retryPolicy() + .perTryTimeout()); EXPECT_EQ(1U, config.route(genHeaders("www.lyft.com", "/foo", "GET"), 0) ->routeEntry() ->retryPolicy() @@ -1118,10 +1119,11 @@ TEST(RouteMatcherTest, Retry) { ->retryPolicy() .retryOn()); - EXPECT_EQ(std::chrono::milliseconds(0), config.route(genHeaders("www.lyft.com", "/foo", "GET"), 0) - ->routeEntry() - ->retryPolicy() - .perTryTimeout()); + EXPECT_EQ(std::chrono::milliseconds(0), + config.route(genHeaders("www.lyft.com", "/foo", "GET"), 0) + ->routeEntry() + ->retryPolicy() + .perTryTimeout()); EXPECT_EQ(0U, config.route(genHeaders("www.lyft.com", "/bar", "GET"), 0) ->routeEntry() ->retryPolicy() @@ -1131,10 +1133,11 @@ TEST(RouteMatcherTest, Retry) { ->retryPolicy() .retryOn()); - EXPECT_EQ(std::chrono::milliseconds(1000), config.route(genHeaders("www.lyft.com", "/", "GET"), 0) - ->routeEntry() - ->retryPolicy() - .perTryTimeout()); + EXPECT_EQ(std::chrono::milliseconds(1000), + config.route(genHeaders("www.lyft.com", "/", "GET"), 0) + ->routeEntry() + ->retryPolicy() + .perTryTimeout()); EXPECT_EQ(3U, config.route(genHeaders("www.lyft.com", "/", "GET"), 0) ->routeEntry() ->retryPolicy() @@ -1187,10 +1190,11 @@ TEST(RouteMatcherTest, GrpcRetry) { EXPECT_FALSE(config.usesRuntime()); - EXPECT_EQ(std::chrono::milliseconds(0), config.route(genHeaders("www.lyft.com", "/foo", "GET"), 0) - ->routeEntry() - ->retryPolicy() - .perTryTimeout()); + EXPECT_EQ(std::chrono::milliseconds(0), + config.route(genHeaders("www.lyft.com", "/foo", "GET"), 0) + ->routeEntry() + ->retryPolicy() + .perTryTimeout()); EXPECT_EQ(1U, config.route(genHeaders("www.lyft.com", "/foo", "GET"), 0) ->routeEntry() ->retryPolicy() @@ -1201,10 +1205,11 @@ TEST(RouteMatcherTest, GrpcRetry) { ->retryPolicy() .retryOn()); - EXPECT_EQ(std::chrono::milliseconds(0), config.route(genHeaders("www.lyft.com", "/foo", "GET"), 0) - ->routeEntry() - ->retryPolicy() - .perTryTimeout()); + EXPECT_EQ(std::chrono::milliseconds(0), + config.route(genHeaders("www.lyft.com", "/foo", "GET"), 0) + ->routeEntry() + ->retryPolicy() + .perTryTimeout()); EXPECT_EQ(0U, config.route(genHeaders("www.lyft.com", "/bar", "GET"), 0) ->routeEntry() ->retryPolicy() @@ -1214,10 +1219,11 @@ TEST(RouteMatcherTest, GrpcRetry) { ->retryPolicy() .retryOn()); - EXPECT_EQ(std::chrono::milliseconds(1000), config.route(genHeaders("www.lyft.com", "/", "GET"), 0) - ->routeEntry() - ->retryPolicy() - .perTryTimeout()); + EXPECT_EQ(std::chrono::milliseconds(1000), + config.route(genHeaders("www.lyft.com", "/", "GET"), 0) + ->routeEntry() + ->retryPolicy() + .perTryTimeout()); EXPECT_EQ(3U, config.route(genHeaders("www.lyft.com", "/", "GET"), 0) ->routeEntry() ->retryPolicy() @@ -2023,5 +2029,5 @@ TEST(RoutePropertyTest, excludeVHRateLimits) { EXPECT_TRUE(config_ptr->route(headers, 0)->routeEntry()->includeVirtualHostRateLimits()); } -} // Router -} // Envoy +} // namespace Router +} // namespace Envoy diff --git a/test/common/router/rds_impl_test.cc b/test/common/router/rds_impl_test.cc index df8f5927031cb..9b855a2b0df42 100644 --- a/test/common/router/rds_impl_test.cc +++ b/test/common/router/rds_impl_test.cc @@ -16,11 +16,11 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::InSequence; using testing::Invoke; using testing::Return; using testing::ReturnRef; +using testing::_; namespace Router { @@ -276,5 +276,5 @@ TEST_F(RdsImplTest, FailureArray) { EXPECT_EQ(1UL, store_.counter("foo.rds.update_failure").value()); } -} // Upstream -} // Envoy +} // namespace Router +} // namespace Envoy diff --git a/test/common/router/retry_state_impl_test.cc b/test/common/router/retry_state_impl_test.cc index c2dbcc84a7566..5e21da3af5e11 100644 --- a/test/common/router/retry_state_impl_test.cc +++ b/test/common/router/retry_state_impl_test.cc @@ -14,9 +14,9 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::NiceMock; using testing::Return; +using testing::_; namespace Router { @@ -307,5 +307,5 @@ TEST_F(RouterRetryStateImplTest, Cancel) { EXPECT_TRUE(state_->shouldRetry(nullptr, connect_failure_, callback_)); } -} // Router -} // Envoy +} // namespace Router +} // namespace Envoy diff --git a/test/common/router/router_ratelimit_test.cc b/test/common/router/router_ratelimit_test.cc index fdb1125031970..573cd51167e41 100644 --- a/test/common/router/router_ratelimit_test.cc +++ b/test/common/router/router_ratelimit_test.cc @@ -18,9 +18,9 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::NiceMock; using testing::ReturnRef; +using testing::_; namespace Router { @@ -661,5 +661,5 @@ TEST_F(RateLimitPolicyEntryTest, CompoundActionsNoDescriptor) { EXPECT_TRUE(descriptors_.empty()); } -} // Router -} // Envoy +} // namespace Router +} // namespace Envoy diff --git a/test/common/router/router_test.cc b/test/common/router/router_test.cc index 5333ea9955447..ef499fd3524b2 100644 --- a/test/common/router/router_test.cc +++ b/test/common/router/router_test.cc @@ -21,13 +21,13 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::AtLeast; using testing::Invoke; using testing::NiceMock; using testing::Return; using testing::ReturnRef; using testing::SaveArg; +using testing::_; namespace Router { @@ -119,11 +119,10 @@ TEST_F(RouterTest, PoolFailureWithPriority) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) .WillOnce(Invoke([&](Http::StreamDecoder&, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { - callbacks.onPoolFailure( - Http::ConnectionPool::PoolFailureReason::ConnectionFailure, - cm_.conn_pool_.host_); - return nullptr; - })); + callbacks.onPoolFailure(Http::ConnectionPool::PoolFailureReason::ConnectionFailure, + cm_.conn_pool_.host_); + return nullptr; + })); Http::TestHeaderMapImpl response_headers{ {":status", "503"}, {"content-length", "57"}, {"content-type", "text/plain"}}; @@ -132,8 +131,9 @@ TEST_F(RouterTest, PoolFailureWithPriority) { EXPECT_CALL(callbacks_.request_info_, setResponseFlag(Http::AccessLog::ResponseFlag::UpstreamConnectionFailure)); EXPECT_CALL(callbacks_.request_info_, onUpstreamHostSelected(_)) - .WillOnce(Invoke([&](const Upstream::HostDescriptionConstSharedPtr host) - -> void { EXPECT_EQ(host_address_, host->address()); })); + .WillOnce(Invoke([&](const Upstream::HostDescriptionConstSharedPtr host) -> void { + EXPECT_EQ(host_address_, host->address()); + })); Http::TestHeaderMapImpl headers; HttpTestUtility::addDefaultHeaders(headers); @@ -208,10 +208,9 @@ TEST_F(RouterTest, NoHost) { Http::TestHeaderMapImpl headers; HttpTestUtility::addDefaultHeaders(headers); router_.decodeHeaders(headers, true); - EXPECT_EQ( - 0U, - cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_maintenance_mode") - .value()); + EXPECT_EQ(0U, cm_.thread_local_cluster_.cluster_.info_->stats_store_ + .counter("upstream_rq_maintenance_mode") + .value()); } TEST_F(RouterTest, MaintenanceMode) { @@ -227,10 +226,9 @@ TEST_F(RouterTest, MaintenanceMode) { Http::TestHeaderMapImpl headers; HttpTestUtility::addDefaultHeaders(headers); router_.decodeHeaders(headers, true); - EXPECT_EQ( - 1U, - cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_maintenance_mode") - .value()); + EXPECT_EQ(1U, cm_.thread_local_cluster_.cluster_.info_->stats_store_ + .counter("upstream_rq_maintenance_mode") + .value()); } TEST_F(RouterTest, ResetDuringEncodeHeaders) { @@ -239,10 +237,10 @@ TEST_F(RouterTest, ResetDuringEncodeHeaders) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) .WillOnce(Invoke([&](Http::StreamDecoder& decoder, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { - response_decoder = &decoder; - callbacks.onPoolReady(encoder, cm_.conn_pool_.host_); - return nullptr; - })); + response_decoder = &decoder; + callbacks.onPoolReady(encoder, cm_.conn_pool_.host_); + return nullptr; + })); EXPECT_CALL(encoder, encodeHeaders(_, true)) .WillOnce(Invoke([&](const Http::HeaderMap&, bool) -> void { @@ -261,13 +259,14 @@ TEST_F(RouterTest, UpstreamTimeout) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) .WillOnce(Invoke([&](Http::StreamDecoder& decoder, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { - response_decoder = &decoder; - callbacks.onPoolReady(encoder, cm_.conn_pool_.host_); - return nullptr; - })); + response_decoder = &decoder; + callbacks.onPoolReady(encoder, cm_.conn_pool_.host_); + return nullptr; + })); EXPECT_CALL(callbacks_.request_info_, onUpstreamHostSelected(_)) - .WillOnce(Invoke([&](const Upstream::HostDescriptionConstSharedPtr host) - -> void { EXPECT_EQ(host_address_, host->address()); })); + .WillOnce(Invoke([&](const Upstream::HostDescriptionConstSharedPtr host) -> void { + EXPECT_EQ(host_address_, host->address()); + })); expectResponseTimerCreate(); @@ -300,13 +299,14 @@ TEST_F(RouterTest, UpstreamTimeoutWithAltResponse) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) .WillOnce(Invoke([&](Http::StreamDecoder& decoder, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { - response_decoder = &decoder; - callbacks.onPoolReady(encoder, cm_.conn_pool_.host_); - return nullptr; - })); + response_decoder = &decoder; + callbacks.onPoolReady(encoder, cm_.conn_pool_.host_); + return nullptr; + })); EXPECT_CALL(callbacks_.request_info_, onUpstreamHostSelected(_)) - .WillOnce(Invoke([&](const Upstream::HostDescriptionConstSharedPtr host) - -> void { EXPECT_EQ(host_address_, host->address()); })); + .WillOnce(Invoke([&](const Upstream::HostDescriptionConstSharedPtr host) -> void { + EXPECT_EQ(host_address_, host->address()); + })); expectResponseTimerCreate(); @@ -338,13 +338,14 @@ TEST_F(RouterTest, UpstreamPerTryTimeout) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) .WillOnce(Invoke([&](Http::StreamDecoder& decoder, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { - response_decoder = &decoder; - callbacks.onPoolReady(encoder, cm_.conn_pool_.host_); - return nullptr; - })); + response_decoder = &decoder; + callbacks.onPoolReady(encoder, cm_.conn_pool_.host_); + return nullptr; + })); EXPECT_CALL(callbacks_.request_info_, onUpstreamHostSelected(_)) - .WillOnce(Invoke([&](const Upstream::HostDescriptionConstSharedPtr host) - -> void { EXPECT_EQ(host_address_, host->address()); })); + .WillOnce(Invoke([&](const Upstream::HostDescriptionConstSharedPtr host) -> void { + EXPECT_EQ(host_address_, host->address()); + })); expectResponseTimerCreate(); expectPerTryTimerCreate(); @@ -366,10 +367,9 @@ TEST_F(RouterTest, UpstreamPerTryTimeout) { EXPECT_CALL(cm_.conn_pool_.host_->outlier_detector_, putHttpResponseCode(504)); per_try_timeout_->callback_(); - EXPECT_EQ( - 1U, - cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_per_try_timeout") - .value()); + EXPECT_EQ(1U, cm_.thread_local_cluster_.cluster_.info_->stats_store_ + .counter("upstream_rq_per_try_timeout") + .value()); EXPECT_EQ(1UL, cm_.conn_pool_.host_->stats().rq_timeout_.value()); } @@ -379,15 +379,16 @@ TEST_F(RouterTest, RetryRequestNotComplete) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) .WillOnce(Invoke([&](Http::StreamDecoder& decoder, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { - response_decoder = &decoder; - callbacks.onPoolReady(encoder1, cm_.conn_pool_.host_); - return nullptr; - })); + response_decoder = &decoder; + callbacks.onPoolReady(encoder1, cm_.conn_pool_.host_); + return nullptr; + })); EXPECT_CALL(callbacks_.request_info_, setResponseFlag(Http::AccessLog::ResponseFlag::UpstreamRemoteReset)); EXPECT_CALL(callbacks_.request_info_, onUpstreamHostSelected(_)) - .WillOnce(Invoke([&](const Upstream::HostDescriptionConstSharedPtr host) - -> void { EXPECT_EQ(host_address_, host->address()); })); + .WillOnce(Invoke([&](const Upstream::HostDescriptionConstSharedPtr host) -> void { + EXPECT_EQ(host_address_, host->address()); + })); Http::TestHeaderMapImpl headers{{"x-envoy-retry-on", "5xx"}, {"x-envoy-internal", "true"}}; HttpTestUtility::addDefaultHeaders(headers); @@ -404,15 +405,16 @@ TEST_F(RouterTest, RetryNoneHealthy) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) .WillOnce(Invoke([&](Http::StreamDecoder& decoder, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { - response_decoder = &decoder; - callbacks.onPoolReady(encoder1, cm_.conn_pool_.host_); - return nullptr; - })); + response_decoder = &decoder; + callbacks.onPoolReady(encoder1, cm_.conn_pool_.host_); + return nullptr; + })); expectResponseTimerCreate(); EXPECT_CALL(callbacks_.request_info_, onUpstreamHostSelected(_)) - .WillOnce(Invoke([&](const Upstream::HostDescriptionConstSharedPtr host) - -> void { EXPECT_EQ(host_address_, host->address()); })); + .WillOnce(Invoke([&](const Upstream::HostDescriptionConstSharedPtr host) -> void { + EXPECT_EQ(host_address_, host->address()); + })); Http::TestHeaderMapImpl headers{{"x-envoy-retry-on", "5xx"}, {"x-envoy-internal", "true"}}; HttpTestUtility::addDefaultHeaders(headers); @@ -438,10 +440,10 @@ TEST_F(RouterTest, RetryUpstreamReset) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) .WillOnce(Invoke([&](Http::StreamDecoder& decoder, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { - response_decoder = &decoder; - callbacks.onPoolReady(encoder1, cm_.conn_pool_.host_); - return nullptr; - })); + response_decoder = &decoder; + callbacks.onPoolReady(encoder1, cm_.conn_pool_.host_); + return nullptr; + })); expectResponseTimerCreate(); Http::TestHeaderMapImpl headers{{"x-envoy-retry-on", "5xx"}, {"x-envoy-internal", "true"}}; @@ -457,10 +459,10 @@ TEST_F(RouterTest, RetryUpstreamReset) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) .WillOnce(Invoke([&](Http::StreamDecoder& decoder, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { - response_decoder = &decoder; - callbacks.onPoolReady(encoder2, cm_.conn_pool_.host_); - return nullptr; - })); + response_decoder = &decoder; + callbacks.onPoolReady(encoder2, cm_.conn_pool_.host_); + return nullptr; + })); router_.retry_state_->callback_(); // Normal response. @@ -476,10 +478,10 @@ TEST_F(RouterTest, RetryUpstreamPerTryTimeout) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) .WillOnce(Invoke([&](Http::StreamDecoder& decoder, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { - response_decoder = &decoder; - callbacks.onPoolReady(encoder1, cm_.conn_pool_.host_); - return nullptr; - })); + response_decoder = &decoder; + callbacks.onPoolReady(encoder1, cm_.conn_pool_.host_); + return nullptr; + })); expectResponseTimerCreate(); expectPerTryTimerCreate(); @@ -498,10 +500,10 @@ TEST_F(RouterTest, RetryUpstreamPerTryTimeout) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) .WillOnce(Invoke([&](Http::StreamDecoder& decoder, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { - response_decoder = &decoder; - callbacks.onPoolReady(encoder2, cm_.conn_pool_.host_); - return nullptr; - })); + response_decoder = &decoder; + callbacks.onPoolReady(encoder2, cm_.conn_pool_.host_); + return nullptr; + })); expectPerTryTimerCreate(); router_.retry_state_->callback_(); @@ -518,10 +520,10 @@ TEST_F(RouterTest, RetryUpstreamResetResponseStarted) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) .WillOnce(Invoke([&](Http::StreamDecoder& decoder, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { - response_decoder = &decoder; - callbacks.onPoolReady(encoder1, cm_.conn_pool_.host_); - return nullptr; - })); + response_decoder = &decoder; + callbacks.onPoolReady(encoder1, cm_.conn_pool_.host_); + return nullptr; + })); expectResponseTimerCreate(); Http::TestHeaderMapImpl headers{{"x-envoy-retry-on", "5xx"}, {"x-envoy-internal", "true"}}; @@ -544,10 +546,10 @@ TEST_F(RouterTest, RetryUpstream5xx) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) .WillOnce(Invoke([&](Http::StreamDecoder& decoder, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { - response_decoder = &decoder; - callbacks.onPoolReady(encoder1, cm_.conn_pool_.host_); - return nullptr; - })); + response_decoder = &decoder; + callbacks.onPoolReady(encoder1, cm_.conn_pool_.host_); + return nullptr; + })); expectResponseTimerCreate(); Http::TestHeaderMapImpl headers{{"x-envoy-retry-on", "5xx"}, {"x-envoy-internal", "true"}}; @@ -566,10 +568,10 @@ TEST_F(RouterTest, RetryUpstream5xx) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) .WillOnce(Invoke([&](Http::StreamDecoder& decoder, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { - response_decoder = &decoder; - callbacks.onPoolReady(encoder2, cm_.conn_pool_.host_); - return nullptr; - })); + response_decoder = &decoder; + callbacks.onPoolReady(encoder2, cm_.conn_pool_.host_); + return nullptr; + })); router_.retry_state_->callback_(); // Normal response. @@ -585,10 +587,10 @@ TEST_F(RouterTest, RetryTimeoutDuringRetryDelay) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) .WillOnce(Invoke([&](Http::StreamDecoder& decoder, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { - response_decoder = &decoder; - callbacks.onPoolReady(encoder1, cm_.conn_pool_.host_); - return nullptr; - })); + response_decoder = &decoder; + callbacks.onPoolReady(encoder1, cm_.conn_pool_.host_); + return nullptr; + })); expectResponseTimerCreate(); Http::TestHeaderMapImpl headers{{"x-envoy-retry-on", "5xx"}, {"x-envoy-internal", "true"}}; @@ -619,10 +621,10 @@ TEST_F(RouterTest, RetryTimeoutDuringRetryDelayWithUpstreamRequestNoHost) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) .WillOnce(Invoke([&](Http::StreamDecoder& decoder, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { - response_decoder = &decoder; - callbacks.onPoolReady(encoder1, cm_.conn_pool_.host_); - return nullptr; - })); + response_decoder = &decoder; + callbacks.onPoolReady(encoder1, cm_.conn_pool_.host_); + return nullptr; + })); expectResponseTimerCreate(); Http::TestHeaderMapImpl headers{{"x-envoy-retry-on", "5xx"}, {"x-envoy-internal", "true"}}; @@ -637,11 +639,11 @@ TEST_F(RouterTest, RetryTimeoutDuringRetryDelayWithUpstreamRequestNoHost) { Http::ConnectionPool::MockCancellable cancellable; EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) - .WillOnce(Invoke([&](Http::StreamDecoder& decoder, Http::ConnectionPool::Callbacks&) - -> Http::ConnectionPool::Cancellable* { - response_decoder = &decoder; - return &cancellable; - })); + .WillOnce(Invoke([&](Http::StreamDecoder& decoder, + Http::ConnectionPool::Callbacks&) -> Http::ConnectionPool::Cancellable* { + response_decoder = &decoder; + return &cancellable; + })); router_.retry_state_->callback_(); // Fire timeout. @@ -663,10 +665,10 @@ TEST_F(RouterTest, RetryUpstream5xxNotComplete) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) .WillOnce(Invoke([&](Http::StreamDecoder& decoder, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { - response_decoder = &decoder; - callbacks.onPoolReady(encoder1, cm_.conn_pool_.host_); - return nullptr; - })); + response_decoder = &decoder; + callbacks.onPoolReady(encoder1, cm_.conn_pool_.host_); + return nullptr; + })); expectResponseTimerCreate(); Http::TestHeaderMapImpl headers{{"x-envoy-retry-on", "5xx"}, {"x-envoy-internal", "true"}}; @@ -692,10 +694,10 @@ TEST_F(RouterTest, RetryUpstream5xxNotComplete) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) .WillOnce(Invoke([&](Http::StreamDecoder& decoder, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { - response_decoder = &decoder; - callbacks.onPoolReady(encoder2, cm_.conn_pool_.host_); - return nullptr; - })); + response_decoder = &decoder; + callbacks.onPoolReady(encoder2, cm_.conn_pool_.host_); + return nullptr; + })); ON_CALL(callbacks_, decodingBuffer()).WillByDefault(Return(body_data.get())); EXPECT_CALL(encoder2, encodeHeaders(_, false)); EXPECT_CALL(encoder2, encodeData(_, false)); @@ -712,8 +714,9 @@ TEST_F(RouterTest, RetryUpstream5xxNotComplete) { EXPECT_EQ(1U, cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("retry.upstream_rq_503") .value()); - EXPECT_EQ(1U, cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_200") - .value()); + EXPECT_EQ( + 1U, + cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_200").value()); EXPECT_EQ(1U, cm_.thread_local_cluster_.cluster_.info_->stats_store_ .counter("zone.zone_name.to_az.upstream_rq_200") .value()); @@ -728,10 +731,10 @@ TEST_F(RouterTest, RetryUpstreamGrpcCancelled) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) .WillOnce(Invoke([&](Http::StreamDecoder& decoder, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { - response_decoder = &decoder; - callbacks.onPoolReady(encoder1, cm_.conn_pool_.host_); - return nullptr; - })); + response_decoder = &decoder; + callbacks.onPoolReady(encoder1, cm_.conn_pool_.host_); + return nullptr; + })); expectResponseTimerCreate(); Http::TestHeaderMapImpl headers{{"x-envoy-grpc-retry-on", "cancelled"}, @@ -752,10 +755,10 @@ TEST_F(RouterTest, RetryUpstreamGrpcCancelled) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) .WillOnce(Invoke([&](Http::StreamDecoder& decoder, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { - response_decoder = &decoder; - callbacks.onPoolReady(encoder2, cm_.conn_pool_.host_); - return nullptr; - })); + response_decoder = &decoder; + callbacks.onPoolReady(encoder2, cm_.conn_pool_.host_); + return nullptr; + })); router_.retry_state_->callback_(); // Normal response. @@ -775,10 +778,10 @@ TEST_F(RouterTest, Shadow) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) .WillOnce(Invoke([&](Http::StreamDecoder& decoder, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { - response_decoder = &decoder; - callbacks.onPoolReady(encoder, cm_.conn_pool_.host_); - return nullptr; - })); + response_decoder = &decoder; + callbacks.onPoolReady(encoder, cm_.conn_pool_.host_); + return nullptr; + })); expectResponseTimerCreate(); EXPECT_CALL(runtime_.snapshot_, featureEnabled("bar", 0, 43, 10000)).WillOnce(Return(true)); @@ -795,11 +798,11 @@ TEST_F(RouterTest, Shadow) { .Times(AtLeast(1)) .WillRepeatedly(Return(body_data.get())); EXPECT_CALL(*shadow_writer_, shadow_("foo", _, std::chrono::milliseconds(10))) - .WillOnce(Invoke([](const std::string&, Http::MessagePtr& request, std::chrono::milliseconds) - -> void { - EXPECT_NE(nullptr, request->body()); - EXPECT_NE(nullptr, request->trailers()); - })); + .WillOnce(Invoke( + [](const std::string&, Http::MessagePtr& request, std::chrono::milliseconds) -> void { + EXPECT_NE(nullptr, request->body()); + EXPECT_NE(nullptr, request->trailers()); + })); router_.decodeTrailers(trailers); Http::HeaderMapPtr response_headers(new Http::TestHeaderMapImpl{{":status", "200"}}); @@ -817,10 +820,10 @@ TEST_F(RouterTest, AltStatName) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) .WillOnce(Invoke([&](Http::StreamDecoder& decoder, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { - response_decoder = &decoder; - callbacks.onPoolReady(encoder, cm_.conn_pool_.host_); - return nullptr; - })); + response_decoder = &decoder; + callbacks.onPoolReady(encoder, cm_.conn_pool_.host_); + return nullptr; + })); Http::TestHeaderMapImpl headers{{"x-envoy-upstream-alt-stat-name", "alt_stat"}, {"x-envoy-internal", "true"}}; @@ -1006,10 +1009,10 @@ TEST_F(RouterTest, CanaryStatusTrue) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) .WillOnce(Invoke([&](Http::StreamDecoder& decoder, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { - response_decoder = &decoder; - callbacks.onPoolReady(encoder, cm_.conn_pool_.host_); - return nullptr; - })); + response_decoder = &decoder; + callbacks.onPoolReady(encoder, cm_.conn_pool_.host_); + return nullptr; + })); Http::TestHeaderMapImpl headers{{"x-envoy-upstream-alt-stat-name", "alt_stat"}, {"x-envoy-internal", "true"}}; @@ -1038,10 +1041,10 @@ TEST_F(RouterTest, CanaryStatusFalse) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) .WillOnce(Invoke([&](Http::StreamDecoder& decoder, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { - response_decoder = &decoder; - callbacks.onPoolReady(encoder, cm_.conn_pool_.host_); - return nullptr; - })); + response_decoder = &decoder; + callbacks.onPoolReady(encoder, cm_.conn_pool_.host_); + return nullptr; + })); Http::TestHeaderMapImpl headers{{"x-envoy-upstream-alt-stat-name", "alt_stat"}, {"x-envoy-internal", "true"}}; @@ -1078,9 +1081,9 @@ TEST_F(RouterTest, AutoHostRewriteEnabled) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) .WillOnce(Invoke([&](Http::StreamDecoder&, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { - callbacks.onPoolReady(encoder, cm_.conn_pool_.host_); - return nullptr; - })); + callbacks.onPoolReady(encoder, cm_.conn_pool_.host_); + return nullptr; + })); // :authority header in the outgoing request should match the DNS name of // the selected upstream host @@ -1090,8 +1093,9 @@ TEST_F(RouterTest, AutoHostRewriteEnabled) { })); EXPECT_CALL(callbacks_.request_info_, onUpstreamHostSelected(_)) - .WillOnce(Invoke([&](const Upstream::HostDescriptionConstSharedPtr host) - -> void { EXPECT_EQ(host_address_, host->address()); })); + .WillOnce(Invoke([&](const Upstream::HostDescriptionConstSharedPtr host) -> void { + EXPECT_EQ(host_address_, host->address()); + })); EXPECT_CALL(callbacks_.route_->route_entry_, autoHostRewrite()).WillOnce(Return(true)); router_.decodeHeaders(incoming_headers, true); } @@ -1112,9 +1116,9 @@ TEST_F(RouterTest, AutoHostRewriteDisabled) { EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) .WillOnce(Invoke([&](Http::StreamDecoder&, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { - callbacks.onPoolReady(encoder, cm_.conn_pool_.host_); - return nullptr; - })); + callbacks.onPoolReady(encoder, cm_.conn_pool_.host_); + return nullptr; + })); // :authority header in the outgoing request should match the :authority header of // the incoming request @@ -1124,11 +1128,12 @@ TEST_F(RouterTest, AutoHostRewriteDisabled) { })); EXPECT_CALL(callbacks_.request_info_, onUpstreamHostSelected(_)) - .WillOnce(Invoke([&](const Upstream::HostDescriptionConstSharedPtr host) - -> void { EXPECT_EQ(host_address_, host->address()); })); + .WillOnce(Invoke([&](const Upstream::HostDescriptionConstSharedPtr host) -> void { + EXPECT_EQ(host_address_, host->address()); + })); EXPECT_CALL(callbacks_.route_->route_entry_, autoHostRewrite()).WillOnce(Return(false)); router_.decodeHeaders(incoming_headers, true); } -} // Router -} // Envoy +} // namespace Router +} // namespace Envoy diff --git a/test/common/router/shadow_writer_impl_test.cc b/test/common/router/shadow_writer_impl_test.cc index 5288e5ae053e8..942eac5bac257 100644 --- a/test/common/router/shadow_writer_impl_test.cc +++ b/test/common/router/shadow_writer_impl_test.cc @@ -11,8 +11,8 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::Invoke; +using testing::_; namespace Router { @@ -59,5 +59,5 @@ TEST(ShadowWriterImplTest, All) { callback->onFailure(Http::AsyncClient::FailureReason::Reset); } -} // Router -} // Envoy +} // namespace Router +} // namespace Envoy diff --git a/test/common/runtime/runtime_impl_test.cc b/test/common/runtime/runtime_impl_test.cc index 06524bea6ed54..6802d3ab6d81f 100644 --- a/test/common/runtime/runtime_impl_test.cc +++ b/test/common/runtime/runtime_impl_test.cc @@ -113,5 +113,5 @@ TEST(NullRuntimeImplTest, All) { EXPECT_TRUE(loader.snapshot().featureEnabled("foo", 50)); } -} // Runtime -} // Envoy +} // namespace Runtime +} // namespace Envoy diff --git a/test/common/runtime/uuid_util_test.cc b/test/common/runtime/uuid_util_test.cc index 2bf8fe3d83006..86ef75e7f712d 100644 --- a/test/common/runtime/uuid_util_test.cc +++ b/test/common/runtime/uuid_util_test.cc @@ -82,4 +82,4 @@ TEST(UUIDUtilsTest, setAndCheckTraceable) { std::string invalid_uuid = ""; EXPECT_FALSE(UuidUtils::setTraceableUuid(invalid_uuid, UuidTraceStatus::Forced)); } -} // Envoy +} // namespace Envoy diff --git a/test/common/ssl/connection_impl_test.cc b/test/common/ssl/connection_impl_test.cc index 16e94217fcb1a..a779dd566ff6f 100644 --- a/test/common/ssl/connection_impl_test.cc +++ b/test/common/ssl/connection_impl_test.cc @@ -25,8 +25,8 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::Invoke; +using testing::_; namespace Ssl { @@ -392,5 +392,5 @@ TEST_P(SslReadBufferLimitTest, SomeLimit) { readBufferLimitTest(32 * 1024, 32 * 1024, 256 * 1024, 1, false); } -} // Ssl -} // Envoy +} // namespace Ssl +} // namespace Envoy diff --git a/test/common/ssl/context_impl_test.cc b/test/common/ssl/context_impl_test.cc index b696e06ee678a..311a76eb67498 100644 --- a/test/common/ssl/context_impl_test.cc +++ b/test/common/ssl/context_impl_test.cc @@ -168,5 +168,5 @@ TEST_F(SslContextImplTest, TestNoCert) { EXPECT_EQ("", context->getCertChainInformation()); } -} // Ssl -} // Envoy +} // namespace Ssl +} // namespace Envoy diff --git a/test/common/ssl/ssl_certs_test.h b/test/common/ssl/ssl_certs_test.h index 23a7ce3e453a0..4aee4a34986c1 100644 --- a/test/common/ssl/ssl_certs_test.h +++ b/test/common/ssl/ssl_certs_test.h @@ -11,4 +11,4 @@ class SslCertsTest : public testing::Test { TestEnvironment::exec({TestEnvironment::runfilesPath("test/common/ssl/gen_unittest_certs.sh")}); } }; -} // Envoy +} // namespace Envoy diff --git a/test/common/stats/stats_impl_test.cc b/test/common/stats/stats_impl_test.cc index 3db1fd2bfea1f..3e1695010db2c 100644 --- a/test/common/stats/stats_impl_test.cc +++ b/test/common/stats/stats_impl_test.cc @@ -35,5 +35,5 @@ TEST(StatsIsolatedStoreImplTest, All) { EXPECT_EQ(2UL, store.gauges().size()); } -} // Stats -} // Envoy +} // namespace Stats +} // namespace Envoy diff --git a/test/common/stats/statsd_test.cc b/test/common/stats/statsd_test.cc index 5a1cde2654d24..4800266b98083 100644 --- a/test/common/stats/statsd_test.cc +++ b/test/common/stats/statsd_test.cc @@ -15,10 +15,10 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::InSequence; using testing::NiceMock; using testing::Return; +using testing::_; namespace Stats { namespace Statsd { @@ -103,6 +103,6 @@ TEST_F(TcpStatsdSinkTest, Overflow) { tls_.shutdownThread(); } -} // Statsd -} // Stats -} // Envoy +} // namespace Statsd +} // namespace Stats +} // namespace Envoy diff --git a/test/common/stats/thread_local_store_test.cc b/test/common/stats/thread_local_store_test.cc index 96ec02240555e..4b6010c561756 100644 --- a/test/common/stats/thread_local_store_test.cc +++ b/test/common/stats/thread_local_store_test.cc @@ -14,11 +14,11 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::InSequence; using testing::Invoke; using testing::NiceMock; using testing::Return; +using testing::_; namespace Stats { @@ -65,12 +65,13 @@ class TestAllocator : public RawStatDataAllocator { class StatsThreadLocalStoreTest : public testing::Test, public RawStatDataAllocator { public: StatsThreadLocalStoreTest() { - ON_CALL(*this, alloc(_)) - .WillByDefault( - Invoke([this](const std::string& name) -> RawStatData* { return alloc_.alloc(name); })); + ON_CALL(*this, alloc(_)).WillByDefault(Invoke([this](const std::string& name) -> RawStatData* { + return alloc_.alloc(name); + })); - ON_CALL(*this, free(_)) - .WillByDefault(Invoke([this](RawStatData& data) -> void { return alloc_.free(data); })); + ON_CALL(*this, free(_)).WillByDefault(Invoke([this](RawStatData& data) -> void { + return alloc_.free(data); + })); EXPECT_CALL(*this, alloc("stats.overflow")); store_.reset(new ThreadLocalStoreImpl(*this)); @@ -311,5 +312,5 @@ TEST_F(StatsThreadLocalStoreTest, ShuttingDown) { EXPECT_CALL(*this, free(_)).Times(5); } -} // Stats -} // Envoy +} // namespace Stats +} // namespace Envoy diff --git a/test/common/stats/udp_statsd_test.cc b/test/common/stats/udp_statsd_test.cc index 86280239effb5..a29797d6932e5 100644 --- a/test/common/stats/udp_statsd_test.cc +++ b/test/common/stats/udp_statsd_test.cc @@ -9,8 +9,8 @@ #include "test/test_common/network_utility.h" #include "gmock/gmock.h" -#include "gtest/gtest.h" #include "spdlog/spdlog.h" +#include "gtest/gtest.h" namespace Envoy { using testing::NiceMock; @@ -47,6 +47,6 @@ TEST_P(UdpStatsdSinkTest, InitWithIpAddress) { tls_.shutdownThread(); } -} // Statsd -} // Stats -} // Envoy +} // namespace Statsd +} // namespace Stats +} // namespace Envoy diff --git a/test/common/tracing/http_tracer_impl_test.cc b/test/common/tracing/http_tracer_impl_test.cc index 70e60003a4bb5..de3646e24b346 100644 --- a/test/common/tracing/http_tracer_impl_test.cc +++ b/test/common/tracing/http_tracer_impl_test.cc @@ -24,12 +24,12 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::Invoke; using testing::NiceMock; using testing::Return; using testing::ReturnRef; using testing::Test; +using testing::_; namespace Tracing { @@ -427,5 +427,5 @@ TEST_F(HttpTracerImplTest, BasicFunctionalityNodeSet) { tracer_->startSpan(config_, request_headers_, request_info_); } -} // Tracing -} // Envoy +} // namespace Tracing +} // namespace Envoy diff --git a/test/common/tracing/lightstep_tracer_impl_test.cc b/test/common/tracing/lightstep_tracer_impl_test.cc index 2779c5ca79828..29f1a76b7351f 100644 --- a/test/common/tracing/lightstep_tracer_impl_test.cc +++ b/test/common/tracing/lightstep_tracer_impl_test.cc @@ -25,12 +25,12 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::Invoke; using testing::NiceMock; using testing::Return; using testing::ReturnRef; using testing::Test; +using testing::_; namespace Tracing { @@ -328,5 +328,5 @@ TEST_F(LightStepDriverTest, SpawnChild) { EXPECT_FALSE(base2_context.empty()); } -} // Tracing -} // Envoy +} // namespace Tracing +} // namespace Envoy diff --git a/test/common/tracing/zipkin/span_buffer_test.cc b/test/common/tracing/zipkin/span_buffer_test.cc index c37e23b941a9c..8b903757a2392 100644 --- a/test/common/tracing/zipkin/span_buffer_test.cc +++ b/test/common/tracing/zipkin/span_buffer_test.cc @@ -101,5 +101,5 @@ TEST(ZipkinSpanBufferTest, sizeConstructorEndtoEnd) { EXPECT_EQ(0ULL, buffer.pendingSpans()); EXPECT_EQ("[]", buffer.toStringifiedJsonArray()); } -} // Zipkin -} // Envoy +} // namespace Zipkin +} // namespace Envoy diff --git a/test/common/tracing/zipkin/span_context_test.cc b/test/common/tracing/zipkin/span_context_test.cc index b25906c59f198..25f2acf48741a 100644 --- a/test/common/tracing/zipkin/span_context_test.cc +++ b/test/common/tracing/zipkin/span_context_test.cc @@ -233,5 +233,5 @@ TEST(ZipkinSpanContextTest, populateFromSpan) { EXPECT_EQ("25c6f38dd0600e78;56707c7b3e1092af;c49193ea42335d1c;cr;cs;sr;ss", span_context_6.serializeToString()); } -} // Zipkin -} // Envoy +} // namespace Zipkin +} // namespace Envoy diff --git a/test/common/tracing/zipkin/tracer_test.cc b/test/common/tracing/zipkin/tracer_test.cc index 81752f03e421e..0ac347c953779 100644 --- a/test/common/tracing/zipkin/tracer_test.cc +++ b/test/common/tracing/zipkin/tracer_test.cc @@ -12,8 +12,8 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -using testing::Return; using testing::NiceMock; +using testing::Return; namespace Envoy { namespace Zipkin { @@ -285,5 +285,5 @@ TEST(ZipkinTracerTest, finishSpan) { endpoint = ann.endpoint(); EXPECT_EQ("my_service_name", endpoint.serviceName()); } -} // Zipkin -} // Envoy +} // namespace Zipkin +} // namespace Envoy diff --git a/test/common/tracing/zipkin/util_test.cc b/test/common/tracing/zipkin/util_test.cc index 2fbf760fbf7d6..c2712ba55569a 100644 --- a/test/common/tracing/zipkin/util_test.cc +++ b/test/common/tracing/zipkin/util_test.cc @@ -38,5 +38,5 @@ TEST(ZipkinUtilTest, utilTests) { "\"val1\"}},\"array_field\":[],\"second_array\":[{\"a1\":10},{\"a2\":\"10\"}]}"; EXPECT_EQ(expected_json, merged_json); } -} // Zipkin -} // Envoy +} // namespace Zipkin +} // namespace Envoy diff --git a/test/common/tracing/zipkin/zipkin_core_types_test.cc b/test/common/tracing/zipkin/zipkin_core_types_test.cc index d70070128ab5b..416dc7a1b4cc8 100644 --- a/test/common/tracing/zipkin/zipkin_core_types_test.cc +++ b/test/common/tracing/zipkin/zipkin_core_types_test.cc @@ -83,9 +83,9 @@ TEST(ZipkinCoreTypesAnnotationTest, defaultConstructor) { EXPECT_EQ("", ann.value()); EXPECT_FALSE(ann.isSetEndpoint()); - uint64_t timestamp = - std::chrono::duration_cast( - ProdSystemTimeSource::instance_.currentTime().time_since_epoch()).count(); + uint64_t timestamp = std::chrono::duration_cast( + ProdSystemTimeSource::instance_.currentTime().time_since_epoch()) + .count(); ann.setTimestamp(timestamp); EXPECT_EQ(timestamp, ann.timestamp()); @@ -141,9 +141,9 @@ TEST(ZipkinCoreTypesAnnotationTest, customConstructor) { Network::Address::InstanceConstSharedPtr addr = Network::Utility::parseInternetAddressAndPort("127.0.0.1:3306"); Endpoint ep(std::string("my_service"), addr); - uint64_t timestamp = - std::chrono::duration_cast( - ProdSystemTimeSource::instance_.currentTime().time_since_epoch()).count(); + uint64_t timestamp = std::chrono::duration_cast( + ProdSystemTimeSource::instance_.currentTime().time_since_epoch()) + .count(); Annotation ann(timestamp, ZipkinCoreConstants::get().CLIENT_SEND, ep); EXPECT_EQ(timestamp, ann.timestamp()); @@ -165,9 +165,9 @@ TEST(ZipkinCoreTypesAnnotationTest, copyConstructor) { Network::Address::InstanceConstSharedPtr addr = Network::Utility::parseInternetAddressAndPort("127.0.0.1:3306"); Endpoint ep(std::string("my_service"), addr); - uint64_t timestamp = - std::chrono::duration_cast( - ProdSystemTimeSource::instance_.currentTime().time_since_epoch()).count(); + uint64_t timestamp = std::chrono::duration_cast( + ProdSystemTimeSource::instance_.currentTime().time_since_epoch()) + .count(); Annotation ann(timestamp, ZipkinCoreConstants::get().CLIENT_SEND, ep); Annotation ann2(ann); @@ -182,9 +182,9 @@ TEST(ZipkinCoreTypesAnnotationTest, assignmentOperator) { Network::Address::InstanceConstSharedPtr addr = Network::Utility::parseInternetAddressAndPort("127.0.0.1:3306"); Endpoint ep(std::string("my_service"), addr); - uint64_t timestamp = - std::chrono::duration_cast( - ProdSystemTimeSource::instance_.currentTime().time_since_epoch()).count(); + uint64_t timestamp = std::chrono::duration_cast( + ProdSystemTimeSource::instance_.currentTime().time_since_epoch()) + .count(); Annotation ann(timestamp, ZipkinCoreConstants::get().CLIENT_SEND, ep); Annotation ann2 = ann; @@ -326,14 +326,15 @@ TEST(ZipkinCoreTypesSpanTest, defaultConstructor) { EXPECT_TRUE(span.isSetTraceIdHigh()); int64_t timestamp = std::chrono::duration_cast( - ProdSystemTimeSource::instance_.currentTime().time_since_epoch()).count(); + ProdSystemTimeSource::instance_.currentTime().time_since_epoch()) + .count(); span.setTimestamp(timestamp); EXPECT_EQ(timestamp, span.timestamp()); EXPECT_TRUE(span.isSetTimestamp()); - int64_t start_time = - std::chrono::duration_cast( - ProdMonotonicTimeSource::instance_.currentTime().time_since_epoch()).count(); + int64_t start_time = std::chrono::duration_cast( + ProdMonotonicTimeSource::instance_.currentTime().time_since_epoch()) + .count(); span.setStartTime(start_time); EXPECT_EQ(start_time, span.startTime()); @@ -377,9 +378,10 @@ TEST(ZipkinCoreTypesSpanTest, defaultConstructor) { EXPECT_EQ( R"({"traceId":")" + span.traceIdAsHexString() + R"(","name":"span_name","id":")" + span.idAsHexString() + R"(","parentId":")" + span.parentIdAsHexString() + - R"(","timestamp":)" + std::to_string(span.timestamp()) + R"(,"duration":3000,)" - R"("annotations":[)" - R"({"timestamp":)" + + R"(","timestamp":)" + std::to_string(span.timestamp()) + + R"(,"duration":3000,)" + R"("annotations":[)" + R"({"timestamp":)" + std::to_string(span.timestamp()) + R"(,"value":"cs","endpoint":)" R"({"ipv4":"192.168.1.2","port":3306,"serviceName":"my_service_name"}}],)" @@ -411,17 +413,19 @@ TEST(ZipkinCoreTypesSpanTest, defaultConstructor) { EXPECT_EQ(R"({"traceId":")" + span.traceIdAsHexString() + R"(","name":"span_name","id":")" + span.idAsHexString() + R"(","parentId":")" + span.parentIdAsHexString() + - R"(","timestamp":)" + std::to_string(span.timestamp()) + R"(,"duration":3000,)" - R"("annotations":[)" - R"({"timestamp":)" + + R"(","timestamp":)" + std::to_string(span.timestamp()) + + R"(,"duration":3000,)" + R"("annotations":[)" + R"({"timestamp":)" + std::to_string(timestamp) + R"(,"value":"cs","endpoint":)" R"({"ipv4":"192.168.1.2","port":3306,"serviceName":"my_service_name"}},)" R"({"timestamp":)" + - std::to_string(timestamp) + R"(,"value":"ss",)" - R"("endpoint":{"ipv4":"192.168.1.2","port":3306,)" - R"("serviceName":"my_service_name"}},)" - R"({"timestamp":)" + + std::to_string(timestamp) + + R"(,"value":"ss",)" + R"("endpoint":{"ipv4":"192.168.1.2","port":3306,)" + R"("serviceName":"my_service_name"}},)" + R"({"timestamp":)" + std::to_string(timestamp) + R"(,"value":"sr","endpoint":{"ipv4":"192.168.1.2","port":3306,)" R"("serviceName":"my_service_name"}}],)" @@ -443,17 +447,19 @@ TEST(ZipkinCoreTypesSpanTest, defaultConstructor) { span.setServiceName("NEW_SERVICE_NAME"); EXPECT_EQ(R"({"traceId":")" + span.traceIdAsHexString() + R"(","name":"span_name","id":")" + span.idAsHexString() + R"(","parentId":")" + span.parentIdAsHexString() + - R"(","timestamp":)" + std::to_string(span.timestamp()) + R"(,"duration":3000,)" - R"("annotations":[)" - R"({"timestamp":)" + + R"(","timestamp":)" + std::to_string(span.timestamp()) + + R"(,"duration":3000,)" + R"("annotations":[)" + R"({"timestamp":)" + std::to_string(timestamp) + R"(,"value":"cs","endpoint":)" R"({"ipv4":"192.168.1.2","port":3306,"serviceName":"NEW_SERVICE_NAME"}},)" R"({"timestamp":)" + - std::to_string(timestamp) + R"(,"value":"ss",)" - R"("endpoint":{"ipv4":"192.168.1.2","port":3306,)" - R"("serviceName":"NEW_SERVICE_NAME"}},)" - R"({"timestamp":)" + + std::to_string(timestamp) + + R"(,"value":"ss",)" + R"("endpoint":{"ipv4":"192.168.1.2","port":3306,)" + R"("serviceName":"NEW_SERVICE_NAME"}},)" + R"({"timestamp":)" + std::to_string(timestamp) + R"(,"value":"sr","endpoint":{"ipv4":"192.168.1.2","port":3306,)" R"("serviceName":"NEW_SERVICE_NAME"}},)" @@ -482,7 +488,8 @@ TEST(ZipkinCoreTypesSpanTest, copyConstructor) { span.setParentId(id); span.setTraceId(id); int64_t timestamp = std::chrono::duration_cast( - ProdSystemTimeSource::instance_.currentTime().time_since_epoch()).count(); + ProdSystemTimeSource::instance_.currentTime().time_since_epoch()) + .count(); span.setTimestamp(timestamp); span.setDuration(3000LL); span.setName("span_name"); @@ -517,7 +524,8 @@ TEST(ZipkinCoreTypesSpanTest, assignmentOperator) { span.setParentId(id); span.setTraceId(id); int64_t timestamp = std::chrono::duration_cast( - ProdSystemTimeSource::instance_.currentTime().time_since_epoch()).count(); + ProdSystemTimeSource::instance_.currentTime().time_since_epoch()) + .count(); span.setTimestamp(timestamp); span.setDuration(3000LL); span.setName("span_name"); @@ -559,5 +567,5 @@ TEST(ZipkinCoreTypesSpanTest, setTag) { EXPECT_EQ("key2", bann.key()); EXPECT_EQ("value2", bann.value()); } -} // Zipkin -} // Envoy +} // namespace Zipkin +} // namespace Envoy diff --git a/test/common/tracing/zipkin/zipkin_tracer_impl_test.cc b/test/common/tracing/zipkin/zipkin_tracer_impl_test.cc index a0969db26c1d5..767d64a1b29cf 100644 --- a/test/common/tracing/zipkin/zipkin_tracer_impl_test.cc +++ b/test/common/tracing/zipkin/zipkin_tracer_impl_test.cc @@ -23,12 +23,12 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -using testing::_; using testing::Invoke; using testing::NiceMock; using testing::Return; using testing::ReturnRef; using testing::Test; +using testing::_; namespace Envoy { namespace Zipkin { @@ -325,5 +325,5 @@ TEST_F(ZipkinDriverTest, ZipkinSpanTest) { zipkin_span2->setTag("key", "value"); EXPECT_EQ(0ULL, zipkin_zipkin_span2.binaryAnnotations().size()); } -} // Zipkin -} // Envoy +} // namespace Zipkin +} // namespace Envoy diff --git a/test/common/upstream/cds_api_impl_test.cc b/test/common/upstream/cds_api_impl_test.cc index 283d36bdd9c09..a91f3d63ff64a 100644 --- a/test/common/upstream/cds_api_impl_test.cc +++ b/test/common/upstream/cds_api_impl_test.cc @@ -15,11 +15,11 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::InSequence; using testing::Invoke; using testing::Return; using testing::ReturnRef; +using testing::_; namespace Upstream { @@ -217,5 +217,5 @@ TEST_F(CdsApiImplTest, FailureArray) { EXPECT_EQ(1UL, store_.counter("cluster_manager.cds.update_failure").value()); } -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/test/common/upstream/cluster_manager_impl_test.cc b/test/common/upstream/cluster_manager_impl_test.cc index cf3fe2dfac217..f7a1b39a010b5 100644 --- a/test/common/upstream/cluster_manager_impl_test.cc +++ b/test/common/upstream/cluster_manager_impl_test.cc @@ -22,15 +22,15 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::InSequence; using testing::Invoke; using testing::NiceMock; using testing::Pointee; using testing::Return; -using testing::ReturnRef; using testing::ReturnNew; +using testing::ReturnRef; using testing::SaveArg; +using testing::_; namespace Upstream { @@ -48,7 +48,8 @@ class TestClusterManagerFactory : public ClusterManagerFactory { Optional eds_config; return ClusterImplBase::create(cluster, cm, stats_, tls_, dns_resolver_, ssl_context_manager_, runtime_, random_, dispatcher_, - eds_config, local_info_, outlier_event_logger).release(); + eds_config, local_info_, outlier_event_logger) + .release(); })); } @@ -349,8 +350,9 @@ TEST_F(ClusterManagerImplTest, TcpHealthChecker) { Json::ObjectSharedPtr loader = Json::Factory::loadFromString(json); Network::MockClientConnection* connection = new NiceMock(); - EXPECT_CALL(factory_.dispatcher_, createClientConnection_(PointeesEq(Network::Utility::resolveUrl( - "tcp://127.0.0.1:11001")))).WillOnce(Return(connection)); + EXPECT_CALL(factory_.dispatcher_, createClientConnection_(PointeesEq( + Network::Utility::resolveUrl("tcp://127.0.0.1:11001")))) + .WillOnce(Return(connection)); create(*loader); factory_.tls_.shutdownThread(); } @@ -875,13 +877,14 @@ TEST(ClusterManagerInitHelper, RemoveClusterWithinInitLoop) { // Set up the scenario seen in Issue 903 where initialize() ultimately results // in the removeCluster() call. In the real bug this was a long and complex call // chain. - EXPECT_CALL(cluster, initialize()) - .WillOnce(Invoke([&]() -> void { init_helper.removeCluster(cluster); })); + EXPECT_CALL(cluster, initialize()).WillOnce(Invoke([&]() -> void { + init_helper.removeCluster(cluster); + })); // Now call onStaticLoadComplete which will exercise maybeFinishInitialize() // which calls initialize() on the members of the secondary init list. init_helper.onStaticLoadComplete(); } -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/test/common/upstream/eds_test.cc b/test/common/upstream/eds_test.cc index 89917b2dd1e1c..2551f5972e126 100644 --- a/test/common/upstream/eds_test.cc +++ b/test/common/upstream/eds_test.cc @@ -91,5 +91,5 @@ TEST_F(EdsTest, OnSuccessConfigUpdate) { EXPECT_TRUE(initialized); } -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/test/common/upstream/health_checker_impl_test.cc b/test/common/upstream/health_checker_impl_test.cc index a87ec9aae3259..02b562471321d 100644 --- a/test/common/upstream/health_checker_impl_test.cc +++ b/test/common/upstream/health_checker_impl_test.cc @@ -22,7 +22,6 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::DoAll; using testing::InSequence; using testing::Invoke; @@ -32,6 +31,7 @@ using testing::Return; using testing::ReturnRef; using testing::SaveArg; using testing::WithArg; +using testing::_; namespace Upstream { @@ -102,8 +102,9 @@ class HttpHealthCheckerImplTest : public testing::Test { Json::ObjectSharedPtr config = Json::Factory::loadFromString(json); health_checker_.reset( new TestHttpHealthCheckerImpl(*cluster_, *config, dispatcher_, runtime_, random_)); - health_checker_->addHostCheckCompleteCb([this](HostSharedPtr host, bool changed_state) - -> void { onHostStatus(host, changed_state); }); + health_checker_->addHostCheckCompleteCb([this](HostSharedPtr host, bool changed_state) -> void { + onHostStatus(host, changed_state); + }); } void setupServiceValidationHC() { @@ -123,8 +124,9 @@ class HttpHealthCheckerImplTest : public testing::Test { Json::ObjectSharedPtr config = Json::Factory::loadFromString(json); health_checker_.reset( new TestHttpHealthCheckerImpl(*cluster_, *config, dispatcher_, runtime_, random_)); - health_checker_->addHostCheckCompleteCb([this](HostSharedPtr host, bool changed_state) - -> void { onHostStatus(host, changed_state); }); + health_checker_->addHostCheckCompleteCb([this](HostSharedPtr host, bool changed_state) -> void { + onHostStatus(host, changed_state); + }); } void expectSessionCreate() { @@ -963,5 +965,5 @@ TEST_F(RedisHealthCheckerImplTest, All) { EXPECT_EQ(2UL, cluster_->info_->stats_store_.counter("health_check.network_failure").value()); } -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/test/common/upstream/host_utility_test.cc b/test/common/upstream/host_utility_test.cc index f8239797c9c0c..6984b0380e193 100644 --- a/test/common/upstream/host_utility_test.cc +++ b/test/common/upstream/host_utility_test.cc @@ -24,5 +24,5 @@ TEST(HostUtilityTest, All) { EXPECT_EQ("/failed_outlier_check", HostUtility::healthFlagsToString(host)); } -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/test/common/upstream/load_balancer_impl_test.cc b/test/common/upstream/load_balancer_impl_test.cc index 6538383fceb11..0fa4db70c6754 100644 --- a/test/common/upstream/load_balancer_impl_test.cc +++ b/test/common/upstream/load_balancer_impl_test.cc @@ -560,5 +560,5 @@ TEST_F(RandomLoadBalancerTest, Normal) { EXPECT_EQ(cluster_.healthy_hosts_[1], lb_.chooseHost(nullptr)); } -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/test/common/upstream/load_balancer_simulation_test.cc b/test/common/upstream/load_balancer_simulation_test.cc index a246f205b292a..f9422d8c414a2 100644 --- a/test/common/upstream/load_balancer_simulation_test.cc +++ b/test/common/upstream/load_balancer_simulation_test.cc @@ -11,8 +11,8 @@ #include "test/mocks/upstream/mocks.h" #include "gmock/gmock.h" -#include "gtest/gtest.h" #include "spdlog/spdlog.h" +#include "gtest/gtest.h" namespace Envoy { using testing::NiceMock; @@ -103,7 +103,8 @@ class DISABLED_SimulationTest : public testing::Test { for (const auto& host_hit_num_pair : hits) { double percent_diff = std::abs((mean - host_hit_num_pair.second) / mean) * 100; std::cout << fmt::format("url:{}, hits:{}, {} % from mean", host_hit_num_pair.first, - host_hit_num_pair.second, percent_diff) << std::endl; + host_hit_num_pair.second, percent_diff) + << std::endl; } } @@ -189,5 +190,5 @@ TEST_F(DISABLED_SimulationTest, unequalZoneDistribution6) { run({3U, 2U, 5U}, {3U, 4U, 5U}, {3U, 4U, 5U}); } -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/test/common/upstream/logical_dns_cluster_test.cc b/test/common/upstream/logical_dns_cluster_test.cc index 9462ccb075fda..00bb73fd41ebd 100644 --- a/test/common/upstream/logical_dns_cluster_test.cc +++ b/test/common/upstream/logical_dns_cluster_test.cc @@ -18,9 +18,9 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::Invoke; using testing::NiceMock; +using testing::_; namespace Upstream { @@ -32,8 +32,9 @@ class LogicalDnsClusterTest : public testing::Test { cluster_.reset(new LogicalDnsCluster(*config, runtime_, stats_store_, ssl_context_manager_, dns_resolver_, tls_, dispatcher_)); cluster_->addMemberUpdateCb( - [&](const std::vector&, const std::vector&) - -> void { membership_updated_.ready(); }); + [&](const std::vector&, const std::vector&) -> void { + membership_updated_.ready(); + }); cluster_->setInitializedCb([&]() -> void { initialized_.ready(); }); } @@ -231,5 +232,5 @@ TEST_F(LogicalDnsClusterTest, Basic) { tls_.shutdownThread(); } -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/test/common/upstream/outlier_detection_impl_test.cc b/test/common/upstream/outlier_detection_impl_test.cc index a809469c09d19..77ffa5e3f852d 100644 --- a/test/common/upstream/outlier_detection_impl_test.cc +++ b/test/common/upstream/outlier_detection_impl_test.cc @@ -20,11 +20,11 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::NiceMock; using testing::Return; using testing::ReturnRef; using testing::SaveArg; +using testing::_; namespace Upstream { namespace Outlier { @@ -229,8 +229,9 @@ TEST_F(OutlierDetectorImplTest, BasicFlow5xx) { EXPECT_EQ(0UL, cluster_.info_->stats_store_.gauge("outlier_detection.ejections_active").value()); EXPECT_EQ(2UL, cluster_.info_->stats_store_.counter("outlier_detection.ejections_total").value()); - EXPECT_EQ(2UL, cluster_.info_->stats_store_.counter("outlier_detection.ejections_consecutive_5xx") - .value()); + EXPECT_EQ( + 2UL, + cluster_.info_->stats_store_.counter("outlier_detection.ejections_consecutive_5xx").value()); } TEST_F(OutlierDetectorImplTest, BasicFlowSuccessRate) { @@ -257,7 +258,8 @@ TEST_F(OutlierDetectorImplTest, BasicFlowSuccessRate) { // Expect non-enforcing logging EXPECT_CALL(*event_logger_, logEject(std::static_pointer_cast(cluster_.hosts_[4]), _, - EjectionType::Consecutive5xx, false)).Times(2); + EjectionType::Consecutive5xx, false)) + .Times(2); // Cause a consecutive SR error on one host. First have 4 of the hosts have perfect SR. loadRq(cluster_.hosts_, 200, 200); @@ -401,8 +403,9 @@ TEST_F(OutlierDetectorImplTest, NotEnforcing) { EXPECT_EQ(0UL, cluster_.info_->stats_store_.gauge("outlier_detection.ejections_active").value()); EXPECT_EQ(1UL, cluster_.info_->stats_store_.counter("outlier_detection.ejections_total").value()); - EXPECT_EQ(1UL, cluster_.info_->stats_store_.counter("outlier_detection.ejections_consecutive_5xx") - .value()); + EXPECT_EQ( + 1UL, + cluster_.info_->stats_store_.counter("outlier_detection.ejections_consecutive_5xx").value()); } TEST_F(OutlierDetectorImplTest, CrossThreadRemoveRace) { @@ -537,7 +540,8 @@ TEST(OutlierDetectionEventLoggerImplTest, All) { "\"-1\", \"cluster\": " "\"fake_cluster\", \"upstream_url\": \"10.0.0.1:443\", \"action\": " "\"eject\", \"type\": \"5xx\", \"num_ejections\": \"0\", " - "\"enforced\": \"true\"}\n")).WillOnce(SaveArg<0>(&log1)); + "\"enforced\": \"true\"}\n")) + .WillOnce(SaveArg<0>(&log1)); event_logger.logEject(host, detector, EjectionType::Consecutive5xx, true); Json::Factory::loadFromString(log1); @@ -546,7 +550,8 @@ TEST(OutlierDetectionEventLoggerImplTest, All) { EXPECT_CALL(*file, write("{\"time\": \"1970-01-01T00:00:00.000Z\", \"secs_since_last_action\": " "\"-1\", \"cluster\": \"fake_cluster\", " "\"upstream_url\": \"10.0.0.1:443\", \"action\": \"uneject\", " - "\"num_ejections\": 0}\n")).WillOnce(SaveArg<0>(&log2)); + "\"num_ejections\": 0}\n")) + .WillOnce(SaveArg<0>(&log2)); event_logger.logUneject(host); Json::Factory::loadFromString(log2); @@ -566,7 +571,8 @@ TEST(OutlierDetectionEventLoggerImplTest, All) { "\"enforced\": \"false\", " "\"host_success_rate\": \"-1\", \"cluster_average_success_rate\": " "\"-1\", \"cluster_success_rate_ejection_threshold\": \"-1\"" - "}\n")).WillOnce(SaveArg<0>(&log3)); + "}\n")) + .WillOnce(SaveArg<0>(&log3)); event_logger.logEject(host, detector, EjectionType::SuccessRate, false); Json::Factory::loadFromString(log3); @@ -575,7 +581,8 @@ TEST(OutlierDetectionEventLoggerImplTest, All) { EXPECT_CALL(*file, write("{\"time\": \"1970-01-01T00:00:00.000Z\", \"secs_since_last_action\": " "\"30\", \"cluster\": \"fake_cluster\", " "\"upstream_url\": \"10.0.0.1:443\", \"action\": \"uneject\", " - "\"num_ejections\": 0}\n")).WillOnce(SaveArg<0>(&log4)); + "\"num_ejections\": 0}\n")) + .WillOnce(SaveArg<0>(&log4)); event_logger.logUneject(host); Json::Factory::loadFromString(log4); } @@ -593,6 +600,6 @@ TEST(OutlierUtility, SRThreshold) { EXPECT_EQ(90.0, ejection_pair.success_rate_average_); } -} // Outlier -} // Upstream -} // Envoy +} // namespace Outlier +} // namespace Upstream +} // namespace Envoy diff --git a/test/common/upstream/resource_manager_impl_test.cc b/test/common/upstream/resource_manager_impl_test.cc index 97c0728e13890..a4fc743690d33 100644 --- a/test/common/upstream/resource_manager_impl_test.cc +++ b/test/common/upstream/resource_manager_impl_test.cc @@ -47,5 +47,5 @@ TEST(ResourceManagerImplTest, RuntimeResourceManager) { EXPECT_FALSE(resource_manager.retries().canCreate()); } -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/test/common/upstream/ring_hash_lb_test.cc b/test/common/upstream/ring_hash_lb_test.cc index fa27d9920a698..b2b4f07553938 100644 --- a/test/common/upstream/ring_hash_lb_test.cc +++ b/test/common/upstream/ring_hash_lb_test.cc @@ -12,9 +12,9 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::NiceMock; using testing::Return; +using testing::_; namespace Upstream { @@ -140,5 +140,5 @@ TEST_F(RingHashLoadBalancerTest, UnevenHosts) { } } -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/test/common/upstream/sds_test.cc b/test/common/upstream/sds_test.cc index cfaeda8e7dd12..c11c1ad14763f 100644 --- a/test/common/upstream/sds_test.cc +++ b/test/common/upstream/sds_test.cc @@ -25,13 +25,13 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::DoAll; using testing::Invoke; using testing::NiceMock; using testing::Return; using testing::SaveArg; using testing::WithArg; +using testing::_; namespace Upstream { @@ -133,8 +133,9 @@ TEST_F(SdsTest, NoHealthChecker) { EXPECT_CALL(membership_updated_, ready()).Times(3); cluster_->addMemberUpdateCb( - [&](const std::vector&, const std::vector&) - -> void { membership_updated_.ready(); }); + [&](const std::vector&, const std::vector&) -> void { + membership_updated_.ready(); + }); cluster_->setInitializedCb([&]() -> void { membership_updated_.ready(); }); Http::MessagePtr message(new Http::ResponseMessageImpl( @@ -364,5 +365,5 @@ TEST_F(SdsTest, FailureArray) { EXPECT_EQ(1UL, cluster_->info()->stats().update_failure_.value()); } -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/test/common/upstream/upstream_impl_test.cc b/test/common/upstream/upstream_impl_test.cc index 35ae0c3f44560..2e79bf25a5f12 100644 --- a/test/common/upstream/upstream_impl_test.cc +++ b/test/common/upstream/upstream_impl_test.cc @@ -26,10 +26,10 @@ namespace Envoy { -using testing::_; using testing::ContainerEq; using testing::Invoke; using testing::NiceMock; +using testing::_; namespace Upstream { @@ -195,8 +195,9 @@ TEST(StrictDnsClusterImplTest, Basic) { ReadyWatcher membership_updated; cluster.addMemberUpdateCb( - [&](const std::vector&, const std::vector&) - -> void { membership_updated.ready(); }); + [&](const std::vector&, const std::vector&) -> void { + membership_updated.ready(); + }); resolver1.expectResolve(*dns_resolver); EXPECT_CALL(*resolver1.timer_, enableTimer(std::chrono::milliseconds(4000))); @@ -528,5 +529,5 @@ TEST(ClusterDefinitionTest, BadDnsClusterConfig) { EXPECT_THROW(loader->validateSchema(Json::Schema::CLUSTER_SCHEMA), Json::Exception); } -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/test/config_test/config_test.cc b/test/config_test/config_test.cc index 93290d1e51b35..3428b26c0867b 100644 --- a/test/config_test/config_test.cc +++ b/test/config_test/config_test.cc @@ -9,14 +9,14 @@ #include "test/test_common/utility.h" #include "gmock/gmock.h" -#include "gtest/gtest.h" #include "spdlog/spdlog.h" +#include "gtest/gtest.h" -using testing::_; using testing::Invoke; using testing::NiceMock; using testing::Return; using testing::ReturnRef; +using testing::_; namespace Envoy { namespace ConfigTest { @@ -37,18 +37,17 @@ class ConfigTest { Server::Configuration::InitialImpl initial_config(*config_json); Server::Configuration::MainImpl main_config; - ON_CALL(server_, clusterManager()) - .WillByDefault( - Invoke([&]() -> Upstream::ClusterManager& { return main_config.clusterManager(); })); + ON_CALL(server_, clusterManager()).WillByDefault(Invoke([&]() -> Upstream::ClusterManager& { + return main_config.clusterManager(); + })); ON_CALL(server_, listenerManager()).WillByDefault(ReturnRef(listener_manager_)); ON_CALL(component_factory_, createFilterFactoryList(_, _)) - .WillByDefault( - Invoke([&](const std::vector& filters, - Server::Configuration::FactoryContext& context) - -> std::vector { - return Server::ProdListenerComponentFactory::createFilterFactoryList_( - filters, server_, context); - })); + .WillByDefault(Invoke([&](const std::vector& filters, + Server::Configuration::FactoryContext& context) + -> std::vector { + return Server::ProdListenerComponentFactory::createFilterFactoryList_(filters, server_, + context); + })); try { main_config.initialize(*config_json, server_, cluster_manager_factory_); @@ -77,5 +76,5 @@ uint32_t run(const std::string& directory) { return num_tested; } -} // ConfigTest -} // Envoy +} // namespace ConfigTest +} // namespace Envoy diff --git a/test/config_test/config_test.h b/test/config_test/config_test.h index c13c4291c86b1..876f8d65fe7e8 100644 --- a/test/config_test/config_test.h +++ b/test/config_test/config_test.h @@ -13,5 +13,5 @@ namespace ConfigTest { */ uint32_t run(const std::string& path); -} // ConfigTest -} // Envoy +} // namespace ConfigTest +} // namespace Envoy diff --git a/test/config_test/example_configs_test.cc b/test/config_test/example_configs_test.cc index 72de448954595..a487c8cce4532 100644 --- a/test/config_test/example_configs_test.cc +++ b/test/config_test/example_configs_test.cc @@ -10,4 +10,4 @@ TEST(ExampleConfigsTest, All) { {TestEnvironment::runfilesPath("test/config_test/example_configs_test_setup.sh")}); EXPECT_EQ(11UL, ConfigTest::run(TestEnvironment::temporaryDirectory() + "/test/config_test")); } -} // Envoy +} // namespace Envoy diff --git a/test/coverage/gcc_only_test/gcc_only_test.cc b/test/coverage/gcc_only_test/gcc_only_test.cc index 44e38a0d5536e..31346323d20e4 100644 --- a/test/coverage/gcc_only_test/gcc_only_test.cc +++ b/test/coverage/gcc_only_test/gcc_only_test.cc @@ -9,4 +9,4 @@ TEST(GccOnly, CompilerCheck) { #endif } -} // Envoy +} // namespace Envoy diff --git a/test/exe/signals_test.cc b/test/exe/signals_test.cc index aa46d72b7e4e6..6c8816dad5c2c 100644 --- a/test/exe/signals_test.cc +++ b/test/exe/signals_test.cc @@ -23,44 +23,52 @@ namespace Envoy { #ifndef ASANITIZED TEST(Signals, InvalidAddressDeathTest) { SignalAction actions; - EXPECT_DEATH([]() -> void { - // Oooooops! - volatile int* nasty_ptr = reinterpret_cast(0x0); - *(nasty_ptr) = 0; - }(), "backtrace.*Segmentation fault"); + EXPECT_DEATH( + []() -> void { + // Oooooops! + volatile int* nasty_ptr = reinterpret_cast(0x0); + *(nasty_ptr) = 0; + }(), + "backtrace.*Segmentation fault"); } TEST(Signals, BusDeathTest) { SignalAction actions; - EXPECT_DEATH([]() -> void { - // Bus error is tricky. There's one way that can work on POSIX systems - // described below but it depends on mmaping a file. Just make it easy and - // raise a bus. - // - // FILE *f = tmpfile(); - // int *p = mmap(0, 4, PROT_WRITE, MAP_PRIVATE, fileno(f), 0); - // *p = 0; - raise(SIGBUS); - }(), "backtrace.*Bus"); + EXPECT_DEATH( + []() -> void { + // Bus error is tricky. There's one way that can work on POSIX systems + // described below but it depends on mmaping a file. Just make it easy and + // raise a bus. + // + // FILE *f = tmpfile(); + // int *p = mmap(0, 4, PROT_WRITE, MAP_PRIVATE, fileno(f), 0); + // *p = 0; + raise(SIGBUS); + }(), + "backtrace.*Bus"); } TEST(Signals, BadMathDeathTest) { SignalAction actions; - EXPECT_DEATH([]() -> void { - // It turns out to be really hard to not have the optimizer get rid of a - // division by zero. Just raise the signal for this test. - raise(SIGFPE); - }(), "backtrace.*Floating point"); + EXPECT_DEATH( + []() -> void { + // It turns out to be really hard to not have the optimizer get rid of a + // division by zero. Just raise the signal for this test. + raise(SIGFPE); + }(), + "backtrace.*Floating point"); } #if defined(__x86_64__) || defined(__i386__) // Unfortunately we don't have a reliable way to do this on other platforms TEST(Signals, IllegalInstructionDeathTest) { SignalAction actions; - EXPECT_DEATH([]() -> void { - // Intel defines the "ud2" opcode to be an invalid instruction: - __asm__("ud2"); - }(), "backtrace.*Illegal"); + EXPECT_DEATH( + []() -> void { + // Intel defines the "ud2" opcode to be an invalid instruction: + __asm__("ud2"); + }(), + "backtrace.*Illegal"); } #endif diff --git a/test/integration/echo_integration_test.cc b/test/integration/echo_integration_test.cc index 01ce5b9c004dc..e38ef12e62c49 100644 --- a/test/integration/echo_integration_test.cc +++ b/test/integration/echo_integration_test.cc @@ -7,8 +7,8 @@ class EchoIntegrationTest : public BaseIntegrationTest, public: EchoIntegrationTest() : BaseIntegrationTest(GetParam()) {} /** - * Initializer for an individual test. - */ + * Initializer for an individual test. + */ void SetUp() override { fake_upstreams_.emplace_back(new FakeUpstream(0, FakeHttpConnection::Type::HTTP1, version_)); registerPort("upstream_0", fake_upstreams_.back()->localAddress()->ip()->port()); @@ -33,13 +33,14 @@ TEST_P(EchoIntegrationTest, Hello) { Buffer::OwnedImpl buffer("hello"); std::string response; RawConnectionDriver connection( - lookupPort("echo"), - buffer, [&](Network::ClientConnection&, const Buffer::Instance& data) -> void { + lookupPort("echo"), buffer, + [&](Network::ClientConnection&, const Buffer::Instance& data) -> void { response.append(TestUtility::bufferToString(data)); connection.close(); - }, version_); + }, + version_); connection.run(); EXPECT_EQ("hello", response); } -} // Envoy +} // namespace Envoy diff --git a/test/integration/fake_upstream.cc b/test/integration/fake_upstream.cc index 530c90e15310e..a27876511d2d4 100644 --- a/test/integration/fake_upstream.cc +++ b/test/integration/fake_upstream.cc @@ -72,8 +72,8 @@ void FakeStream::encodeData(Buffer::Instance& data, bool end_stream) { void FakeStream::encodeTrailers(const Http::HeaderMapImpl& trailers) { std::shared_ptr trailers_copy( new Http::HeaderMapImpl(static_cast(trailers))); - parent_.connection().dispatcher().post([this, trailers_copy]() - -> void { encoder_.encodeTrailers(*trailers_copy); }); + parent_.connection().dispatcher().post( + [this, trailers_copy]() -> void { encoder_.encodeTrailers(*trailers_copy); }); } void FakeStream::encodeResetStream() { @@ -315,4 +315,4 @@ Network::FilterStatus FakeRawConnection::ReadFilter::onData(Buffer::Instance& da parent_.connection_event_.notify_one(); return Network::FilterStatus::StopIteration; } -} // Envoy +} // namespace Envoy diff --git a/test/integration/fake_upstream.h b/test/integration/fake_upstream.h index dc264ddd0f2ca..1bb9c3cec1bdc 100644 --- a/test/integration/fake_upstream.h +++ b/test/integration/fake_upstream.h @@ -231,4 +231,4 @@ class FakeUpstream : Logger::Loggable, public Network::Filt std::list new_connections_; FakeHttpConnection::Type http_type_; }; -} // Envoy +} // namespace Envoy diff --git a/test/integration/grpc_json_transcoder_integration_test.cc b/test/integration/grpc_json_transcoder_integration_test.cc index 448d04b2c05b6..1be7afa78845f 100644 --- a/test/integration/grpc_json_transcoder_integration_test.cc +++ b/test/integration/grpc_json_transcoder_integration_test.cc @@ -11,12 +11,12 @@ #include "google/protobuf/util/message_differencer.h" #include "gtest/gtest.h" -using google::protobuf::util::MessageDifferencer; -using google::protobuf::util::Status; -using google::protobuf::util::error::Code; using google::protobuf::Empty; using google::protobuf::Message; using google::protobuf::TextFormat; +using google::protobuf::util::MessageDifferencer; +using google::protobuf::util::Status; +using google::protobuf::util::error::Code; namespace Envoy { @@ -113,11 +113,13 @@ class GrpcJsonTranscoderIntegrationTest response->waitForEndStream(); EXPECT_TRUE(response->complete()); - response_headers.iterate([](const Http::HeaderEntry& entry, void* context) -> void { - IntegrationStreamDecoder* response = static_cast(context); - Http::LowerCaseString lower_key{entry.key().c_str()}; - EXPECT_STREQ(entry.value().c_str(), response->headers().get(lower_key)->value().c_str()); - }, response.get()); + response_headers.iterate( + [](const Http::HeaderEntry& entry, void* context) -> void { + IntegrationStreamDecoder* response = static_cast(context); + Http::LowerCaseString lower_key{entry.key().c_str()}; + EXPECT_STREQ(entry.value().c_str(), response->headers().get(lower_key)->value().c_str()); + }, + response.get()); if (!response_body.empty()) { EXPECT_EQ(response_body, response->body()); } @@ -150,11 +152,11 @@ TEST_P(GrpcJsonTranscoderIntegrationTest, UnaryGet) { testTranscoding( Http::TestHeaderMapImpl{{":method", "GET"}, {":path", "/shelves"}, {":authority", "host"}}, "", {""}, {R"(shelves { id: 20 theme: "Children" } - shelves { id: 1 theme: "Foo" } )"}, - Status::OK, Http::TestHeaderMapImpl{{":status", "200"}, - {"content-type", "application/json"}, - {"content-length", "69"}, - {"grpc-status", "0"}}, + shelves { id: 1 theme: "Foo" } )"}, Status::OK, + Http::TestHeaderMapImpl{{":status", "200"}, + {"content-type", "application/json"}, + {"content-length", "69"}, + {"grpc-status", "0"}}, R"({"shelves":[{"id":"20","theme":"Children"},{"id":"1","theme":"Foo"}]})"); } @@ -221,8 +223,9 @@ TEST_P(GrpcJsonTranscoderIntegrationTest, ServerStreamingGet) { testTranscoding( Http::TestHeaderMapImpl{ {":method", "GET"}, {":path", "/shelves/1/books"}, {":authority", "host"}}, - "", {"shelf: 1"}, {R"(id: 1 author: "Neal Stephenson" title: "Readme")", - R"(id: 2 author: "George R.R. Martin" title: "A Game of Thrones")"}, + "", {"shelf: 1"}, + {R"(id: 1 author: "Neal Stephenson" title: "Readme")", + R"(id: 2 author: "George R.R. Martin" title: "A Game of Thrones")"}, Status::OK, Http::TestHeaderMapImpl{{":status", "200"}, {"content-type", "application/json"}}, R"([{"id":"1","author":"Neal Stephenson","title":"Readme"})" R"(,{"id":"2","author":"George R.R. Martin","title":"A Game of Thrones"}])"); @@ -252,9 +255,10 @@ TEST_P(GrpcJsonTranscoderIntegrationTest, StreamingPost) { R"(id: 6 theme: "Children")", R"(id: 7 theme: "Documentary")", R"(id: 8 theme: "Mystery")"}, - Status::OK, Http::TestHeaderMapImpl{{":status", "200"}, - {"content-type", "application/json"}, - {"transfer-encoding", "chunked"}}, + Status::OK, + Http::TestHeaderMapImpl{{":status", "200"}, + {"content-type", "application/json"}, + {"transfer-encoding", "chunked"}}, R"([{"id":"3","theme":"Classics"})" R"(,{"id":"4","theme":"Satire"})" R"(,{"id":"5","theme":"Russian"})" diff --git a/test/integration/http2_integration_test.cc b/test/integration/http2_integration_test.cc index 1158eb4487f11..67c231cb1cf56 100644 --- a/test/integration/http2_integration_test.cc +++ b/test/integration/http2_integration_test.cc @@ -116,8 +116,8 @@ TEST_P(Http2IntegrationTest, MaxHeadersInCodec) { Http::StreamEncoder* downstream_request{}; executeActions( {[&]() -> void { - codec_client = makeHttpConnection(lookupPort("http"), Http::CodecClient::Type::HTTP2); - }, + codec_client = makeHttpConnection(lookupPort("http"), Http::CodecClient::Type::HTTP2); + }, [&]() -> void { downstream_request = &codec_client->startRequest(big_headers, *response); }, [&]() -> void { response->waitForReset(); }, [&]() -> void { codec_client->close(); }}); } @@ -130,10 +130,11 @@ TEST_P(Http2IntegrationTest, BadMagic) { Buffer::OwnedImpl buffer("hello"); std::string response; RawConnectionDriver connection( - lookupPort("http"), - buffer, [&](Network::ClientConnection&, const Buffer::Instance& data) -> void { + lookupPort("http"), buffer, + [&](Network::ClientConnection&, const Buffer::Instance& data) -> void { response.append(TestUtility::bufferToString(data)); - }, version_); + }, + version_); connection.run(); EXPECT_EQ("", response); @@ -143,10 +144,11 @@ TEST_P(Http2IntegrationTest, BadFrame) { Buffer::OwnedImpl buffer("PRI * HTTP/2.0\r\n\r\nSM\r\n\r\nhelloworldcauseanerror"); std::string response; RawConnectionDriver connection( - lookupPort("http"), - buffer, [&](Network::ClientConnection&, const Buffer::Instance& data) -> void { + lookupPort("http"), buffer, + [&](Network::ClientConnection&, const Buffer::Instance& data) -> void { response.append(TestUtility::bufferToString(data)); - }, version_); + }, + version_); connection.run(); EXPECT_TRUE(response.find("SETTINGS expected") != std::string::npos); @@ -158,8 +160,8 @@ TEST_P(Http2IntegrationTest, GoAway) { IntegrationStreamDecoderPtr response(new IntegrationStreamDecoder(*dispatcher_)); executeActions( {[&]() -> void { - codec_client = makeHttpConnection(lookupPort("http"), Http::CodecClient::Type::HTTP2); - }, + codec_client = makeHttpConnection(lookupPort("http"), Http::CodecClient::Type::HTTP2); + }, [&]() -> void { encoder = &codec_client->startRequest(Http::TestHeaderMapImpl{{":method", "GET"}, {":path", "/healthcheck"}, @@ -191,8 +193,8 @@ TEST_P(Http2IntegrationTest, SimultaneousRequest) { FakeStreamPtr upstream_request2; executeActions( {[&]() -> void { - codec_client = makeHttpConnection(lookupPort("http"), Http::CodecClient::Type::HTTP2); - }, + codec_client = makeHttpConnection(lookupPort("http"), Http::CodecClient::Type::HTTP2); + }, // Start request 1 [&]() -> void { encoder1 = &codec_client->startRequest(Http::TestHeaderMapImpl{{":method", "POST"}, @@ -271,4 +273,4 @@ TEST_P(Http2IntegrationTest, SimultaneousRequest) { [&]() -> void { fake_upstream_connection2->close(); }, [&]() -> void { fake_upstream_connection2->waitForDisconnect(); }}); } -} // Envoy +} // namespace Envoy diff --git a/test/integration/http2_integration_test.h b/test/integration/http2_integration_test.h index 1c6f895d3d053..7daad5071fbe2 100644 --- a/test/integration/http2_integration_test.h +++ b/test/integration/http2_integration_test.h @@ -28,4 +28,4 @@ class Http2IntegrationTest : public BaseIntegrationTest, fake_upstreams_.clear(); } }; -} // Envoy +} // namespace Envoy diff --git a/test/integration/http2_upstream_integration_test.cc b/test/integration/http2_upstream_integration_test.cc index 94f4dffc16e5a..ea583cbe01cef 100644 --- a/test/integration/http2_upstream_integration_test.cc +++ b/test/integration/http2_upstream_integration_test.cc @@ -109,8 +109,8 @@ TEST_P(Http2UpstreamIntegrationTest, BidirectionalStreaming) { FakeStreamPtr upstream_request; executeActions( {[&]() -> void { - codec_client = makeHttpConnection(lookupPort("http"), Http::CodecClient::Type::HTTP2); - }, + codec_client = makeHttpConnection(lookupPort("http"), Http::CodecClient::Type::HTTP2); + }, // Start request [&]() -> void { encoder = &codec_client->startRequest(Http::TestHeaderMapImpl{{":method", "POST"}, @@ -167,8 +167,8 @@ TEST_P(Http2UpstreamIntegrationTest, BidirectionalStreamingReset) { FakeStreamPtr upstream_request; executeActions( {[&]() -> void { - codec_client = makeHttpConnection(lookupPort("http"), Http::CodecClient::Type::HTTP2); - }, + codec_client = makeHttpConnection(lookupPort("http"), Http::CodecClient::Type::HTTP2); + }, // Start request [&]() -> void { encoder = &codec_client->startRequest(Http::TestHeaderMapImpl{{":method", "POST"}, @@ -226,8 +226,8 @@ TEST_P(Http2UpstreamIntegrationTest, SimultaneousRequest) { FakeStreamPtr upstream_request2; executeActions( {[&]() -> void { - codec_client = makeHttpConnection(lookupPort("http"), Http::CodecClient::Type::HTTP2); - }, + codec_client = makeHttpConnection(lookupPort("http"), Http::CodecClient::Type::HTTP2); + }, // Start request 1 [&]() -> void { encoder1 = &codec_client->startRequest(Http::TestHeaderMapImpl{{":method", "POST"}, @@ -301,4 +301,4 @@ TEST_P(Http2UpstreamIntegrationTest, SimultaneousRequest) { [&]() -> void { fake_upstream_connection->close(); }, [&]() -> void { fake_upstream_connection->waitForDisconnect(); }}); } -} // Envoy +} // namespace Envoy diff --git a/test/integration/http2_upstream_integration_test.h b/test/integration/http2_upstream_integration_test.h index 609edab35c1e1..fe7ca71b8b86d 100644 --- a/test/integration/http2_upstream_integration_test.h +++ b/test/integration/http2_upstream_integration_test.h @@ -29,4 +29,4 @@ class Http2UpstreamIntegrationTest : public BaseIntegrationTest, fake_upstreams_.clear(); } }; -} // Envoy +} // namespace Envoy diff --git a/test/integration/integration.cc b/test/integration/integration.cc index e414f5b0cf0c2..51773455ae5f8 100644 --- a/test/integration/integration.cc +++ b/test/integration/integration.cc @@ -25,8 +25,8 @@ #include "test/test_common/printers.h" #include "test/test_common/utility.h" -#include "gtest/gtest.h" #include "spdlog/spdlog.h" +#include "gtest/gtest.h" namespace Envoy { IntegrationStreamDecoder::IntegrationStreamDecoder(Event::Dispatcher& dispatcher) @@ -247,8 +247,9 @@ BaseIntegrationTest::makeHttpConnection(Network::ClientConnectionPtr&& conn, Http::CodecClient::Type type) { std::shared_ptr cluster{new NiceMock()}; Upstream::HostDescriptionConstSharedPtr host_description{new Upstream::HostDescriptionImpl( - cluster, "", Network::Utility::resolveUrl(fmt::format( - "tcp://{}:80", Network::Test::getLoopbackAddressUrlString(version_))), + cluster, "", + Network::Utility::resolveUrl( + fmt::format("tcp://{}:80", Network::Test::getLoopbackAddressUrlString(version_))), false, "")}; return IntegrationCodecClientPtr{ new IntegrationCodecClient(*dispatcher_, std::move(conn), host_description, type)}; @@ -296,35 +297,32 @@ void BaseIntegrationTest::testRouterRequestAndResponseWithBody(Network::ClientCo FakeHttpConnectionPtr fake_upstream_connection; IntegrationStreamDecoderPtr response(new IntegrationStreamDecoder(*dispatcher_)); FakeStreamPtr request; - executeActions({[&]() -> void { codec_client = makeHttpConnection(std::move(conn), type); }, - [&]() -> void { - Http::TestHeaderMapImpl headers{{":method", "POST"}, - {":path", "/test/long/url"}, - {":scheme", "http"}, - {":authority", "host"}, - {"x-lyft-user-id", "123"}, - {"x-forwarded-for", "10.0.0.1"}}; - if (big_header) { - headers.addViaCopy("big", std::string(4096, 'a')); - } + executeActions( + {[&]() -> void { codec_client = makeHttpConnection(std::move(conn), type); }, + [&]() -> void { + Http::TestHeaderMapImpl headers{ + {":method", "POST"}, {":path", "/test/long/url"}, {":scheme", "http"}, + {":authority", "host"}, {"x-lyft-user-id", "123"}, {"x-forwarded-for", "10.0.0.1"}}; + if (big_header) { + headers.addViaCopy("big", std::string(4096, 'a')); + } - codec_client->makeRequestWithBody(headers, request_size, *response); - }, - [&]() -> void { - fake_upstream_connection = - fake_upstreams_[0]->waitForHttpConnection(*dispatcher_); - }, - [&]() -> void { request = fake_upstream_connection->waitForNewStream(); }, - [&]() -> void { request->waitForEndStream(*dispatcher_); }, - [&]() -> void { - request->encodeHeaders(Http::TestHeaderMapImpl{{":status", "200"}}, false); - request->encodeData(response_size, true); - }, - [&]() -> void { response->waitForEndStream(); }, - // Cleanup both downstream and upstream - [&]() -> void { codec_client->close(); }, - [&]() -> void { fake_upstream_connection->close(); }, - [&]() -> void { fake_upstream_connection->waitForDisconnect(); }}); + codec_client->makeRequestWithBody(headers, request_size, *response); + }, + [&]() -> void { + fake_upstream_connection = fake_upstreams_[0]->waitForHttpConnection(*dispatcher_); + }, + [&]() -> void { request = fake_upstream_connection->waitForNewStream(); }, + [&]() -> void { request->waitForEndStream(*dispatcher_); }, + [&]() -> void { + request->encodeHeaders(Http::TestHeaderMapImpl{{":status", "200"}}, false); + request->encodeData(response_size, true); + }, + [&]() -> void { response->waitForEndStream(); }, + // Cleanup both downstream and upstream + [&]() -> void { codec_client->close(); }, + [&]() -> void { fake_upstream_connection->close(); }, + [&]() -> void { fake_upstream_connection->waitForDisconnect(); }}); EXPECT_TRUE(request->complete()); EXPECT_EQ(request_size, request->bodyLength()); @@ -567,7 +565,8 @@ void BaseIntegrationTest::testRouterDownstreamDisconnectBeforeResponseComplete( request->encodeHeaders(Http::TestHeaderMapImpl{{":status", "200"}}, false); request->encodeData(512, false); }, - [&]() -> void { response->waitForBodyData(512); }, [&]() -> void { codec_client->close(); }}; + [&]() -> void { response->waitForBodyData(512); }, + [&]() -> void { codec_client->close(); }}; if (fake_upstreams_[0]->httpType() == FakeHttpConnection::Type::HTTP1) { actions.push_back([&]() -> void { fake_upstream_connection->waitForDisconnect(); }); @@ -698,8 +697,8 @@ void BaseIntegrationTest::testGrpcRetry() { Http::TestHeaderMapImpl response_trailers{{"response1", "trailer1"}, {"grpc-status", "0"}}; executeActions( {[&]() -> void { - codec_client = makeHttpConnection(lookupPort("http"), Http::CodecClient::Type::HTTP2); - }, + codec_client = makeHttpConnection(lookupPort("http"), Http::CodecClient::Type::HTTP2); + }, [&]() -> void { Http::StreamEncoder* request_encoder; request_encoder = &codec_client->startRequest( @@ -824,10 +823,11 @@ void BaseIntegrationTest::sendRawHttpAndWaitForResponse(const char* raw_http, std::string* response) { Buffer::OwnedImpl buffer(raw_http); RawConnectionDriver connection( - lookupPort("http"), - buffer, [&](Network::ClientConnection&, const Buffer::Instance& data) -> void { + lookupPort("http"), buffer, + [&](Network::ClientConnection&, const Buffer::Instance& data) -> void { response->append(TestUtility::bufferToString(data)); - }, version_); + }, + version_); connection.run(); } @@ -860,11 +860,12 @@ void BaseIntegrationTest::testHttp10Request() { Buffer::OwnedImpl buffer("GET / HTTP/1.0\r\n\r\n"); std::string response; RawConnectionDriver connection( - lookupPort("http"), - buffer, [&](Network::ClientConnection& client, const Buffer::Instance& data) -> void { + lookupPort("http"), buffer, + [&](Network::ClientConnection& client, const Buffer::Instance& data) -> void { response.append(TestUtility::bufferToString(data)); client.close(Network::ConnectionCloseType::NoFlush); - }, version_); + }, + version_); connection.run(); EXPECT_TRUE(response.find("HTTP/1.1 426 Upgrade Required\r\n") == 0); @@ -874,11 +875,12 @@ void BaseIntegrationTest::testNoHost() { Buffer::OwnedImpl buffer("GET / HTTP/1.1\r\n\r\n"); std::string response; RawConnectionDriver connection( - lookupPort("http"), - buffer, [&](Network::ClientConnection& client, const Buffer::Instance& data) -> void { + lookupPort("http"), buffer, + [&](Network::ClientConnection& client, const Buffer::Instance& data) -> void { response.append(TestUtility::bufferToString(data)); client.close(Network::ConnectionCloseType::NoFlush); - }, version_); + }, + version_); connection.run(); EXPECT_TRUE(response.find("HTTP/1.1 400 Bad Request\r\n") == 0); @@ -888,11 +890,12 @@ void BaseIntegrationTest::testBadPath() { Buffer::OwnedImpl buffer("GET http://api.lyft.com HTTP/1.1\r\nHost: host\r\n\r\n"); std::string response; RawConnectionDriver connection( - lookupPort("http"), - buffer, [&](Network::ClientConnection& client, const Buffer::Instance& data) -> void { + lookupPort("http"), buffer, + [&](Network::ClientConnection& client, const Buffer::Instance& data) -> void { response.append(TestUtility::bufferToString(data)); client.close(Network::ConnectionCloseType::NoFlush); - }, version_); + }, + version_); connection.run(); EXPECT_TRUE(response.find("HTTP/1.1 404 Not Found\r\n") == 0); @@ -1013,8 +1016,8 @@ void BaseIntegrationTest::testUpstreamProtocolError() { FakeRawConnectionPtr fake_upstream_connection; executeActions( {[&]() -> void { - codec_client = makeHttpConnection(lookupPort("http"), Http::CodecClient::Type::HTTP1); - }, + codec_client = makeHttpConnection(lookupPort("http"), Http::CodecClient::Type::HTTP1); + }, [&]() -> void { codec_client->startRequest(Http::TestHeaderMapImpl{{":method", "GET"}, {":path", "/test/long/url"}, @@ -1099,9 +1102,9 @@ void BaseIntegrationTest::testTrailers(uint64_t request_size, uint64_t response_ Http::TestHeaderMapImpl response_trailers{{"response1", "trailer1"}, {"response2", "trailer2"}}; executeActions( {[&]() -> void { - codec_client = - makeHttpConnection(lookupPort("http_buffer"), Http::CodecClient::Type::HTTP2); - }, + codec_client = + makeHttpConnection(lookupPort("http_buffer"), Http::CodecClient::Type::HTTP2); + }, [&]() -> void { request_encoder = &codec_client->startRequest(Http::TestHeaderMapImpl{{":method", "POST"}, @@ -1141,4 +1144,4 @@ void BaseIntegrationTest::testTrailers(uint64_t request_size, uint64_t response_ EXPECT_THAT(*response->trailers(), HeaderMapEqualRef(&response_trailers)); } } -} // Envoy +} // namespace Envoy diff --git a/test/integration/integration.h b/test/integration/integration.h index 46f8b7e69b132..3a0719063a6f4 100644 --- a/test/integration/integration.h +++ b/test/integration/integration.h @@ -223,4 +223,4 @@ class BaseIntegrationTest : Logger::Loggable { TestEnvironment::PortMap port_map_; Network::Address::IpVersion version_; }; -} // Envoy +} // namespace Envoy diff --git a/test/integration/integration_admin_test.cc b/test/integration/integration_admin_test.cc index 85be6ecb2c84f..aebd18188d05a 100644 --- a/test/integration/integration_admin_test.cc +++ b/test/integration/integration_admin_test.cc @@ -6,8 +6,8 @@ #include "test/integration/utility.h" -#include "gtest/gtest.h" #include "spdlog/spdlog.h" +#include "gtest/gtest.h" namespace Envoy { @@ -166,4 +166,4 @@ TEST_P(IntegrationAdminTest, AdminCpuProfilerStart) { } #endif -} // Envoy +} // namespace Envoy diff --git a/test/integration/integration_admin_test.h b/test/integration/integration_admin_test.h index 9c9c2addf2296..3f75245a4a747 100644 --- a/test/integration/integration_admin_test.h +++ b/test/integration/integration_admin_test.h @@ -31,4 +31,4 @@ class IntegrationAdminTest : public BaseIntegrationTest, } }; -} // Envoy +} // namespace Envoy diff --git a/test/integration/integration_test.cc b/test/integration/integration_test.cc index c0ce67013a1a2..76057b3aaa57b 100644 --- a/test/integration/integration_test.cc +++ b/test/integration/integration_test.cc @@ -32,19 +32,19 @@ TEST_P(IntegrationTest, DrainClose) { testDrainClose(Http::CodecClient::Type::HT TEST_P(IntegrationTest, ConnectionClose) { IntegrationCodecClientPtr codec_client; IntegrationStreamDecoderPtr response(new IntegrationStreamDecoder(*dispatcher_)); - executeActions({[&]() -> void { - codec_client = makeHttpConnection(lookupPort("http"), Http::CodecClient::Type::HTTP1); - }, - [&]() -> void { - codec_client->makeHeaderOnlyRequest( - Http::TestHeaderMapImpl{{":method", "GET"}, - {":path", "/healthcheck"}, - {":authority", "host"}, - {"connection", "close"}}, - *response); - }, - [&]() -> void { response->waitForEndStream(); }, - [&]() -> void { codec_client->waitForDisconnect(); }}); + executeActions( + {[&]() -> void { + codec_client = makeHttpConnection(lookupPort("http"), Http::CodecClient::Type::HTTP1); + }, + [&]() -> void { + codec_client->makeHeaderOnlyRequest(Http::TestHeaderMapImpl{{":method", "GET"}, + {":path", "/healthcheck"}, + {":authority", "host"}, + {"connection", "close"}}, + *response); + }, + [&]() -> void { response->waitForEndStream(); }, + [&]() -> void { codec_client->waitForDisconnect(); }}); EXPECT_TRUE(response->complete()); EXPECT_STREQ("200", response->headers().Status()->value().c_str()); @@ -171,4 +171,4 @@ TEST_P(IntegrationTest, TcpProxyDownstreamDisconnect) { [&]() -> void { fake_upstream_connection->waitForData(10); }, [&]() -> void { fake_upstream_connection->waitForDisconnect(); }}); } -} // Envoy +} // namespace Envoy diff --git a/test/integration/integration_test.h b/test/integration/integration_test.h index b91f1dc733faa..5a0f9fff62042 100644 --- a/test/integration/integration_test.h +++ b/test/integration/integration_test.h @@ -29,4 +29,4 @@ class IntegrationTest : public BaseIntegrationTest, fake_upstreams_.clear(); } }; -} // Envoy +} // namespace Envoy diff --git a/test/integration/proxy_proto_integration_test.cc b/test/integration/proxy_proto_integration_test.cc index fb713ec565cfe..76bc76e3d9d51 100644 --- a/test/integration/proxy_proto_integration_test.cc +++ b/test/integration/proxy_proto_integration_test.cc @@ -31,4 +31,4 @@ TEST_P(ProxyProtoIntegrationTest, RouterRequestAndResponseWithBodyNoBufferV6) { false); } -} // Envoy +} // namespace Envoy diff --git a/test/integration/proxy_proto_integration_test.h b/test/integration/proxy_proto_integration_test.h index 8ce4a8b0b5fa9..6c16edf5ce806 100644 --- a/test/integration/proxy_proto_integration_test.h +++ b/test/integration/proxy_proto_integration_test.h @@ -31,4 +31,4 @@ class ProxyProtoIntegrationTest : public BaseIntegrationTest, fake_upstreams_.clear(); } }; -} // Envoy +} // namespace Envoy diff --git a/test/integration/server.cc b/test/integration/server.cc index 596c89e6a3cea..d3b1f22c95c8d 100644 --- a/test/integration/server.cc +++ b/test/integration/server.cc @@ -30,7 +30,7 @@ class TestHotRestart : public HotRestart { std::string version() override { return "1"; } }; -} // Server +} // namespace Server IntegrationTestServerPtr IntegrationTestServer::create(const std::string& config_path, const Network::Address::IpVersion version) { @@ -76,4 +76,4 @@ void IntegrationTestServer::threadRoutine(const Network::Address::IpVersion vers server_->run(); server_.reset(); } -} // Envoy +} // namespace Envoy diff --git a/test/integration/server.h b/test/integration/server.h index feec1ab3037af..f58363cb77f3d 100644 --- a/test/integration/server.h +++ b/test/integration/server.h @@ -74,7 +74,7 @@ class TestComponentFactory : public ComponentFactory { } }; -} // Server +} // namespace Server namespace Stats { @@ -163,7 +163,7 @@ class TestIsolatedStoreImpl : public StoreRoot { IsolatedStoreImpl store_; }; -} // Stats +} // namespace Stats class IntegrationTestServer; typedef std::unique_ptr IntegrationTestServerPtr; @@ -218,4 +218,4 @@ class IntegrationTestServer : Logger::Loggable, Server::TestDrainManager* drain_manager_{}; Stats::TestIsolatedStoreImpl stats_store_; }; -} // Envoy +} // namespace Envoy diff --git a/test/integration/ssl_integration_test.cc b/test/integration/ssl_integration_test.cc index 85f5fc905841e..59ac27717f512 100644 --- a/test/integration/ssl_integration_test.cc +++ b/test/integration/ssl_integration_test.cc @@ -12,9 +12,9 @@ #include "test/test_common/network_utility.h" #include "gmock/gmock.h" -#include "gtest/gtest.h" #include "integration.h" #include "utility.h" +#include "gtest/gtest.h" using testing::Return; @@ -170,5 +170,5 @@ TEST_P(SslIntegrationTest, AltAlpn) { checkStats(); } -} // Ssl -} // Envoy +} // namespace Ssl +} // namespace Envoy diff --git a/test/integration/ssl_integration_test.h b/test/integration/ssl_integration_test.h index 0f295ce24ff9c..7f892363a9461 100644 --- a/test/integration/ssl_integration_test.h +++ b/test/integration/ssl_integration_test.h @@ -65,5 +65,5 @@ class SslIntegrationTest : public BaseIntegrationTest, ClientContextPtr client_ssl_ctx_alpn_san_; }; -} // Ssl -} // Envoy +} // namespace Ssl +} // namespace Envoy diff --git a/test/integration/uds_integration_test.cc b/test/integration/uds_integration_test.cc index f82d571aa4e0c..79608e3a47c78 100644 --- a/test/integration/uds_integration_test.cc +++ b/test/integration/uds_integration_test.cc @@ -33,4 +33,4 @@ TEST_P(UdsIntegrationTest, RouterDownstreamDisconnectBeforeResponseComplete) { testRouterDownstreamDisconnectBeforeResponseComplete(makeClientConnection(lookupPort("http")), Http::CodecClient::Type::HTTP1); } -} // Envoy +} // namespace Envoy diff --git a/test/integration/uds_integration_test.h b/test/integration/uds_integration_test.h index 03d3ca47a586d..b9e83bbdb1c4c 100644 --- a/test/integration/uds_integration_test.h +++ b/test/integration/uds_integration_test.h @@ -34,4 +34,4 @@ class UdsIntegrationTest : public BaseIntegrationTest, fake_upstreams_.clear(); } }; -} // Envoy +} // namespace Envoy diff --git a/test/integration/utility.cc b/test/integration/utility.cc index d4f609586d2ee..45e100b9f7e18 100644 --- a/test/integration/utility.cc +++ b/test/integration/utility.cc @@ -59,12 +59,14 @@ IntegrationUtil::makeSingleRequest(uint32_t port, const std::string& method, con Event::DispatcherPtr dispatcher(api.allocateDispatcher()); std::shared_ptr cluster{new NiceMock()}; Upstream::HostDescriptionConstSharedPtr host_description{new Upstream::HostDescriptionImpl( - cluster, "", Network::Utility::resolveUrl(fmt::format( - "tcp://{}:80", Network::Test::getLoopbackAddressUrlString(version))), + cluster, "", + Network::Utility::resolveUrl( + fmt::format("tcp://{}:80", Network::Test::getLoopbackAddressUrlString(version))), false, "")}; Http::CodecClientProd client( - type, dispatcher->createClientConnection(Network::Utility::resolveUrl(fmt::format( - "tcp://{}:{}", Network::Test::getLoopbackAddressUrlString(version), port))), + type, + dispatcher->createClientConnection(Network::Utility::resolveUrl( + fmt::format("tcp://{}:{}", Network::Test::getLoopbackAddressUrlString(version), port))), host_description); BufferingStreamDecoderPtr response(new BufferingStreamDecoder([&]() -> void { client.close(); })); Http::StreamEncoder& encoder = client.newStream(*response); @@ -117,4 +119,4 @@ Network::FilterStatus WaitForPayloadReader::onData(Buffer::Instance& data) { return Network::FilterStatus::StopIteration; } -} // Envoy +} // namespace Envoy diff --git a/test/integration/utility.h b/test/integration/utility.h index b48c10f4a2a7a..2b76e11a102d1 100644 --- a/test/integration/utility.h +++ b/test/integration/utility.h @@ -138,4 +138,4 @@ class WaitForPayloadReader : public Network::ReadFilterBaseImpl { std::string data_; }; -} // Envoy +} // namespace Envoy diff --git a/test/integration/xfcc_integration_test.cc b/test/integration/xfcc_integration_test.cc index 5a36198418ec9..5eff2c68927e2 100644 --- a/test/integration/xfcc_integration_test.cc +++ b/test/integration/xfcc_integration_test.cc @@ -13,10 +13,10 @@ #include "test/test_common/utility.h" #include "gmock/gmock.h" -#include "gtest/gtest.h" #include "integration.h" #include "ssl_integration_test.h" #include "utility.h" +#include "gtest/gtest.h" namespace Envoy { namespace Xfcc { @@ -141,8 +141,8 @@ void XfccIntegrationTest::testRequestAndResponseWithXfccHeader(Network::ClientCo executeActions( {[&]() -> void { - codec_client = makeHttpConnection(std::move(conn), Http::CodecClient::Type::HTTP1); - }, + codec_client = makeHttpConnection(std::move(conn), Http::CodecClient::Type::HTTP1); + }, [&]() -> void { codec_client->makeHeaderOnlyRequest(header_map, *response); }, [&]() -> void { fake_upstream_connection = fake_upstreams_[0]->waitForHttpConnection(*dispatcher_); @@ -253,5 +253,5 @@ TEST_P(XfccIntegrationTest, NonTlsEnforceSanitize) { startTestServerWithXfccConfig("forward_only", ""); testRequestAndResponseWithXfccHeader(makeClientConnection(), previous_xfcc_, ""); } -} // Xfcc -} // Envoy +} // namespace Xfcc +} // namespace Envoy diff --git a/test/integration/xfcc_integration_test.h b/test/integration/xfcc_integration_test.h index 57455d0d137fc..2f394eb7cd03a 100644 --- a/test/integration/xfcc_integration_test.h +++ b/test/integration/xfcc_integration_test.h @@ -53,5 +53,5 @@ class XfccIntegrationTest : public BaseIntegrationTest, Ssl::ClientContextPtr client_mtls_ssl_ctx_; Ssl::ServerContextPtr upstream_ssl_ctx_; }; -} // Xfcc -} // Envoy +} // namespace Xfcc +} // namespace Envoy diff --git a/test/main.cc b/test/main.cc index a5c693f60c796..cc00c32f7332b 100644 --- a/test/main.cc +++ b/test/main.cc @@ -19,8 +19,10 @@ int main(int argc, char** argv) { Envoy::SignalAction handle_sigs; #endif - ::setenv("TEST_RUNDIR", (Envoy::TestEnvironment::getCheckedEnvVar("TEST_SRCDIR") + "/" + - Envoy::TestEnvironment::getCheckedEnvVar("TEST_WORKSPACE")).c_str(), + ::setenv("TEST_RUNDIR", + (Envoy::TestEnvironment::getCheckedEnvVar("TEST_SRCDIR") + "/" + + Envoy::TestEnvironment::getCheckedEnvVar("TEST_WORKSPACE")) + .c_str(), 1); // Select whether to test only for IPv4, IPv6, or both. The default is to // test for both. Options are {"v4only", "v6only", "all"}. Set diff --git a/test/mocks/access_log/mocks.cc b/test/mocks/access_log/mocks.cc index 62260a22cfd02..0901d1eb726cb 100644 --- a/test/mocks/access_log/mocks.cc +++ b/test/mocks/access_log/mocks.cc @@ -4,8 +4,8 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::Return; +using testing::_; namespace AccessLog { @@ -15,5 +15,5 @@ MockAccessLogManager::MockAccessLogManager() { MockAccessLogManager::~MockAccessLogManager() {} -} // AccessLog -} // Envoy +} // namespace AccessLog +} // namespace Envoy diff --git a/test/mocks/access_log/mocks.h b/test/mocks/access_log/mocks.h index 6cb045907f3e5..59d484062199a 100644 --- a/test/mocks/access_log/mocks.h +++ b/test/mocks/access_log/mocks.h @@ -24,5 +24,5 @@ class MockAccessLogManager : public AccessLogManager { std::shared_ptr file_{new testing::NiceMock()}; }; -} // AccessLog -} // Envoy +} // namespace AccessLog +} // namespace Envoy diff --git a/test/mocks/api/mocks.cc b/test/mocks/api/mocks.cc index b5128f7567df9..6f1eeb99925d9 100644 --- a/test/mocks/api/mocks.cc +++ b/test/mocks/api/mocks.cc @@ -4,8 +4,8 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::Return; +using testing::_; namespace Api { @@ -13,5 +13,5 @@ MockApi::MockApi() { ON_CALL(*this, createFile(_, _, _, _)).WillByDefault(Return MockApi::~MockApi() {} -} // Api -} // Envoy +} // namespace Api +} // namespace Envoy diff --git a/test/mocks/api/mocks.h b/test/mocks/api/mocks.h index c36b5f00dbbbc..f1bb208af2602 100644 --- a/test/mocks/api/mocks.h +++ b/test/mocks/api/mocks.h @@ -33,5 +33,5 @@ class MockApi : public Api { std::shared_ptr file_{new Filesystem::MockFile()}; }; -} // Api -} // Envoy +} // namespace Api +} // namespace Envoy diff --git a/test/mocks/buffer/mocks.h b/test/mocks/buffer/mocks.h index 5e464e7ed8e23..e82e33d5c539d 100644 --- a/test/mocks/buffer/mocks.h +++ b/test/mocks/buffer/mocks.h @@ -23,4 +23,4 @@ ACTION_P(AddBufferToString, target_string) { target_string->append(TestUtility::bufferToString(arg0)); arg0.drain(arg0.length()); } -} // Envoy +} // namespace Envoy diff --git a/test/mocks/common.cc b/test/mocks/common.cc index f9c78dedcd2f5..2b6bb8a59f305 100644 --- a/test/mocks/common.cc +++ b/test/mocks/common.cc @@ -9,4 +9,4 @@ MockSystemTimeSource::~MockSystemTimeSource() {} MockMonotonicTimeSource::MockMonotonicTimeSource() {} MockMonotonicTimeSource::~MockMonotonicTimeSource() {} -} // Envoy +} // namespace Envoy diff --git a/test/mocks/common.h b/test/mocks/common.h index 5eb9159372b50..672a34c9ba504 100644 --- a/test/mocks/common.h +++ b/test/mocks/common.h @@ -44,4 +44,4 @@ class MockMonotonicTimeSource : public MonotonicTimeSource { MOCK_METHOD0(currentTime, MonotonicTime()); }; -} // Envoy +} // namespace Envoy diff --git a/test/mocks/config/mocks.h b/test/mocks/config/mocks.h index bf9c17b94eb68..4382126f52535 100644 --- a/test/mocks/config/mocks.h +++ b/test/mocks/config/mocks.h @@ -23,5 +23,5 @@ template class MockSubscription : public Subscription& resources)); }; -} // Config -} // Envoy +} // namespace Config +} // namespace Envoy diff --git a/test/mocks/event/mocks.cc b/test/mocks/event/mocks.cc index a772fe84bbd26..b581d434a15d8 100644 --- a/test/mocks/event/mocks.cc +++ b/test/mocks/event/mocks.cc @@ -4,18 +4,19 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::Invoke; using testing::NiceMock; using testing::Return; using testing::ReturnNew; using testing::SaveArg; +using testing::_; namespace Event { MockDispatcher::MockDispatcher() { - ON_CALL(*this, clearDeferredDeleteList()) - .WillByDefault(Invoke([this]() -> void { to_delete_.clear(); })); + ON_CALL(*this, clearDeferredDeleteList()).WillByDefault(Invoke([this]() -> void { + to_delete_.clear(); + })); ON_CALL(*this, createTimer_(_)).WillByDefault(ReturnNew>()); ON_CALL(*this, post(_)).WillByDefault(Invoke([](PostCb cb) -> void { cb(); })); } @@ -35,5 +36,5 @@ MockTimer::~MockTimer() {} MockFileEvent::MockFileEvent() {} MockFileEvent::~MockFileEvent() {} -} // Event -} // Envoy +} // namespace Event +} // namespace Envoy diff --git a/test/mocks/event/mocks.h b/test/mocks/event/mocks.h index ff25330e9989b..60c770c9df86c 100644 --- a/test/mocks/event/mocks.h +++ b/test/mocks/event/mocks.h @@ -131,5 +131,5 @@ class MockFileEvent : public FileEvent { MOCK_METHOD1(setEnabled, void(uint32_t events)); }; -} // Event -} // Envoy +} // namespace Event +} // namespace Envoy diff --git a/test/mocks/filesystem/mocks.cc b/test/mocks/filesystem/mocks.cc index 0ad888a4dba92..a00e289ddc62c 100644 --- a/test/mocks/filesystem/mocks.cc +++ b/test/mocks/filesystem/mocks.cc @@ -35,5 +35,5 @@ MockFile::~MockFile() {} MockWatcher::MockWatcher() {} MockWatcher::~MockWatcher() {} -} // Filesystem -} // Envoy +} // namespace Filesystem +} // namespace Envoy diff --git a/test/mocks/filesystem/mocks.h b/test/mocks/filesystem/mocks.h index 3846e6faf7312..346362350c611 100644 --- a/test/mocks/filesystem/mocks.h +++ b/test/mocks/filesystem/mocks.h @@ -52,5 +52,5 @@ class MockWatcher : public Watcher { MOCK_METHOD3(addWatch, void(const std::string&, uint32_t, OnChangedCb)); }; -} // Filesystem -} // Envoy +} // namespace Filesystem +} // namespace Envoy diff --git a/test/mocks/grpc/mocks.cc b/test/mocks/grpc/mocks.cc index f05afcaf3ed05..75127d607c5ad 100644 --- a/test/mocks/grpc/mocks.cc +++ b/test/mocks/grpc/mocks.cc @@ -9,5 +9,5 @@ MockRpcChannelCallbacks::~MockRpcChannelCallbacks() {} MockRpcChannel::MockRpcChannel() {} MockRpcChannel::~MockRpcChannel() {} -} // Grpc -} // Envoy +} // namespace Grpc +} // namespace Envoy diff --git a/test/mocks/grpc/mocks.h b/test/mocks/grpc/mocks.h index 9d5b5cdc39e61..db8fdcf187fe4 100644 --- a/test/mocks/grpc/mocks.h +++ b/test/mocks/grpc/mocks.h @@ -70,9 +70,9 @@ class MockRpcChannel : public RpcChannel { ::google::protobuf::Message* response, ::google::protobuf::Closure* done)); }; -} // Grpc +} // namespace Grpc MATCHER_P(ProtoMessageEqual, rhs, "") { return arg->SerializeAsString() == rhs->SerializeAsString(); } -} // Envoy +} // namespace Envoy diff --git a/test/mocks/http/mocks.cc b/test/mocks/http/mocks.cc index 77e63cdd10259..a52a719836f6b 100644 --- a/test/mocks/http/mocks.cc +++ b/test/mocks/http/mocks.cc @@ -7,11 +7,11 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::Invoke; using testing::Return; using testing::ReturnRef; using testing::SaveArg; +using testing::_; namespace Http { @@ -34,20 +34,19 @@ MockStreamCallbacks::MockStreamCallbacks() {} MockStreamCallbacks::~MockStreamCallbacks() {} MockStream::MockStream() { - ON_CALL(*this, addCallbacks(_)) - .WillByDefault( - Invoke([this](StreamCallbacks& callbacks) -> void { callbacks_.push_back(&callbacks); })); + ON_CALL(*this, addCallbacks(_)).WillByDefault(Invoke([this](StreamCallbacks& callbacks) -> void { + callbacks_.push_back(&callbacks); + })); ON_CALL(*this, removeCallbacks(_)) .WillByDefault( Invoke([this](StreamCallbacks& callbacks) -> void { callbacks_.remove(&callbacks); })); - ON_CALL(*this, resetStream(_)) - .WillByDefault(Invoke([this](StreamResetReason reason) -> void { - for (StreamCallbacks* callbacks : callbacks_) { - callbacks->onResetStream(reason); - } - })); + ON_CALL(*this, resetStream(_)).WillByDefault(Invoke([this](StreamResetReason reason) -> void { + for (StreamCallbacks* callbacks : callbacks_) { + callbacks->onResetStream(reason); + } + })); } MockStream::~MockStream() {} @@ -94,27 +93,29 @@ MockStreamEncoderFilterCallbacks::~MockStreamEncoderFilterCallbacks() {} MockStreamDecoderFilter::MockStreamDecoderFilter() { ON_CALL(*this, setDecoderFilterCallbacks(_)) - .WillByDefault(Invoke([this](StreamDecoderFilterCallbacks& callbacks) - -> void { callbacks_ = &callbacks; })); + .WillByDefault(Invoke( + [this](StreamDecoderFilterCallbacks& callbacks) -> void { callbacks_ = &callbacks; })); } MockStreamDecoderFilter::~MockStreamDecoderFilter() {} MockStreamEncoderFilter::MockStreamEncoderFilter() { ON_CALL(*this, setEncoderFilterCallbacks(_)) - .WillByDefault(Invoke([this](StreamEncoderFilterCallbacks& callbacks) - -> void { callbacks_ = &callbacks; })); + .WillByDefault(Invoke( + [this](StreamEncoderFilterCallbacks& callbacks) -> void { callbacks_ = &callbacks; })); } MockStreamEncoderFilter::~MockStreamEncoderFilter() {} MockStreamFilter::MockStreamFilter() { ON_CALL(*this, setDecoderFilterCallbacks(_)) - .WillByDefault(Invoke([this](StreamDecoderFilterCallbacks& callbacks) - -> void { decoder_callbacks_ = &callbacks; })); + .WillByDefault(Invoke([this](StreamDecoderFilterCallbacks& callbacks) -> void { + decoder_callbacks_ = &callbacks; + })); ON_CALL(*this, setEncoderFilterCallbacks(_)) - .WillByDefault(Invoke([this](StreamEncoderFilterCallbacks& callbacks) - -> void { encoder_callbacks_ = &callbacks; })); + .WillByDefault(Invoke([this](StreamEncoderFilterCallbacks& callbacks) -> void { + encoder_callbacks_ = &callbacks; + })); } MockStreamFilter::~MockStreamFilter() {} @@ -137,7 +138,7 @@ MockAsyncClientStream::~MockAsyncClientStream() {} MockFilterChainFactoryCallbacks::MockFilterChainFactoryCallbacks() {} MockFilterChainFactoryCallbacks::~MockFilterChainFactoryCallbacks() {} -} // Http +} // namespace Http namespace Http { namespace ConnectionPool { @@ -148,8 +149,8 @@ MockCancellable::~MockCancellable() {} MockInstance::MockInstance() {} MockInstance::~MockInstance() {} -} // ConnectionPool -} // Http +} // namespace ConnectionPool +} // namespace Http namespace Http { namespace AccessLog { @@ -164,6 +165,6 @@ MockRequestInfo::MockRequestInfo() { MockRequestInfo::~MockRequestInfo() {} -} // AccessLog -} // Http -} // Envoy +} // namespace AccessLog +} // namespace Http +} // namespace Envoy diff --git a/test/mocks/http/mocks.h b/test/mocks/http/mocks.h index d93cb094492fb..36dcc647e9f4b 100644 --- a/test/mocks/http/mocks.h +++ b/test/mocks/http/mocks.h @@ -64,7 +64,7 @@ class MockRequestInfo : public RequestInfo { SystemTime start_time_; }; -} // AccessLog +} // namespace AccessLog class MockConnectionManagerConfig : public ConnectionManagerConfig { public: @@ -412,7 +412,7 @@ class MockFilterChainFactoryCallbacks : public Http::FilterChainFactoryCallbacks MOCK_METHOD1(addStreamFilter, void(Http::StreamFilterSharedPtr filter)); MOCK_METHOD1(addAccessLogHandler, void(Http::AccessLog::InstanceSharedPtr handler)); }; -} // Http +} // namespace Http namespace Http { namespace ConnectionPool { @@ -440,8 +440,8 @@ class MockInstance : public Instance { new testing::NiceMock()}; }; -} // ConnectionPool -} // Http +} // namespace ConnectionPool +} // namespace Http MATCHER_P(HeaderMapEqual, rhs, "") { Http::HeaderMapImpl& lhs = *dynamic_cast(arg.get()); @@ -452,4 +452,4 @@ MATCHER_P(HeaderMapEqualRef, rhs, "") { const Http::HeaderMapImpl& lhs = *dynamic_cast(&arg); return lhs == *dynamic_cast(rhs); } -} // Envoy +} // namespace Envoy diff --git a/test/mocks/init/mocks.cc b/test/mocks/init/mocks.cc index 9607f8c8c34e3..a62ab110442e4 100644 --- a/test/mocks/init/mocks.cc +++ b/test/mocks/init/mocks.cc @@ -6,8 +6,8 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::Invoke; +using testing::_; namespace Init { @@ -22,11 +22,12 @@ MockTarget::MockTarget() { MockTarget::~MockTarget() {} MockManager::MockManager() { - ON_CALL(*this, registerTarget(_)) - .WillByDefault(Invoke([this](Target& target) -> void { targets_.push_back(&target); })); + ON_CALL(*this, registerTarget(_)).WillByDefault(Invoke([this](Target& target) -> void { + targets_.push_back(&target); + })); } MockManager::~MockManager() {} -} // Init -} // Envoy +} // namespace Init +} // namespace Envoy diff --git a/test/mocks/init/mocks.h b/test/mocks/init/mocks.h index b9bd38e57081a..f2bae7d9dcc2a 100644 --- a/test/mocks/init/mocks.h +++ b/test/mocks/init/mocks.h @@ -40,5 +40,5 @@ class MockManager : public Manager { ReadyWatcher initialized_; }; -} // Init -} // Envoy +} // namespace Init +} // namespace Envoy diff --git a/test/mocks/local_info/mocks.cc b/test/mocks/local_info/mocks.cc index d2b356638d3b1..15ac6893c7dc6 100644 --- a/test/mocks/local_info/mocks.cc +++ b/test/mocks/local_info/mocks.cc @@ -20,5 +20,5 @@ MockLocalInfo::MockLocalInfo() : address_(new Network::Address::Ipv4Instance("12 MockLocalInfo::~MockLocalInfo() {} -} // LocalInfo -} // Envoy +} // namespace LocalInfo +} // namespace Envoy diff --git a/test/mocks/local_info/mocks.h b/test/mocks/local_info/mocks.h index 83cf703b89d5e..96f3c5f5b07ea 100644 --- a/test/mocks/local_info/mocks.h +++ b/test/mocks/local_info/mocks.h @@ -25,5 +25,5 @@ class MockLocalInfo : public LocalInfo { std::string node_name_{"node_name"}; }; -} // LocalInfo -} // Envoy +} // namespace LocalInfo +} // namespace Envoy diff --git a/test/mocks/network/mocks.cc b/test/mocks/network/mocks.cc index 7b62e24451388..1dee8d2e9fe14 100644 --- a/test/mocks/network/mocks.cc +++ b/test/mocks/network/mocks.cc @@ -13,12 +13,12 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::Invoke; using testing::Return; using testing::ReturnPointee; using testing::ReturnRef; using testing::SaveArg; +using testing::_; namespace Network { @@ -46,20 +46,20 @@ template static void initializeMockConnection(T& connection) { ON_CALL(connection, dispatcher()).WillByDefault(ReturnRef(connection.dispatcher_)); ON_CALL(connection, readEnabled()).WillByDefault(ReturnPointee(&connection.read_enabled_)); ON_CALL(connection, addConnectionCallbacks(_)) - .WillByDefault(Invoke([&connection](Network::ConnectionCallbacks& callbacks) - -> void { connection.callbacks_.push_back(&callbacks); })); - ON_CALL(connection, close(_)) - .WillByDefault(Invoke([&connection](ConnectionCloseType) -> void { - connection.raiseEvents(Network::ConnectionEvent::LocalClose); + .WillByDefault(Invoke([&connection](Network::ConnectionCallbacks& callbacks) -> void { + connection.callbacks_.push_back(&callbacks); })); + ON_CALL(connection, close(_)).WillByDefault(Invoke([&connection](ConnectionCloseType) -> void { + connection.raiseEvents(Network::ConnectionEvent::LocalClose); + })); ON_CALL(connection, remoteAddress()).WillByDefault(ReturnPointee(connection.remote_address_)); ON_CALL(connection, id()).WillByDefault(Return(connection.next_id_)); ON_CALL(connection, state()).WillByDefault(ReturnPointee(&connection.state_)); // The real implementation will move the buffer data into the socket. - ON_CALL(connection, write(_)) - .WillByDefault( - Invoke([](Buffer::Instance& buffer) -> void { buffer.drain(buffer.length()); })); + ON_CALL(connection, write(_)).WillByDefault(Invoke([](Buffer::Instance& buffer) -> void { + buffer.drain(buffer.length()); + })); } MockConnection::MockConnection() { initializeMockConnection(*this); } @@ -130,5 +130,5 @@ MockListener::~MockListener() { onDestroy(); } MockConnectionHandler::MockConnectionHandler() {} MockConnectionHandler::~MockConnectionHandler() {} -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/test/mocks/network/mocks.h b/test/mocks/network/mocks.h index 3b5c189664cfa..b34887a30fc07 100644 --- a/test/mocks/network/mocks.h +++ b/test/mocks/network/mocks.h @@ -237,5 +237,5 @@ class MockConnectionHandler : public ConnectionHandler { MOCK_METHOD0(stopListeners, void()); }; -} // Network -} // Envoy +} // namespace Network +} // namespace Envoy diff --git a/test/mocks/ratelimit/mocks.cc b/test/mocks/ratelimit/mocks.cc index b4179e0153a55..d059fb1bc68d1 100644 --- a/test/mocks/ratelimit/mocks.cc +++ b/test/mocks/ratelimit/mocks.cc @@ -6,5 +6,5 @@ namespace RateLimit { MockClient::MockClient() {} MockClient::~MockClient() {} -} // RateLimit -} // Envoy +} // namespace RateLimit +} // namespace Envoy diff --git a/test/mocks/ratelimit/mocks.h b/test/mocks/ratelimit/mocks.h index a5cb0b9cd798d..26478974afda0 100644 --- a/test/mocks/ratelimit/mocks.h +++ b/test/mocks/ratelimit/mocks.h @@ -31,5 +31,5 @@ inline bool operator==(const Descriptor& lhs, const Descriptor& rhs) { return lhs.entries_ == rhs.entries_; } -} // RateLimit -} // Envoy +} // namespace RateLimit +} // namespace Envoy diff --git a/test/mocks/redis/mocks.cc b/test/mocks/redis/mocks.cc index d7589a5798af1..85245270d7cab 100644 --- a/test/mocks/redis/mocks.cc +++ b/test/mocks/redis/mocks.cc @@ -10,8 +10,8 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::Invoke; +using testing::_; namespace Redis { @@ -51,8 +51,9 @@ bool operator==(const RespValue& lhs, const RespValue& rhs) { MockEncoder::MockEncoder() { ON_CALL(*this, encode(_, _)) - .WillByDefault(Invoke([this](const RespValue& value, Buffer::Instance& out) - -> void { real_encoder_.encode(value, out); })); + .WillByDefault(Invoke([this](const RespValue& value, Buffer::Instance& out) -> void { + real_encoder_.encode(value, out); + })); } MockEncoder::~MockEncoder() {} @@ -64,11 +65,12 @@ namespace ConnPool { MockClient::MockClient() { ON_CALL(*this, addConnectionCallbacks(_)) - .WillByDefault(Invoke([this](Network::ConnectionCallbacks& callbacks) - -> void { callbacks_.push_back(&callbacks); })); - ON_CALL(*this, close()) - .WillByDefault( - Invoke([this]() -> void { raiseEvents(Network::ConnectionEvent::LocalClose); })); + .WillByDefault(Invoke([this](Network::ConnectionCallbacks& callbacks) -> void { + callbacks_.push_back(&callbacks); + })); + ON_CALL(*this, close()).WillByDefault(Invoke([this]() -> void { + raiseEvents(Network::ConnectionEvent::LocalClose); + })); } MockClient::~MockClient() {} @@ -82,7 +84,7 @@ MockPoolCallbacks::~MockPoolCallbacks() {} MockInstance::MockInstance() {} MockInstance::~MockInstance() {} -} // ConnPool +} // namespace ConnPool namespace CommandSplitter { @@ -95,6 +97,6 @@ MockSplitCallbacks::~MockSplitCallbacks() {} MockInstance::MockInstance() {} MockInstance::~MockInstance() {} -} // CommandSplitter -} // Redis -} // Envoy +} // namespace CommandSplitter +} // namespace Redis +} // namespace Envoy diff --git a/test/mocks/redis/mocks.h b/test/mocks/redis/mocks.h index f00550e5f6041..1b9edcda22f22 100644 --- a/test/mocks/redis/mocks.h +++ b/test/mocks/redis/mocks.h @@ -85,7 +85,7 @@ class MockInstance : public Instance { PoolCallbacks& callbacks)); }; -} // ConnPool +} // namespace ConnPool namespace CommandSplitter { @@ -119,6 +119,6 @@ class MockInstance : public Instance { MOCK_METHOD2(makeRequest_, SplitRequest*(const RespValue& request, SplitCallbacks& callbacks)); }; -} // CommandSplitter -} // Redis -} // Envoy +} // namespace CommandSplitter +} // namespace Redis +} // namespace Envoy diff --git a/test/mocks/router/mocks.cc b/test/mocks/router/mocks.cc index 67a7563fed679..85b972d624554 100644 --- a/test/mocks/router/mocks.cc +++ b/test/mocks/router/mocks.cc @@ -6,11 +6,11 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::NiceMock; using testing::Return; using testing::ReturnRef; using testing::SaveArg; +using testing::_; namespace Router { @@ -77,5 +77,5 @@ MockConfig::~MockConfig() {} MockRoute::MockRoute() { ON_CALL(*this, routeEntry()).WillByDefault(Return(&route_entry_)); } MockRoute::~MockRoute() {} -} // Router -} // Envoy +} // namespace Router +} // namespace Envoy diff --git a/test/mocks/router/mocks.h b/test/mocks/router/mocks.h index 4a59fe30f8258..948942042638e 100644 --- a/test/mocks/router/mocks.h +++ b/test/mocks/router/mocks.h @@ -204,5 +204,5 @@ class MockConfig : public Config { std::list response_headers_to_remove_; }; -} // Router -} // Envoy +} // namespace Router +} // namespace Envoy diff --git a/test/mocks/runtime/mocks.cc b/test/mocks/runtime/mocks.cc index 617a8f604104e..73dea53f3230c 100644 --- a/test/mocks/runtime/mocks.cc +++ b/test/mocks/runtime/mocks.cc @@ -4,8 +4,8 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::ReturnArg; +using testing::_; namespace Runtime { @@ -17,5 +17,5 @@ MockLoader::MockLoader() { ON_CALL(*this, snapshot()).WillByDefault(ReturnRef(sn MockLoader::~MockLoader() {} -} // Runtime -} // Envoy +} // namespace Runtime +} // namespace Envoy diff --git a/test/mocks/runtime/mocks.h b/test/mocks/runtime/mocks.h index b7eb091eb24d6..c80ac0ab3c3eb 100644 --- a/test/mocks/runtime/mocks.h +++ b/test/mocks/runtime/mocks.h @@ -40,5 +40,5 @@ class MockLoader : public Loader { testing::NiceMock snapshot_; }; -} // Runtime -} // Envoy +} // namespace Runtime +} // namespace Envoy diff --git a/test/mocks/server/mocks.cc b/test/mocks/server/mocks.cc index 1f10775e1468e..7431d89f2b2dc 100644 --- a/test/mocks/server/mocks.cc +++ b/test/mocks/server/mocks.cc @@ -5,11 +5,11 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -using testing::_; using testing::Return; using testing::ReturnNew; using testing::ReturnRef; using testing::SaveArg; +using testing::_; namespace Envoy { namespace Server { @@ -104,6 +104,6 @@ MockFactoryContext::MockFactoryContext() { MockFactoryContext::~MockFactoryContext() {} -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/test/mocks/server/mocks.h b/test/mocks/server/mocks.h index ace46446cce9a..f22d1b4e9f38f 100644 --- a/test/mocks/server/mocks.h +++ b/test/mocks/server/mocks.h @@ -30,8 +30,8 @@ #include "test/mocks/upstream/mocks.h" #include "gmock/gmock.h" -#include "gtest/gtest.h" #include "spdlog/spdlog.h" +#include "gtest/gtest.h" namespace Envoy { namespace Server { @@ -308,6 +308,6 @@ class MockFactoryContext : public FactoryContext { testing::NiceMock thread_local_; }; -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/test/mocks/ssl/mocks.cc b/test/mocks/ssl/mocks.cc index 2b4cf8848b948..30da3c11bf3d0 100644 --- a/test/mocks/ssl/mocks.cc +++ b/test/mocks/ssl/mocks.cc @@ -12,5 +12,5 @@ MockConnection::~MockConnection() {} MockClientContext::MockClientContext() {} MockClientContext::~MockClientContext() {} -} // Ssl -} // Envoy +} // namespace Ssl +} // namespace Envoy diff --git a/test/mocks/ssl/mocks.h b/test/mocks/ssl/mocks.h old mode 100755 new mode 100644 index ecdc0c7d8ae61..0f94daae167c0 --- a/test/mocks/ssl/mocks.h +++ b/test/mocks/ssl/mocks.h @@ -55,5 +55,5 @@ class MockClientContext : public ClientContext { MOCK_METHOD0(getCertChainInformation, std::string()); }; -} // Ssl -} // Envoy +} // namespace Ssl +} // namespace Envoy diff --git a/test/mocks/stats/mocks.cc b/test/mocks/stats/mocks.cc index 2128d213e5e8c..a3dfe2372fb32 100644 --- a/test/mocks/stats/mocks.cc +++ b/test/mocks/stats/mocks.cc @@ -26,5 +26,5 @@ MockStore::~MockStore() {} MockIsolatedStatsStore::MockIsolatedStatsStore() {} MockIsolatedStatsStore::~MockIsolatedStatsStore() {} -} // Stats -} // Envoy +} // namespace Stats +} // namespace Envoy diff --git a/test/mocks/stats/mocks.h b/test/mocks/stats/mocks.h index 23e98ab0ff275..a15b091e0f882 100644 --- a/test/mocks/stats/mocks.h +++ b/test/mocks/stats/mocks.h @@ -95,5 +95,5 @@ class MockIsolatedStatsStore : public IsolatedStoreImpl { MOCK_METHOD2(deliverTimingToSinks, void(const std::string&, std::chrono::milliseconds)); }; -} // Stats -} // Envoy +} // namespace Stats +} // namespace Envoy diff --git a/test/mocks/thread_local/mocks.cc b/test/mocks/thread_local/mocks.cc index 0fad042a8704e..75eae39a87c10 100644 --- a/test/mocks/thread_local/mocks.cc +++ b/test/mocks/thread_local/mocks.cc @@ -4,8 +4,8 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::Invoke; +using testing::_; namespace ThreadLocal { @@ -19,5 +19,5 @@ MockInstance::MockInstance() { MockInstance::~MockInstance() {} -} // ThreadLocal -} // Envoy +} // namespace ThreadLocal +} // namespace Envoy diff --git a/test/mocks/thread_local/mocks.h b/test/mocks/thread_local/mocks.h index 19a53ebde13ca..7dbf6d4d2bc07 100644 --- a/test/mocks/thread_local/mocks.h +++ b/test/mocks/thread_local/mocks.h @@ -40,5 +40,5 @@ class MockInstance : public Instance { std::unordered_map data_; }; -} // ThreadLocal -} // Envoy +} // namespace ThreadLocal +} // namespace Envoy diff --git a/test/mocks/tracing/mocks.cc b/test/mocks/tracing/mocks.cc index dc0fb763d0b07..a88d223660473 100644 --- a/test/mocks/tracing/mocks.cc +++ b/test/mocks/tracing/mocks.cc @@ -27,5 +27,5 @@ MockHttpTracer::~MockHttpTracer() {} MockDriver::MockDriver() {} MockDriver::~MockDriver() {} -} // Tracing -} // Envoy +} // namespace Tracing +} // namespace Envoy diff --git a/test/mocks/tracing/mocks.h b/test/mocks/tracing/mocks.h index d939d0fc336e1..6d9117fcc4b89 100644 --- a/test/mocks/tracing/mocks.h +++ b/test/mocks/tracing/mocks.h @@ -79,5 +79,5 @@ class MockDriver : public Driver { const std::string& operation_name, SystemTime start_time)); }; -} // Tracing -} // Envoy +} // namespace Tracing +} // namespace Envoy diff --git a/test/mocks/upstream/cluster_info.h b/test/mocks/upstream/cluster_info.h index c2cf7977da78a..048e7356b5604 100644 --- a/test/mocks/upstream/cluster_info.h +++ b/test/mocks/upstream/cluster_info.h @@ -48,5 +48,5 @@ class MockClusterInfo : public ClusterInfo { LoadBalancerType lb_type_{LoadBalancerType::RoundRobin}; }; -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/test/mocks/upstream/host.h b/test/mocks/upstream/host.h index a3acf1c8c4bb0..43c7f77a2febf 100644 --- a/test/mocks/upstream/host.h +++ b/test/mocks/upstream/host.h @@ -59,7 +59,7 @@ class MockDetector : public Detector { std::list callbacks_; }; -} // Outlier +} // namespace Outlier class MockHostDescription : public HostDescription { public: @@ -125,5 +125,5 @@ class MockHost : public Host { HostStats stats_{ALL_HOST_STATS(POOL_COUNTER(stats_store_), POOL_GAUGE(stats_store_))}; }; -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/test/mocks/upstream/mocks.cc b/test/mocks/upstream/mocks.cc index b64ad4ccd955d..d7318fedebd98 100644 --- a/test/mocks/upstream/mocks.cc +++ b/test/mocks/upstream/mocks.cc @@ -12,12 +12,12 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::Invoke; using testing::Return; using testing::ReturnPointee; using testing::ReturnRef; using testing::SaveArg; +using testing::_; namespace Upstream { namespace Outlier { @@ -29,13 +29,14 @@ MockEventLogger::MockEventLogger() {} MockEventLogger::~MockEventLogger() {} MockDetector::MockDetector() { - ON_CALL(*this, addChangedStateCb(_)) - .WillByDefault(Invoke([this](ChangeStateCb cb) -> void { callbacks_.push_back(cb); })); + ON_CALL(*this, addChangedStateCb(_)).WillByDefault(Invoke([this](ChangeStateCb cb) -> void { + callbacks_.push_back(cb); + })); } MockDetector::~MockDetector() {} -} // Outlier +} // namespace Outlier MockHostDescription::MockHostDescription() : address_(Network::Utility::resolveUrl("tcp://10.0.0.1:443")) { @@ -68,16 +69,17 @@ MockClusterInfo::MockClusterInfo() ON_CALL(*this, stats()).WillByDefault(ReturnRef(stats_)); ON_CALL(*this, statsScope()).WillByDefault(ReturnRef(stats_store_)); ON_CALL(*this, resourceManager(_)) - .WillByDefault(Invoke([this](ResourcePriority) - -> Upstream::ResourceManager& { return *resource_manager_; })); + .WillByDefault(Invoke( + [this](ResourcePriority) -> Upstream::ResourceManager& { return *resource_manager_; })); ON_CALL(*this, lbType()).WillByDefault(ReturnPointee(&lb_type_)); } MockClusterInfo::~MockClusterInfo() {} MockCluster::MockCluster() { - ON_CALL(*this, addMemberUpdateCb(_)) - .WillByDefault(Invoke([this](MemberUpdateCb cb) -> void { callbacks_.push_back(cb); })); + ON_CALL(*this, addMemberUpdateCb(_)).WillByDefault(Invoke([this](MemberUpdateCb cb) -> void { + callbacks_.push_back(cb); + })); ON_CALL(*this, hosts()).WillByDefault(ReturnRef(hosts_)); ON_CALL(*this, healthyHosts()).WillByDefault(ReturnRef(healthy_hosts_)); ON_CALL(*this, hostsPerZone()).WillByDefault(ReturnRef(hosts_per_zone_)); @@ -117,8 +119,9 @@ MockClusterManager::MockClusterManager() { MockClusterManager::~MockClusterManager() {} MockHealthChecker::MockHealthChecker() { - ON_CALL(*this, addHostCheckCompleteCb(_)) - .WillByDefault(Invoke([this](HostStatusCb cb) -> void { callbacks_.push_back(cb); })); + ON_CALL(*this, addHostCheckCompleteCb(_)).WillByDefault(Invoke([this](HostStatusCb cb) -> void { + callbacks_.push_back(cb); + })); } MockHealthChecker::~MockHealthChecker() {} @@ -129,5 +132,5 @@ MockCdsApi::MockCdsApi() { MockCdsApi::~MockCdsApi() {} -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/test/mocks/upstream/mocks.h b/test/mocks/upstream/mocks.h index cd866f0e221b9..a80ffe4d4eddc 100644 --- a/test/mocks/upstream/mocks.h +++ b/test/mocks/upstream/mocks.h @@ -141,5 +141,5 @@ class MockCdsApi : public CdsApi { std::function initialized_callback_; }; -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/test/server/backtrace_test.cc b/test/server/backtrace_test.cc index fd012d5d8939b..4b49766103ba3 100644 --- a/test/server/backtrace_test.cc +++ b/test/server/backtrace_test.cc @@ -17,4 +17,4 @@ TEST(Backward, InvalidUsageTest) { BackwardsTrace tracer; tracer.logTrace(); } -} // Envoy +} // namespace Envoy diff --git a/test/server/config/http/config_test.cc b/test/server/config/http/config_test.cc index ff50ade710dcf..85fd6358fba31 100644 --- a/test/server/config/http/config_test.cc +++ b/test/server/config/http/config_test.cc @@ -22,9 +22,9 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::NiceMock; using testing::Return; +using testing::_; namespace Server { namespace Configuration { @@ -281,6 +281,6 @@ TEST(HttpTracerConfigTest, DoubleRegistrationTest) { "Double registration for name: 'zipkin'"); } -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/test/server/config/network/config_test.cc b/test/server/config/network/config_test.cc index e9c3391f72c16..3db67be240588 100644 --- a/test/server/config/network/config_test.cc +++ b/test/server/config/network/config_test.cc @@ -18,8 +18,8 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::NiceMock; +using testing::_; namespace Server { namespace Configuration { @@ -408,6 +408,6 @@ TEST(NetworkFilterConfigTest, DoubleRegistrationTest) { EnvoyException, "Double registration for name: 'client_ssl_auth'"); } -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/test/server/config/network/http_connection_manager_test.cc b/test/server/config/network/http_connection_manager_test.cc index 68fb2fb4aa0ff..2ff9300af1576 100644 --- a/test/server/config/network/http_connection_manager_test.cc +++ b/test/server/config/network/http_connection_manager_test.cc @@ -165,6 +165,6 @@ TEST(HttpConnectionManagerConfigUtilityTest, DetermineNextProtocol) { } } -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/test/server/config_validation/async_client_test.cc b/test/server/config_validation/async_client_test.cc index fcaa91bd273a7..2d198746f1c0d 100644 --- a/test/server/config_validation/async_client_test.cc +++ b/test/server/config_validation/async_client_test.cc @@ -21,5 +21,5 @@ TEST(ValidationAsyncClientTest, MockedMethods) { EXPECT_EQ(nullptr, client.start(stream_callbacks, Optional())); } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/test/server/config_validation/cluster_manager_test.cc b/test/server/config_validation/cluster_manager_test.cc index 76f64c1da40b0..dc51d19157c58 100644 --- a/test/server/config_validation/cluster_manager_test.cc +++ b/test/server/config_validation/cluster_manager_test.cc @@ -54,5 +54,5 @@ TEST(ValidationClusterManagerTest, MockedMethods) { EXPECT_EQ(nullptr, client.start(stream_callbacks, Optional())); } -} // Upstream -} // Envoy +} // namespace Upstream +} // namespace Envoy diff --git a/test/server/config_validation/server_test.cc b/test/server/config_validation/server_test.cc index 4523fbf082ccd..86817b93c111f 100644 --- a/test/server/config_validation/server_test.cc +++ b/test/server/config_validation/server_test.cc @@ -41,5 +41,5 @@ INSTANTIATE_TEST_CASE_P(ValidConfigs, ValidationServerTest, ::testing::Values("front-envoy.json", "google_com_proxy.json", "s2s-grpc-envoy.json", "service-envoy.json")); -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/test/server/configuration_impl_test.cc b/test/server/configuration_impl_test.cc index 1632b634731b9..9abd6518693f8 100644 --- a/test/server/configuration_impl_test.cc +++ b/test/server/configuration_impl_test.cc @@ -251,6 +251,6 @@ TEST_F(ConfigurationImplTest, ConfigurationFailsWhenInvalidTracerSpecified) { EnvoyException, "No HttpTracerFactory found for type: invalid"); } -} // Configuration -} // Server -} // Envoy +} // namespace Configuration +} // namespace Server +} // namespace Envoy diff --git a/test/server/connection_handler_test.cc b/test/server/connection_handler_test.cc index 4bed4a3f086f5..4d3e85b19317d 100644 --- a/test/server/connection_handler_test.cc +++ b/test/server/connection_handler_test.cc @@ -10,12 +10,12 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -using testing::_; using testing::ByRef; using testing::InSequence; using testing::Invoke; using testing::NiceMock; using testing::Return; +using testing::_; namespace Envoy { namespace Server { @@ -215,5 +215,5 @@ TEST_F(ConnectionHandlerTest, FindListenerByAddress) { EXPECT_CALL(*listener3, onDestroy()); } -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/test/server/drain_manager_impl_test.cc b/test/server/drain_manager_impl_test.cc index e2eab6edaf79a..d4b4d7ed79cc1 100644 --- a/test/server/drain_manager_impl_test.cc +++ b/test/server/drain_manager_impl_test.cc @@ -8,9 +8,9 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::Return; using testing::SaveArg; +using testing::_; namespace Server { @@ -51,5 +51,5 @@ TEST(DrainManagerImplTest, All) { EXPECT_TRUE(drain_manager.drainClose()); } -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/test/server/guarddog_impl_test.cc b/test/server/guarddog_impl_test.cc index e65e665b23e3d..baef92f35f3cc 100644 --- a/test/server/guarddog_impl_test.cc +++ b/test/server/guarddog_impl_test.cc @@ -34,10 +34,9 @@ class GuardDogDeathTest : public testing::Test { GuardDogDeathTest() : config_kill_(1000, 1000, 100, 1000), config_multikill_(1000, 1000, 1000, 500), mock_time_(0) { - ON_CALL(time_source_, currentTime()) - .WillByDefault(testing::Invoke([this]() { - return std::chrono::steady_clock::time_point(std::chrono::milliseconds(mock_time_)); - })); + ON_CALL(time_source_, currentTime()).WillByDefault(testing::Invoke([this]() { + return std::chrono::steady_clock::time_point(std::chrono::milliseconds(mock_time_)); + })); } /** @@ -134,10 +133,9 @@ TEST_F(GuardDogAlmostDeadTest, NearDeathTest) { class GuardDogMissTest : public testing::Test { protected: GuardDogMissTest() : config_miss_(500, 1000, 0, 0), config_mega_(1000, 500, 0, 0), mock_time_(0) { - ON_CALL(time_source_, currentTime()) - .WillByDefault(testing::Invoke([this]() { - return std::chrono::steady_clock::time_point(std::chrono::milliseconds(mock_time_)); - })); + ON_CALL(time_source_, currentTime()).WillByDefault(testing::Invoke([this]() { + return std::chrono::steady_clock::time_point(std::chrono::milliseconds(mock_time_)); + })); } NiceMock config_miss_; @@ -169,10 +167,9 @@ TEST_F(GuardDogMissTest, MissTest) { TEST_F(GuardDogMissTest, MegaMissTest) { // This test checks the actual collected statistics after doing some timer // advances that should and shouldn't increment the counters. - ON_CALL(time_source_, currentTime()) - .WillByDefault(testing::Invoke([this]() { - return std::chrono::steady_clock::time_point(std::chrono::milliseconds(mock_time_)); - })); + ON_CALL(time_source_, currentTime()).WillByDefault(testing::Invoke([this]() { + return std::chrono::steady_clock::time_point(std::chrono::milliseconds(mock_time_)); + })); GuardDogImpl gd(stats_store_, config_mega_, time_source_); auto unpet_dog = gd.createWatchDog(0); // We'd better start at 0: @@ -193,10 +190,9 @@ TEST_F(GuardDogMissTest, MissCountTest) { // This tests a flake discovered in the MissTest where real timeout or // spurious condition_variable wakeup causes the counter to get incremented // more than it should be. - ON_CALL(time_source_, currentTime()) - .WillByDefault(testing::Invoke([this]() { - return std::chrono::steady_clock::time_point(std::chrono::milliseconds(mock_time_)); - })); + ON_CALL(time_source_, currentTime()).WillByDefault(testing::Invoke([this]() { + return std::chrono::steady_clock::time_point(std::chrono::milliseconds(mock_time_)); + })); GuardDogImpl gd(stats_store_, config_miss_, time_source_); auto sometimes_pet_dog = gd.createWatchDog(0); // These steps are executed once without ever touching the watchdog. @@ -279,5 +275,5 @@ TEST(WatchDogTimeTest, AtomicIsAtomicTest) { ASSERT_EQ(atomic_time.is_lock_free(), true); } -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/test/server/http/admin_test.cc b/test/server/http/admin_test.cc index 9b40cbdbce580..2f892274c9914 100644 --- a/test/server/http/admin_test.cc +++ b/test/server/http/admin_test.cc @@ -15,8 +15,8 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::NiceMock; +using testing::_; namespace Server { @@ -120,13 +120,14 @@ TEST_P(AdminInstanceTest, AdminBadAddressOutPath) { } TEST_P(AdminInstanceTest, CustomHandler) { - auto callback = - [&](const std::string&, Buffer::Instance&) -> Http::Code { return Http::Code::Accepted; }; + auto callback = [&](const std::string&, Buffer::Instance&) -> Http::Code { + return Http::Code::Accepted; + }; admin_.addHandler("/foo/bar", "hello", callback); Buffer::OwnedImpl response; EXPECT_EQ(Http::Code::Accepted, admin_.runCallback("/foo/bar", response)); } -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/test/server/http/health_check_test.cc b/test/server/http/health_check_test.cc index b1d25fcba6d68..781750a3dc60a 100644 --- a/test/server/http/health_check_test.cc +++ b/test/server/http/health_check_test.cc @@ -13,13 +13,13 @@ #include "gtest/gtest.h" namespace Envoy { -using testing::_; using testing::DoAll; using testing::Invoke; using testing::NiceMock; using testing::Return; using testing::ReturnRef; using testing::SaveArg; +using testing::_; class HealthCheckFilterTest : public testing::Test { public: @@ -220,4 +220,4 @@ TEST(HealthCheckFilterConfig, notFailingWhenNotPassThroughAndTimeoutNotSet) { healthCheckFilterConfig.createFilterFactory(*config, "dummy_stats_prefix", context); } -} // Envoy +} // namespace Envoy diff --git a/test/server/init_manager_impl_test.cc b/test/server/init_manager_impl_test.cc index d191882b94583..530e67df30cd9 100644 --- a/test/server/init_manager_impl_test.cc +++ b/test/server/init_manager_impl_test.cc @@ -5,9 +5,9 @@ #include "gmock/gmock.h" -using testing::_; using testing::InSequence; using testing::Invoke; +using testing::_; namespace Envoy { namespace Server { @@ -39,8 +39,9 @@ TEST_F(InitManagerImplTest, TargetRemoveWhileInitializing) { Init::MockTarget target; manager_.registerTarget(target); - EXPECT_CALL(target, initialize(_)) - .WillOnce(Invoke([](std::function callback) -> void { callback(); })); + EXPECT_CALL(target, initialize(_)).WillOnce(Invoke([](std::function callback) -> void { + callback(); + })); EXPECT_CALL(initialized_, ready()); manager_.initialize([&]() -> void { initialized_.ready(); }); } @@ -62,5 +63,5 @@ TEST_F(InitManagerImplTest, TargetAfterInitializing) { target1.callback_(); } -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/test/server/listener_manager_impl_test.cc b/test/server/listener_manager_impl_test.cc index 346c2370d27e7..cbb664a0587bf 100644 --- a/test/server/listener_manager_impl_test.cc +++ b/test/server/listener_manager_impl_test.cc @@ -9,9 +9,9 @@ #include "gtest/gtest.h" -using testing::_; using testing::Invoke; using testing::NiceMock; +using testing::_; namespace Envoy { namespace Server { @@ -21,13 +21,12 @@ class ListenerManagerImplTest : public testing::Test { ListenerManagerImplTest() { // Use real filter loading by default. ON_CALL(listener_factory_, createFilterFactoryList(_, _)) - .WillByDefault( - Invoke([&](const std::vector& filters, - Server::Configuration::FactoryContext& context) - -> std::vector { - return Server::ProdListenerComponentFactory::createFilterFactoryList_( - filters, server_, context); - })); + .WillByDefault(Invoke([&](const std::vector& filters, + Server::Configuration::FactoryContext& context) + -> std::vector { + return Server::ProdListenerComponentFactory::createFilterFactoryList_(filters, server_, + context); + })); } NiceMock server_; @@ -266,5 +265,5 @@ TEST_F(ListenerManagerImplTest, DeprecatedFilterConfigFactoryRegistrationTest) { manager_.addListener(*loader); } -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/test/server/options_impl_test.cc b/test/server/options_impl_test.cc index c01f290c253d3..f5151a217ec47 100644 --- a/test/server/options_impl_test.cc +++ b/test/server/options_impl_test.cc @@ -7,8 +7,8 @@ #include "server/options_impl.h" -#include "gtest/gtest.h" #include "spdlog/spdlog.h" +#include "gtest/gtest.h" namespace Envoy { // Do the ugly work of turning a std::string into a char** and create an OptionsImpl. Args are @@ -69,4 +69,4 @@ TEST(OptionsImplTest, BadCliOption) { EXPECT_DEATH(createOptionsImpl("envoy -c hello --local-address-ip-version foo"), "error: unknown IP address version 'foo'"); } -} // Envoy +} // namespace Envoy diff --git a/test/server/server_test.cc b/test/server/server_test.cc index fb2ea2d7f56b0..4293cf443249f 100644 --- a/test/server/server_test.cc +++ b/test/server/server_test.cc @@ -43,5 +43,5 @@ TEST_P(ServerInstanceImplTest, Stats) { EXPECT_NE(nullptr, TestUtility::findCounter(stats_store_, "server.watchdog_miss")); } -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/test/server/worker_impl_test.cc b/test/server/worker_impl_test.cc index 5dcdaecca1d4c..3c98ecbdd68d9 100644 --- a/test/server/worker_impl_test.cc +++ b/test/server/worker_impl_test.cc @@ -8,11 +8,11 @@ #include "gtest/gtest.h" -using testing::_; using testing::InSequence; using testing::InvokeWithoutArgs; using testing::NiceMock; using testing::Return; +using testing::_; namespace Envoy { namespace Server { @@ -69,10 +69,9 @@ TEST_F(WorkerImplTest, All) { .WillOnce(InvokeWithoutArgs([current_thread_id]() -> void { EXPECT_NE(current_thread_id, std::this_thread::get_id()); })); - EXPECT_CALL(ready, ready()) - .WillOnce(InvokeWithoutArgs([current_thread_id]() -> void { - EXPECT_NE(current_thread_id, std::this_thread::get_id()); - })); + EXPECT_CALL(ready, ready()).WillOnce(InvokeWithoutArgs([current_thread_id]() -> void { + EXPECT_NE(current_thread_id, std::this_thread::get_id()); + })); worker_.removeListener(listener2, [&ready]() -> void { ready.ready(); }); // Now test adding and removing a listener without stopping it first. @@ -88,14 +87,13 @@ TEST_F(WorkerImplTest, All) { .WillOnce(InvokeWithoutArgs([current_thread_id]() -> void { EXPECT_NE(current_thread_id, std::this_thread::get_id()); })); - EXPECT_CALL(ready, ready()) - .WillOnce(InvokeWithoutArgs([current_thread_id]() -> void { - EXPECT_NE(current_thread_id, std::this_thread::get_id()); - })); + EXPECT_CALL(ready, ready()).WillOnce(InvokeWithoutArgs([current_thread_id]() -> void { + EXPECT_NE(current_thread_id, std::this_thread::get_id()); + })); worker_.removeListener(listener3, [&ready]() -> void { ready.ready(); }); worker_.stop(); } -} // Server -} // Envoy +} // namespace Server +} // namespace Envoy diff --git a/test/test_common/environment.cc b/test/test_common/environment.cc index e8b2911b1a250..211fabf6e61e5 100644 --- a/test/test_common/environment.cc +++ b/test/test_common/environment.cc @@ -198,4 +198,4 @@ void TestEnvironment::exec(const std::vector& args) { RELEASE_ASSERT(false); } } -} // Envoy +} // namespace Envoy diff --git a/test/test_common/environment.h b/test/test_common/environment.h index 9f845776a50d7..acd3ace847bb7 100644 --- a/test/test_common/environment.h +++ b/test/test_common/environment.h @@ -142,4 +142,4 @@ class TestEnvironment { */ static void exec(const std::vector& args); }; -} // Envoy +} // namespace Envoy diff --git a/test/test_common/network_utility.cc b/test/test_common/network_utility.cc index 441753c6b70e2..d12866301ddf5 100644 --- a/test/test_common/network_utility.cc +++ b/test/test_common/network_utility.cc @@ -22,8 +22,8 @@ namespace Test { Address::InstanceConstSharedPtr findOrCheckFreePort(Address::InstanceConstSharedPtr addr_port, Address::SocketType type) { if (addr_port == nullptr || addr_port->type() != Address::Type::Ip) { - ADD_FAILURE() << "Not an internet address: " << (addr_port == nullptr ? "nullptr" - : addr_port->asString()); + ADD_FAILURE() << "Not an internet address: " + << (addr_port == nullptr ? "nullptr" : addr_port->asString()); return nullptr; } const int fd = addr_port->socket(type); @@ -173,6 +173,6 @@ std::pair bindFreeLoopbackPort(Address::Ip throw EnvoyException(msg); } -} // Test -} // Network -} // Envoy +} // namespace Test +} // namespace Network +} // namespace Envoy diff --git a/test/test_common/network_utility.h b/test/test_common/network_utility.h index d3504485ba2cc..81590ac0a7505 100644 --- a/test/test_common/network_utility.h +++ b/test/test_common/network_utility.h @@ -96,6 +96,6 @@ bool supportsIpVersion(const Address::IpVersion version); std::pair bindFreeLoopbackPort(Address::IpVersion version, Address::SocketType type); -} // Test -} // Network -} // Envoy +} // namespace Test +} // namespace Network +} // namespace Envoy diff --git a/test/test_common/network_utility_test.cc b/test/test_common/network_utility_test.cc index f889f0d5d62ac..a95c5722f3a77 100644 --- a/test/test_common/network_utility_test.cc +++ b/test/test_common/network_utility_test.cc @@ -47,4 +47,4 @@ TEST_P(NetworkUtilityTest, DISABLED_ValidateBindFreeLoopbackPort) { } // namespace Test } // namespace Network -} // Envoy +} // namespace Envoy diff --git a/test/test_common/printers.cc b/test/test_common/printers.cc index bc1ae2c95fc12..522adc95fd4a6 100644 --- a/test/test_common/printers.cc +++ b/test/test_common/printers.cc @@ -11,10 +11,12 @@ namespace Envoy { namespace Http { void PrintTo(const HeaderMapImpl& headers, std::ostream* os) { - headers.iterate([](const HeaderEntry& header, void* context) -> void { - std::ostream* os = static_cast(context); - *os << "{'" << header.key().c_str() << "','" << header.value().c_str() << "'}"; - }, os); + headers.iterate( + [](const HeaderEntry& header, void* context) -> void { + std::ostream* os = static_cast(context); + *os << "{'" << header.key().c_str() << "','" << header.value().c_str() << "'}"; + }, + os); } void PrintTo(const HeaderMapPtr& headers, std::ostream* os) { @@ -24,7 +26,7 @@ void PrintTo(const HeaderMapPtr& headers, std::ostream* os) { void PrintTo(const HeaderMap& headers, std::ostream* os) { PrintTo(*dynamic_cast(&headers), os); } -} // Http +} // namespace Http namespace Buffer { void PrintTo(const Instance& buffer, std::ostream* os) { @@ -34,11 +36,11 @@ void PrintTo(const Instance& buffer, std::ostream* os) { void PrintTo(const Buffer::OwnedImpl& buffer, std::ostream* os) { PrintTo(dynamic_cast(buffer), os); } -} // Buffer +} // namespace Buffer namespace Redis { void PrintTo(const RespValue& value, std::ostream* os) { *os << value.toString(); } void PrintTo(const RespValuePtr& value, std::ostream* os) { *os << value->toString(); } -} // Redis -} // Envoy +} // namespace Redis +} // namespace Envoy diff --git a/test/test_common/printers.h b/test/test_common/printers.h index c3ab68cbb5b5d..536cc8140333b 100644 --- a/test/test_common/printers.h +++ b/test/test_common/printers.h @@ -20,7 +20,7 @@ class HeaderMap; typedef std::unique_ptr HeaderMapPtr; void PrintTo(const HeaderMap& headers, std::ostream* os); void PrintTo(const HeaderMapPtr& headers, std::ostream* os); -} // Http +} // namespace Http namespace Buffer { /** @@ -34,7 +34,7 @@ void PrintTo(const Instance& buffer, std::ostream* os); */ class OwnedImpl; void PrintTo(const OwnedImpl& buffer, std::ostream* os); -} // Buffer +} // namespace Buffer namespace Redis { /** @@ -44,5 +44,5 @@ class RespValue; typedef std::unique_ptr RespValuePtr; void PrintTo(const RespValue& value, std::ostream* os); void PrintTo(const RespValuePtr& value, std::ostream* os); -} // Redis -} // Envoy +} // namespace Redis +} // namespace Envoy diff --git a/test/test_common/utility.cc b/test/test_common/utility.cc index c01460fa4b0d7..e8067cf0ad82b 100644 --- a/test/test_common/utility.cc +++ b/test/test_common/utility.cc @@ -19,8 +19,8 @@ #include "test/test_common/printers.h" -#include "gtest/gtest.h" #include "spdlog/spdlog.h" +#include "gtest/gtest.h" namespace Envoy { @@ -184,5 +184,5 @@ bool TestHeaderMapImpl::has(const std::string& key) { return get(LowerCaseString bool TestHeaderMapImpl::has(const LowerCaseString& key) { return get(key) != nullptr; } -} // Http -} // Envoy +} // namespace Http +} // namespace Envoy diff --git a/test/test_common/utility.h b/test/test_common/utility.h index 8e4c07ff15767..c2a8ad7e626a5 100644 --- a/test/test_common/utility.h +++ b/test/test_common/utility.h @@ -140,7 +140,7 @@ class TestHeaderMapImpl : public HeaderMapImpl { bool has(const LowerCaseString& key); }; -} // Http +} // namespace Http MATCHER_P(ProtoEq, rhs, "") { return TestUtility::protoEqual(arg, rhs); } diff --git a/test/test_runner.h b/test/test_runner.h index 573bfc84c2ee1..3a92b0b6c5a4a 100644 --- a/test/test_runner.h +++ b/test/test_runner.h @@ -33,4 +33,4 @@ class TestRunner { return RUN_ALL_TESTS(); } }; -} // Envoy +} // namespace Envoy diff --git a/test/tools/config_load_check/config_load_check.cc b/test/tools/config_load_check/config_load_check.cc index a6c1bb0ad2e4e..20e4fcde88742 100644 --- a/test/tools/config_load_check/config_load_check.cc +++ b/test/tools/config_load_check/config_load_check.cc @@ -5,15 +5,16 @@ #include "test/config_test/config_test.h" -#include "gtest/gtest.h" #include "spdlog/spdlog.h" +#include "gtest/gtest.h" int main(int argc, char* argv[]) { if (argc != 2) { std::cerr << "Usage: config_load_check PATH\n" "\nValidate configuration files against json schema\n" "\n\tPATH - root of the path that holds the json files to verify." - " The tool recursively searches for json files to validate." << std::endl; + " The tool recursively searches for json files to validate." + << std::endl; return EXIT_FAILURE; } try { diff --git a/test/tools/router_check/json/tool_config_schemas.cc b/test/tools/router_check/json/tool_config_schemas.cc index 1be18f237d684..413e3fab98133 100644 --- a/test/tools/router_check/json/tool_config_schemas.cc +++ b/test/tools/router_check/json/tool_config_schemas.cc @@ -74,4 +74,4 @@ const std::string& Json::ToolSchema::routerCheckSchema() { return *router_check_schema; } -} // Envoy +} // namespace Envoy diff --git a/test/tools/router_check/json/tool_config_schemas.h b/test/tools/router_check/json/tool_config_schemas.h index 6ee31e626929c..6c1b6b95f384f 100644 --- a/test/tools/router_check/json/tool_config_schemas.h +++ b/test/tools/router_check/json/tool_config_schemas.h @@ -14,5 +14,5 @@ class ToolSchema { static const std::string& routerCheckSchema(); }; -} // Json -} // Envoy +} // namespace Json +} // namespace Envoy diff --git a/test/tools/router_check/router.cc b/test/tools/router_check/router.cc index 5f35da61c1d45..eb473ba005ae3 100644 --- a/test/tools/router_check/router.cc +++ b/test/tools/router_check/router.cc @@ -70,22 +70,33 @@ bool RouterCheckTool::compareEntriesInJson(const std::string& expected_route_jso } Json::ObjectSharedPtr validate = check_config->getObject("validate"); - const std::unordered_map> checkers = { - {"cluster_name", [this](ToolConfig& tool_config, const std::string& expected) - -> bool { return compareCluster(tool_config, expected); }}, - {"virtual_cluster_name", - [this](ToolConfig& tool_config, const std::string& expected) - -> bool { return compareVirtualCluster(tool_config, expected); }}, - {"virtual_host_name", [this](ToolConfig& tool_config, const std::string& expected) - -> bool { return compareVirtualHost(tool_config, expected); }}, - {"path_rewrite", [this](ToolConfig& tool_config, const std::string& expected) - -> bool { return compareRewritePath(tool_config, expected); }}, - {"host_rewrite", [this](ToolConfig& tool_config, const std::string& expected) - -> bool { return compareRewriteHost(tool_config, expected); }}, - {"path_redirect", [this](ToolConfig& tool_config, const std::string& expected) - -> bool { return compareRedirectPath(tool_config, expected); }}, - }; + const std::unordered_map> + checkers = { + {"cluster_name", + [this](ToolConfig& tool_config, const std::string& expected) -> bool { + return compareCluster(tool_config, expected); + }}, + {"virtual_cluster_name", + [this](ToolConfig& tool_config, const std::string& expected) -> bool { + return compareVirtualCluster(tool_config, expected); + }}, + {"virtual_host_name", + [this](ToolConfig& tool_config, const std::string& expected) -> bool { + return compareVirtualHost(tool_config, expected); + }}, + {"path_rewrite", + [this](ToolConfig& tool_config, const std::string& expected) -> bool { + return compareRewritePath(tool_config, expected); + }}, + {"host_rewrite", + [this](ToolConfig& tool_config, const std::string& expected) -> bool { + return compareRewriteHost(tool_config, expected); + }}, + {"path_redirect", + [this](ToolConfig& tool_config, const std::string& expected) -> bool { + return compareRedirectPath(tool_config, expected); + }}, + }; // Call appropriate function for each match case for (std::pair> test : checkers) { @@ -190,4 +201,4 @@ bool RouterCheckTool::compareResults(const std::string& actual, const std::strin } return false; } -} // Envoy +} // namespace Envoy diff --git a/test/tools/router_check/router.h b/test/tools/router_check/router.h index 987392d743266..f9a3bc04706cb 100644 --- a/test/tools/router_check/router.h +++ b/test/tools/router_check/router.h @@ -92,4 +92,4 @@ class RouterCheckTool : Logger::Loggable { std::unique_ptr> cm_; std::unique_ptr config_; }; -} // Envoy +} // namespace Envoy diff --git a/tools/check_format.py b/tools/check_format.py index 3d34a1ba3cc4a..2d342de6a1cf0 100755 --- a/tools/check_format.py +++ b/tools/check_format.py @@ -10,7 +10,7 @@ "./bazel-") SUFFIXES = (".cc", ".h", "BUILD") -CLANG_FORMAT_PATH = os.getenv("CLANG-FORMAT", "clang-format-3.6") +CLANG_FORMAT_PATH = os.getenv("CLANG-FORMAT", "clang-format-5.0") BUILDIFIER_PATH = os.getenv("BUILDIFIER", "/usr/lib/go/bin/buildifier") ENVOY_BUILD_FIXER_PATH = os.path.join( os.path.dirname(os.path.abspath(sys.argv[0])), "envoy_build_fixer.py") From 2dd95346f3d570eb5d6635becfe8111d36ed1fb7 Mon Sep 17 00:00:00 2001 From: Matt Klein Date: Wed, 5 Jul 2017 09:48:21 -0700 Subject: [PATCH 2/3] fix --- test/integration/ssl_utility.cc | 4 ++-- test/integration/ssl_utility.h | 4 ++-- test/integration/tcp_proxy_integration_test.cc | 2 +- test/integration/tcp_proxy_integration_test.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/integration/ssl_utility.cc b/test/integration/ssl_utility.cc index a59ed24c3e292..887e91d2915d7 100644 --- a/test/integration/ssl_utility.cc +++ b/test/integration/ssl_utility.cc @@ -68,5 +68,5 @@ Network::Address::InstanceConstSharedPtr getSslAddress(const Network::Address::I return Network::Utility::resolveUrl(url); } -} // Ssl -} // Envoy +} // namespace Ssl +} // namespace Envoy diff --git a/test/integration/ssl_utility.h b/test/integration/ssl_utility.h index 490aba3bf7eb6..4672535966102 100644 --- a/test/integration/ssl_utility.h +++ b/test/integration/ssl_utility.h @@ -11,5 +11,5 @@ ClientContextPtr createClientSslContext(bool alpn, bool san, ContextManager& con Network::Address::InstanceConstSharedPtr getSslAddress(const Network::Address::IpVersion& version, int port); -} // Ssl -} // Envoy +} // namespace Ssl +} // namespace Envoy diff --git a/test/integration/tcp_proxy_integration_test.cc b/test/integration/tcp_proxy_integration_test.cc index 01ee4b7c24c16..48705282080a1 100644 --- a/test/integration/tcp_proxy_integration_test.cc +++ b/test/integration/tcp_proxy_integration_test.cc @@ -130,4 +130,4 @@ TEST_P(TcpProxyIntegrationTest, SendTlsToTlsListener) { } } // namespace -} // Envoy +} // namespace Envoy diff --git a/test/integration/tcp_proxy_integration_test.h b/test/integration/tcp_proxy_integration_test.h index 99b99dcebf722..c7b4da7d08d4d 100644 --- a/test/integration/tcp_proxy_integration_test.h +++ b/test/integration/tcp_proxy_integration_test.h @@ -27,4 +27,4 @@ class TcpProxyIntegrationTest : public BaseIntegrationTest, fake_upstreams_.clear(); } }; -} // Envoy +} // namespace Envoy From d76138f1ec50fc6ed2d660ea3a406eb1de279142 Mon Sep 17 00:00:00 2001 From: Matt Klein Date: Wed, 5 Jul 2017 10:00:41 -0700 Subject: [PATCH 3/3] fix --- .clang-format | 1 + test/common/http/utility_test.cc | 2 +- test/common/json/config_schemas_test.cc | 2 +- test/common/network/cidr_range_test.cc | 2 +- test/common/stats/udp_statsd_test.cc | 2 +- test/common/upstream/load_balancer_simulation_test.cc | 2 +- test/config_test/config_test.cc | 2 +- test/integration/integration.cc | 2 +- test/integration/integration_admin_test.cc | 2 +- test/integration/ssl_integration_test.cc | 2 +- test/integration/xfcc_integration_test.cc | 2 +- test/mocks/server/mocks.h | 2 +- test/server/options_impl_test.cc | 2 +- test/test_common/utility.cc | 2 +- test/tools/config_load_check/config_load_check.cc | 2 +- 15 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.clang-format b/.clang-format index 2509bf2d30855..d505816559e16 100644 --- a/.clang-format +++ b/.clang-format @@ -4,5 +4,6 @@ AccessModifierOffset: -2 ColumnLimit: 100 DerivePointerAlignment: false PointerAlignment: Left +SortIncludes: false ... diff --git a/test/common/http/utility_test.cc b/test/common/http/utility_test.cc index cfd3d650559b1..feadc87995df2 100644 --- a/test/common/http/utility_test.cc +++ b/test/common/http/utility_test.cc @@ -9,8 +9,8 @@ #include "test/test_common/printers.h" #include "test/test_common/utility.h" -#include "spdlog/spdlog.h" #include "gtest/gtest.h" +#include "spdlog/spdlog.h" namespace Envoy { namespace Http { diff --git a/test/common/json/config_schemas_test.cc b/test/common/json/config_schemas_test.cc index 0f86827964824..367ff0a3f223a 100644 --- a/test/common/json/config_schemas_test.cc +++ b/test/common/json/config_schemas_test.cc @@ -8,8 +8,8 @@ #include "test/test_common/utility.h" #include "gmock/gmock.h" -#include "spdlog/spdlog.h" #include "gtest/gtest.h" +#include "spdlog/spdlog.h" namespace Envoy { using testing::_; diff --git a/test/common/network/cidr_range_test.cc b/test/common/network/cidr_range_test.cc index 01f87b710b6f6..1600c24771347 100644 --- a/test/common/network/cidr_range_test.cc +++ b/test/common/network/cidr_range_test.cc @@ -10,8 +10,8 @@ #include "common/network/cidr_range.h" #include "common/network/utility.h" -#include "spdlog/spdlog.h" #include "gtest/gtest.h" +#include "spdlog/spdlog.h" // We are adding things into the std namespace. // Note that this is technically undefined behavior! diff --git a/test/common/stats/udp_statsd_test.cc b/test/common/stats/udp_statsd_test.cc index a29797d6932e5..2a8a88bac299e 100644 --- a/test/common/stats/udp_statsd_test.cc +++ b/test/common/stats/udp_statsd_test.cc @@ -9,8 +9,8 @@ #include "test/test_common/network_utility.h" #include "gmock/gmock.h" -#include "spdlog/spdlog.h" #include "gtest/gtest.h" +#include "spdlog/spdlog.h" namespace Envoy { using testing::NiceMock; diff --git a/test/common/upstream/load_balancer_simulation_test.cc b/test/common/upstream/load_balancer_simulation_test.cc index f9422d8c414a2..4391ad700330d 100644 --- a/test/common/upstream/load_balancer_simulation_test.cc +++ b/test/common/upstream/load_balancer_simulation_test.cc @@ -11,8 +11,8 @@ #include "test/mocks/upstream/mocks.h" #include "gmock/gmock.h" -#include "spdlog/spdlog.h" #include "gtest/gtest.h" +#include "spdlog/spdlog.h" namespace Envoy { using testing::NiceMock; diff --git a/test/config_test/config_test.cc b/test/config_test/config_test.cc index 3428b26c0867b..f9820f0739973 100644 --- a/test/config_test/config_test.cc +++ b/test/config_test/config_test.cc @@ -9,8 +9,8 @@ #include "test/test_common/utility.h" #include "gmock/gmock.h" -#include "spdlog/spdlog.h" #include "gtest/gtest.h" +#include "spdlog/spdlog.h" using testing::Invoke; using testing::NiceMock; diff --git a/test/integration/integration.cc b/test/integration/integration.cc index 51773455ae5f8..be18c8dc2a2e8 100644 --- a/test/integration/integration.cc +++ b/test/integration/integration.cc @@ -25,8 +25,8 @@ #include "test/test_common/printers.h" #include "test/test_common/utility.h" -#include "spdlog/spdlog.h" #include "gtest/gtest.h" +#include "spdlog/spdlog.h" namespace Envoy { IntegrationStreamDecoder::IntegrationStreamDecoder(Event::Dispatcher& dispatcher) diff --git a/test/integration/integration_admin_test.cc b/test/integration/integration_admin_test.cc index aebd18188d05a..9d5bbdb698d8f 100644 --- a/test/integration/integration_admin_test.cc +++ b/test/integration/integration_admin_test.cc @@ -6,8 +6,8 @@ #include "test/integration/utility.h" -#include "spdlog/spdlog.h" #include "gtest/gtest.h" +#include "spdlog/spdlog.h" namespace Envoy { diff --git a/test/integration/ssl_integration_test.cc b/test/integration/ssl_integration_test.cc index 59ac27717f512..0475398806c87 100644 --- a/test/integration/ssl_integration_test.cc +++ b/test/integration/ssl_integration_test.cc @@ -12,9 +12,9 @@ #include "test/test_common/network_utility.h" #include "gmock/gmock.h" +#include "gtest/gtest.h" #include "integration.h" #include "utility.h" -#include "gtest/gtest.h" using testing::Return; diff --git a/test/integration/xfcc_integration_test.cc b/test/integration/xfcc_integration_test.cc index 5eff2c68927e2..a272bf14cb632 100644 --- a/test/integration/xfcc_integration_test.cc +++ b/test/integration/xfcc_integration_test.cc @@ -13,10 +13,10 @@ #include "test/test_common/utility.h" #include "gmock/gmock.h" +#include "gtest/gtest.h" #include "integration.h" #include "ssl_integration_test.h" #include "utility.h" -#include "gtest/gtest.h" namespace Envoy { namespace Xfcc { diff --git a/test/mocks/server/mocks.h b/test/mocks/server/mocks.h index f22d1b4e9f38f..ffc69e21053ce 100644 --- a/test/mocks/server/mocks.h +++ b/test/mocks/server/mocks.h @@ -30,8 +30,8 @@ #include "test/mocks/upstream/mocks.h" #include "gmock/gmock.h" -#include "spdlog/spdlog.h" #include "gtest/gtest.h" +#include "spdlog/spdlog.h" namespace Envoy { namespace Server { diff --git a/test/server/options_impl_test.cc b/test/server/options_impl_test.cc index f5151a217ec47..5774249149e14 100644 --- a/test/server/options_impl_test.cc +++ b/test/server/options_impl_test.cc @@ -7,8 +7,8 @@ #include "server/options_impl.h" -#include "spdlog/spdlog.h" #include "gtest/gtest.h" +#include "spdlog/spdlog.h" namespace Envoy { // Do the ugly work of turning a std::string into a char** and create an OptionsImpl. Args are diff --git a/test/test_common/utility.cc b/test/test_common/utility.cc index e8067cf0ad82b..067426486c61d 100644 --- a/test/test_common/utility.cc +++ b/test/test_common/utility.cc @@ -19,8 +19,8 @@ #include "test/test_common/printers.h" -#include "spdlog/spdlog.h" #include "gtest/gtest.h" +#include "spdlog/spdlog.h" namespace Envoy { diff --git a/test/tools/config_load_check/config_load_check.cc b/test/tools/config_load_check/config_load_check.cc index 20e4fcde88742..4d3574bd2d44a 100644 --- a/test/tools/config_load_check/config_load_check.cc +++ b/test/tools/config_load_check/config_load_check.cc @@ -5,8 +5,8 @@ #include "test/config_test/config_test.h" -#include "spdlog/spdlog.h" #include "gtest/gtest.h" +#include "spdlog/spdlog.h" int main(int argc, char* argv[]) { if (argc != 2) {