diff --git a/api/envoy/admin/v3/server_info.proto b/api/envoy/admin/v3/server_info.proto index 108cb8a11548..15b2c74e8831 100644 --- a/api/envoy/admin/v3/server_info.proto +++ b/api/envoy/admin/v3/server_info.proto @@ -87,9 +87,9 @@ message CommandLineOptions { Immediate = 1; } - reserved 12, 20, 21; + reserved 12, 20, 21, 29; - reserved "max_stats", "max_obj_name_len"; + reserved "max_stats", "max_obj_name_len", "bootstrap_version"; // See :option:`--base-id` for details. uint64 base_id = 1; @@ -178,9 +178,6 @@ message CommandLineOptions { // See :option:`--disable-extensions` for details. repeated string disabled_extensions = 28; - // See :option:`--bootstrap-version` for details. - uint32 bootstrap_version = 29; - // See :option:`--enable-fine-grain-logging` for details. bool enable_fine_grain_logging = 34; diff --git a/api/envoy/admin/v4alpha/server_info.proto b/api/envoy/admin/v4alpha/server_info.proto index 18e59c92b0ef..122aed413441 100644 --- a/api/envoy/admin/v4alpha/server_info.proto +++ b/api/envoy/admin/v4alpha/server_info.proto @@ -86,9 +86,9 @@ message CommandLineOptions { Immediate = 1; } - reserved 12, 20, 21; + reserved 12, 20, 21, 29; - reserved "max_stats", "max_obj_name_len"; + reserved "max_stats", "max_obj_name_len", "bootstrap_version"; // See :option:`--base-id` for details. uint64 base_id = 1; @@ -177,9 +177,6 @@ message CommandLineOptions { // See :option:`--disable-extensions` for details. repeated string disabled_extensions = 28; - // See :option:`--bootstrap-version` for details. - uint32 bootstrap_version = 29; - // See :option:`--enable-fine-grain-logging` for details. bool enable_fine_grain_logging = 34; diff --git a/configs/envoy_double_proxy.template.yaml b/configs/envoy_double_proxy.template.yaml index e620b9024f09..b574d6a518c5 100644 --- a/configs/envoy_double_proxy.template.yaml +++ b/configs/envoy_double_proxy.template.yaml @@ -136,11 +136,6 @@ static_resources: address: front-proxy.yourcompany.net port_value: 9400 protocol: TCP - # There are so few connections going back - # that we can get some imbalance. Until we come up - # with a better solution just limit the requests - # so we can cycle and get better spread. - max_requests_per_connection: 25000 transport_socket: name: envoy.transport_sockets.tls typed_config: @@ -161,6 +156,12 @@ static_resources: "@type": type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions explicit_http_config: http2_protocol_options: {} + common_http_protocol_options: + # There are so few connections going back + # that we can get some imbalance. Until we come up + # with a better solution just limit the requests + # so we can cycle and get better spread. + max_requests_per_connection: 25000 - name: lightstep_saas type: LOGICAL_DNS lb_policy: ROUND_ROBIN diff --git a/contrib/kafka/filters/network/test/broker/integration_test/envoy_config_yaml.j2 b/contrib/kafka/filters/network/test/broker/integration_test/envoy_config_yaml.j2 index 085413792af7..af945c5c61d7 100644 --- a/contrib/kafka/filters/network/test/broker/integration_test/envoy_config_yaml.j2 +++ b/contrib/kafka/filters/network/test/broker/integration_test/envoy_config_yaml.j2 @@ -28,7 +28,6 @@ static_resources: address: 127.0.0.1 port_value: {{ data['kafka_real_port'] }} admin: - access_log_path: /dev/null profile_path: /dev/null address: socket_address: { address: 127.0.0.1, port_value: {{ data['envoy_monitoring_port'] }} } diff --git a/contrib/rocketmq_proxy/filters/network/test/config_test.cc b/contrib/rocketmq_proxy/filters/network/test/config_test.cc index eb63ad3ae960..62e5eb051632 100644 --- a/contrib/rocketmq_proxy/filters/network/test/config_test.cc +++ b/contrib/rocketmq_proxy/filters/network/test/config_test.cc @@ -20,10 +20,9 @@ namespace RocketmqProxy { using RocketmqProxyProto = envoy::extensions::filters::network::rocketmq_proxy::v3::RocketmqProxy; -RocketmqProxyProto parseRocketmqProxyFromV3Yaml(const std::string& yaml, - bool avoid_boosting = true) { +RocketmqProxyProto parseRocketmqProxyFromV3Yaml(const std::string& yaml) { RocketmqProxyProto rocketmq_proxy; - TestUtility::loadFromYaml(yaml, rocketmq_proxy, false, avoid_boosting); + TestUtility::loadFromYaml(yaml, rocketmq_proxy); return rocketmq_proxy; } diff --git a/docs/root/configuration/http/http_filters/_include/composite.yaml b/docs/root/configuration/http/http_filters/_include/composite.yaml index 256647da314d..f7c4c4f0dbae 100644 --- a/docs/root/configuration/http/http_filters/_include/composite.yaml +++ b/docs/root/configuration/http/http_filters/_include/composite.yaml @@ -1,5 +1,4 @@ admin: - access_log_path: /tmp/admin_access.log address: socket_address: {address: 0.0.0.0, port_value: 9901} diff --git a/docs/root/operations/cli.rst b/docs/root/operations/cli.rst index 34e50110842a..72d243f0868d 100644 --- a/docs/root/operations/cli.rst +++ b/docs/root/operations/cli.rst @@ -31,13 +31,6 @@ following are the command line options that Envoy supports. ./envoy -c bootstrap.yaml --config-yaml "node: {id: 'node1'}" -.. option:: --bootstrap-version - - *(optional)* The API version to load the bootstrap as. The value should be a single integer, e.g. - to parse the bootstrap configuration as V3, specify ``--bootstrap-version 3``. If unset, Envoy will - attempt to load the bootstrap as the previous API version and upgrade it to the latest. If that fails, - Envoy will attempt to load the configuration as the latest version. - .. option:: --mode *(optional)* One of the operating modes for Envoy: diff --git a/docs/root/version_history/current.rst b/docs/root/version_history/current.rst index 37b026b20b61..1783ea60a3f6 100644 --- a/docs/root/version_history/current.rst +++ b/docs/root/version_history/current.rst @@ -5,6 +5,8 @@ Incompatible Behavior Changes ----------------------------- *Changes that are expected to cause an incompatibility if applicable; deployment changes are likely required* +* config: the ``--bootstrap-version`` CLI flag has been removed, Envoy has only been able to accept v3 + bootstrap configurations since 1.18.0. * contrib: the :ref:`squash filter ` has been moved to :ref:`contrib images `. * contrib: the :ref:`kafka broker filter ` has been moved to diff --git a/docs/root/version_history/v1.17.0.rst b/docs/root/version_history/v1.17.0.rst index ace3ea40fd97..1d612e757312 100644 --- a/docs/root/version_history/v1.17.0.rst +++ b/docs/root/version_history/v1.17.0.rst @@ -5,7 +5,7 @@ Incompatible Behavior Changes ----------------------------- *Changes that are expected to cause an incompatibility if applicable; deployment changes are likely required* -* config: v2 is now fatal-by-default. This may be overridden by setting :option:`--bootstrap-version` 2 on the CLI for a v2 bootstrap file and also enabling the runtime ``envoy.reloadable_features.enable_deprecated_v2_api`` feature. +* config: v2 is now fatal-by-default. This may be overridden by setting ``--bootstrap-version 2`` on the CLI for a v2 bootstrap file and also enabling the runtime ``envoy.reloadable_features.enable_deprecated_v2_api`` feature. Minor Behavior Changes ---------------------- diff --git a/envoy/config/BUILD b/envoy/config/BUILD index cb8b6a9ce6cf..4b3c37ef9714 100644 --- a/envoy/config/BUILD +++ b/envoy/config/BUILD @@ -70,7 +70,6 @@ envoy_cc_library( hdrs = ["subscription.h"], deps = [ "//envoy/stats:stats_macros", - "//source/common/config:api_type_oracle_lib", "//source/common/protobuf", "@envoy_api//envoy/service/discovery/v3:pkg_cc_proto", ], diff --git a/envoy/registry/BUILD b/envoy/registry/BUILD index de34bccd492f..e38fbd470149 100644 --- a/envoy/registry/BUILD +++ b/envoy/registry/BUILD @@ -13,7 +13,6 @@ envoy_cc_library( hdrs = ["registry.h"], deps = [ "//source/common/common:assert_lib", - "//source/common/config:api_type_oracle_lib", "//source/common/protobuf:utility_lib", "//source/extensions/common:utility_lib", "@envoy_api//envoy/config/core/v3:pkg_cc_proto", diff --git a/envoy/registry/registry.h b/envoy/registry/registry.h index 1bc909f23c76..941006d7d228 100644 --- a/envoy/registry/registry.h +++ b/envoy/registry/registry.h @@ -13,7 +13,6 @@ #include "source/common/common/fmt.h" #include "source/common/common/logger.h" #include "source/common/common/utility.h" -#include "source/common/config/api_type_oracle.h" #include "source/common/protobuf/utility.h" #include "source/extensions/common/utility.h" @@ -356,25 +355,16 @@ template class FactoryRegistry : public Logger::Loggablefind(config_type); - if (it != mapping->end() && it->second != factory) { - // Mark double-registered types with a nullptr. - // See issue https://github.com/envoyproxy/envoy/issues/9643. - ENVOY_LOG(warn, "Double registration for type: '{}' by '{}' and '{}'", config_type, - factory->name(), it->second ? it->second->name() : ""); - it->second = nullptr; - } else { - mapping->emplace(std::make_pair(config_type, factory)); - } - - const Protobuf::Descriptor* previous = - Config::ApiTypeOracle::getEarlierVersionDescriptor(config_type); - if (previous == nullptr) { - break; - } - config_type = previous->full_name(); + // Register config types in the mapping. + auto it = mapping->find(config_type); + if (it != mapping->end() && it->second != factory) { + // Mark double-registered types with a nullptr. + // See issue https://github.com/envoyproxy/envoy/issues/9643. + ENVOY_LOG(warn, "Double registration for type: '{}' by '{}' and '{}'", config_type, + factory->name(), it->second ? it->second->name() : ""); + it->second = nullptr; + } else { + mapping->emplace(std::make_pair(config_type, factory)); } } diff --git a/envoy/server/options.h b/envoy/server/options.h index 05729bbe0181..3968b7f88ca3 100644 --- a/envoy/server/options.h +++ b/envoy/server/options.h @@ -126,11 +126,6 @@ class Options { */ virtual const envoy::config::bootstrap::v3::Bootstrap& configProto() const PURE; - /** - * @return const absl::optional& the bootstrap version to use, if specified. - */ - virtual const absl::optional& bootstrapVersion() const PURE; - /** * @return bool allow unknown fields in the static configuration? */ diff --git a/examples/grpc-bridge/client/envoy-proxy.yaml b/examples/grpc-bridge/client/envoy-proxy.yaml index 31668610eb03..65795feae685 100644 --- a/examples/grpc-bridge/client/envoy-proxy.yaml +++ b/examples/grpc-bridge/client/envoy-proxy.yaml @@ -38,7 +38,11 @@ static_resources: type: LOGICAL_DNS dns_lookup_family: V4_ONLY lb_policy: ROUND_ROBIN - http_protocol_options: {} + typed_extension_protocol_options: + envoy.extensions.upstreams.http.v3.HttpProtocolOptions: + "@type": type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions + explicit_http_config: + http_protocol_options: {} load_assignment: cluster_name: backend-proxy endpoints: diff --git a/examples/tls-inspector/envoy.yaml b/examples/tls-inspector/envoy.yaml index b8e444dae1f2..75c5c52572ab 100644 --- a/examples/tls-inspector/envoy.yaml +++ b/examples/tls-inspector/envoy.yaml @@ -1,5 +1,4 @@ admin: - access_log_path: "/dev/null" address: socket_address: address: 0.0.0.0 diff --git a/examples/udp/envoy.yaml b/examples/udp/envoy.yaml index e516eff5fd94..309d7e056046 100644 --- a/examples/udp/envoy.yaml +++ b/examples/udp/envoy.yaml @@ -28,7 +28,6 @@ static_resources: port_value: 5005 admin: - access_log_path: "/dev/null" address: socket_address: address: 0.0.0.0 diff --git a/generated_api_shadow/envoy/admin/v3/server_info.proto b/generated_api_shadow/envoy/admin/v3/server_info.proto index 917afc06eb0e..7593ade49a62 100644 --- a/generated_api_shadow/envoy/admin/v3/server_info.proto +++ b/generated_api_shadow/envoy/admin/v3/server_info.proto @@ -88,7 +88,9 @@ message CommandLineOptions { Immediate = 1; } - reserved 12; + reserved 12, 29; + + reserved "bootstrap_version"; // See :option:`--base-id` for details. uint64 base_id = 1; @@ -177,9 +179,6 @@ message CommandLineOptions { // See :option:`--disable-extensions` for details. repeated string disabled_extensions = 28; - // See :option:`--bootstrap-version` for details. - uint32 bootstrap_version = 29; - // See :option:`--enable-fine-grain-logging` for details. bool enable_fine_grain_logging = 34; diff --git a/generated_api_shadow/envoy/admin/v4alpha/server_info.proto b/generated_api_shadow/envoy/admin/v4alpha/server_info.proto index 18e59c92b0ef..122aed413441 100644 --- a/generated_api_shadow/envoy/admin/v4alpha/server_info.proto +++ b/generated_api_shadow/envoy/admin/v4alpha/server_info.proto @@ -86,9 +86,9 @@ message CommandLineOptions { Immediate = 1; } - reserved 12, 20, 21; + reserved 12, 20, 21, 29; - reserved "max_stats", "max_obj_name_len"; + reserved "max_stats", "max_obj_name_len", "bootstrap_version"; // See :option:`--base-id` for details. uint64 base_id = 1; @@ -177,9 +177,6 @@ message CommandLineOptions { // See :option:`--disable-extensions` for details. repeated string disabled_extensions = 28; - // See :option:`--bootstrap-version` for details. - uint32 bootstrap_version = 29; - // See :option:`--enable-fine-grain-logging` for details. bool enable_fine_grain_logging = 34; diff --git a/source/common/config/BUILD b/source/common/config/BUILD index 3e8b524d35be..2fd7a8c75748 100644 --- a/source/common/config/BUILD +++ b/source/common/config/BUILD @@ -8,16 +8,6 @@ licenses(["notice"]) # Apache 2 envoy_package() -envoy_cc_library( - name = "api_type_oracle_lib", - srcs = ["api_type_oracle.cc"], - hdrs = ["api_type_oracle.h"], - deps = [ - "//source/common/protobuf", - "@com_github_cncf_udpa//udpa/annotations:pkg_cc_proto", - ], -) - envoy_cc_library( name = "api_version_lib", hdrs = ["api_version.h"], @@ -196,7 +186,6 @@ envoy_cc_library( ":delta_subscription_state_lib", ":grpc_stream_lib", ":pausable_ack_queue_lib", - ":version_converter_lib", ":watch_map_lib", ":xds_context_params_lib", ":xds_resource_lib", @@ -217,7 +206,6 @@ envoy_cc_library( deps = [ ":api_version_lib", ":decoded_resource_lib", - ":version_converter_lib", "//envoy/config:subscription_interface", "//envoy/event:dispatcher_interface", "//source/common/buffer:buffer_lib", @@ -302,11 +290,7 @@ envoy_cc_library( envoy_cc_library( name = "resource_name_lib", hdrs = ["resource_name.h"], - deps = [ - ":api_type_oracle_lib", - "//source/common/common:assert_lib", - "@envoy_api//envoy/config/core/v3:pkg_cc_proto", - ], + deps = ["//source/common/common:assert_lib"], ) envoy_cc_library( @@ -383,8 +367,6 @@ envoy_cc_library( srcs = ["utility.cc"], hdrs = ["utility.h"], deps = [ - ":api_type_oracle_lib", - ":version_converter_lib", "//envoy/config:grpc_mux_interface", "//envoy/config:subscription_interface", "//envoy/local_info:local_info_interface", @@ -412,20 +394,6 @@ envoy_cc_library( ], ) -envoy_cc_library( - name = "version_converter_lib", - srcs = ["version_converter.cc"], - hdrs = ["version_converter.h"], - deps = [ - ":api_type_oracle_lib", - "//source/common/common:assert_lib", - "//source/common/protobuf", - "//source/common/protobuf:visitor_lib", - "//source/common/protobuf:well_known_lib", - "@envoy_api//envoy/config/core/v3:pkg_cc_proto", - ], -) - envoy_cc_library( name = "watch_map_lib", srcs = ["watch_map.cc"], diff --git a/source/common/config/api_type_oracle.cc b/source/common/config/api_type_oracle.cc deleted file mode 100644 index 66da4f79a928..000000000000 --- a/source/common/config/api_type_oracle.cc +++ /dev/null @@ -1,36 +0,0 @@ -#include "source/common/config/api_type_oracle.h" - -#include "udpa/annotations/versioning.pb.h" - -namespace Envoy { -namespace Config { - -const Protobuf::Descriptor* -ApiTypeOracle::getEarlierVersionDescriptor(const std::string& message_type) { - const auto previous_message_string = getEarlierVersionMessageTypeName(message_type); - if (previous_message_string != absl::nullopt) { - const Protobuf::Descriptor* earlier_desc = - Protobuf::DescriptorPool::generated_pool()->FindMessageTypeByName( - previous_message_string.value()); - return earlier_desc; - } else { - return nullptr; - } -} - -const absl::optional -ApiTypeOracle::getEarlierVersionMessageTypeName(const std::string& message_type) { - // Determine if there is an earlier API version for message_type. - const Protobuf::Descriptor* desc = - Protobuf::DescriptorPool::generated_pool()->FindMessageTypeByName(std::string{message_type}); - if (desc == nullptr) { - return absl::nullopt; - } - if (desc->options().HasExtension(udpa::annotations::versioning)) { - return desc->options().GetExtension(udpa::annotations::versioning).previous_message_type(); - } - return absl::nullopt; -} - -} // namespace Config -} // namespace Envoy diff --git a/source/common/config/api_type_oracle.h b/source/common/config/api_type_oracle.h deleted file mode 100644 index 7320309b33cc..000000000000 --- a/source/common/config/api_type_oracle.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include "source/common/protobuf/protobuf.h" - -#include "absl/strings/string_view.h" -#include "absl/types/optional.h" - -namespace Envoy { -namespace Config { - -class ApiTypeOracle { -public: - /** - * Based on a given message, determine if there exists an earlier version of - * this message. If so, return the descriptor for the earlier - * message, to support upgrading via VersionConverter::upgrade(). - * - * @param message_type protobuf message type - * @return const Protobuf::Descriptor* descriptor for earlier message version - * corresponding to message, if any, otherwise nullptr. - */ - static const Protobuf::Descriptor* getEarlierVersionDescriptor(const std::string& message_type); - - static const absl::optional - getEarlierVersionMessageTypeName(const std::string& message_type); -}; - -} // namespace Config -} // namespace Envoy diff --git a/source/common/config/grpc_mux_impl.cc b/source/common/config/grpc_mux_impl.cc index 7ee032ee792e..4242599901a7 100644 --- a/source/common/config/grpc_mux_impl.cc +++ b/source/common/config/grpc_mux_impl.cc @@ -4,7 +4,6 @@ #include "source/common/config/decoded_resource_impl.h" #include "source/common/config/utility.h" -#include "source/common/config/version_converter.h" #include "source/common/memory/utils.h" #include "source/common/protobuf/protobuf.h" @@ -36,14 +35,12 @@ using AllMuxes = ThreadSafeSingleton; GrpcMuxImpl::GrpcMuxImpl(const LocalInfo::LocalInfo& local_info, Grpc::RawAsyncClientPtr async_client, Event::Dispatcher& dispatcher, const Protobuf::MethodDescriptor& service_method, - envoy::config::core::v3::ApiVersion transport_api_version, Random::RandomGenerator& random, Stats::Scope& scope, const RateLimitSettings& rate_limit_settings, bool skip_subsequent_node) : grpc_stream_(this, std::move(async_client), service_method, random, dispatcher, scope, rate_limit_settings), local_info_(local_info), skip_subsequent_node_(skip_subsequent_node), - first_stream_request_(true), transport_api_version_(transport_api_version), - dispatcher_(dispatcher), + first_stream_request_(true), dispatcher_(dispatcher), dynamic_update_callback_handle_(local_info.contextProvider().addDynamicContextUpdateCallback( [this](absl::string_view resource_type_url) { onDynamicContextUpdate(resource_type_url); @@ -94,7 +91,6 @@ void GrpcMuxImpl::sendDiscoveryRequest(const std::string& type_url) { } else { request.clear_node(); } - VersionConverter::prepareMessageForGrpcWire(request, transport_api_version_); ENVOY_LOG(trace, "Sending DiscoveryRequest for {}: {}", type_url, request.ShortDebugString()); grpc_stream_.sendMessage(request); first_stream_request_ = false; diff --git a/source/common/config/grpc_mux_impl.h b/source/common/config/grpc_mux_impl.h index ec15658c7297..e9d1a61828c7 100644 --- a/source/common/config/grpc_mux_impl.h +++ b/source/common/config/grpc_mux_impl.h @@ -34,7 +34,6 @@ class GrpcMuxImpl : public GrpcMux, public: GrpcMuxImpl(const LocalInfo::LocalInfo& local_info, Grpc::RawAsyncClientPtr async_client, Event::Dispatcher& dispatcher, const Protobuf::MethodDescriptor& service_method, - envoy::config::core::v3::ApiVersion transport_api_version, Random::RandomGenerator& random, Stats::Scope& scope, const RateLimitSettings& rate_limit_settings, bool skip_subsequent_node); @@ -185,7 +184,6 @@ class GrpcMuxImpl : public GrpcMux, // store them; rather, they are simply dropped. This string is a type // URL. std::unique_ptr> request_queue_; - const envoy::config::core::v3::ApiVersion transport_api_version_; Event::Dispatcher& dispatcher_; Common::CallbackHandlePtr dynamic_update_callback_handle_; diff --git a/source/common/config/http_subscription_impl.cc b/source/common/config/http_subscription_impl.cc index ecf6afffa9b9..76b201444f5b 100644 --- a/source/common/config/http_subscription_impl.cc +++ b/source/common/config/http_subscription_impl.cc @@ -10,7 +10,6 @@ #include "source/common/common/utility.h" #include "source/common/config/decoded_resource_impl.h" #include "source/common/config/utility.h" -#include "source/common/config/version_converter.h" #include "source/common/http/headers.h" #include "source/common/protobuf/protobuf.h" #include "source/common/protobuf/utility.h" @@ -25,15 +24,15 @@ HttpSubscriptionImpl::HttpSubscriptionImpl( const std::string& remote_cluster_name, Event::Dispatcher& dispatcher, Random::RandomGenerator& random, std::chrono::milliseconds refresh_interval, std::chrono::milliseconds request_timeout, const Protobuf::MethodDescriptor& service_method, - absl::string_view type_url, envoy::config::core::v3::ApiVersion transport_api_version, - SubscriptionCallbacks& callbacks, OpaqueResourceDecoder& resource_decoder, - SubscriptionStats stats, std::chrono::milliseconds init_fetch_timeout, + absl::string_view type_url, SubscriptionCallbacks& callbacks, + OpaqueResourceDecoder& resource_decoder, SubscriptionStats stats, + std::chrono::milliseconds init_fetch_timeout, ProtobufMessage::ValidationVisitor& validation_visitor) : Http::RestApiFetcher(cm, remote_cluster_name, dispatcher, random, refresh_interval, request_timeout), callbacks_(callbacks), resource_decoder_(resource_decoder), stats_(stats), dispatcher_(dispatcher), init_fetch_timeout_(init_fetch_timeout), - validation_visitor_(validation_visitor), transport_api_version_(transport_api_version) { + validation_visitor_(validation_visitor) { request_.mutable_node()->CopyFrom(local_info.node()); request_.set_type_url(std::string(type_url)); ASSERT(service_method.options().HasExtension(google::api::http)); @@ -74,7 +73,7 @@ void HttpSubscriptionImpl::createRequest(Http::RequestMessage& request) { stats_.update_attempt_.inc(); request.headers().setReferenceMethod(Http::Headers::get().MethodValues.Post); request.headers().setPath(path_); - request.body().add(VersionConverter::getJsonStringFromMessage(request_, transport_api_version_)); + request.body().add(MessageUtil::getJsonStringFromMessageOrDie(request_)); request.headers().setReferenceContentType(Http::Headers::get().ContentTypeValues.Json); request.headers().setContentLength(request.body().length()); } diff --git a/source/common/config/http_subscription_impl.h b/source/common/config/http_subscription_impl.h index d5f4d93948c8..cd6de9a46a95 100644 --- a/source/common/config/http_subscription_impl.h +++ b/source/common/config/http_subscription_impl.h @@ -27,7 +27,6 @@ class HttpSubscriptionImpl : public Http::RestApiFetcher, Random::RandomGenerator& random, std::chrono::milliseconds refresh_interval, std::chrono::milliseconds request_timeout, const Protobuf::MethodDescriptor& service_method, absl::string_view type_url, - envoy::config::core::v3::ApiVersion transport_api_version, SubscriptionCallbacks& callbacks, OpaqueResourceDecoder& resource_decoder, SubscriptionStats stats, std::chrono::milliseconds init_fetch_timeout, ProtobufMessage::ValidationVisitor& validation_visitor); @@ -60,7 +59,6 @@ class HttpSubscriptionImpl : public Http::RestApiFetcher, std::chrono::milliseconds init_fetch_timeout_; Event::TimerPtr init_fetch_timeout_timer_; ProtobufMessage::ValidationVisitor& validation_visitor_; - const envoy::config::core::v3::ApiVersion transport_api_version_; }; } // namespace Config diff --git a/source/common/config/new_grpc_mux_impl.cc b/source/common/config/new_grpc_mux_impl.cc index 06103f514b09..085edec3150d 100644 --- a/source/common/config/new_grpc_mux_impl.cc +++ b/source/common/config/new_grpc_mux_impl.cc @@ -6,7 +6,6 @@ #include "source/common/common/backoff_strategy.h" #include "source/common/common/token_bucket_impl.h" #include "source/common/config/utility.h" -#include "source/common/config/version_converter.h" #include "source/common/config/xds_context_params.h" #include "source/common/config/xds_resource.h" #include "source/common/memory/utils.h" @@ -38,7 +37,6 @@ using AllMuxes = ThreadSafeSingleton; NewGrpcMuxImpl::NewGrpcMuxImpl(Grpc::RawAsyncClientPtr&& async_client, Event::Dispatcher& dispatcher, const Protobuf::MethodDescriptor& service_method, - envoy::config::core::v3::ApiVersion transport_api_version, Random::RandomGenerator& random, Stats::Scope& scope, const RateLimitSettings& rate_limit_settings, const LocalInfo::LocalInfo& local_info) @@ -49,7 +47,7 @@ NewGrpcMuxImpl::NewGrpcMuxImpl(Grpc::RawAsyncClientPtr&& async_client, [this](absl::string_view resource_type_url) { onDynamicContextUpdate(resource_type_url); })), - transport_api_version_(transport_api_version), dispatcher_(dispatcher) { + dispatcher_(dispatcher) { AllMuxes::get().insert(this); } @@ -272,7 +270,6 @@ void NewGrpcMuxImpl::trySendDiscoveryRequests() { } else { request = sub->second->sub_state_.getNextRequestAckless(); } - VersionConverter::prepareMessageForGrpcWire(request, transport_api_version_); grpc_stream_.sendMessage(request); } grpc_stream_.maybeUpdateQueueSizeStat(pausable_ack_queue_.size()); diff --git a/source/common/config/new_grpc_mux_impl.h b/source/common/config/new_grpc_mux_impl.h index ff6a7c5f7d44..5c2940ebfe8e 100644 --- a/source/common/config/new_grpc_mux_impl.h +++ b/source/common/config/new_grpc_mux_impl.h @@ -31,10 +31,8 @@ class NewGrpcMuxImpl Logger::Loggable { public: NewGrpcMuxImpl(Grpc::RawAsyncClientPtr&& async_client, Event::Dispatcher& dispatcher, - const Protobuf::MethodDescriptor& service_method, - envoy::config::core::v3::ApiVersion transport_api_version, - Random::RandomGenerator& random, Stats::Scope& scope, - const RateLimitSettings& rate_limit_settings, + const Protobuf::MethodDescriptor& service_method, Random::RandomGenerator& random, + Stats::Scope& scope, const RateLimitSettings& rate_limit_settings, const LocalInfo::LocalInfo& local_info); ~NewGrpcMuxImpl() override; @@ -178,7 +176,6 @@ class NewGrpcMuxImpl const LocalInfo::LocalInfo& local_info_; Common::CallbackHandlePtr dynamic_update_callback_handle_; - const envoy::config::core::v3::ApiVersion transport_api_version_; Event::Dispatcher& dispatcher_; // True iff Envoy is shutting down; no messages should be sent on the `grpc_stream_` when this is diff --git a/source/common/config/resource_name.h b/source/common/config/resource_name.h index b3ca8e817526..16d84e97bd6a 100644 --- a/source/common/config/resource_name.h +++ b/source/common/config/resource_name.h @@ -3,58 +3,21 @@ #include #include -#include "envoy/config/core/v3/config_source.pb.h" - -#include "source/common/common/assert.h" -#include "source/common/config/api_type_oracle.h" - namespace Envoy { namespace Config { /** - * Get resource name from api type and version. - */ -template -std::string getResourceName(envoy::config::core::v3::ApiVersion resource_api_version) { - switch (resource_api_version) { - case envoy::config::core::v3::ApiVersion::AUTO: - case envoy::config::core::v3::ApiVersion::V2: - return ApiTypeOracle::getEarlierVersionMessageTypeName(Current().GetDescriptor()->full_name()) - .value(); - case envoy::config::core::v3::ApiVersion::V3: - return Current().GetDescriptor()->full_name(); - default: - NOT_REACHED_GCOVR_EXCL_LINE; - } -} - -/** - * Get type url from api type and version. - */ -template -std::string getTypeUrl(envoy::config::core::v3::ApiVersion resource_api_version) { - return "type.googleapis.com/" + getResourceName(resource_api_version); -} - -/** - * get all version resource names. + * Get resource name from api type. */ -template std::vector getAllVersionResourceNames() { - return std::vector{ - Current().GetDescriptor()->full_name(), - ApiTypeOracle::getEarlierVersionMessageTypeName(Current().GetDescriptor()->full_name()) - .value()}; +template std::string getResourceName() { + return Current().GetDescriptor()->full_name(); } /** - * get all version type urls. + * Get type url from api type. */ -template std::vector getAllVersionTypeUrls() { - auto resource_names = getAllVersionResourceNames(); - for (auto&& resource_name : resource_names) { - resource_name = "type.googleapis.com/" + resource_name; - } - return resource_names; +template std::string getTypeUrl() { + return "type.googleapis.com/" + getResourceName(); } } // namespace Config diff --git a/source/common/config/subscription_base.h b/source/common/config/subscription_base.h index 447931d1c36b..7207c26582e8 100644 --- a/source/common/config/subscription_base.h +++ b/source/common/config/subscription_base.h @@ -10,20 +10,14 @@ namespace Config { template struct SubscriptionBase : public Config::SubscriptionCallbacks { public: - SubscriptionBase(const envoy::config::core::v3::ApiVersion api_version, - ProtobufMessage::ValidationVisitor& validation_visitor, + SubscriptionBase(ProtobufMessage::ValidationVisitor& validation_visitor, absl::string_view name_field) - : resource_decoder_(validation_visitor, name_field), api_version_(api_version) {} + : resource_decoder_(validation_visitor, name_field) {} - std::string getResourceName() const { - return Envoy::Config::getResourceName(api_version_); - } + std::string getResourceName() const { return Envoy::Config::getResourceName(); } protected: Config::OpaqueResourceDecoderImpl resource_decoder_; - -private: - const envoy::config::core::v3::ApiVersion api_version_; }; } // namespace Config diff --git a/source/common/config/subscription_factory_impl.cc b/source/common/config/subscription_factory_impl.cc index e21ece1f106b..74f5fb439e3e 100644 --- a/source/common/config/subscription_factory_impl.cc +++ b/source/common/config/subscription_factory_impl.cc @@ -41,7 +41,8 @@ SubscriptionPtr SubscriptionFactoryImpl::subscriptionFromConfigSource( const envoy::config::core::v3::ApiConfigSource& api_config_source = config.api_config_source(); Utility::checkApiConfigSourceSubscriptionBackingCluster(cm_.primaryClusters(), api_config_source); - const auto transport_api_version = Utility::getAndCheckTransportVersion(api_config_source); + Utility::checkTransportVersion(api_config_source); + const auto transport_api_version = envoy::config::core::v3::ApiVersion::V3; switch (api_config_source.api_type()) { case envoy::config::core::v3::ApiConfigSource::hidden_envoy_deprecated_UNSUPPORTED_REST_LEGACY: throw EnvoyException( @@ -53,9 +54,8 @@ SubscriptionPtr SubscriptionFactoryImpl::subscriptionFromConfigSource( local_info_, cm_, api_config_source.cluster_names()[0], dispatcher_, api_.randomGenerator(), Utility::apiConfigSourceRefreshDelay(api_config_source), Utility::apiConfigSourceRequestTimeout(api_config_source), - restMethod(type_url, transport_api_version), type_url, transport_api_version, callbacks, - resource_decoder, stats, Utility::configSourceInitialFetchTimeout(config), - validation_visitor_); + restMethod(type_url, transport_api_version), type_url, callbacks, resource_decoder, stats, + Utility::configSourceInitialFetchTimeout(config), validation_visitor_); case envoy::config::core::v3::ApiConfigSource::GRPC: return std::make_unique( std::make_shared( @@ -63,8 +63,8 @@ SubscriptionPtr SubscriptionFactoryImpl::subscriptionFromConfigSource( Utility::factoryForGrpcApiConfigSource(cm_.grpcAsyncClientManager(), api_config_source, scope, true) ->createUncachedRawAsyncClient(), - dispatcher_, sotwGrpcMethod(type_url, transport_api_version), transport_api_version, - api_.randomGenerator(), scope, Utility::parseRateLimitSettings(api_config_source), + dispatcher_, sotwGrpcMethod(type_url, transport_api_version), api_.randomGenerator(), + scope, Utility::parseRateLimitSettings(api_config_source), api_config_source.set_node_on_first_message_only()), callbacks, resource_decoder, stats, type_url, dispatcher_, Utility::configSourceInitialFetchTimeout(config), @@ -75,9 +75,8 @@ SubscriptionPtr SubscriptionFactoryImpl::subscriptionFromConfigSource( Config::Utility::factoryForGrpcApiConfigSource(cm_.grpcAsyncClientManager(), api_config_source, scope, true) ->createUncachedRawAsyncClient(), - dispatcher_, deltaGrpcMethod(type_url, transport_api_version), transport_api_version, - api_.randomGenerator(), scope, Utility::parseRateLimitSettings(api_config_source), - local_info_), + dispatcher_, deltaGrpcMethod(type_url, transport_api_version), api_.randomGenerator(), + scope, Utility::parseRateLimitSettings(api_config_source), local_info_), callbacks, resource_decoder, stats, type_url, dispatcher_, Utility::configSourceInitialFetchTimeout(config), /*is_aggregated*/ false, options); } @@ -135,8 +134,8 @@ SubscriptionPtr SubscriptionFactoryImpl::collectionSubscriptionFromUrl( api_config_source, scope, true) ->createUncachedRawAsyncClient(), dispatcher_, deltaGrpcMethod(type_url, envoy::config::core::v3::ApiVersion::V3), - envoy::config::core::v3::ApiVersion::V3, api_.randomGenerator(), scope, - Utility::parseRateLimitSettings(api_config_source), local_info_), + api_.randomGenerator(), scope, Utility::parseRateLimitSettings(api_config_source), + local_info_), callbacks, resource_decoder, stats, dispatcher_, Utility::configSourceInitialFetchTimeout(config), false, options); } diff --git a/source/common/config/utility.cc b/source/common/config/utility.cc index a1e7a5bb09c9..12ff90cfee2a 100644 --- a/source/common/config/utility.cc +++ b/source/common/config/utility.cc @@ -13,8 +13,6 @@ #include "source/common/common/fmt.h" #include "source/common/common/hex.h" #include "source/common/common/utility.h" -#include "source/common/config/api_type_oracle.h" -#include "source/common/config/version_converter.h" #include "source/common/config/well_known_names.h" #include "source/common/protobuf/protobuf.h" #include "source/common/protobuf/utility.h" diff --git a/source/common/config/utility.h b/source/common/config/utility.h index e4227ff06cae..f6d753eaa7d0 100644 --- a/source/common/config/utility.h +++ b/source/common/config/utility.h @@ -185,15 +185,11 @@ class Utility { const envoy::config::core::v3::ApiConfigSource& api_config_source); /** - * Access transport_api_version field in ApiConfigSource, while validating version - * compatibility. + * Validate transport_api_version field in ApiConfigSource. * @param api_config_source the config source to extract transport API version from. - * @return envoy::config::core::v3::ApiVersion transport API version * @throws DeprecatedMajorVersionException when the transport version is disabled. */ - template - static envoy::config::core::v3::ApiVersion - getAndCheckTransportVersion(const Proto& api_config_source) { + template static void checkTransportVersion(const Proto& api_config_source) { const auto transport_api_version = api_config_source.transport_api_version(); ASSERT(Thread::MainThread::isMainThread()); if (transport_api_version == envoy::config::core::v3::ApiVersion::AUTO || @@ -206,12 +202,8 @@ class Utility { "following the advice in https://www.envoyproxy.io/docs/envoy/latest/faq/api/transition.", api_config_source.DebugString()); ENVOY_LOG_MISC(warn, warning); - if (!Runtime::runtimeFeatureEnabled( - "envoy.test_only.broken_in_production.enable_deprecated_v2_api")) { - throw DeprecatedMajorVersionException(warning); - } + throw DeprecatedMajorVersionException(warning); } - return transport_api_version; } /** diff --git a/source/common/config/version_converter.cc b/source/common/config/version_converter.cc deleted file mode 100644 index be6bfa25b5ac..000000000000 --- a/source/common/config/version_converter.cc +++ /dev/null @@ -1,232 +0,0 @@ -#include "source/common/config/version_converter.h" - -#include "envoy/common/exception.h" - -#include "source/common/common/assert.h" -#include "source/common/common/macros.h" -#include "source/common/config/api_type_oracle.h" -#include "source/common/protobuf/visitor.h" -#include "source/common/protobuf/well_known.h" - -#include "absl/strings/match.h" - -namespace Envoy { -namespace Config { - -namespace { - -class ProtoVisitor { -public: - virtual ~ProtoVisitor() = default; - - // Invoked when a field is visited, with the message, field descriptor and - // context. Returns a new context for use when traversing the sub-message in a - // field. - virtual const void* onField(Protobuf::Message&, const Protobuf::FieldDescriptor&, - const void* ctxt) { - return ctxt; - } - - // Invoked when a message is visited, with the message and a context. - virtual void onMessage(Protobuf::Message&, const void*){}; -}; - -// Reinterpret a Protobuf message as another Protobuf message by converting to wire format and back. -// This only works for messages that can be effectively duck typed this way, e.g. with a subtype -// relationship modulo field name. -void wireCast(const Protobuf::Message& src, Protobuf::Message& dst) { - // This should should generally succeed, but if there are malformed UTF-8 strings in a message, - // this can fail. - if (!dst.ParseFromString(src.SerializeAsString())) { - throw EnvoyException("Unable to deserialize during wireCast()"); - } -} - -// Create a new dynamic message based on some message wire cast to the target -// descriptor. If the descriptor is null, a copy is performed. -DynamicMessagePtr createForDescriptorWithCast(const Protobuf::Message& message, - const Protobuf::Descriptor* desc) { - auto dynamic_message = std::make_unique(); - if (desc != nullptr) { - dynamic_message->msg_.reset(dynamic_message->dynamic_msg_factory_.GetPrototype(desc)->New()); - wireCast(message, *dynamic_message->msg_); - return dynamic_message; - } - // Unnecessary copy, since the existing message is being treated as - // "dynamic". However, we want to transfer an owned object, so this is the - // best we can do. - dynamic_message->msg_.reset(message.New()); - dynamic_message->msg_->MergeFrom(message); - return dynamic_message; -} - -} // namespace - -void VersionConverter::upgrade(const Protobuf::Message& prev_message, - Protobuf::Message& next_message) { - wireCast(prev_message, next_message); - // Track original type to support recoverOriginal(). - annotateWithOriginalType(*prev_message.GetDescriptor(), next_message); -} - -// This needs to be recursive, since sub-messages are consumed and stored -// internally, we later want to recover their original types. -void VersionConverter::annotateWithOriginalType(const Protobuf::Descriptor& prev_descriptor, - Protobuf::Message& upgraded_message) { - class TypeAnnotatingProtoVisitor : public ProtobufMessage::ProtoVisitor { - public: - void onMessage(Protobuf::Message& message, const void* ctxt) override { - const Protobuf::Descriptor* descriptor = message.GetDescriptor(); - const Protobuf::Reflection* reflection = message.GetReflection(); - const Protobuf::Descriptor* prev_descriptor = static_cast(ctxt); - // If there is no previous descriptor for this message, we don't need to annotate anything. - if (prev_descriptor == nullptr) { - return; - } - // If they are the same type, there's no possibility of any different type - // further down, so we're done. - if (descriptor->full_name() == prev_descriptor->full_name()) { - return; - } - auto* unknown_field_set = reflection->MutableUnknownFields(&message); - unknown_field_set->AddLengthDelimited(ProtobufWellKnown::OriginalTypeFieldNumber, - prev_descriptor->full_name()); - } - - const void* onField(Protobuf::Message&, const Protobuf::FieldDescriptor& field, - const void* ctxt) override { - const Protobuf::Descriptor* prev_descriptor = static_cast(ctxt); - // If there is no previous descriptor for this field, we don't need to annotate anything. - if (prev_descriptor == nullptr) { - return nullptr; - } - // TODO(htuch): This is a terrible hack, there should be no per-resource - // business logic in this file. The reason this is required is that - // endpoints, when captured in configuration such as inlined hosts in - // Clusters for config dump purposes, can potentially contribute a - // significant amount to memory consumption. stats_integration_test - // complains as a result if we increase any memory due to type annotations. - // In theory, we should be able to just clean up these annotations in - // ClusterManagerImpl with type erasure, but protobuf doesn't free up memory - // as expected, we probably need some arena level trick to address this. - if (prev_descriptor->full_name() == "envoy.api.v2.Cluster" && - field.name() == "load_assignment") { - // This will cause the sub-message visit to abort early. - return field.message_type(); - } - const Protobuf::FieldDescriptor* prev_field = - prev_descriptor->FindFieldByNumber(field.number()); - return prev_field != nullptr ? prev_field->message_type() : nullptr; - } - }; - TypeAnnotatingProtoVisitor proto_visitor; - ProtobufMessage::traverseMutableMessage(proto_visitor, upgraded_message, &prev_descriptor); -} - -void VersionConverter::eraseOriginalTypeInformation(Protobuf::Message& message) { - class TypeErasingProtoVisitor : public ProtobufMessage::ProtoVisitor { - public: - void onMessage(Protobuf::Message& message, const void*) override { - const Protobuf::Reflection* reflection = message.GetReflection(); - auto* unknown_field_set = reflection->MutableUnknownFields(&message); - unknown_field_set->DeleteByNumber(ProtobufWellKnown::OriginalTypeFieldNumber); - } - }; - TypeErasingProtoVisitor proto_visitor; - ProtobufMessage::traverseMutableMessage(proto_visitor, message, nullptr); -} - -DynamicMessagePtr VersionConverter::recoverOriginal(const Protobuf::Message& upgraded_message) { - const Protobuf::Reflection* reflection = upgraded_message.GetReflection(); - const auto& unknown_field_set = reflection->GetUnknownFields(upgraded_message); - for (int i = 0; i < unknown_field_set.field_count(); ++i) { - const auto& unknown_field = unknown_field_set.field(i); - if (unknown_field.number() == ProtobufWellKnown::OriginalTypeFieldNumber) { - ASSERT(unknown_field.type() == Protobuf::UnknownField::TYPE_LENGTH_DELIMITED); - const std::string& original_type = unknown_field.length_delimited(); - const Protobuf::Descriptor* original_descriptor = - Protobuf::DescriptorPool::generated_pool()->FindMessageTypeByName(original_type); - auto result = createForDescriptorWithCast(upgraded_message, original_descriptor); - // We should clear out the OriginalTypeFieldNumber in the recovered message. - eraseOriginalTypeInformation(*result->msg_); - return result; - } - } - return createForDescriptorWithCast(upgraded_message, nullptr); -} - -DynamicMessagePtr VersionConverter::downgrade(const Protobuf::Message& message) { - const Protobuf::Descriptor* prev_desc = - ApiTypeOracle::getEarlierVersionDescriptor(message.GetDescriptor()->full_name()); - return createForDescriptorWithCast(message, prev_desc); -} - -std::string -VersionConverter::getJsonStringFromMessage(const Protobuf::Message& message, - envoy::config::core::v3::ApiVersion api_version) { - DynamicMessagePtr dynamic_message; - switch (api_version) { - case envoy::config::core::v3::ApiVersion::AUTO: - FALLTHRU; - case envoy::config::core::v3::ApiVersion::V2: { - // TODO(htuch): this works as long as there are no new fields in the v3+ - // DiscoveryRequest. When they are added, we need to do a full v2 conversion - // and also discard unknown fields. Tracked at - // https://github.com/envoyproxy/envoy/issues/9619. - dynamic_message = downgrade(message); - break; - } - case envoy::config::core::v3::ApiVersion::V3: { - // We need to scrub the hidden fields. - dynamic_message = std::make_unique(); - dynamic_message->msg_.reset(message.New()); - dynamic_message->msg_->MergeFrom(message); - VersionUtil::scrubHiddenEnvoyDeprecated(*dynamic_message->msg_); - break; - } - default: - NOT_REACHED_GCOVR_EXCL_LINE; - } - eraseOriginalTypeInformation(*dynamic_message->msg_); - std::string json; - Protobuf::util::JsonPrintOptions json_options; - json_options.preserve_proto_field_names = true; - const auto status = - Protobuf::util::MessageToJsonString(*dynamic_message->msg_, &json, json_options); - // This should always succeed unless something crash-worthy such as out-of-memory. - RELEASE_ASSERT(status.ok(), ""); - return json; -} - -void VersionConverter::prepareMessageForGrpcWire(Protobuf::Message& message, - envoy::config::core::v3::ApiVersion api_version) { - // TODO(htuch): this works as long as there are no new fields in the v3+ - // DiscoveryRequest. When they are added, we need to do a full v2 conversion - // and also discard unknown fields. Tracked at - // https://github.com/envoyproxy/envoy/issues/9619. - if (api_version == envoy::config::core::v3::ApiVersion::V3) { - VersionUtil::scrubHiddenEnvoyDeprecated(message); - } - eraseOriginalTypeInformation(message); -} - -void VersionUtil::scrubHiddenEnvoyDeprecated(Protobuf::Message& message) { - class HiddenFieldScrubbingProtoVisitor : public ProtobufMessage::ProtoVisitor { - public: - const void* onField(Protobuf::Message& message, const Protobuf::FieldDescriptor& field, - const void*) override { - const Protobuf::Reflection* reflection = message.GetReflection(); - if (absl::StartsWith(field.name(), DeprecatedFieldShadowPrefix)) { - reflection->ClearField(&message, &field); - } - return nullptr; - } - }; - HiddenFieldScrubbingProtoVisitor proto_visitor; - ProtobufMessage::traverseMutableMessage(proto_visitor, message, nullptr); -} - -const char VersionUtil::DeprecatedFieldShadowPrefix[] = "hidden_envoy_deprecated_"; - -} // namespace Config -} // namespace Envoy diff --git a/source/common/config/version_converter.h b/source/common/config/version_converter.h deleted file mode 100644 index a7f5db3e9d8a..000000000000 --- a/source/common/config/version_converter.h +++ /dev/null @@ -1,133 +0,0 @@ -#pragma once - -#include "envoy/config/core/v3/config_source.pb.h" - -#include "source/common/protobuf/protobuf.h" - -// Convenience macro for downgrading a message and obtaining a reference. -#define API_DOWNGRADE(msg) (*Envoy::Config::VersionConverter::downgrade(msg)->msg_) - -// Convenience macro for recovering original message and obtaining a reference. -#define API_RECOVER_ORIGINAL(msg) (*Envoy::Config::VersionConverter::recoverOriginal(msg)->msg_) - -namespace Envoy { -namespace Config { - -// An instance of a dynamic message from a DynamicMessageFactory. -struct DynamicMessage { - // The dynamic message factory must outlive the message. - Protobuf::DynamicMessageFactory dynamic_msg_factory_; - - // Dynamic message. - ProtobufTypes::MessagePtr msg_; -}; - -using DynamicMessagePtr = std::unique_ptr; - -class VersionConverter { -public: - /** - * Upgrade a message from an earlier to later version of the Envoy API. This - * performs a simple wire-level reinterpretation of the fields. As a result of - * shadow protos, earlier deprecated fields such as foo are materialized as - * hidden_envoy_deprecated_foo. - * - * This should be used when you have wire input (e.g. bootstrap, xDS, some - * opaque config) that might be at any supported version and want to upgrade - * to Envoy's internal latest API usage. - * - * @param prev_message previous version message input. - * @param next_message next version message to generate. - * - * @throw EnvoyException if a Protobuf (de)serialization error occurs. - */ - static void upgrade(const Protobuf::Message& prev_message, Protobuf::Message& next_message); - - /** - * Downgrade a message to the previous version. If no previous version exists, - * the given message is copied in the return value. This is not super - * efficient, most uses are expected to be tests and performance agnostic - * code. - * - * This is used primarily in tests, to allow tests to internally use the - * latest supported API but ensure that earlier versions are used on the wire. - * - * @param message message input. - * @return DynamicMessagePtr with the downgraded message (and associated - * factory state). - * - * @throw EnvoyException if a Protobuf (de)serialization error occurs. - */ - static DynamicMessagePtr downgrade(const Protobuf::Message& message); - - /** - * Obtain JSON wire representation for an Envoy internal API message at v3 - * based on a given transport API version. This will downgrade() to an earlier - * version or scrub the shadow deprecated fields in the existing one. - * - * This is typically used when Envoy is generating a JSON wire message from - * some internally generated message, e.g. DiscoveryRequest, and we want to - * ensure it matches a specific API version. For example, a v3 - * DiscoveryRequest must have any deprecated v2 fields removed (they only - * exist because of shadowing) and a v2 DiscoveryRequest needs to have type - * envoy.api.v2.DiscoveryRequest to ensure JSON representations have the - * correct field names (after renames/deprecations are reversed). - * - * @param message message input. - * @param api_version target API version. - * @return std::string JSON representation. - */ - static std::string getJsonStringFromMessage(const Protobuf::Message& message, - envoy::config::core::v3::ApiVersion api_version); - - /** - * Modify a v3 message to make it suitable for sending as a gRPC message. This - * requires that a v3 message has hidden_envoy_deprecated_* fields removed, - * and that for all versions that original type information is removed. - * - * @param message message to modify. - * @param api_version target API version. - */ - static void prepareMessageForGrpcWire(Protobuf::Message& message, - envoy::config::core::v3::ApiVersion api_version); - - /** - * Annotate an upgraded message with original message type information. - * - * @param prev_descriptor descriptor for original type. - * @param upgraded_message upgraded message. - */ - static void annotateWithOriginalType(const Protobuf::Descriptor& prev_descriptor, - Protobuf::Message& upgraded_message); - - /** - * For a message that may have been upgraded, recover the original message. - * This is useful for config dump, debug output etc. - * - * @param upgraded_message upgraded message input. - * - * @return DynamicMessagePtr original message (as a dynamic message). - * - * @throw EnvoyException if a Protobuf (de)serialization error occurs. - */ - static DynamicMessagePtr recoverOriginal(const Protobuf::Message& upgraded_message); - - /** - * Remove original type information, when it's not needed, e.g. in tests. - * - * @param message upgraded message to scrub. - */ - static void eraseOriginalTypeInformation(Protobuf::Message& message); -}; - -class VersionUtil { -public: - // Some helpers for working with earlier message version deprecated fields. - static void scrubHiddenEnvoyDeprecated(Protobuf::Message& message); - - // A prefix that is added to deprecated fields names upon shadowing. - static const char DeprecatedFieldShadowPrefix[]; -}; - -} // namespace Config -} // namespace Envoy diff --git a/source/common/config/xds_mux/BUILD b/source/common/config/xds_mux/BUILD index de337592a86f..323f17a5d8bb 100644 --- a/source/common/config/xds_mux/BUILD +++ b/source/common/config/xds_mux/BUILD @@ -63,7 +63,6 @@ envoy_cc_library( "//envoy/grpc:async_client_interface", "//source/common/config:grpc_stream_lib", "//source/common/config:pausable_ack_queue_lib", - "//source/common/config:version_converter_lib", "//source/common/config:watch_map_lib", "//source/common/config:xds_context_params_lib", "//source/common/config:xds_resource_lib", diff --git a/source/common/config/xds_mux/grpc_mux_impl.cc b/source/common/config/xds_mux/grpc_mux_impl.cc index 0e62f1022d94..c2eba80b4ad8 100644 --- a/source/common/config/xds_mux/grpc_mux_impl.cc +++ b/source/common/config/xds_mux/grpc_mux_impl.cc @@ -6,7 +6,6 @@ #include "source/common/common/backoff_strategy.h" #include "source/common/config/decoded_resource_impl.h" #include "source/common/config/utility.h" -#include "source/common/config/version_converter.h" #include "source/common/config/xds_context_params.h" #include "source/common/config/xds_resource.h" #include "source/common/memory/utils.h" @@ -177,7 +176,6 @@ void GrpcMuxImpl::sendGrpcMessage(RQ& msg_proto, S& sub_state) { !skipSubsequentNode()) { msg_proto.mutable_node()->CopyFrom(localInfo().node()); } - VersionConverter::prepareMessageForGrpcWire(msg_proto, transportApiVersion()); sendMessage(msg_proto); setAnyRequestSentYetInCurrentStream(true); sub_state.clearDynamicContextChanged(); diff --git a/source/common/filter/config_discovery_impl.cc b/source/common/filter/config_discovery_impl.cc index a88074f30490..7c686d166436 100644 --- a/source/common/filter/config_discovery_impl.cc +++ b/source/common/filter/config_discovery_impl.cc @@ -70,7 +70,6 @@ FilterConfigSubscription::FilterConfigSubscription( const std::string& stat_prefix, FilterConfigProviderManagerImpl& filter_config_provider_manager, const std::string& subscription_id) : Config::SubscriptionBase( - envoy::config::core::v3::ApiVersion::V3, factory_context.messageValidationContext().dynamicValidationVisitor(), "name"), filter_config_name_(filter_config_name), factory_context_(factory_context), validator_(factory_context.messageValidationContext().dynamicValidationVisitor()), diff --git a/source/common/grpc/BUILD b/source/common/grpc/BUILD index 0681c33674b5..8e3cc89fd7e7 100644 --- a/source/common/grpc/BUILD +++ b/source/common/grpc/BUILD @@ -33,7 +33,6 @@ envoy_cc_library( ":typed_async_client_lib", "//envoy/grpc:async_client_interface", "//source/common/buffer:zero_copy_input_stream_lib", - "//source/common/config:version_converter_lib", "//source/common/http:async_client_lib", "@envoy_api//envoy/config/core/v3:pkg_cc_proto", ], diff --git a/source/common/grpc/typed_async_client.h b/source/common/grpc/typed_async_client.h index 22a009054357..af9e8df9492a 100644 --- a/source/common/grpc/typed_async_client.h +++ b/source/common/grpc/typed_async_client.h @@ -6,7 +6,6 @@ #include "envoy/grpc/async_client.h" #include "source/common/common/empty_string.h" -#include "source/common/config/version_converter.h" namespace Envoy { namespace Grpc { @@ -40,12 +39,6 @@ template class AsyncStream /* : public RawAsyncStream */ { void sendMessage(const Protobuf::Message& request, bool end_stream) { Internal::sendMessageUntyped(stream_, std::move(request), end_stream); } - void sendMessage(const Protobuf::Message& request, - envoy::config::core::v3::ApiVersion transport_api_version, bool end_stream) { - Config::VersionConverter::prepareMessageForGrpcWire(const_cast(request), - transport_api_version); - Internal::sendMessageUntyped(stream_, std::move(request), end_stream); - } void closeStream() { stream_->closeStream(); } void resetStream() { stream_->resetStream(); } bool isAboveWriteBufferHighWatermark() const { @@ -86,55 +79,6 @@ template class AsyncRequestCallbacks : public RawAsyncReques } }; -/** - * Versioned methods wrapper. - */ -class VersionedMethods { -public: - VersionedMethods(const std::string& v3, const std::string& v2, const std::string& v2_alpha = "") - : v3_(Protobuf::DescriptorPool::generated_pool()->FindMethodByName(v3)), - v2_(Protobuf::DescriptorPool::generated_pool()->FindMethodByName(v2)), - v2_alpha_(v2_alpha.empty() - ? nullptr - : Protobuf::DescriptorPool::generated_pool()->FindMethodByName(v2_alpha)) {} - - /** - * Given a version, return the method descriptor for a specific version. - * - * @param api_version target API version. - * @param use_alpha if this is an alpha version of an API method. - * - * @return Protobuf::MethodDescriptor& of a method for a specific version. - */ - const Protobuf::MethodDescriptor& - getMethodDescriptorForVersion(envoy::config::core::v3::ApiVersion api_version, - bool use_alpha = false) const { - switch (api_version) { - case envoy::config::core::v3::ApiVersion::AUTO: - FALLTHRU; - case envoy::config::core::v3::ApiVersion::V2: { - const auto* descriptor = use_alpha ? v2_alpha_ : v2_; - ASSERT(descriptor != nullptr); - return *descriptor; - } - - case envoy::config::core::v3::ApiVersion::V3: { - const auto* descriptor = v3_; - ASSERT(descriptor != nullptr); - return *descriptor; - } - - default: - NOT_REACHED_GCOVR_EXCL_LINE; - } - } - -private: - const Protobuf::MethodDescriptor* v3_{nullptr}; - const Protobuf::MethodDescriptor* v2_{nullptr}; - const Protobuf::MethodDescriptor* v2_alpha_{nullptr}; -}; - /** * Convenience subclasses for AsyncStreamCallbacks. */ @@ -170,16 +114,6 @@ template class AsyncClient /* : public Raw return Internal::sendUntyped(client_.get(), service_method, request, callbacks, parent_span, options); } - virtual AsyncRequest* send(const Protobuf::MethodDescriptor& service_method, - const Protobuf::Message& request, - AsyncRequestCallbacks& callbacks, Tracing::Span& parent_span, - const Http::AsyncClient::RequestOptions& options, - envoy::config::core::v3::ApiVersion transport_api_version) { - Config::VersionConverter::prepareMessageForGrpcWire(const_cast(request), - transport_api_version); - return Internal::sendUntyped(client_.get(), service_method, request, callbacks, parent_span, - options); - } virtual AsyncStream start(const Protobuf::MethodDescriptor& service_method, AsyncStreamCallbacks& callbacks, diff --git a/source/common/local_info/BUILD b/source/common/local_info/BUILD index 254710601695..6ef5460977b4 100644 --- a/source/common/local_info/BUILD +++ b/source/common/local_info/BUILD @@ -14,7 +14,6 @@ envoy_cc_library( deps = [ "//envoy/local_info:local_info_interface", "//source/common/config:context_provider_lib", - "//source/common/config:version_converter_lib", "//source/common/stats:symbol_table_lib", "@envoy_api//envoy/config/core/v3:pkg_cc_proto", ], diff --git a/source/common/local_info/local_info_impl.h b/source/common/local_info/local_info_impl.h index 6280d782088c..8f5b3e5fba56 100644 --- a/source/common/local_info/local_info_impl.h +++ b/source/common/local_info/local_info_impl.h @@ -6,7 +6,6 @@ #include "envoy/local_info/local_info.h" #include "source/common/config/context_provider_impl.h" -#include "source/common/config/version_converter.h" #include "source/common/stats/symbol_table_impl.h" namespace Envoy { diff --git a/source/common/protobuf/BUILD b/source/common/protobuf/BUILD index 64bfefa6c003..d3235a5757e9 100644 --- a/source/common/protobuf/BUILD +++ b/source/common/protobuf/BUILD @@ -61,7 +61,6 @@ envoy_cc_library( deps = [ ":message_validator_lib", ":protobuf", - ":well_known_lib", "//envoy/api:api_interface", "//envoy/protobuf:message_validator_interface", "//envoy/runtime:runtime_interface", @@ -70,8 +69,6 @@ envoy_cc_library( "//source/common/common:hash_lib", "//source/common/common:stl_helpers", "//source/common/common:utility_lib", - "//source/common/config:api_type_oracle_lib", - "//source/common/config:version_converter_lib", "//source/common/protobuf:visitor_lib", "//source/common/runtime:runtime_features_lib", "@com_github_cncf_udpa//udpa/annotations:pkg_cc_proto", @@ -86,8 +83,3 @@ envoy_cc_library( hdrs = ["visitor.h"], deps = [":protobuf"], ) - -envoy_cc_library( - name = "well_known_lib", - hdrs = ["well_known.h"], -) diff --git a/source/common/protobuf/utility.cc b/source/common/protobuf/utility.cc index 04f5907db2cb..c81d1b924501 100644 --- a/source/common/protobuf/utility.cc +++ b/source/common/protobuf/utility.cc @@ -10,12 +10,9 @@ #include "source/common/common/assert.h" #include "source/common/common/documentation_url.h" #include "source/common/common/fmt.h" -#include "source/common/config/api_type_oracle.h" -#include "source/common/config/version_converter.h" #include "source/common/protobuf/message_validator_impl.h" #include "source/common/protobuf/protobuf.h" #include "source/common/protobuf/visitor.h" -#include "source/common/protobuf/well_known.h" #include "source/common/runtime/runtime_features.h" #include "absl/strings/match.h" @@ -27,19 +24,6 @@ using namespace std::chrono_literals; namespace Envoy { namespace { -// For historical reasons, these v2 protos are allowed in v3 and will not be removed during the v2 -// turn down. -static const absl::flat_hash_set& v2ProtosAllowedInV3() { - CONSTRUCT_ON_FIRST_USE( - absl::flat_hash_set, - {"envoy.config.health_checker.redis.v2.Redis", - "envoy.config.filter.thrift.router.v2alpha1.Router", - "envoy.config.resource_monitor.fixed_heap.v2alpha.FixedHeapConfig", - "envoy.config.resource_monitor.injected_resource.v2alpha.InjectedResourceConfig", - "envoy.config.retry.omit_canary_hosts.v2.OmitCanaryHostsPredicate", - "envoy.config.retry.previous_hosts.v2.PreviousHostsPredicate"}); -} - absl::string_view filenameFromPath(absl::string_view full_path) { size_t index = full_path.rfind("/"); if (index == std::string::npos || index == full_path.size()) { @@ -122,7 +106,7 @@ ProtobufWkt::Value parseYamlNode(const YAML::Node& node) { void jsonConvertInternal(const Protobuf::Message& source, ProtobufMessage::ValidationVisitor& validation_visitor, - Protobuf::Message& dest, bool do_boosting = true) { + Protobuf::Message& dest) { Protobuf::util::JsonPrintOptions json_options; json_options.preserve_proto_field_names = true; std::string json; @@ -131,66 +115,7 @@ void jsonConvertInternal(const Protobuf::Message& source, throw EnvoyException(fmt::format("Unable to convert protobuf message to JSON string: {} {}", status.ToString(), source.DebugString())); } - MessageUtil::loadFromJson(json, dest, validation_visitor, do_boosting); -} - -enum class MessageVersion { - // This is an earlier version of a message, a later one exists. - EarlierVersion, - // This is the latest version of a message. - LatestVersion, - // Validating to see if the latest version will also be accepted; only apply message validators - // without side effects, validations should be strict. - LatestVersionValidate, -}; - -using MessageXformFn = std::function; - -class ApiBoostRetryException : public EnvoyException { -public: - ApiBoostRetryException(const std::string& message) : EnvoyException(message) {} -}; - -// Apply a function transforming a message (e.g. loading JSON into the message). -// First we try with the message's earlier type, and if unsuccessful (or no -// earlier) type, then the current type. This allows us to take a v3 Envoy -// internal proto and ingest both v2 and v3 in methods such as loadFromJson. -// This relies on the property that any v3 configuration that is readable as -// v2 has the same semantics in v2/v3, which holds due to the highly structured -// vN/v(N+1) mechanical transforms. -void tryWithApiBoosting(MessageXformFn f, Protobuf::Message& message) { - const Protobuf::Descriptor* earlier_version_desc = - Config::ApiTypeOracle::getEarlierVersionDescriptor(message.GetDescriptor()->full_name()); - // If there is no earlier version of a message, just apply f directly. - if (earlier_version_desc == nullptr) { - f(message, MessageVersion::LatestVersion); - return; - } - - Protobuf::DynamicMessageFactory dmf; - auto earlier_message = ProtobufTypes::MessagePtr(dmf.GetPrototype(earlier_version_desc)->New()); - ASSERT(earlier_message != nullptr); - TRY_ASSERT_MAIN_THREAD { - // Try apply f with an earlier version of the message, then upgrade the - // result. - f(*earlier_message, MessageVersion::EarlierVersion); - // If we succeed at the earlier version, we ask the counterfactual, would this have worked at a - // later version? If not, this is v2 only and we need to warn. This is a waste of CPU cycles but - // we expect that JSON/YAML fragments will not be in use by any CPU limited use cases. - TRY_ASSERT_MAIN_THREAD { f(message, MessageVersion::LatestVersionValidate); } - END_TRY - catch (EnvoyException& e) { - MessageUtil::onVersionUpgradeDeprecation(e.what()); - } - // Now we do the real work of upgrading. - Config::VersionConverter::upgrade(*earlier_message, message); - } - END_TRY - catch (ApiBoostRetryException&) { - // If we fail at the earlier version, try f at the current version of the - // message. - f(message, MessageVersion::LatestVersion); - } + MessageUtil::loadFromJson(json, dest, validation_visitor); } // Logs a warning for use of a deprecated field or runtime-overridden use of an @@ -296,41 +221,6 @@ void ProtoExceptionUtil::throwProtoValidationException(const std::string& valida throw ProtoValidationException(validation_error, message); } -void MessageUtil::onVersionUpgradeDeprecation(absl::string_view desc, bool /*reject*/) { - const std::string& warning_str = - fmt::format("Configuration does not parse cleanly as v3. v2 configuration is " - "deprecated and will be removed from Envoy at the start of Q1 2021: {}", - desc); - // Always log at trace level. This is useful for tests that don't want to rely on possible - // elision. - ENVOY_LOG_MISC(trace, warning_str); - // Log each distinct message at warn level once every 5s. We use a static map here, which is fine - // as we are always on the main thread. - static auto* last_warned = new absl::flat_hash_map(); - const auto now = t_logclock::now().time_since_epoch().count(); - const auto it = last_warned->find(warning_str); - if (it == last_warned->end() || - (now - it->second) > std::chrono::duration_cast(5s).count()) { - ENVOY_LOG_MISC(warn, warning_str); - (*last_warned)[warning_str] = now; - } - Runtime::Loader* loader = Runtime::LoaderSingleton::getExisting(); - // We only log, and don't bump stats, if we're sufficiently early in server initialization (i.e. - // bootstrap). - if (loader != nullptr) { - loader->countDeprecatedFeatureUse(); - } - if (!Runtime::runtimeFeatureEnabled( - "envoy.test_only.broken_in_production.enable_deprecated_v2_api")) { - throw DeprecatedMajorVersionException(fmt::format( - "The v2 xDS major version is deprecated and disabled by default. Support for v2 will be " - "removed from Envoy at the start of Q1 2021. You may make use of v2 in Q4 2020 by " - "following " - "the advice in https://www.envoyproxy.io/docs/envoy/latest/faq/api/transition. ({})", - desc)); - } -} - size_t MessageUtil::hash(const Protobuf::Message& message) { std::string text_format; @@ -347,51 +237,35 @@ size_t MessageUtil::hash(const Protobuf::Message& message) { } void MessageUtil::loadFromJson(const std::string& json, Protobuf::Message& message, - ProtobufMessage::ValidationVisitor& validation_visitor, - bool do_boosting) { - auto load_json = [&json, &validation_visitor](Protobuf::Message& message, - MessageVersion message_version) { - Protobuf::util::JsonParseOptions options; - options.case_insensitive_enum_parsing = true; - // Let's first try and get a clean parse when checking for unknown fields; - // this should be the common case. - options.ignore_unknown_fields = false; - const auto strict_status = Protobuf::util::JsonStringToMessage(json, &message, options); - if (strict_status.ok()) { - // Success, no need to do any extra work. - return; - } - // If we fail, we see if we get a clean parse when allowing unknown fields. - // This is essentially a workaround - // for https://github.com/protocolbuffers/protobuf/issues/5967. - // TODO(htuch): clean this up when protobuf supports JSON/YAML unknown field - // detection directly. - options.ignore_unknown_fields = true; - const auto relaxed_status = Protobuf::util::JsonStringToMessage(json, &message, options); - // If we still fail with relaxed unknown field checking, the error has nothing - // to do with unknown fields. - if (!relaxed_status.ok()) { - throw EnvoyException("Unable to parse JSON as proto (" + relaxed_status.ToString() + - "): " + json); - } - // We know it's an unknown field at this point. If we're at the latest - // version, then it's definitely an unknown field, otherwise we try to - // load again at a later version. - if (message_version == MessageVersion::LatestVersion) { - validation_visitor.onUnknownField("type " + message.GetTypeName() + " reason " + - strict_status.ToString()); - } else if (message_version == MessageVersion::LatestVersionValidate) { - throw ProtobufMessage::UnknownProtoFieldException(absl::StrCat("Unknown field in: ", json)); - } else { - throw ApiBoostRetryException("Unknown field, possibly a rename, try again."); - } - }; - - if (do_boosting) { - tryWithApiBoosting(load_json, message); - } else { - load_json(message, MessageVersion::LatestVersion); + ProtobufMessage::ValidationVisitor& validation_visitor) { + Protobuf::util::JsonParseOptions options; + options.case_insensitive_enum_parsing = true; + // Let's first try and get a clean parse when checking for unknown fields; + // this should be the common case. + options.ignore_unknown_fields = false; + const auto strict_status = Protobuf::util::JsonStringToMessage(json, &message, options); + if (strict_status.ok()) { + // Success, no need to do any extra work. + return; } + // If we fail, we see if we get a clean parse when allowing unknown fields. + // This is essentially a workaround + // for https://github.com/protocolbuffers/protobuf/issues/5967. + // TODO(htuch): clean this up when protobuf supports JSON/YAML unknown field + // detection directly. + options.ignore_unknown_fields = true; + const auto relaxed_status = Protobuf::util::JsonStringToMessage(json, &message, options); + // If we still fail with relaxed unknown field checking, the error has nothing + // to do with unknown fields. + if (!relaxed_status.ok()) { + throw EnvoyException("Unable to parse JSON as proto (" + relaxed_status.ToString() + + "): " + json); + } + // We know it's an unknown field at this point. If we're at the latest + // version, then it's definitely an unknown field, otherwise we try to + // load again at a later version. + validation_visitor.onUnknownField("type " + message.GetTypeName() + " reason " + + strict_status.ToString()); } void MessageUtil::loadFromJson(const std::string& json, ProtobufWkt::Struct& message) { @@ -401,92 +275,42 @@ void MessageUtil::loadFromJson(const std::string& json, ProtobufWkt::Struct& mes } void MessageUtil::loadFromYaml(const std::string& yaml, Protobuf::Message& message, - ProtobufMessage::ValidationVisitor& validation_visitor, - bool do_boosting) { + ProtobufMessage::ValidationVisitor& validation_visitor) { ProtobufWkt::Value value = ValueUtil::loadFromYaml(yaml); if (value.kind_case() == ProtobufWkt::Value::kStructValue || value.kind_case() == ProtobufWkt::Value::kListValue) { - jsonConvertInternal(value, validation_visitor, message, do_boosting); + jsonConvertInternal(value, validation_visitor, message); return; } throw EnvoyException("Unable to convert YAML as JSON: " + yaml); } -void MessageUtil::loadFromYaml(const std::string& yaml, ProtobufWkt::Struct& message) { - // No need to validate if converting to a Struct, since there are no unknown - // fields possible. - return loadFromYaml(yaml, message, ProtobufMessage::getNullValidationVisitor()); -} - void MessageUtil::loadFromFile(const std::string& path, Protobuf::Message& message, ProtobufMessage::ValidationVisitor& validation_visitor, - Api::Api& api, bool do_boosting) { + Api::Api& api) { const std::string contents = api.fileSystem().fileReadToEnd(path); // If the filename ends with .pb, attempt to parse it as a binary proto. if (absl::EndsWithIgnoreCase(path, FileExtensions::get().ProtoBinary)) { // Attempt to parse the binary format. - auto read_proto_binary = [&contents, &validation_visitor](Protobuf::Message& message, - MessageVersion message_version) { - TRY_ASSERT_MAIN_THREAD { - if (message.ParseFromString(contents)) { - MessageUtil::checkForUnexpectedFields( - message, message_version == MessageVersion::LatestVersionValidate - ? ProtobufMessage::getStrictValidationVisitor() - : validation_visitor); - } - return; - } - END_TRY - catch (EnvoyException& ex) { - if (message_version == MessageVersion::LatestVersion || - message_version == MessageVersion::LatestVersionValidate) { - // Failed reading the latest version - pass the same error upwards - throw ex; - } - } - throw ApiBoostRetryException( - "Failed to parse at earlier version, trying again at later version."); - }; - - if (do_boosting) { - // Attempts to read as the previous version and upgrade, and if it fails - // attempts to read as latest version. - tryWithApiBoosting(read_proto_binary, message); - } else { - read_proto_binary(message, MessageVersion::LatestVersion); + if (message.ParseFromString(contents)) { + MessageUtil::checkForUnexpectedFields(message, validation_visitor); } return; } // If the filename ends with .pb_text, attempt to parse it as a text proto. if (absl::EndsWithIgnoreCase(path, FileExtensions::get().ProtoText)) { - auto read_proto_text = [&contents, &path](Protobuf::Message& message, - MessageVersion message_version) { - if (Protobuf::TextFormat::ParseFromString(contents, &message)) { - return; - } - if (message_version == MessageVersion::LatestVersion || - message_version == MessageVersion::LatestVersionValidate) { - throw EnvoyException("Unable to parse file \"" + path + "\" as a text protobuf (type " + - message.GetTypeName() + ")"); - } else { - throw ApiBoostRetryException( - "Failed to parse at earlier version, trying again at later version."); - } - }; - - if (do_boosting) { - tryWithApiBoosting(read_proto_text, message); - } else { - read_proto_text(message, MessageVersion::LatestVersion); + if (Protobuf::TextFormat::ParseFromString(contents, &message)) { + return; } - return; + throw EnvoyException("Unable to parse file \"" + path + "\" as a text protobuf (type " + + message.GetTypeName() + ")"); } if (absl::EndsWithIgnoreCase(path, FileExtensions::get().Yaml) || absl::EndsWithIgnoreCase(path, FileExtensions::get().Yml)) { - loadFromYaml(contents, message, validation_visitor, do_boosting); + loadFromYaml(contents, message, validation_visitor); } else { - loadFromJson(contents, message, validation_visitor, do_boosting); + loadFromJson(contents, message, validation_visitor); } } @@ -545,7 +369,7 @@ class UnexpectedFieldProtoVisitor : public ProtobufMessage::ConstProtoVisitor { // If this field is deprecated, warn or throw an error. if (field.options().deprecated()) { - if (absl::StartsWith(field.name(), Config::VersionUtil::DeprecatedFieldShadowPrefix)) { + if (absl::StartsWith(field.name(), "hidden_envoy_deprecated_")) { // The field was marked as hidden_envoy_deprecated and an error must be thrown, // unless it is part of an explicit test that needs access to the deprecated field // when we enable runtime deprecation override to allow point field overrides for tests. @@ -579,9 +403,6 @@ class UnexpectedFieldProtoVisitor : public ProtobufMessage::ConstProtoVisitor { if (!unknown_fields.empty()) { std::string error_msg; for (int n = 0; n < unknown_fields.field_count(); ++n) { - if (unknown_fields.field(n).number() == ProtobufWellKnown::OriginalTypeFieldNumber) { - continue; - } error_msg += absl::StrCat(n > 0 ? ", " : "", unknown_fields.field(n).number()); } // We use the validation visitor but have hard coded behavior below for deprecated fields. @@ -605,8 +426,7 @@ void MessageUtil::checkForUnexpectedFields(const Protobuf::Message& message, ProtobufMessage::ValidationVisitor& validation_visitor, Runtime::Loader* runtime) { UnexpectedFieldProtoVisitor unexpected_field_visitor(validation_visitor, runtime); - ProtobufMessage::traverseMessage(unexpected_field_visitor, API_RECOVER_ORIGINAL(message), - nullptr); + ProtobufMessage::traverseMessage(unexpected_field_visitor, message, nullptr); } std::string MessageUtil::getYamlStringFromMessage(const Protobuf::Message& message, @@ -673,35 +493,6 @@ std::string MessageUtil::getJsonStringFromMessageOrError(const Protobuf::Message } void MessageUtil::unpackTo(const ProtobufWkt::Any& any_message, Protobuf::Message& message) { - // If we don't have a type URL match, try an earlier version. - const absl::string_view any_full_name = - TypeUtil::typeUrlToDescriptorFullName(any_message.type_url()); - if (any_full_name != message.GetDescriptor()->full_name()) { - const Protobuf::Descriptor* earlier_version_desc = - Config::ApiTypeOracle::getEarlierVersionDescriptor(message.GetDescriptor()->full_name()); - // If the earlier version matches, unpack and upgrade. - if (earlier_version_desc != nullptr && any_full_name == earlier_version_desc->full_name()) { - // Take the Any message but adjust its type URL, since earlier/later versions are wire - // compatible. - ProtobufWkt::Any any_message_with_fixup; - any_message_with_fixup.MergeFrom(any_message); - any_message_with_fixup.set_type_url("type.googleapis.com/" + - message.GetDescriptor()->full_name()); - if (!any_message_with_fixup.UnpackTo(&message)) { - throw EnvoyException(fmt::format("Unable to unpack as {}: {}", - earlier_version_desc->full_name(), - any_message_with_fixup.DebugString())); - } - Config::VersionConverter::annotateWithOriginalType(*earlier_version_desc, message); - // We allow some v2 protos in v3 for historical reasons. - if (v2ProtosAllowedInV3().count(any_full_name) == 0) { - MessageUtil::onVersionUpgradeDeprecation(any_full_name); - } - return; - } - } - // Otherwise, just unpack to the message. Type URL mismatches will be signaled - // by UnpackTo failure. if (!any_message.UnpackTo(&message)) { throw EnvoyException(fmt::format("Unable to unpack as {}: {}", message.GetDescriptor()->full_name(), @@ -893,6 +684,14 @@ void MessageUtil::redact(Protobuf::Message& message) { ::Envoy::redact(&message, /* ancestor_is_sensitive = */ false); } +void MessageUtil::wireCast(const Protobuf::Message& src, Protobuf::Message& dst) { + // This should should generally succeed, but if there are malformed UTF-8 strings in a message, + // this can fail. + if (!dst.ParseFromString(src.SerializeAsString())) { + throw EnvoyException("Unable to deserialize during wireCast()"); + } +} + ProtobufWkt::Value ValueUtil::loadFromYaml(const std::string& yaml) { TRY_ASSERT_MAIN_THREAD { return parseYamlNode(YAML::Load(yaml)); } END_TRY diff --git a/source/common/protobuf/utility.h b/source/common/protobuf/utility.h index 7ccc41394eaf..e8f4a61cd90b 100644 --- a/source/common/protobuf/utility.h +++ b/source/common/protobuf/utility.h @@ -11,7 +11,6 @@ #include "source/common/common/hash.h" #include "source/common/common/stl_helpers.h" #include "source/common/common/utility.h" -#include "source/common/config/version_converter.h" #include "source/common/protobuf/protobuf.h" #include "source/common/singleton/const_singleton.h" @@ -252,16 +251,12 @@ class MessageUtil { static std::size_t hash(const Protobuf::Message& message); static void loadFromJson(const std::string& json, Protobuf::Message& message, - ProtobufMessage::ValidationVisitor& validation_visitor, - bool do_boosting = true); + ProtobufMessage::ValidationVisitor& validation_visitor); static void loadFromJson(const std::string& json, ProtobufWkt::Struct& message); static void loadFromYaml(const std::string& yaml, Protobuf::Message& message, - ProtobufMessage::ValidationVisitor& validation_visitor, - bool do_boosting = true); - static void loadFromYaml(const std::string& yaml, ProtobufWkt::Struct& message); + ProtobufMessage::ValidationVisitor& validation_visitor); static void loadFromFile(const std::string& path, Protobuf::Message& message, - ProtobufMessage::ValidationVisitor& validation_visitor, Api::Api& api, - bool do_boosting = true); + ProtobufMessage::ValidationVisitor& validation_visitor, Api::Api& api); /** * Checks for use of deprecated fields in message and all sub-messages. @@ -292,15 +287,14 @@ class MessageUtil { std::string err; if (!Validate(message, &err)) { - ProtoExceptionUtil::throwProtoValidationException(err, API_RECOVER_ORIGINAL(message)); + ProtoExceptionUtil::throwProtoValidationException(err, message); } } template static void loadFromYamlAndValidate(const std::string& yaml, MessageType& message, - ProtobufMessage::ValidationVisitor& validation_visitor, - bool avoid_boosting = false) { - loadFromYaml(yaml, message, validation_visitor, !avoid_boosting); + ProtobufMessage::ValidationVisitor& validation_visitor) { + loadFromYaml(yaml, message, validation_visitor); validate(message, validation_visitor); } @@ -394,14 +388,6 @@ class MessageUtil { return typed_message; }; - /** - * Invoke when a version upgrade (e.g. v2 -> v3) is detected. This may warn or throw - * depending on where we are in the major version deprecation cycle. - * @param desc description of upgrade to include in warning or exception. - * @param reject should a DeprecatedMajorVersionException be thrown on failure? - */ - static void onVersionUpgradeDeprecation(absl::string_view desc, bool reject = true); - /** * Obtain a string field from a protobuf message dynamically. * @@ -533,6 +519,17 @@ class MessageUtil { * @param message message to redact. */ static void redact(Protobuf::Message& message); + + /** + * Reinterpret a Protobuf message as another Protobuf message by converting to wire format and + * back. This only works for messages that can be effectively duck typed this way, e.g. with a + * subtype relationship modulo field name. + * + * @param src source message. + * @param dst destination message. + * @throw EnvoyException if a conversion error occurs. + */ + static void wireCast(const Protobuf::Message& src, Protobuf::Message& dst); }; class ValueUtil { diff --git a/source/common/protobuf/visitor.cc b/source/common/protobuf/visitor.cc index ed6d0b6857d9..0e22cb2f076a 100644 --- a/source/common/protobuf/visitor.cc +++ b/source/common/protobuf/visitor.cc @@ -3,27 +3,6 @@ namespace Envoy { namespace ProtobufMessage { -void traverseMutableMessage(ProtoVisitor& visitor, Protobuf::Message& message, const void* ctxt) { - visitor.onMessage(message, ctxt); - const Protobuf::Descriptor* descriptor = message.GetDescriptor(); - const Protobuf::Reflection* reflection = message.GetReflection(); - for (int i = 0; i < descriptor->field_count(); ++i) { - const Protobuf::FieldDescriptor* field = descriptor->field(i); - const void* field_ctxt = visitor.onField(message, *field, ctxt); - // If this is a message, recurse to visit fields in the sub-message. - if (field->cpp_type() == Protobuf::FieldDescriptor::CPPTYPE_MESSAGE) { - if (field->is_repeated()) { - const int size = reflection->FieldSize(message, field); - for (int j = 0; j < size; ++j) { - traverseMutableMessage(visitor, *reflection->MutableRepeatedMessage(&message, field, j), - field_ctxt); - } - } else if (reflection->HasField(message, field)) { - traverseMutableMessage(visitor, *reflection->MutableMessage(&message, field), field_ctxt); - } - } - } -} void traverseMessage(ConstProtoVisitor& visitor, const Protobuf::Message& message, const void* ctxt) { visitor.onMessage(message, ctxt); diff --git a/source/common/protobuf/visitor.h b/source/common/protobuf/visitor.h index 129f5e52d474..3c2b782a84e9 100644 --- a/source/common/protobuf/visitor.h +++ b/source/common/protobuf/visitor.h @@ -5,21 +5,6 @@ namespace Envoy { namespace ProtobufMessage { -class ProtoVisitor { -public: - virtual ~ProtoVisitor() = default; - - // Invoked when a field is visited, with the message, field descriptor and context. Returns a new - // context for use when traversing the sub-message in a field. - virtual const void* onField(Protobuf::Message&, const Protobuf::FieldDescriptor&, - const void* ctxt) { - return ctxt; - } - - // Invoked when a message is visited, with the message and a context. - virtual void onMessage(Protobuf::Message&, const void*){}; -}; - class ConstProtoVisitor { public: virtual ~ConstProtoVisitor() = default; @@ -35,7 +20,6 @@ class ConstProtoVisitor { virtual void onMessage(const Protobuf::Message&, const void*){}; }; -void traverseMutableMessage(ProtoVisitor& visitor, Protobuf::Message& message, const void* ctxt); void traverseMessage(ConstProtoVisitor& visitor, const Protobuf::Message& message, const void* ctxt); diff --git a/source/common/protobuf/well_known.h b/source/common/protobuf/well_known.h deleted file mode 100644 index dcd2a9a82b4b..000000000000 --- a/source/common/protobuf/well_known.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include - -namespace Envoy { -namespace ProtobufWellKnown { - -// Used by VersionConverter to track the original type of an upgraded message. -// Magic number in this file derived from top 28bit of SHA256 digest of -// "original type". -constexpr uint32_t OriginalTypeFieldNumber = 183412668; - -} // namespace ProtobufWellKnown -} // namespace Envoy diff --git a/source/common/router/BUILD b/source/common/router/BUILD index 0a5ab46ba76c..ffea1d8aa65e 100644 --- a/source/common/router/BUILD +++ b/source/common/router/BUILD @@ -180,7 +180,6 @@ envoy_cc_library( "//source/common/config:subscription_base_interface", "//source/common/config:subscription_factory_lib", "//source/common/config:utility_lib", - "//source/common/config:version_converter_lib", "//source/common/init:manager_lib", "//source/common/init:target_lib", "//source/common/init:watcher_lib", @@ -230,7 +229,6 @@ envoy_cc_library( "//source/common/config:config_provider_lib", "//source/common/config:resource_name_lib", "//source/common/config:subscription_base_interface", - "//source/common/config:version_converter_lib", "//source/common/config:xds_resource_lib", "//source/common/init:manager_lib", "//source/common/init:watcher_lib", diff --git a/source/common/router/config_impl.cc b/source/common/router/config_impl.cc index 6faba0e21f1b..34d5ed5b361b 100644 --- a/source/common/router/config_impl.cc +++ b/source/common/router/config_impl.cc @@ -218,10 +218,7 @@ CorsPolicyImpl::CorsPolicyImpl(const envoy::config::route::v3::CorsPolicy& confi Runtime::Loader& loader) : config_(config), loader_(loader), allow_methods_(config.allow_methods()), allow_headers_(config.allow_headers()), expose_headers_(config.expose_headers()), - max_age_(config.max_age()), - legacy_enabled_(config.has_hidden_envoy_deprecated_enabled() - ? config.hidden_envoy_deprecated_enabled().value() - : true) { + max_age_(config.max_age()) { for (const auto& string_match : config.allow_origin_string_match()) { allow_origins_.push_back( std::make_unique>( @@ -239,9 +236,6 @@ ShadowPolicyImpl::ShadowPolicyImpl(const RequestMirrorPolicy& config) { if (config.has_runtime_fraction()) { runtime_key_ = config.runtime_fraction().runtime_key(); default_value_ = config.runtime_fraction().default_value(); - } else { - runtime_key_ = config.hidden_envoy_deprecated_runtime_key(); - default_value_.set_numerator(0); } trace_sampled_ = PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, trace_sampled, true); } @@ -377,23 +371,10 @@ RouteEntryImplBase::RouteEntryImplBase(const VirtualHostImpl& vhost, } if (!route.route().request_mirror_policies().empty()) { - if (route.route().has_hidden_envoy_deprecated_request_mirror_policy()) { - // protobuf does not allow `oneof` to contain a field labeled `repeated`, so we do our own - // xor-like check. - // https://github.com/protocolbuffers/protobuf/issues/2592 - // The alternative solution suggested (wrapping the oneof in a repeated message) would still - // break wire compatibility. - // (see https://github.com/envoyproxy/envoy/issues/439#issuecomment-383622723) - throw EnvoyException("Cannot specify both request_mirror_policy and request_mirror_policies"); - } for (const auto& mirror_policy_config : route.route().request_mirror_policies()) { shadow_policies_.push_back(std::make_unique(mirror_policy_config)); } - } else if (route.route().has_hidden_envoy_deprecated_request_mirror_policy()) { - shadow_policies_.push_back(std::make_unique( - route.route().hidden_envoy_deprecated_request_mirror_policy())); } - // If this is a weighted_cluster, we create N internal route entries // (called WeightedClusterEntry), such that each object is a simple // single cluster, pointing back to the parent. Metadata criteria diff --git a/source/common/router/config_impl.h b/source/common/router/config_impl.h index d18eb41969b5..75c3dc70a227 100644 --- a/source/common/router/config_impl.h +++ b/source/common/router/config_impl.h @@ -164,7 +164,7 @@ class CorsPolicyImpl : public CorsPolicy { return loader_.snapshot().featureEnabled(filter_enabled.runtime_key(), filter_enabled.default_value()); } - return legacy_enabled_; + return true; }; bool shadowEnabled() const override { if (config_.has_shadow_enabled()) { @@ -184,7 +184,6 @@ class CorsPolicyImpl : public CorsPolicy { const std::string expose_headers_; const std::string max_age_; absl::optional allow_credentials_{}; - const bool legacy_enabled_; }; class ConfigImpl; diff --git a/source/common/router/config_utility.cc b/source/common/router/config_utility.cc index 0c618ffd70cf..c56e4d651c41 100644 --- a/source/common/router/config_utility.cc +++ b/source/common/router/config_utility.cc @@ -27,14 +27,7 @@ maybeCreateStringMatcher(const envoy::config::route::v3::QueryParameterMatcher& } case envoy::config::route::v3::QueryParameterMatcher::QueryParameterMatchSpecifierCase:: QUERY_PARAMETER_MATCH_SPECIFIER_NOT_SET: { - if (config.hidden_envoy_deprecated_value().empty()) { - // Present match. - return absl::nullopt; - } - - envoy::type::matcher::v3::StringMatcher matcher_config; - matcher_config.set_exact(config.hidden_envoy_deprecated_value()); - return Matchers::StringMatcherImpl(matcher_config); + return absl::nullopt; } } diff --git a/source/common/router/rds_impl.cc b/source/common/router/rds_impl.cc index b77905327580..049e0f752fde 100644 --- a/source/common/router/rds_impl.cc +++ b/source/common/router/rds_impl.cc @@ -14,7 +14,6 @@ #include "source/common/common/fmt.h" #include "source/common/config/api_version.h" #include "source/common/config/utility.h" -#include "source/common/config/version_converter.h" #include "source/common/http/header_map_impl.h" #include "source/common/protobuf/utility.h" #include "source/common/router/config_impl.h" @@ -74,7 +73,6 @@ RdsRouteConfigSubscription::RdsRouteConfigSubscription( const std::string& stat_prefix, const OptionalHttpFilters& optional_http_filters, Envoy::Router::RouteConfigProviderManagerImpl& route_config_provider_manager) : Envoy::Config::SubscriptionBase( - rds.config_source().resource_api_version(), factory_context.messageValidationContext().dynamicValidationVisitor(), "name"), route_config_name_(rds.route_config_name()), scope_(factory_context.scope().createScope(stat_prefix + "rds." + route_config_name_ + ".")), @@ -140,11 +138,7 @@ void RdsRouteConfigSubscription::onConfigUpdate( route_config_name_, config_update_info_->configHash()); maybeCreateInitManager(version_info, noop_init_manager, resume_rds); vhds_subscription_ = std::make_unique( - config_update_info_, factory_context_, stat_prefix_, route_config_provider_opt_, - config_update_info_->protobufConfiguration() - .vhds() - .config_source() - .resource_api_version()); + config_update_info_, factory_context_, stat_prefix_, route_config_provider_opt_); vhds_subscription_->registerInitTargetWithInitManager( noop_init_manager == nullptr ? local_init_manager_ : *noop_init_manager); } @@ -399,7 +393,7 @@ RouteConfigProviderManagerImpl::dumpRouteConfigs( auto* dynamic_config = config_dump->mutable_dynamic_route_configs()->Add(); dynamic_config->set_version_info(subscription->routeConfigUpdate()->configVersion()); dynamic_config->mutable_route_config()->PackFrom( - API_RECOVER_ORIGINAL(subscription->routeConfigUpdate()->protobufConfiguration())); + subscription->routeConfigUpdate()->protobufConfiguration()); TimestampUtil::systemClockToTimestamp(subscription->routeConfigUpdate()->lastUpdated(), *dynamic_config->mutable_last_updated()); } @@ -411,8 +405,7 @@ RouteConfigProviderManagerImpl::dumpRouteConfigs( continue; } auto* static_config = config_dump->mutable_static_route_configs()->Add(); - static_config->mutable_route_config()->PackFrom( - API_RECOVER_ORIGINAL(provider->configInfo().value().config_)); + static_config->mutable_route_config()->PackFrom(provider->configInfo().value().config_); TimestampUtil::systemClockToTimestamp(provider->lastUpdated(), *static_config->mutable_last_updated()); } diff --git a/source/common/router/scoped_rds.cc b/source/common/router/scoped_rds.cc index 90133db6992d..eac4557b0ceb 100644 --- a/source/common/router/scoped_rds.cc +++ b/source/common/router/scoped_rds.cc @@ -14,7 +14,6 @@ #include "source/common/common/utility.h" #include "source/common/config/api_version.h" #include "source/common/config/resource_name.h" -#include "source/common/config/version_converter.h" #include "source/common/config/xds_resource.h" #include "source/common/init/manager_impl.h" #include "source/common/init/watcher_impl.h" @@ -108,7 +107,6 @@ ScopedRdsConfigSubscription::ScopedRdsConfigSubscription( : DeltaConfigSubscriptionInstance("SRDS", manager_identifier, config_provider_manager, factory_context), Envoy::Config::SubscriptionBase( - scoped_rds.scoped_rds_config_source().resource_api_version(), factory_context.messageValidationContext().dynamicValidationVisitor(), "name"), factory_context_(factory_context), name_(name), scope_(factory_context.scope().createScope(stat_prefix + "scoped_rds." + name + ".")), @@ -345,13 +343,12 @@ void ScopedRdsConfigSubscription::onConfigUpdate( // server. std::unique_ptr srds_initialization_continuation; ASSERT(localInitManager().state() > Init::Manager::State::Uninitialized); - const auto type_urls = - Envoy::Config::getAllVersionTypeUrls(); + const auto type_url = Envoy::Config::getTypeUrl(); // Pause RDS to not send a burst of RDS requests until we start all the new subscriptions. // In the case that localInitManager is uninitialized, RDS is already paused // either by Server init or LDS init. if (factory_context_.clusterManager().adsMux()) { - resume_rds = factory_context_.clusterManager().adsMux()->pause(type_urls); + resume_rds = factory_context_.clusterManager().adsMux()->pause(type_url); } // if local init manager is initialized, the parent init manager may have gone away. if (localInitManager().state() == Init::Manager::State::Initialized) { @@ -538,8 +535,7 @@ ScopedRoutesConfigProviderManager::dumpConfigs(const Matchers::StringMatcher& na if (!name_matcher.match(it.second->configProto().name())) { continue; } - dynamic_config->mutable_scoped_route_configs()->Add()->PackFrom( - API_RECOVER_ORIGINAL(it.second->configProto())); + dynamic_config->mutable_scoped_route_configs()->Add()->PackFrom(it.second->configProto()); } TimestampUtil::systemClockToTimestamp(subscription->lastUpdated(), *dynamic_config->mutable_last_updated()); @@ -556,8 +552,7 @@ ScopedRoutesConfigProviderManager::dumpConfigs(const Matchers::StringMatcher& na if (!name_matcher.match(config_proto->name())) { continue; } - inline_config->mutable_scoped_route_configs()->Add()->PackFrom( - API_RECOVER_ORIGINAL(*config_proto)); + inline_config->mutable_scoped_route_configs()->Add()->PackFrom(*config_proto); } TimestampUtil::systemClockToTimestamp(provider->lastUpdated(), *inline_config->mutable_last_updated()); diff --git a/source/common/router/vhds.cc b/source/common/router/vhds.cc index b943391d511f..324d952c42b6 100644 --- a/source/common/router/vhds.cc +++ b/source/common/router/vhds.cc @@ -23,10 +23,8 @@ namespace Router { VhdsSubscription::VhdsSubscription(RouteConfigUpdatePtr& config_update_info, Server::Configuration::ServerFactoryContext& factory_context, const std::string& stat_prefix, - absl::optional& route_config_provider_opt, - envoy::config::core::v3::ApiVersion resource_api_version) + absl::optional& route_config_provider_opt) : Envoy::Config::SubscriptionBase( - resource_api_version, factory_context.messageValidationContext().dynamicValidationVisitor(), "name"), config_update_info_(config_update_info), scope_(factory_context.scope().createScope(stat_prefix + "vhds." + diff --git a/source/common/router/vhds.h b/source/common/router/vhds.h index 099b00ff322d..e1d36da175af 100644 --- a/source/common/router/vhds.h +++ b/source/common/router/vhds.h @@ -42,9 +42,7 @@ class VhdsSubscription : Envoy::Config::SubscriptionBase& route_config_providers, - const envoy::config::core::v3::ApiVersion resource_api_version = - envoy::config::core::v3::ApiVersion::AUTO); + absl::optional& route_config_providers); ~VhdsSubscription() override { init_target_.ready(); } void registerInitTargetWithInitManager(Init::Manager& m) { m.add(init_target_); } diff --git a/source/common/runtime/runtime_impl.cc b/source/common/runtime/runtime_impl.cc index 85a7fc91ecec..bf5ad44ffe5e 100644 --- a/source/common/runtime/runtime_impl.cc +++ b/source/common/runtime/runtime_impl.cc @@ -453,8 +453,8 @@ void LoaderImpl::onRtdsReady() { RtdsSubscription::RtdsSubscription( LoaderImpl& parent, const envoy::config::bootstrap::v3::RuntimeLayer::RtdsLayer& rtds_layer, Stats::Store& store, ProtobufMessage::ValidationVisitor& validation_visitor) - : Envoy::Config::SubscriptionBase( - rtds_layer.rtds_config().resource_api_version(), validation_visitor, "name"), + : Envoy::Config::SubscriptionBase(validation_visitor, + "name"), parent_(parent), config_source_(rtds_layer.rtds_config()), store_(store), stats_scope_(store_.createScope("runtime")), resource_name_(rtds_layer.name()), init_target_("RTDS " + resource_name_, [this]() { start(); }) {} diff --git a/source/common/secret/BUILD b/source/common/secret/BUILD index acef30c90ef7..b7b25aedbe5b 100644 --- a/source/common/secret/BUILD +++ b/source/common/secret/BUILD @@ -19,7 +19,6 @@ envoy_cc_library( "//envoy/server:transport_socket_config_interface", "//source/common/common:assert_lib", "//source/common/common:minimal_logger_lib", - "//source/common/config:version_converter_lib", "//source/common/protobuf:utility_lib", "@envoy_api//envoy/admin/v3:pkg_cc_proto", "@envoy_api//envoy/config/core/v3:pkg_cc_proto", diff --git a/source/common/secret/sds_api.cc b/source/common/secret/sds_api.cc index 558798eeb74e..253391f44940 100644 --- a/source/common/secret/sds_api.cc +++ b/source/common/secret/sds_api.cc @@ -20,7 +20,7 @@ SdsApi::SdsApi(envoy::config::core::v3::ConfigSource sds_config, absl::string_vi ProtobufMessage::ValidationVisitor& validation_visitor, Stats::Store& stats, std::function destructor_cb, Event::Dispatcher& dispatcher, Api::Api& api) : Envoy::Config::SubscriptionBase( - sds_config.resource_api_version(), validation_visitor, "name"), + validation_visitor, "name"), init_target_(fmt::format("SdsApi {}", sds_config_name), [this] { initialize(); }), dispatcher_(dispatcher), api_(api), scope_(stats.createScope(absl::StrCat("sds.", sds_config_name, "."))), diff --git a/source/common/secret/secret_manager_impl.cc b/source/common/secret/secret_manager_impl.cc index 5238ff77ae9e..17f356346144 100644 --- a/source/common/secret/secret_manager_impl.cc +++ b/source/common/secret/secret_manager_impl.cc @@ -8,7 +8,6 @@ #include "source/common/common/assert.h" #include "source/common/common/logger.h" -#include "source/common/config/version_converter.h" #include "source/common/protobuf/utility.h" #include "source/common/secret/sds_api.h" #include "source/common/secret/secret_provider_impl.h" @@ -155,11 +154,6 @@ GenericSecretConfigProviderSharedPtr SecretManagerImpl::findOrCreateGenericSecre ProtobufTypes::MessagePtr SecretManagerImpl::dumpSecretConfigs(const Matchers::StringMatcher& name_matcher) { - // TODO(htuch): unlike other config providers, we're recreating the original - // Secrets below. This makes it hard to support API_RECOVER_ORIGINAL()-style - // recovery of the original config message. As a result, for now we're - // providing v3 config dumps. For Secrets, the main deprecation of interest - // are the use of v2 Struct config() and verify_subject_alt_name. auto config_dump = std::make_unique(); // Handle static tls key/cert providers. for (const auto& cert_iter : static_tls_certificate_providers_) { diff --git a/source/common/tcp_proxy/tcp_proxy.cc b/source/common/tcp_proxy/tcp_proxy.cc index 8e368db82b32..575005feabdf 100644 --- a/source/common/tcp_proxy/tcp_proxy.cc +++ b/source/common/tcp_proxy/tcp_proxy.cc @@ -138,13 +138,6 @@ Config::Config(const envoy::extensions::filters::network::tcp_proxy::v3::TcpProx return drain_manager; }); - if (config.has_hidden_envoy_deprecated_deprecated_v1()) { - for (const envoy::extensions::filters::network::tcp_proxy::v3::TcpProxy::DeprecatedV1::TCPRoute& - route_desc : config.hidden_envoy_deprecated_deprecated_v1().routes()) { - routes_.emplace_back(std::make_shared(*this, route_desc)); - } - } - if (!config.cluster().empty()) { envoy::extensions::filters::network::tcp_proxy::v3::TcpProxy::DeprecatedV1::TCPRoute default_route; diff --git a/source/common/upstream/BUILD b/source/common/upstream/BUILD index 7d6858495114..3d40cb3ef9d0 100644 --- a/source/common/upstream/BUILD +++ b/source/common/upstream/BUILD @@ -70,7 +70,6 @@ envoy_cc_library( "//source/common/config:grpc_mux_lib", "//source/common/config:subscription_factory_lib", "//source/common/config:utility_lib", - "//source/common/config:version_converter_lib", "//source/common/config:xds_resource_lib", "//source/common/grpc:async_client_manager_lib", "//source/common/http:async_client_lib", @@ -236,7 +235,6 @@ envoy_cc_library( "//envoy/stats:stats_macros", "//envoy/upstream:cluster_manager_interface", "//source/common/common:minimal_logger_lib", - "//source/common/config:version_converter_lib", "//source/common/grpc:async_client_lib", "@envoy_api//envoy/service/load_stats/v3:pkg_cc_proto", ], @@ -271,7 +269,6 @@ envoy_cc_library( "//source/common/common:backoff_lib", "//source/common/common:minimal_logger_lib", "//source/common/config:utility_lib", - "//source/common/config:version_converter_lib", "//source/common/grpc:async_client_lib", "//source/common/network:resolver_lib", "//source/common/protobuf:message_validator_lib", @@ -425,7 +422,6 @@ envoy_cc_library( "//source/common/config:subscription_base_interface", "//source/common/config:subscription_factory_lib", "//source/common/config:utility_lib", - "//source/common/config:version_converter_lib", "//source/common/network:address_lib", "//source/common/network:resolver_lib", "//source/common/network:utility_lib", diff --git a/source/common/upstream/cds_api_helper.cc b/source/common/upstream/cds_api_helper.cc index c75b1526d2f0..ddfb2f6a78d0 100644 --- a/source/common/upstream/cds_api_helper.cc +++ b/source/common/upstream/cds_api_helper.cc @@ -19,9 +19,8 @@ CdsApiHelper::onConfigUpdate(const std::vector& adde const std::string& system_version_info) { Config::ScopedResume maybe_resume_eds; if (cm_.adsMux()) { - const auto type_urls = - Config::getAllVersionTypeUrls(); - maybe_resume_eds = cm_.adsMux()->pause(type_urls); + const auto type_url = Config::getTypeUrl(); + maybe_resume_eds = cm_.adsMux()->pause(type_url); } ENVOY_LOG(info, "{}: add {} cluster(s), remove {} cluster(s)", name_, added_resources.size(), diff --git a/source/common/upstream/cds_api_impl.cc b/source/common/upstream/cds_api_impl.cc index 3c9d8ab46b6d..64c2c5a25cce 100644 --- a/source/common/upstream/cds_api_impl.cc +++ b/source/common/upstream/cds_api_impl.cc @@ -20,8 +20,8 @@ CdsApiImpl::CdsApiImpl(const envoy::config::core::v3::ConfigSource& cds_config, const xds::core::v3::ResourceLocator* cds_resources_locator, ClusterManager& cm, Stats::Scope& scope, ProtobufMessage::ValidationVisitor& validation_visitor) - : Envoy::Config::SubscriptionBase( - cds_config.resource_api_version(), validation_visitor, "name"), + : Envoy::Config::SubscriptionBase(validation_visitor, + "name"), helper_(cm, "cds"), cm_(cm), scope_(scope.createScope("cluster_manager.cds.")) { const auto resource_name = getResourceName(); if (cds_resources_locator == nullptr) { diff --git a/source/common/upstream/cluster_manager_impl.cc b/source/common/upstream/cluster_manager_impl.cc index f0a1d07cc052..cd3be72d7d5d 100644 --- a/source/common/upstream/cluster_manager_impl.cc +++ b/source/common/upstream/cluster_manager_impl.cc @@ -23,7 +23,6 @@ #include "source/common/common/utility.h" #include "source/common/config/new_grpc_mux_impl.h" #include "source/common/config/utility.h" -#include "source/common/config/version_converter.h" #include "source/common/config/xds_resource.h" #include "source/common/grpc/async_client_manager_impl.h" #include "source/common/http/async_client_impl.h" @@ -185,9 +184,9 @@ void ClusterManagerInitHelper::maybeFinishInitialize() { // avoid double pause ClusterLoadAssignment. Config::ScopedResume maybe_resume_eds; if (cm_.adsMux()) { - const auto type_urls = - Config::getAllVersionTypeUrls(); - maybe_resume_eds = cm_.adsMux()->pause(type_urls); + const auto type_url = + Config::getTypeUrl(); + maybe_resume_eds = cm_.adsMux()->pause(type_url); } initializeSecondaryClusters(); } @@ -338,22 +337,18 @@ ClusterManagerImpl::ClusterManagerImpl( if (dyn_resources.has_ads_config()) { if (dyn_resources.ads_config().api_type() == envoy::config::core::v3::ApiConfigSource::DELTA_GRPC) { + Config::Utility::checkTransportVersion(dyn_resources.ads_config()); ads_mux_ = std::make_shared( Config::Utility::factoryForGrpcApiConfigSource(*async_client_manager_, dyn_resources.ads_config(), stats, false) ->createUncachedRawAsyncClient(), main_thread_dispatcher, *Protobuf::DescriptorPool::generated_pool()->FindMethodByName( - Config::Utility::getAndCheckTransportVersion(dyn_resources.ads_config()) == - envoy::config::core::v3::ApiVersion::V3 - // TODO(htuch): consolidate with type_to_endpoint.cc, once we sort out the future - // direction of that module re: https://github.com/envoyproxy/envoy/issues/10650. - ? "envoy.service.discovery.v3.AggregatedDiscoveryService.DeltaAggregatedResources" - : "envoy.service.discovery.v2.AggregatedDiscoveryService." - "DeltaAggregatedResources"), - Config::Utility::getAndCheckTransportVersion(dyn_resources.ads_config()), random_, stats_, + "envoy.service.discovery.v3.AggregatedDiscoveryService.DeltaAggregatedResources"), + random_, stats_, Envoy::Config::Utility::parseRateLimitSettings(dyn_resources.ads_config()), local_info); } else { + Config::Utility::checkTransportVersion(dyn_resources.ads_config()); ads_mux_ = std::make_shared( local_info, Config::Utility::factoryForGrpcApiConfigSource(*async_client_manager_, @@ -361,15 +356,8 @@ ClusterManagerImpl::ClusterManagerImpl( ->createUncachedRawAsyncClient(), main_thread_dispatcher, *Protobuf::DescriptorPool::generated_pool()->FindMethodByName( - Config::Utility::getAndCheckTransportVersion(dyn_resources.ads_config()) == - envoy::config::core::v3::ApiVersion::V3 - // TODO(htuch): consolidate with type_to_endpoint.cc, once we sort out the future - // direction of that module re: https://github.com/envoyproxy/envoy/issues/10650. - ? "envoy.service.discovery.v3.AggregatedDiscoveryService." - "StreamAggregatedResources" - : "envoy.service.discovery.v2.AggregatedDiscoveryService." - "StreamAggregatedResources"), - Config::Utility::getAndCheckTransportVersion(dyn_resources.ads_config()), random_, stats_, + "envoy.service.discovery.v3.AggregatedDiscoveryService.StreamAggregatedResources"), + random_, stats_, Envoy::Config::Utility::parseRateLimitSettings(dyn_resources.ads_config()), bootstrap.dynamic_resources().ads_config().set_node_on_first_message_only()); } @@ -444,12 +432,13 @@ void ClusterManagerImpl::initializeSecondaryClusters( if (cm_config.has_load_stats_config()) { const auto& load_stats_config = cm_config.load_stats_config(); + Config::Utility::checkTransportVersion(load_stats_config); load_stats_reporter_ = std::make_unique( local_info_, *this, stats_, Config::Utility::factoryForGrpcApiConfigSource(*async_client_manager_, load_stats_config, stats_, false) ->createUncachedRawAsyncClient(), - Config::Utility::getAndCheckTransportVersion(load_stats_config), dispatcher_); + dispatcher_); } } @@ -859,10 +848,10 @@ void ClusterManagerImpl::updateClusterCounts() { const bool all_clusters_initialized = init_helper_.state() == ClusterManagerInitHelper::State::AllClustersInitialized; if (all_clusters_initialized && ads_mux_) { - const auto type_urls = Config::getAllVersionTypeUrls(); + const auto type_url = Config::getTypeUrl(); const uint64_t previous_warming = cm_stats_.warming_clusters_.value(); if (previous_warming == 0 && !warming_clusters_.empty()) { - resume_cds_ = ads_mux_->pause(type_urls); + resume_cds_ = ads_mux_->pause(type_url); } else if (previous_warming > 0 && warming_clusters_.empty()) { ASSERT(resume_cds_ != nullptr); resume_cds_.reset(); @@ -1108,13 +1097,13 @@ ClusterManagerImpl::dumpClusterConfigs(const Matchers::StringMatcher& name_match } if (!cluster.added_via_api_) { auto& static_cluster = *config_dump->mutable_static_clusters()->Add(); - static_cluster.mutable_cluster()->PackFrom(API_RECOVER_ORIGINAL(cluster.cluster_config_)); + static_cluster.mutable_cluster()->PackFrom(cluster.cluster_config_); TimestampUtil::systemClockToTimestamp(cluster.last_updated_, *(static_cluster.mutable_last_updated())); } else { auto& dynamic_cluster = *config_dump->mutable_dynamic_active_clusters()->Add(); dynamic_cluster.set_version_info(cluster.version_info_); - dynamic_cluster.mutable_cluster()->PackFrom(API_RECOVER_ORIGINAL(cluster.cluster_config_)); + dynamic_cluster.mutable_cluster()->PackFrom(cluster.cluster_config_); TimestampUtil::systemClockToTimestamp(cluster.last_updated_, *(dynamic_cluster.mutable_last_updated())); } @@ -1127,7 +1116,7 @@ ClusterManagerImpl::dumpClusterConfigs(const Matchers::StringMatcher& name_match } auto& dynamic_cluster = *config_dump->mutable_dynamic_warming_clusters()->Add(); dynamic_cluster.set_version_info(cluster.version_info_); - dynamic_cluster.mutable_cluster()->PackFrom(API_RECOVER_ORIGINAL(cluster.cluster_config_)); + dynamic_cluster.mutable_cluster()->PackFrom(cluster.cluster_config_); TimestampUtil::systemClockToTimestamp(cluster.last_updated_, *(dynamic_cluster.mutable_last_updated())); } diff --git a/source/common/upstream/eds.cc b/source/common/upstream/eds.cc index 11d0b3923990..b25bdc07e582 100644 --- a/source/common/upstream/eds.cc +++ b/source/common/upstream/eds.cc @@ -9,7 +9,6 @@ #include "source/common/common/utility.h" #include "source/common/config/api_version.h" #include "source/common/config/decoded_resource_impl.h" -#include "source/common/config/version_converter.h" namespace Envoy { namespace Upstream { @@ -21,7 +20,6 @@ EdsClusterImpl::EdsClusterImpl( : BaseDynamicClusterImpl(cluster, runtime, factory_context, std::move(stats_scope), added_via_api, factory_context.dispatcher().timeSource()), Envoy::Config::SubscriptionBase( - cluster.eds_cluster_config().eds_config().resource_api_version(), factory_context.messageValidationVisitor(), "cluster_name"), local_info_(factory_context.localInfo()), cluster_name_(cluster.eds_cluster_config().service_name().empty() @@ -132,9 +130,6 @@ void EdsClusterImpl::onConfigUpdate(const std::vectorenabled()) { diff --git a/source/common/upstream/health_discovery_service.cc b/source/common/upstream/health_discovery_service.cc index 96f3c07580ac..9fad649f3e15 100644 --- a/source/common/upstream/health_discovery_service.cc +++ b/source/common/upstream/health_discovery_service.cc @@ -9,7 +9,6 @@ #include "envoy/service/health/v3/hds.pb.validate.h" #include "envoy/stats/scope.h" -#include "source/common/config/version_converter.h" #include "source/common/protobuf/message_validator_impl.h" #include "source/common/protobuf/protobuf.h" #include "source/common/protobuf/utility.h" @@ -29,7 +28,6 @@ static constexpr uint32_t RetryInitialDelayMilliseconds = 1000; static constexpr uint32_t RetryMaxDelayMilliseconds = 30000; HdsDelegate::HdsDelegate(Stats::Scope& scope, Grpc::RawAsyncClientPtr async_client, - envoy::config::core::v3::ApiVersion transport_api_version, Event::Dispatcher& dispatcher, Runtime::Loader& runtime, Envoy::Stats::Store& stats, Ssl::ContextManager& ssl_context_manager, ClusterInfoFactory& info_factory, @@ -39,13 +37,10 @@ HdsDelegate::HdsDelegate(Stats::Scope& scope, Grpc::RawAsyncClientPtr async_clie ProtobufMessage::ValidationVisitor& validation_visitor, Api::Api& api, const Server::Options& options) : stats_{ALL_HDS_STATS(POOL_COUNTER_PREFIX(scope, "hds_delegate."))}, - service_method_(Grpc::VersionedMethods( - "envoy.service.health.v3.HealthDiscoveryService.StreamHealthCheck", - "envoy.service.discovery.v2.HealthDiscoveryService.StreamHealthCheck") - .getMethodDescriptorForVersion(transport_api_version)), - async_client_(std::move(async_client)), transport_api_version_(transport_api_version), - dispatcher_(dispatcher), runtime_(runtime), store_stats_(stats), - ssl_context_manager_(ssl_context_manager), info_factory_(info_factory), + service_method_(*Protobuf::DescriptorPool::generated_pool()->FindMethodByName( + "envoy.service.health.v3.HealthDiscoveryService.StreamHealthCheck")), + async_client_(std::move(async_client)), dispatcher_(dispatcher), runtime_(runtime), + store_stats_(stats), ssl_context_manager_(ssl_context_manager), info_factory_(info_factory), access_log_manager_(access_log_manager), cm_(cm), local_info_(local_info), admin_(admin), singleton_manager_(singleton_manager), tls_(tls), specifier_hash_(0), validation_visitor_(validation_visitor), api_(api), options_(options) { @@ -87,8 +82,6 @@ void HdsDelegate::establishNewStream() { return; } - Config::VersionConverter::prepareMessageForGrpcWire(health_check_request_, - transport_api_version_); ENVOY_LOG(debug, "Sending HealthCheckRequest {} ", health_check_request_.DebugString()); stream_->sendMessage(health_check_request_, false); stats_.responses_.inc(); diff --git a/source/common/upstream/health_discovery_service.h b/source/common/upstream/health_discovery_service.h index dd9b37722ee4..342e0e56ca27 100644 --- a/source/common/upstream/health_discovery_service.h +++ b/source/common/upstream/health_discovery_service.h @@ -148,7 +148,6 @@ class HdsDelegate : Grpc::AsyncStreamCallbacks { public: HdsDelegate(Stats::Scope& scope, Grpc::RawAsyncClientPtr async_client, - envoy::config::core::v3::ApiVersion transport_api_version, Event::Dispatcher& dispatcher, Runtime::Loader& runtime, Envoy::Stats::Store& stats, Ssl::ContextManager& ssl_context_manager, ClusterInfoFactory& info_factory, AccessLog::AccessLogManager& access_log_manager, ClusterManager& cm, @@ -188,7 +187,6 @@ class HdsDelegate : Grpc::AsyncStreamCallbacks async_client_; - const envoy::config::core::v3::ApiVersion transport_api_version_; Grpc::AsyncStream stream_{}; Event::Dispatcher& dispatcher_; diff --git a/source/common/upstream/load_stats_reporter.cc b/source/common/upstream/load_stats_reporter.cc index 3b3f1bd06d08..1121ecc6247c 100644 --- a/source/common/upstream/load_stats_reporter.cc +++ b/source/common/upstream/load_stats_reporter.cc @@ -3,7 +3,6 @@ #include "envoy/service/load_stats/v3/lrs.pb.h" #include "envoy/stats/scope.h" -#include "source/common/config/version_converter.h" #include "source/common/protobuf/protobuf.h" namespace Envoy { @@ -12,15 +11,12 @@ namespace Upstream { LoadStatsReporter::LoadStatsReporter(const LocalInfo::LocalInfo& local_info, ClusterManager& cluster_manager, Stats::Scope& scope, Grpc::RawAsyncClientPtr async_client, - envoy::config::core::v3::ApiVersion transport_api_version, Event::Dispatcher& dispatcher) : cm_(cluster_manager), stats_{ALL_LOAD_REPORTER_STATS( POOL_COUNTER_PREFIX(scope, "load_reporter."))}, - async_client_(std::move(async_client)), transport_api_version_(transport_api_version), - service_method_( - Grpc::VersionedMethods("envoy.service.load_stats.v3.LoadReportingService.StreamLoadStats", - "envoy.service.load_stats.v2.LoadReportingService.StreamLoadStats") - .getMethodDescriptorForVersion(transport_api_version)), + async_client_(std::move(async_client)), + service_method_(*Protobuf::DescriptorPool::generated_pool()->FindMethodByName( + "envoy.service.load_stats.v3.LoadReportingService.StreamLoadStats")), time_source_(dispatcher.timeSource()) { request_.mutable_node()->MergeFrom(local_info.node()); request_.mutable_node()->add_client_features("envoy.lrs.supports_send_all_clusters"); @@ -111,7 +107,6 @@ void LoadStatsReporter::sendLoadStatsRequest() { clusters_[cluster_name] = now; } - Config::VersionConverter::prepareMessageForGrpcWire(request_, transport_api_version_); ENVOY_LOG(trace, "Sending LoadStatsRequest: {}", request_.DebugString()); stream_->sendMessage(request_, false); stats_.responses_.inc(); diff --git a/source/common/upstream/load_stats_reporter.h b/source/common/upstream/load_stats_reporter.h index 97302ad1223f..4ab1c9e4a8a2 100644 --- a/source/common/upstream/load_stats_reporter.h +++ b/source/common/upstream/load_stats_reporter.h @@ -34,7 +34,6 @@ class LoadStatsReporter public: LoadStatsReporter(const LocalInfo::LocalInfo& local_info, ClusterManager& cluster_manager, Stats::Scope& scope, Grpc::RawAsyncClientPtr async_client, - envoy::config::core::v3::ApiVersion transport_api_version, Event::Dispatcher& dispatcher); // Grpc::AsyncStreamCallbacks @@ -60,7 +59,6 @@ class LoadStatsReporter Grpc::AsyncClient async_client_; - const envoy::config::core::v3::ApiVersion transport_api_version_; Grpc::AsyncStream stream_{}; const Protobuf::MethodDescriptor& service_method_; Event::TimerPtr retry_timer_; diff --git a/source/extensions/access_loggers/common/grpc_access_logger.h b/source/extensions/access_loggers/common/grpc_access_logger.h index 2e008a9c1522..416d19164662 100644 --- a/source/extensions/access_loggers/common/grpc_access_logger.h +++ b/source/extensions/access_loggers/common/grpc_access_logger.h @@ -68,22 +68,16 @@ template class GrpcAccessLogge * @param config supplies the configuration for the logger. * @return GrpcAccessLoggerSharedPtr ready for logging requests. */ - virtual typename GrpcAccessLogger::SharedPtr - getOrCreateLogger(const ConfigProto& config, - envoy::config::core::v3::ApiVersion transport_version, - GrpcAccessLoggerType logger_type, Stats::Scope& scope) PURE; + virtual typename GrpcAccessLogger::SharedPtr getOrCreateLogger(const ConfigProto& config, + GrpcAccessLoggerType logger_type, + Stats::Scope& scope) PURE; }; template class GrpcAccessLogClient { public: GrpcAccessLogClient(const Grpc::RawAsyncClientSharedPtr& client, const Protobuf::MethodDescriptor& service_method) - : GrpcAccessLogClient(client, service_method, absl::nullopt) {} - GrpcAccessLogClient(const Grpc::RawAsyncClientSharedPtr& client, - const Protobuf::MethodDescriptor& service_method, - envoy::config::core::v3::ApiVersion transport_api_version) - : client_(client), service_method_(service_method), - transport_api_version_(transport_api_version) {} + : client_(client), service_method_(service_method) {} public: struct LocalStream : public Grpc::AsyncStreamCallbacks { @@ -123,11 +117,7 @@ template class GrpcAccessLogClient { if (stream_->stream_->isAboveWriteBufferHighWatermark()) { return false; } - if (transport_api_version_.has_value()) { - stream_->stream_->sendMessage(request, transport_api_version_.value(), false); - } else { - stream_->stream_->sendMessage(request, false); - } + stream_->stream_->sendMessage(request, false); } else { // Clear out the stream data due to stream creation failure. stream_.reset(); @@ -138,7 +128,6 @@ template class GrpcAccessLogClient { Grpc::AsyncClient client_; std::unique_ptr stream_; const Protobuf::MethodDescriptor& service_method_; - const absl::optional transport_api_version_; }; } // namespace Detail @@ -173,16 +162,7 @@ class GrpcAccessLogger : public Detail::GrpcAccessLoggerenableTimer(buffer_flush_interval_msec_); @@ -278,10 +258,9 @@ class GrpcAccessLoggerCache : public Singleton::Instance, }); } - typename GrpcAccessLogger::SharedPtr - getOrCreateLogger(const ConfigProto& config, - envoy::config::core::v3::ApiVersion transport_version, - GrpcAccessLoggerType logger_type, Stats::Scope& scope) override { + typename GrpcAccessLogger::SharedPtr getOrCreateLogger(const ConfigProto& config, + GrpcAccessLoggerType logger_type, + Stats::Scope& scope) override { // TODO(euroelessar): Consider cleaning up loggers. auto& cache = tls_slot_->getTyped(); const auto cache_key = std::make_pair(MessageUtil::hash(config), logger_type); @@ -290,7 +269,7 @@ class GrpcAccessLoggerCache : public Singleton::Instance, return it->second; } const auto logger = createLogger( - config, transport_version, + config, async_client_manager_.factoryForGrpcService(config.grpc_service(), scope_, false) ->createUncachedRawAsyncClient(), std::chrono::milliseconds(PROTOBUF_GET_MS_OR_DEFAULT(config, buffer_flush_interval, 1000)), @@ -316,8 +295,7 @@ class GrpcAccessLoggerCache : public Singleton::Instance, // Create the specific logger type for this cache. virtual typename GrpcAccessLogger::SharedPtr - createLogger(const ConfigProto& config, envoy::config::core::v3::ApiVersion transport_version, - const Grpc::RawAsyncClientSharedPtr& client, + createLogger(const ConfigProto& config, const Grpc::RawAsyncClientSharedPtr& client, std::chrono::milliseconds buffer_flush_interval_msec, uint64_t max_buffer_size_bytes, Event::Dispatcher& dispatcher, Stats::Scope& scope) PURE; diff --git a/source/extensions/access_loggers/grpc/grpc_access_log_impl.cc b/source/extensions/access_loggers/grpc/grpc_access_log_impl.cc index 1e5c68f0f373..e544a52af191 100644 --- a/source/extensions/access_loggers/grpc/grpc_access_log_impl.cc +++ b/source/extensions/access_loggers/grpc/grpc_access_log_impl.cc @@ -18,15 +18,11 @@ namespace GrpcCommon { GrpcAccessLoggerImpl::GrpcAccessLoggerImpl( const Grpc::RawAsyncClientSharedPtr& client, std::string log_name, std::chrono::milliseconds buffer_flush_interval_msec, uint64_t max_buffer_size_bytes, - Event::Dispatcher& dispatcher, const LocalInfo::LocalInfo& local_info, Stats::Scope& scope, - envoy::config::core::v3::ApiVersion transport_api_version) - : GrpcAccessLogger( - std::move(client), buffer_flush_interval_msec, max_buffer_size_bytes, dispatcher, scope, - GRPC_LOG_STATS_PREFIX, - Grpc::VersionedMethods("envoy.service.accesslog.v3.AccessLogService.StreamAccessLogs", - "envoy.service.accesslog.v2.AccessLogService.StreamAccessLogs") - .getMethodDescriptorForVersion(transport_api_version), - transport_api_version), + Event::Dispatcher& dispatcher, const LocalInfo::LocalInfo& local_info, Stats::Scope& scope) + : GrpcAccessLogger(std::move(client), buffer_flush_interval_msec, max_buffer_size_bytes, + dispatcher, scope, GRPC_LOG_STATS_PREFIX, + *Protobuf::DescriptorPool::generated_pool()->FindMethodByName( + "envoy.service.accesslog.v3.AccessLogService.StreamAccessLogs")), log_name_(log_name), local_info_(local_info) {} void GrpcAccessLoggerImpl::addEntry(envoy::data::accesslog::v3::HTTPAccessLogEntry&& entry) { @@ -55,13 +51,12 @@ GrpcAccessLoggerCacheImpl::GrpcAccessLoggerCacheImpl(Grpc::AsyncClientManager& a GrpcAccessLoggerImpl::SharedPtr GrpcAccessLoggerCacheImpl::createLogger( const envoy::extensions::access_loggers::grpc::v3::CommonGrpcAccessLogConfig& config, - envoy::config::core::v3::ApiVersion transport_version, const Grpc::RawAsyncClientSharedPtr& client, std::chrono::milliseconds buffer_flush_interval_msec, uint64_t max_buffer_size_bytes, Event::Dispatcher& dispatcher, Stats::Scope& scope) { return std::make_shared(client, config.log_name(), buffer_flush_interval_msec, max_buffer_size_bytes, - dispatcher, local_info_, scope, transport_version); + dispatcher, local_info_, scope); } } // namespace GrpcCommon diff --git a/source/extensions/access_loggers/grpc/grpc_access_log_impl.h b/source/extensions/access_loggers/grpc/grpc_access_log_impl.h index 07bf8400fdc1..43b542327476 100644 --- a/source/extensions/access_loggers/grpc/grpc_access_log_impl.h +++ b/source/extensions/access_loggers/grpc/grpc_access_log_impl.h @@ -26,8 +26,7 @@ class GrpcAccessLoggerImpl GrpcAccessLoggerImpl(const Grpc::RawAsyncClientSharedPtr& client, std::string log_name, std::chrono::milliseconds buffer_flush_interval_msec, uint64_t max_buffer_size_bytes, Event::Dispatcher& dispatcher, - const LocalInfo::LocalInfo& local_info, Stats::Scope& scope, - envoy::config::core::v3::ApiVersion transport_api_version); + const LocalInfo::LocalInfo& local_info, Stats::Scope& scope); private: // Extensions::AccessLoggers::GrpcCommon::GrpcAccessLogger @@ -53,7 +52,6 @@ class GrpcAccessLoggerCacheImpl // Common::GrpcAccessLoggerCache GrpcAccessLoggerImpl::SharedPtr createLogger(const envoy::extensions::access_loggers::grpc::v3::CommonGrpcAccessLogConfig& config, - envoy::config::core::v3::ApiVersion transport_version, const Grpc::RawAsyncClientSharedPtr& client, std::chrono::milliseconds buffer_flush_interval_msec, uint64_t max_buffer_size_bytes, Event::Dispatcher& dispatcher, Stats::Scope& scope) override; diff --git a/source/extensions/access_loggers/grpc/http_grpc_access_log_impl.cc b/source/extensions/access_loggers/grpc/http_grpc_access_log_impl.cc index cb37f1315efd..f35715c37ad9 100644 --- a/source/extensions/access_loggers/grpc/http_grpc_access_log_impl.cc +++ b/source/extensions/access_loggers/grpc/http_grpc_access_log_impl.cc @@ -41,11 +41,10 @@ HttpGrpcAccessLog::HttpGrpcAccessLog( for (const auto& header : config_.additional_response_trailers_to_log()) { response_trailers_to_log_.emplace_back(header); } - - tls_slot_->set([this, transport_version = Envoy::Config::Utility::getAndCheckTransportVersion( - config_.common_config())](Event::Dispatcher&) { + Envoy::Config::Utility::checkTransportVersion(config_.common_config()); + tls_slot_->set([this](Event::Dispatcher&) { return std::make_shared(access_logger_cache_->getOrCreateLogger( - config_.common_config(), transport_version, Common::GrpcAccessLoggerType::HTTP, scope_)); + config_.common_config(), Common::GrpcAccessLoggerType::HTTP, scope_)); }); } diff --git a/source/extensions/access_loggers/grpc/tcp_grpc_access_log_impl.cc b/source/extensions/access_loggers/grpc/tcp_grpc_access_log_impl.cc index c475f134a7b6..7fbcee911d5b 100644 --- a/source/extensions/access_loggers/grpc/tcp_grpc_access_log_impl.cc +++ b/source/extensions/access_loggers/grpc/tcp_grpc_access_log_impl.cc @@ -24,10 +24,10 @@ TcpGrpcAccessLog::TcpGrpcAccessLog( Stats::Scope& scope) : Common::ImplBase(std::move(filter)), scope_(scope), config_(std::move(config)), tls_slot_(tls.allocateSlot()), access_logger_cache_(std::move(access_logger_cache)) { - tls_slot_->set([this, transport_version = Config::Utility::getAndCheckTransportVersion( - config_.common_config())](Event::Dispatcher&) { + Config::Utility::checkTransportVersion(config_.common_config()); + tls_slot_->set([this](Event::Dispatcher&) { return std::make_shared(access_logger_cache_->getOrCreateLogger( - config_.common_config(), transport_version, Common::GrpcAccessLoggerType::TCP, scope_)); + config_.common_config(), Common::GrpcAccessLoggerType::TCP, scope_)); }); } diff --git a/source/extensions/access_loggers/open_telemetry/access_log_impl.cc b/source/extensions/access_loggers/open_telemetry/access_log_impl.cc index f3376483ad31..48c4166395da 100644 --- a/source/extensions/access_loggers/open_telemetry/access_log_impl.cc +++ b/source/extensions/access_loggers/open_telemetry/access_log_impl.cc @@ -40,11 +40,10 @@ AccessLog::AccessLog( : Common::ImplBase(std::move(filter)), scope_(scope), tls_slot_(tls.allocateSlot()), access_logger_cache_(std::move(access_logger_cache)) { - tls_slot_->set([this, config, - transport_version = Envoy::Config::Utility::getAndCheckTransportVersion( - config.common_config())](Event::Dispatcher&) { + Envoy::Config::Utility::checkTransportVersion(config.common_config()); + tls_slot_->set([this, config](Event::Dispatcher&) { return std::make_shared(access_logger_cache_->getOrCreateLogger( - config.common_config(), transport_version, Common::GrpcAccessLoggerType::HTTP, scope_)); + config.common_config(), Common::GrpcAccessLoggerType::HTTP, scope_)); }); ProtobufWkt::Struct body_format; diff --git a/source/extensions/access_loggers/open_telemetry/grpc_access_log_impl.cc b/source/extensions/access_loggers/open_telemetry/grpc_access_log_impl.cc index cc84242c93d6..215f7cfba9e4 100644 --- a/source/extensions/access_loggers/open_telemetry/grpc_access_log_impl.cc +++ b/source/extensions/access_loggers/open_telemetry/grpc_access_log_impl.cc @@ -23,15 +23,11 @@ namespace OpenTelemetry { GrpcAccessLoggerImpl::GrpcAccessLoggerImpl( const Grpc::RawAsyncClientSharedPtr& client, std::string log_name, std::chrono::milliseconds buffer_flush_interval_msec, uint64_t max_buffer_size_bytes, - Event::Dispatcher& dispatcher, const LocalInfo::LocalInfo& local_info, Stats::Scope& scope, - envoy::config::core::v3::ApiVersion transport_api_version) - : GrpcAccessLogger( - client, buffer_flush_interval_msec, max_buffer_size_bytes, dispatcher, scope, - GRPC_LOG_STATS_PREFIX, - Grpc::VersionedMethods("opentelemetry.proto.collector.logs.v1.LogsService.Export", - "opentelemetry.proto.collector.logs.v1.LogsService.Export") - .getMethodDescriptorForVersion(transport_api_version), - transport_api_version) { + Event::Dispatcher& dispatcher, const LocalInfo::LocalInfo& local_info, Stats::Scope& scope) + : GrpcAccessLogger(client, buffer_flush_interval_msec, max_buffer_size_bytes, dispatcher, scope, + GRPC_LOG_STATS_PREFIX, + *Protobuf::DescriptorPool::generated_pool()->FindMethodByName( + "opentelemetry.proto.collector.logs.v1.LogsService.Export")) { initMessageRoot(log_name, local_info); } @@ -78,13 +74,12 @@ GrpcAccessLoggerCacheImpl::GrpcAccessLoggerCacheImpl(Grpc::AsyncClientManager& a GrpcAccessLoggerImpl::SharedPtr GrpcAccessLoggerCacheImpl::createLogger( const envoy::extensions::access_loggers::grpc::v3::CommonGrpcAccessLogConfig& config, - envoy::config::core::v3::ApiVersion transport_version, const Grpc::RawAsyncClientSharedPtr& client, std::chrono::milliseconds buffer_flush_interval_msec, uint64_t max_buffer_size_bytes, Event::Dispatcher& dispatcher, Stats::Scope& scope) { return std::make_shared(client, config.log_name(), buffer_flush_interval_msec, max_buffer_size_bytes, - dispatcher, local_info_, scope, transport_version); + dispatcher, local_info_, scope); } } // namespace OpenTelemetry diff --git a/source/extensions/access_loggers/open_telemetry/grpc_access_log_impl.h b/source/extensions/access_loggers/open_telemetry/grpc_access_log_impl.h index 52e61e134ee3..7af83f529de4 100644 --- a/source/extensions/access_loggers/open_telemetry/grpc_access_log_impl.h +++ b/source/extensions/access_loggers/open_telemetry/grpc_access_log_impl.h @@ -38,8 +38,7 @@ class GrpcAccessLoggerImpl GrpcAccessLoggerImpl(const Grpc::RawAsyncClientSharedPtr& client, std::string log_name, std::chrono::milliseconds buffer_flush_interval_msec, uint64_t max_buffer_size_bytes, Event::Dispatcher& dispatcher, - const LocalInfo::LocalInfo& local_info, Stats::Scope& scope, - envoy::config::core::v3::ApiVersion transport_api_version); + const LocalInfo::LocalInfo& local_info, Stats::Scope& scope); private: void initMessageRoot(const std::string& log_name, const LocalInfo::LocalInfo& local_info); @@ -67,7 +66,6 @@ class GrpcAccessLoggerCacheImpl // Common::GrpcAccessLoggerCache GrpcAccessLoggerImpl::SharedPtr createLogger(const envoy::extensions::access_loggers::grpc::v3::CommonGrpcAccessLogConfig& config, - envoy::config::core::v3::ApiVersion transport_version, const Grpc::RawAsyncClientSharedPtr& client, std::chrono::milliseconds buffer_flush_interval_msec, uint64_t max_buffer_size_bytes, Event::Dispatcher& dispatcher, Stats::Scope& scope) override; diff --git a/source/extensions/common/tap/tap_config_base.cc b/source/extensions/common/tap/tap_config_base.cc index b1f9785c6588..f2d733c21c00 100644 --- a/source/extensions/common/tap/tap_config_base.cc +++ b/source/extensions/common/tap/tap_config_base.cc @@ -6,7 +6,6 @@ #include "source/common/common/assert.h" #include "source/common/common/fmt.h" -#include "source/common/config/version_converter.h" #include "source/common/protobuf/utility.h" #include "source/extensions/common/matcher/matcher.h" @@ -83,7 +82,7 @@ TapConfigBaseImpl::TapConfigBaseImpl(const envoy::config::tap::v3::TapConfig& pr // Fallback to use the deprecated match_config field and upgrade (wire cast) it to the new // MatchPredicate which is backward compatible with the old MatchPredicate originally // introduced in the Tap filter. - Config::VersionConverter::upgrade(proto_config.match_config(), match); + MessageUtil::wireCast(proto_config.match_config(), match); } else { throw EnvoyException(fmt::format("Neither match nor match_config is set in TapConfig: {}", proto_config.DebugString())); diff --git a/source/extensions/filters/common/ext_authz/ext_authz_grpc_impl.cc b/source/extensions/filters/common/ext_authz/ext_authz_grpc_impl.cc index b3b62d7dd904..d462a5179572 100644 --- a/source/extensions/filters/common/ext_authz/ext_authz_grpc_impl.cc +++ b/source/extensions/filters/common/ext_authz/ext_authz_grpc_impl.cc @@ -17,13 +17,10 @@ namespace Common { namespace ExtAuthz { GrpcClientImpl::GrpcClientImpl(const Grpc::RawAsyncClientSharedPtr& async_client, - const absl::optional& timeout, - envoy::config::core::v3::ApiVersion transport_api_version) + const absl::optional& timeout) : async_client_(async_client), timeout_(timeout), - service_method_(Grpc::VersionedMethods("envoy.service.auth.v3.Authorization.Check", - "envoy.service.auth.v2.Authorization.Check") - .getMethodDescriptorForVersion(transport_api_version)), - transport_api_version_(transport_api_version) {} + service_method_(*Protobuf::DescriptorPool::generated_pool()->FindMethodByName( + "envoy.service.auth.v3.Authorization.Check")) {} GrpcClientImpl::~GrpcClientImpl() { ASSERT(!callbacks_); } @@ -43,8 +40,7 @@ void GrpcClientImpl::check(RequestCallbacks& callbacks, options.setParentContext(Http::AsyncClient::ParentContext{&stream_info}); ENVOY_LOG(trace, "Sending CheckRequest: {}", request.DebugString()); - request_ = async_client_->send(service_method_, request, *this, parent_span, options, - transport_api_version_); + request_ = async_client_->send(service_method_, request, *this, parent_span, options); } void GrpcClientImpl::onSuccess(std::unique_ptr&& response, diff --git a/source/extensions/filters/common/ext_authz/ext_authz_grpc_impl.h b/source/extensions/filters/common/ext_authz/ext_authz_grpc_impl.h index 48f9498dfbf7..f13d6bd6d33c 100644 --- a/source/extensions/filters/common/ext_authz/ext_authz_grpc_impl.h +++ b/source/extensions/filters/common/ext_authz/ext_authz_grpc_impl.h @@ -44,8 +44,7 @@ class GrpcClientImpl : public Client, public Logger::Loggable { public: GrpcClientImpl(const Grpc::RawAsyncClientSharedPtr& async_client, - const absl::optional& timeout, - envoy::config::core::v3::ApiVersion transport_api_version); + const absl::optional& timeout); ~GrpcClientImpl() override; // ExtAuthz::Client @@ -70,7 +69,6 @@ class GrpcClientImpl : public Client, absl::optional timeout_; RequestCallbacks* callbacks_{}; const Protobuf::MethodDescriptor& service_method_; - const envoy::config::core::v3::ApiVersion transport_api_version_; }; using GrpcClientImplPtr = std::unique_ptr; diff --git a/source/extensions/filters/common/ratelimit/ratelimit_impl.cc b/source/extensions/filters/common/ratelimit/ratelimit_impl.cc index 2c361c318067..fbb8858dfd2f 100644 --- a/source/extensions/filters/common/ratelimit/ratelimit_impl.cc +++ b/source/extensions/filters/common/ratelimit/ratelimit_impl.cc @@ -20,14 +20,10 @@ namespace Common { namespace RateLimit { GrpcClientImpl::GrpcClientImpl(const Grpc::RawAsyncClientSharedPtr& async_client, - const absl::optional& timeout, - envoy::config::core::v3::ApiVersion transport_api_version) + const absl::optional& timeout) : async_client_(async_client), timeout_(timeout), - service_method_( - Grpc::VersionedMethods("envoy.service.ratelimit.v3.RateLimitService.ShouldRateLimit", - "envoy.service.ratelimit.v2.RateLimitService.ShouldRateLimit") - .getMethodDescriptorForVersion(transport_api_version)), - transport_api_version_(transport_api_version) {} + service_method_(*Protobuf::DescriptorPool::generated_pool()->FindMethodByName( + "envoy.service.ratelimit.v3.RateLimitService.ShouldRateLimit")) {} GrpcClientImpl::~GrpcClientImpl() { ASSERT(!callbacks_); } @@ -71,8 +67,7 @@ void GrpcClientImpl::limit(RequestCallbacks& callbacks, const std::string& domai request_ = async_client_->send(service_method_, request, *this, parent_span, Http::AsyncClient::RequestOptions().setTimeout(timeout_).setParentContext( - Http::AsyncClient::ParentContext{&stream_info}), - transport_api_version_); + Http::AsyncClient::ParentContext{&stream_info})); } void GrpcClientImpl::onSuccess( @@ -124,14 +119,13 @@ void GrpcClientImpl::onFailure(Grpc::Status::GrpcStatus status, const std::strin ClientPtr rateLimitClient(Server::Configuration::FactoryContext& context, const envoy::config::core::v3::GrpcService& grpc_service, - const std::chrono::milliseconds timeout, - envoy::config::core::v3::ApiVersion transport_api_version) { + const std::chrono::milliseconds timeout) { // TODO(ramaraochavali): register client to singleton when GrpcClientImpl supports concurrent // requests. return std::make_unique( context.clusterManager().grpcAsyncClientManager().getOrCreateRawAsyncClient( grpc_service, context.scope(), true, Grpc::CacheOption::CacheWhenRuntimeEnabled), - timeout, transport_api_version); + timeout); } } // namespace RateLimit diff --git a/source/extensions/filters/common/ratelimit/ratelimit_impl.h b/source/extensions/filters/common/ratelimit/ratelimit_impl.h index f97d473c6837..fa48d9b61b34 100644 --- a/source/extensions/filters/common/ratelimit/ratelimit_impl.h +++ b/source/extensions/filters/common/ratelimit/ratelimit_impl.h @@ -45,8 +45,7 @@ class GrpcClientImpl : public Client, public Logger::Loggable { public: GrpcClientImpl(const Grpc::RawAsyncClientSharedPtr& async_client, - const absl::optional& timeout, - envoy::config::core::v3::ApiVersion transport_api_version); + const absl::optional& timeout); ~GrpcClientImpl() override; static void createRequest(envoy::service::ratelimit::v3::RateLimitRequest& request, @@ -74,7 +73,6 @@ class GrpcClientImpl : public Client, absl::optional timeout_; RequestCallbacks* callbacks_{}; const Protobuf::MethodDescriptor& service_method_; - const envoy::config::core::v3::ApiVersion transport_api_version_; }; /** @@ -82,8 +80,7 @@ class GrpcClientImpl : public Client, */ ClientPtr rateLimitClient(Server::Configuration::FactoryContext& context, const envoy::config::core::v3::GrpcService& grpc_service, - const std::chrono::milliseconds timeout, - envoy::config::core::v3::ApiVersion transport_api_version); + const std::chrono::milliseconds timeout); } // namespace RateLimit } // namespace Common diff --git a/source/extensions/filters/http/ext_authz/config.cc b/source/extensions/filters/http/ext_authz/config.cc index 6ca079a363fd..04413850987d 100644 --- a/source/extensions/filters/http/ext_authz/config.cc +++ b/source/extensions/filters/http/ext_authz/config.cc @@ -47,27 +47,27 @@ Http::FilterFactoryCb ExtAuthzFilterConfig::createFilterFactoryFromProtoTyped( const uint32_t timeout_ms = PROTOBUF_GET_MS_OR_DEFAULT(proto_config.grpc_service(), timeout, DefaultTimeout); - callback = [&context, filter_config, timeout_ms, proto_config, - transport_api_version = Config::Utility::getAndCheckTransportVersion(proto_config)]( - Http::FilterChainFactoryCallbacks& callbacks) { + Config::Utility::checkTransportVersion(proto_config); + callback = [&context, filter_config, timeout_ms, + proto_config](Http::FilterChainFactoryCallbacks& callbacks) { auto client = std::make_unique( context.clusterManager().grpcAsyncClientManager().getOrCreateRawAsyncClient( proto_config.grpc_service(), context.scope(), true, Grpc::CacheOption::AlwaysCache), - std::chrono::milliseconds(timeout_ms), transport_api_version); + std::chrono::milliseconds(timeout_ms)); callbacks.addStreamFilter(std::make_shared(filter_config, std::move(client))); }; } else { // Envoy gRPC client. const uint32_t timeout_ms = PROTOBUF_GET_MS_OR_DEFAULT(proto_config.grpc_service(), timeout, DefaultTimeout); - callback = [grpc_service = proto_config.grpc_service(), &context, filter_config, timeout_ms, - transport_api_version = Config::Utility::getAndCheckTransportVersion(proto_config)]( - Http::FilterChainFactoryCallbacks& callbacks) { + Config::Utility::checkTransportVersion(proto_config); + callback = [grpc_service = proto_config.grpc_service(), &context, filter_config, + timeout_ms](Http::FilterChainFactoryCallbacks& callbacks) { Grpc::RawAsyncClientSharedPtr raw_client = context.clusterManager().grpcAsyncClientManager().getOrCreateRawAsyncClient( grpc_service, context.scope(), true, Grpc::CacheOption::AlwaysCache); auto client = std::make_unique( - raw_client, std::chrono::milliseconds(timeout_ms), transport_api_version); + raw_client, std::chrono::milliseconds(timeout_ms)); callbacks.addStreamFilter(std::make_shared(filter_config, std::move(client))); }; } diff --git a/source/extensions/filters/http/ratelimit/config.cc b/source/extensions/filters/http/ratelimit/config.cc index 0db542d17a9a..b49ea57da241 100644 --- a/source/extensions/filters/http/ratelimit/config.cc +++ b/source/extensions/filters/http/ratelimit/config.cc @@ -27,14 +27,12 @@ Http::FilterFactoryCb RateLimitFilterConfig::createFilterFactoryFromProtoTyped( const std::chrono::milliseconds timeout = std::chrono::milliseconds(PROTOBUF_GET_MS_OR_DEFAULT(proto_config, timeout, 20)); + Config::Utility::checkTransportVersion(proto_config.rate_limit_service()); return [proto_config, &context, timeout, - transport_version = - Config::Utility::getAndCheckTransportVersion(proto_config.rate_limit_service()), filter_config](Http::FilterChainFactoryCallbacks& callbacks) -> void { callbacks.addStreamFilter(std::make_shared( filter_config, Filters::Common::RateLimit::rateLimitClient( - context, proto_config.rate_limit_service().grpc_service(), timeout, - transport_version))); + context, proto_config.rate_limit_service().grpc_service(), timeout))); }; } diff --git a/source/extensions/filters/network/ext_authz/config.cc b/source/extensions/filters/network/ext_authz/config.cc index ce3bf91c9b6d..f2e074a4c64a 100644 --- a/source/extensions/filters/network/ext_authz/config.cc +++ b/source/extensions/filters/network/ext_authz/config.cc @@ -27,16 +27,16 @@ Network::FilterFactoryCb ExtAuthzConfigFactory::createFilterFactoryFromProtoType proto_config, context.scope(), context.getServerFactoryContext().bootstrap()); const uint32_t timeout_ms = PROTOBUF_GET_MS_OR_DEFAULT(proto_config.grpc_service(), timeout, 200); + Envoy::Config::Utility::checkTransportVersion(proto_config); return [grpc_service = proto_config.grpc_service(), &context, ext_authz_config, - transport_api_version = Envoy::Config::Utility::getAndCheckTransportVersion(proto_config), timeout_ms](Network::FilterManager& filter_manager) -> void { auto async_client_factory = context.clusterManager().grpcAsyncClientManager().factoryForGrpcService( grpc_service, context.scope(), true); auto client = std::make_unique( - async_client_factory->createUncachedRawAsyncClient(), std::chrono::milliseconds(timeout_ms), - transport_api_version); + async_client_factory->createUncachedRawAsyncClient(), + std::chrono::milliseconds(timeout_ms)); filter_manager.addReadFilter(Network::ReadFilterSharedPtr{ std::make_shared(ext_authz_config, std::move(client))}); }; diff --git a/source/extensions/filters/network/ratelimit/config.cc b/source/extensions/filters/network/ratelimit/config.cc index fdf84987e9ff..c665500cee0e 100644 --- a/source/extensions/filters/network/ratelimit/config.cc +++ b/source/extensions/filters/network/ratelimit/config.cc @@ -28,14 +28,12 @@ Network::FilterFactoryCb RateLimitConfigFactory::createFilterFactoryFromProtoTyp ConfigSharedPtr filter_config(new Config(proto_config, context.scope(), context.runtime())); const std::chrono::milliseconds timeout = std::chrono::milliseconds(PROTOBUF_GET_MS_OR_DEFAULT(proto_config, timeout, 20)); - - return [proto_config, &context, timeout, filter_config, - transport_version = Envoy::Config::Utility::getAndCheckTransportVersion( - proto_config.rate_limit_service())](Network::FilterManager& filter_manager) -> void { + Envoy::Config::Utility::checkTransportVersion(proto_config.rate_limit_service()); + return [proto_config, &context, timeout, + filter_config](Network::FilterManager& filter_manager) -> void { filter_manager.addReadFilter(std::make_shared( filter_config, Filters::Common::RateLimit::rateLimitClient( - context, proto_config.rate_limit_service().grpc_service(), timeout, - transport_version))); + context, proto_config.rate_limit_service().grpc_service(), timeout))); }; } diff --git a/source/extensions/filters/network/tcp_proxy/config.cc b/source/extensions/filters/network/tcp_proxy/config.cc index ccdc6e7a69da..8de0ac9224a7 100644 --- a/source/extensions/filters/network/tcp_proxy/config.cc +++ b/source/extensions/filters/network/tcp_proxy/config.cc @@ -17,10 +17,6 @@ Network::FilterFactoryCb ConfigFactory::createFilterFactoryFromProtoTyped( ASSERT(!proto_config.stat_prefix().empty()); auto _ = Envoy::Router::HeaderParser::configure(proto_config.tunneling_config().headers_to_add()); - if (proto_config.has_hidden_envoy_deprecated_deprecated_v1()) { - ASSERT(proto_config.hidden_envoy_deprecated_deprecated_v1().routes_size() > 0); - } - Envoy::TcpProxy::ConfigSharedPtr filter_config( std::make_shared(proto_config, context)); return [filter_config, &context](Network::FilterManager& filter_manager) -> void { diff --git a/source/extensions/filters/network/thrift_proxy/filters/ratelimit/config.cc b/source/extensions/filters/network/thrift_proxy/filters/ratelimit/config.cc index 82217079c8e9..c1baa8ba3117 100644 --- a/source/extensions/filters/network/thrift_proxy/filters/ratelimit/config.cc +++ b/source/extensions/filters/network/thrift_proxy/filters/ratelimit/config.cc @@ -30,14 +30,12 @@ RateLimitFilterConfig::createFilterFactoryFromProtoTyped( const std::chrono::milliseconds timeout = std::chrono::milliseconds(PROTOBUF_GET_MS_OR_DEFAULT(proto_config, timeout, 20)); - return [proto_config, &context, timeout, config, - transport_version = Envoy::Config::Utility::getAndCheckTransportVersion( - proto_config.rate_limit_service())]( - ThriftProxy::ThriftFilters::FilterChainFactoryCallbacks& callbacks) -> void { + Envoy::Config::Utility::checkTransportVersion(proto_config.rate_limit_service()); + return [proto_config, &context, timeout, + config](ThriftProxy::ThriftFilters::FilterChainFactoryCallbacks& callbacks) -> void { callbacks.addDecoderFilter(std::make_shared( config, Filters::Common::RateLimit::rateLimitClient( - context, proto_config.rate_limit_service().grpc_service(), timeout, - transport_version))); + context, proto_config.rate_limit_service().grpc_service(), timeout))); }; } diff --git a/source/extensions/filters/udp/dns_filter/dns_filter.cc b/source/extensions/filters/udp/dns_filter/dns_filter.cc index f2e9e5fcf9b1..1e869093389d 100644 --- a/source/extensions/filters/udp/dns_filter/dns_filter.cc +++ b/source/extensions/filters/udp/dns_filter/dns_filter.cc @@ -206,8 +206,7 @@ bool DnsFilterEnvoyConfig::loadServerConfig( // is thrown. If no table can be read, the filter will refer all queries to an external // DNS server, if configured, otherwise all queries will be responded to with Name Error. MessageUtil::loadFromFile(datasource.filename(), table, - ProtobufMessage::getNullValidationVisitor(), api_, - false /* do_boosting */); + ProtobufMessage::getNullValidationVisitor(), api_); data_source_loaded = true; } catch (const ProtobufMessage::UnknownProtoFieldException& e) { ENVOY_LOG(warn, "Invalid field in DNS Filter datasource configuration: {}", e.what()); diff --git a/source/extensions/stat_sinks/metrics_service/config.cc b/source/extensions/stat_sinks/metrics_service/config.cc index 716e62fd34a7..6e1841b0302f 100644 --- a/source/extensions/stat_sinks/metrics_service/config.cc +++ b/source/extensions/stat_sinks/metrics_service/config.cc @@ -25,7 +25,7 @@ MetricsServiceSinkFactory::createStatsSink(const Protobuf::Message& config, MessageUtil::downcastAndValidate( config, server.messageValidationContext().staticValidationVisitor()); const auto& grpc_service = sink_config.grpc_service(); - const auto transport_api_version = Config::Utility::getAndCheckTransportVersion(sink_config); + Config::Utility::checkTransportVersion(sink_config); ENVOY_LOG(debug, "Metrics Service gRPC service configuration: {}", grpc_service.DebugString()); std::shared_ptr( server.clusterManager().grpcAsyncClientManager().getOrCreateRawAsyncClient( grpc_service, server.scope(), false, Grpc::CacheOption::CacheWhenRuntimeEnabled), - server.localInfo(), transport_api_version); + server.localInfo()); return std::make_unique>( diff --git a/source/extensions/stat_sinks/metrics_service/grpc_metrics_service_impl.cc b/source/extensions/stat_sinks/metrics_service/grpc_metrics_service_impl.cc index 5e5c602e206f..8c6cebeecccd 100644 --- a/source/extensions/stat_sinks/metrics_service/grpc_metrics_service_impl.cc +++ b/source/extensions/stat_sinks/metrics_service/grpc_metrics_service_impl.cc @@ -18,17 +18,13 @@ namespace Extensions { namespace StatSinks { namespace MetricsService { -GrpcMetricsStreamerImpl::GrpcMetricsStreamerImpl( - Grpc::RawAsyncClientSharedPtr raw_async_client, const LocalInfo::LocalInfo& local_info, - envoy::config::core::v3::ApiVersion transport_api_version) +GrpcMetricsStreamerImpl::GrpcMetricsStreamerImpl(Grpc::RawAsyncClientSharedPtr raw_async_client, + const LocalInfo::LocalInfo& local_info) : GrpcMetricsStreamer(raw_async_client), local_info_(local_info), - service_method_( - Grpc::VersionedMethods("envoy.service.metrics.v3.MetricsService.StreamMetrics", - "envoy.service.metrics.v2.MetricsService.StreamMetrics") - .getMethodDescriptorForVersion(transport_api_version)), - transport_api_version_(transport_api_version) {} + service_method_(*Protobuf::DescriptorPool::generated_pool()->FindMethodByName( + "envoy.service.metrics.v3.MetricsService.StreamMetrics")) {} void GrpcMetricsStreamerImpl::send(MetricsPtr&& metrics) { envoy::service::metrics::v3::StreamMetricsMessage message; @@ -42,7 +38,7 @@ void GrpcMetricsStreamerImpl::send(MetricsPtr&& metrics) { *identifier->mutable_node() = local_info_.node(); } if (stream_ != nullptr) { - stream_->sendMessage(message, transport_api_version_, false); + stream_->sendMessage(message, false); } } diff --git a/source/extensions/stat_sinks/metrics_service/grpc_metrics_service_impl.h b/source/extensions/stat_sinks/metrics_service/grpc_metrics_service_impl.h index 90496ec06eda..5a1bab6bcf52 100644 --- a/source/extensions/stat_sinks/metrics_service/grpc_metrics_service_impl.h +++ b/source/extensions/stat_sinks/metrics_service/grpc_metrics_service_impl.h @@ -64,8 +64,7 @@ class GrpcMetricsStreamerImpl envoy::service::metrics::v3::StreamMetricsResponse> { public: GrpcMetricsStreamerImpl(Grpc::RawAsyncClientSharedPtr raw_async_client, - const LocalInfo::LocalInfo& local_info, - envoy::config::core::v3::ApiVersion transport_api_version); + const LocalInfo::LocalInfo& local_info); // GrpcMetricsStreamer void send(MetricsPtr&& metrics) override; @@ -76,7 +75,6 @@ class GrpcMetricsStreamerImpl private: const LocalInfo::LocalInfo& local_info_; const Protobuf::MethodDescriptor& service_method_; - const envoy::config::core::v3::ApiVersion transport_api_version_; }; using GrpcMetricsStreamerImplPtr = std::unique_ptr; diff --git a/source/server/BUILD b/source/server/BUILD index 630e61710f15..b29bb1a84e33 100644 --- a/source/server/BUILD +++ b/source/server/BUILD @@ -465,7 +465,6 @@ envoy_cc_library( "//source/common/common:basic_resource_lib", "//source/common/common:empty_string", "//source/common/config:utility_lib", - "//source/common/config:version_converter_lib", "//source/common/http:conn_manager_lib", "//source/common/init:manager_lib", "//source/common/init:target_lib", diff --git a/source/server/config_validation/server.cc b/source/server/config_validation/server.cc index 1eaac379016a..6a0039c7f189 100644 --- a/source/server/config_validation/server.cc +++ b/source/server/config_validation/server.cc @@ -92,7 +92,7 @@ void ValidationInstance::initialize(const Options& options, overload_manager_ = std::make_unique( dispatcher(), stats(), threadLocal(), bootstrap_.overload_manager(), messageValidationContext().staticValidationVisitor(), *api_, options_); - Configuration::InitialImpl initial_config(bootstrap_, options); + Configuration::InitialImpl initial_config(bootstrap_); initial_config.initAdminAccessLog(bootstrap_, *this); admin_ = std::make_unique(initial_config.admin().address()); listener_manager_ = diff --git a/source/server/configuration_impl.cc b/source/server/configuration_impl.cc index 3322819a08fd..a4556846df54 100644 --- a/source/server/configuration_impl.cc +++ b/source/server/configuration_impl.cc @@ -192,9 +192,7 @@ WatchdogImpl::WatchdogImpl(const envoy::config::bootstrap::v3::Watchdog& watchdo actions_ = watchdog.actions(); } -InitialImpl::InitialImpl(const envoy::config::bootstrap::v3::Bootstrap& bootstrap, - const Options& options) - : enable_deprecated_v2_api_(options.bootstrapVersion() == 2u) { +InitialImpl::InitialImpl(const envoy::config::bootstrap::v3::Bootstrap& bootstrap) { const auto& admin = bootstrap.admin(); admin_.profile_path_ = @@ -219,16 +217,6 @@ InitialImpl::InitialImpl(const envoy::config::bootstrap::v3::Bootstrap& bootstra layered_runtime_.add_layers()->mutable_admin_layer(); } } - if (enable_deprecated_v2_api_) { - auto* enabled_deprecated_v2_api_layer = layered_runtime_.add_layers(); - enabled_deprecated_v2_api_layer->set_name("enabled_deprecated_v2_api (auto-injected)"); - auto* static_layer = enabled_deprecated_v2_api_layer->mutable_static_layer(); - ProtobufWkt::Value val; - val.set_bool_value(true); - (*static_layer - ->mutable_fields())["envoy.test_only.broken_in_production.enable_deprecated_v2_api"] = - val; - } } void InitialImpl::initAdminAccessLog(const envoy::config::bootstrap::v3::Bootstrap& bootstrap, diff --git a/source/server/configuration_impl.h b/source/server/configuration_impl.h index b833c264bc53..7efa5e22fda5 100644 --- a/source/server/configuration_impl.h +++ b/source/server/configuration_impl.h @@ -170,7 +170,7 @@ class WatchdogImpl : public Watchdog { */ class InitialImpl : public Initial { public: - InitialImpl(const envoy::config::bootstrap::v3::Bootstrap& bootstrap, const Options& options); + InitialImpl(const envoy::config::bootstrap::v3::Bootstrap& bootstrap); // Server::Configuration::Initial Admin& admin() override { return admin_; } @@ -199,7 +199,6 @@ class InitialImpl : public Initial { Network::Socket::OptionsSharedPtr socket_options_; }; - const bool enable_deprecated_v2_api_; AdminImpl admin_; absl::optional flags_path_; envoy::config::bootstrap::v3::LayeredRuntime layered_runtime_; diff --git a/source/server/lds_api.cc b/source/server/lds_api.cc index 1a1f9f9aed98..349251d870a9 100644 --- a/source/server/lds_api.cc +++ b/source/server/lds_api.cc @@ -24,8 +24,8 @@ LdsApiImpl::LdsApiImpl(const envoy::config::core::v3::ConfigSource& lds_config, Upstream::ClusterManager& cm, Init::Manager& init_manager, Stats::Scope& scope, ListenerManager& lm, ProtobufMessage::ValidationVisitor& validation_visitor) - : Envoy::Config::SubscriptionBase( - lds_config.resource_api_version(), validation_visitor, "name"), + : Envoy::Config::SubscriptionBase(validation_visitor, + "name"), listener_manager_(lm), scope_(scope.createScope("listener_manager.lds.")), cm_(cm), init_target_("LDS", [this]() { subscription_->start({}); }) { const auto resource_name = getResourceName(); @@ -44,9 +44,8 @@ void LdsApiImpl::onConfigUpdate(const std::vector& a const std::string& system_version_info) { Config::ScopedResume maybe_resume_rds; if (cm_.adsMux()) { - const auto type_urls = - Config::getAllVersionTypeUrls(); - maybe_resume_rds = cm_.adsMux()->pause(type_urls); + const auto type_url = Config::getTypeUrl(); + maybe_resume_rds = cm_.adsMux()->pause(type_url); } bool any_applied = false; diff --git a/source/server/listener_manager_impl.cc b/source/server/listener_manager_impl.cc index 30678ef23730..afd6ebd142d6 100644 --- a/source/server/listener_manager_impl.cc +++ b/source/server/listener_manager_impl.cc @@ -16,7 +16,6 @@ #include "source/common/common/assert.h" #include "source/common/common/fmt.h" #include "source/common/config/utility.h" -#include "source/common/config/version_converter.h" #include "source/common/network/filter_matcher.h" #include "source/common/network/io_socket_handle_impl.h" #include "source/common/network/listen_socket_impl.h" @@ -72,7 +71,7 @@ envoy::admin::v3::ListenersConfigDump::DynamicListener* getOrCreateDynamicListen void fillState(envoy::admin::v3::ListenersConfigDump::DynamicListenerState& state, const ListenerImpl& listener) { state.set_version_info(listener.versionInfo()); - state.mutable_listener()->PackFrom(API_RECOVER_ORIGINAL(listener.config())); + state.mutable_listener()->PackFrom(listener.config()); TimestampUtil::systemClockToTimestamp(listener.last_updated_, *(state.mutable_last_updated())); } } // namespace @@ -265,7 +264,7 @@ ListenerManagerImpl::dumpListenerConfigs(const Matchers::StringMatcher& name_mat } if (listener->blockRemove()) { auto& static_listener = *config_dump->mutable_static_listeners()->Add(); - static_listener.mutable_listener()->PackFrom(API_RECOVER_ORIGINAL(listener->config())); + static_listener.mutable_listener()->PackFrom(listener->config()); TimestampUtil::systemClockToTimestamp(listener->last_updated_, *(static_listener.mutable_last_updated())); continue; @@ -369,7 +368,7 @@ bool ListenerManagerImpl::addOrUpdateListener(const envoy::config::listener::v3: TimestampUtil::systemClockToTimestamp(server_.api().timeSource().systemTime(), *(it->second->mutable_last_update_attempt())); it->second->set_details(e.what()); - it->second->mutable_failed_configuration()->PackFrom(API_RECOVER_ORIGINAL(config)); + it->second->mutable_failed_configuration()->PackFrom(config); throw e; } error_state_tracker_.erase(it); diff --git a/source/server/options_impl.cc b/source/server/options_impl.cc index 57becc5a89e4..e2c5d08baefe 100644 --- a/source/server/options_impl.cc +++ b/source/server/options_impl.cc @@ -71,11 +71,6 @@ OptionsImpl::OptionsImpl(std::vector args, TCLAP::ValueArg config_yaml( "", "config-yaml", "Inline YAML configuration, merges with the contents of --config-path", false, "", "string", cmd); - TCLAP::ValueArg bootstrap_version( - "", "bootstrap-version", - "API version to parse the bootstrap config as (e.g. 3). If " - "unset, all known versions will be attempted", - false, 0, "string", cmd); TCLAP::SwitchArg allow_unknown_fields("", "allow-unknown-fields", "allow unknown fields in static configuration (DEPRECATED)", @@ -241,9 +236,6 @@ OptionsImpl::OptionsImpl(std::vector args, config_path_ = config_path.getValue(); config_yaml_ = config_yaml.getValue(); - if (bootstrap_version.getValue() != 0) { - bootstrap_version_ = bootstrap_version.getValue(); - } if (allow_unknown_fields.getValue()) { ENVOY_LOG(warn, "--allow-unknown-fields is deprecated, use --allow-unknown-static-fields instead."); diff --git a/source/server/options_impl.h b/source/server/options_impl.h index 9efd569cf2bd..a9c18df08b94 100644 --- a/source/server/options_impl.h +++ b/source/server/options_impl.h @@ -58,7 +58,6 @@ class OptionsImpl : public Server::Options, protected Logger::Loggable& bootstrapVersion() const override { return bootstrap_version_; } const std::string& configYaml() const override { return config_yaml_; } bool allowUnknownStaticFields() const override { return allow_unknown_static_fields_; } bool rejectUnknownDynamicFields() const override { return reject_unknown_dynamic_fields_; } @@ -175,7 +173,6 @@ class OptionsImpl : public Server::Options, protected Logger::Loggable bootstrap_version_; std::string config_yaml_; bool allow_unknown_static_fields_{false}; bool reject_unknown_dynamic_fields_{false}; diff --git a/source/server/server.cc b/source/server/server.cc index 6ab74b6007f7..872e4d54b2a3 100644 --- a/source/server/server.cc +++ b/source/server/server.cc @@ -30,7 +30,6 @@ #include "source/common/config/grpc_mux_impl.h" #include "source/common/config/new_grpc_mux_impl.h" #include "source/common/config/utility.h" -#include "source/common/config/version_converter.h" #include "source/common/config/xds_resource.h" #include "source/common/http/codes.h" #include "source/common/http/headers.h" @@ -279,19 +278,6 @@ ProcessContextOptRef InstanceImpl::processContext() { } namespace { -// Loads a bootstrap object, potentially at a specific version (upgrading if necessary). -void loadBootstrap(absl::optional bootstrap_version, - envoy::config::bootstrap::v3::Bootstrap& bootstrap, - std::function load_function) { - - if (!bootstrap_version.has_value()) { - load_function(bootstrap, true); - } else if (*bootstrap_version == 3) { - load_function(bootstrap, false); - } else { - throw EnvoyException(fmt::format("Unknown bootstrap version {}.", *bootstrap_version)); - } -} bool canBeRegisteredAsInlineHeader(const Http::LowerCaseString& header_name) { // 'set-cookie' cannot currently be registered as an inline header. @@ -349,19 +335,11 @@ void InstanceUtil::loadBootstrapConfig(envoy::config::bootstrap::v3::Bootstrap& } if (!config_path.empty()) { - loadBootstrap( - options.bootstrapVersion(), bootstrap, - [&config_path, &validation_visitor, &api](Protobuf::Message& message, bool do_boosting) { - MessageUtil::loadFromFile(config_path, message, validation_visitor, api, do_boosting); - }); + MessageUtil::loadFromFile(config_path, bootstrap, validation_visitor, api); } if (!config_yaml.empty()) { envoy::config::bootstrap::v3::Bootstrap bootstrap_override; - loadBootstrap( - options.bootstrapVersion(), bootstrap_override, - [&config_yaml, &validation_visitor](Protobuf::Message& message, bool do_boosting) { - MessageUtil::loadFromYaml(config_yaml, message, validation_visitor, do_boosting); - }); + MessageUtil::loadFromYaml(config_yaml, bootstrap_override, validation_visitor); // TODO(snowp): The fact that we do a merge here doesn't seem to be covered under test. bootstrap.MergeFrom(bootstrap_override); } @@ -460,15 +438,6 @@ void InstanceImpl::initialize(const Options& options, bootstrap_.mutable_node()->set_user_agent_name("envoy"); } - // If user has set user_agent_version in the bootstrap config, use it. - // Default to the internal server version. - if (!bootstrap_.node().user_agent_version().empty()) { - std::string user_agent_version = bootstrap_.node().user_agent_version(); - bootstrap_.mutable_node()->set_hidden_envoy_deprecated_build_version(user_agent_version); - } else { - bootstrap_.mutable_node()->set_hidden_envoy_deprecated_build_version(VersionInfo::version()); - } - // If user has set user_agent_build_version in the bootstrap config, use it. // Default to the internal server version. if (!bootstrap_.node().user_agent_build_version().has_version()) { @@ -492,7 +461,7 @@ void InstanceImpl::initialize(const Options& options, stats().symbolTable(), bootstrap_.node(), bootstrap_.node_context_params(), local_address, options.serviceZone(), options.serviceClusterName(), options.serviceNodeName()); - Configuration::InitialImpl initial_config(bootstrap_, options); + Configuration::InitialImpl initial_config(bootstrap_); // Learn original_start_time_ if our parent is still around to inform us of it. const auto parent_admin_shutdown_response = restarter_.sendParentAdminShutdownRequest(); @@ -708,14 +677,14 @@ void InstanceImpl::onRuntimeReady() { async_client_manager_ = std::make_unique( *config_.clusterManager(), thread_local_, time_source_, *api_, grpc_context_.statNames()); TRY_ASSERT_MAIN_THREAD { + Config::Utility::checkTransportVersion(hds_config); hds_delegate_ = std::make_unique( stats_store_, Config::Utility::factoryForGrpcApiConfigSource(*async_client_manager_, hds_config, stats_store_, false) ->createUncachedRawAsyncClient(), - Config::Utility::getAndCheckTransportVersion(hds_config), *dispatcher_, - Runtime::LoaderSingleton::get(), stats_store_, *ssl_context_manager_, info_factory_, - access_log_manager_, *config_.clusterManager(), *local_info_, *admin_, + *dispatcher_, Runtime::LoaderSingleton::get(), stats_store_, *ssl_context_manager_, + info_factory_, access_log_manager_, *config_.clusterManager(), *local_info_, *admin_, *singleton_manager_, thread_local_, messageValidationContext().dynamicValidationVisitor(), *api_, options_); } @@ -825,14 +794,13 @@ RunHelper::RunHelper(Instance& instance, const Options& options, Event::Dispatch return; } - const auto type_urls = - Config::getAllVersionTypeUrls(); + const auto type_url = Config::getTypeUrl(); // Pause RDS to ensure that we don't send any requests until we've // subscribed to all the RDS resources. The subscriptions happen in the init callbacks, // so we pause RDS until we've completed all the callbacks. Config::ScopedResume maybe_resume_rds; if (cm.adsMux()) { - maybe_resume_rds = cm.adsMux()->pause(type_urls); + maybe_resume_rds = cm.adsMux()->pause(type_url); } ENVOY_LOG(info, "all clusters initialized. initializing init manager"); diff --git a/test/common/access_log/access_log_impl_test.cc b/test/common/access_log/access_log_impl_test.cc index b52e2d038057..126088c418d3 100644 --- a/test/common/access_log/access_log_impl_test.cc +++ b/test/common/access_log/access_log_impl_test.cc @@ -39,10 +39,9 @@ namespace Envoy { namespace AccessLog { namespace { -envoy::config::accesslog::v3::AccessLog parseAccessLogFromV3Yaml(const std::string& yaml, - bool avoid_boosting = true) { +envoy::config::accesslog::v3::AccessLog parseAccessLogFromV3Yaml(const std::string& yaml) { envoy::config::accesslog::v3::AccessLog access_log; - TestUtility::loadFromYamlAndValidate(yaml, access_log, false, avoid_boosting); + TestUtility::loadFromYamlAndValidate(yaml, access_log); return access_log; } diff --git a/test/common/config/BUILD b/test/common/config/BUILD index f662aaa300cc..98e410592787 100644 --- a/test/common/config/BUILD +++ b/test/common/config/BUILD @@ -16,15 +16,6 @@ envoy_cc_test( deps = ["@envoy_api//envoy/config/cluster/v3:pkg_cc_proto"], ) -envoy_cc_test( - name = "api_type_oracle_test", - srcs = ["api_type_oracle_test.cc"], - deps = [ - "//source/common/config:api_type_oracle_lib", - "@envoy_api//envoy/extensions/filters/http/ip_tagging/v3:pkg_cc_proto", - ], -) - envoy_cc_test( name = "decoded_resource_impl_test", srcs = ["decoded_resource_impl_test.cc"], @@ -149,7 +140,6 @@ envoy_cc_test( "//source/common/config:api_version_lib", "//source/common/config:grpc_mux_lib", "//source/common/config:protobuf_link_hacks", - "//source/common/config:version_converter_lib", "//source/common/protobuf", "//source/common/stats:isolated_store_lib", "//test/common/stats:stat_test_utility_lib", @@ -175,7 +165,6 @@ envoy_cc_test( deps = [ "//source/common/config:new_grpc_mux_lib", "//source/common/config:protobuf_link_hacks", - "//source/common/config:version_converter_lib", "//source/common/config/xds_mux:grpc_mux_lib", "//source/common/protobuf", "//test/common/stats:stat_test_utility_lib", @@ -202,7 +191,6 @@ envoy_cc_test( deps = [ "//source/common/config:protobuf_link_hacks", "//source/common/config:resource_name_lib", - "//source/common/config:version_converter_lib", "//source/common/config/xds_mux:grpc_mux_lib", "//source/common/protobuf", "//test/common/stats:stat_test_utility_lib", @@ -258,7 +246,6 @@ envoy_cc_test_library( "//source/common/config:api_version_lib", "//source/common/config:grpc_mux_lib", "//source/common/config:grpc_subscription_lib", - "//source/common/config:version_converter_lib", "//test/mocks/config:config_mocks", "//test/mocks/event:event_mocks", "//test/mocks/grpc:grpc_mocks", @@ -279,7 +266,6 @@ envoy_cc_test_library( ":subscription_test_harness", "//source/common/common:utility_lib", "//source/common/config:new_grpc_mux_lib", - "//source/common/config:version_converter_lib", "//source/common/grpc:common_lib", "//test/mocks/config:config_mocks", "//test/mocks/event:event_mocks", @@ -544,27 +530,6 @@ envoy_cc_test_library( hdrs = ["xds_test_utility.h"], ) -envoy_proto_library( - name = "version_converter_proto", - srcs = ["version_converter.proto"], -) - -envoy_cc_test( - name = "version_converter_test", - srcs = ["version_converter_test.cc"], - deps = [ - ":version_converter_proto_cc_proto", - "//source/common/config:api_version_lib", - "//source/common/config:version_converter_lib", - "//source/common/protobuf:well_known_lib", - "//test/test_common:test_time_lib", - "//test/test_common:utility_lib", - "@envoy_api//envoy/api/v2:pkg_cc_proto", - "@envoy_api//envoy/config/cluster/v3:pkg_cc_proto", - "@envoy_api//envoy/service/discovery/v3:pkg_cc_proto", - ], -) - envoy_cc_test( name = "watched_directory_test", srcs = ["watched_directory_test.cc"], diff --git a/test/common/config/api_type_oracle_test.cc b/test/common/config/api_type_oracle_test.cc deleted file mode 100644 index d4cda061cde5..000000000000 --- a/test/common/config/api_type_oracle_test.cc +++ /dev/null @@ -1,26 +0,0 @@ -#include "envoy/extensions/filters/http/ip_tagging/v3/ip_tagging.pb.h" - -#include "source/common/config/api_type_oracle.h" - -#include "gtest/gtest.h" - -// API_NO_BOOST_FILE - -namespace Envoy { -namespace Config { -namespace { - -TEST(ApiTypeOracleTest, All) { - envoy::extensions::filters::http::ip_tagging::v3::IPTagging v3_config; - ProtobufWkt::Any non_api_type; - - EXPECT_EQ(nullptr, - ApiTypeOracle::getEarlierVersionDescriptor(non_api_type.GetDescriptor()->full_name())); - EXPECT_NE(envoy::extensions::filters::http::ip_tagging::v3::IPTagging::descriptor()->full_name(), - ApiTypeOracle::getEarlierVersionMessageTypeName(v3_config.GetDescriptor()->full_name()) - .value()); -} - -} // namespace -} // namespace Config -} // namespace Envoy diff --git a/test/common/config/delta_subscription_impl_test.cc b/test/common/config/delta_subscription_impl_test.cc index 6e3660c3a95b..13ab2522e325 100644 --- a/test/common/config/delta_subscription_impl_test.cc +++ b/test/common/config/delta_subscription_impl_test.cc @@ -142,9 +142,8 @@ TEST(DeltaSubscriptionImplFixturelessTest, NoGrpcStream) { Protobuf::DescriptorPool::generated_pool()->FindMethodByName( "envoy.service.endpoint.v3.EndpointDiscoveryService.StreamEndpoints"); NewGrpcMuxImplSharedPtr xds_context = std::make_shared( - std::unique_ptr(async_client), dispatcher, *method_descriptor, - envoy::config::core::v3::ApiVersion::AUTO, random, stats_store, rate_limit_settings, - local_info); + std::unique_ptr(async_client), dispatcher, *method_descriptor, random, + stats_store, rate_limit_settings, local_info); GrpcSubscriptionImplPtr subscription = std::make_unique( xds_context, callbacks, resource_decoder, stats, Config::TypeUrl::get().ClusterLoadAssignment, diff --git a/test/common/config/delta_subscription_test_harness.h b/test/common/config/delta_subscription_test_harness.h index 82a604def30a..f184a721ea35 100644 --- a/test/common/config/delta_subscription_test_harness.h +++ b/test/common/config/delta_subscription_test_harness.h @@ -9,7 +9,6 @@ #include "source/common/config/grpc_subscription_impl.h" #include "source/common/config/new_grpc_mux_impl.h" -#include "source/common/config/version_converter.h" #include "source/common/grpc/common.h" #include "test/common/config/subscription_test_harness.h" @@ -43,8 +42,7 @@ class DeltaSubscriptionTestHarness : public SubscriptionTestHarness { EXPECT_CALL(dispatcher_, createTimer_(_)).Times(2); xds_context_ = std::make_shared( std::unique_ptr(async_client_), dispatcher_, *method_descriptor_, - envoy::config::core::v3::ApiVersion::AUTO, random_, stats_store_, rate_limit_settings_, - local_info_); + random_, stats_store_, rate_limit_settings_, local_info_); subscription_ = std::make_unique( xds_context_, callbacks_, resource_decoder_, stats_, Config::TypeUrl::get().ClusterLoadAssignment, dispatcher_, init_fetch_timeout, false, diff --git a/test/common/config/grpc_mux_impl_test.cc b/test/common/config/grpc_mux_impl_test.cc index e9ff44b70f8b..8fbd8de8cee0 100644 --- a/test/common/config/grpc_mux_impl_test.cc +++ b/test/common/config/grpc_mux_impl_test.cc @@ -9,7 +9,6 @@ #include "source/common/config/grpc_mux_impl.h" #include "source/common/config/protobuf_link_hacks.h" #include "source/common/config/utility.h" -#include "source/common/config/version_converter.h" #include "source/common/protobuf/protobuf.h" #include "source/common/stats/isolated_store_impl.h" @@ -60,7 +59,7 @@ class GrpcMuxImplTestBase : public testing::Test { local_info_, std::unique_ptr(async_client_), dispatcher_, *Protobuf::DescriptorPool::generated_pool()->FindMethodByName( "envoy.service.discovery.v3.AggregatedDiscoveryService.StreamAggregatedResources"), - envoy::config::core::v3::ApiVersion::AUTO, random_, stats_, rate_limit_settings_, true); + random_, stats_, rate_limit_settings_, true); } void setup(const RateLimitSettings& custom_rate_limit_settings) { @@ -68,8 +67,7 @@ class GrpcMuxImplTestBase : public testing::Test { local_info_, std::unique_ptr(async_client_), dispatcher_, *Protobuf::DescriptorPool::generated_pool()->FindMethodByName( "envoy.service.discovery.v3.AggregatedDiscoveryService.StreamAggregatedResources"), - envoy::config::core::v3::ApiVersion::AUTO, random_, stats_, custom_rate_limit_settings, - true); + random_, stats_, custom_rate_limit_settings, true); } void expectSendMessage(const std::string& type_url, @@ -77,7 +75,7 @@ class GrpcMuxImplTestBase : public testing::Test { bool first = false, const std::string& nonce = "", const Protobuf::int32 error_code = Grpc::Status::WellKnownGrpcStatus::Ok, const std::string& error_message = "") { - API_NO_BOOST(envoy::service::discovery::v3::DiscoveryRequest) expected_request; + envoy::service::discovery::v3::DiscoveryRequest expected_request; if (first) { expected_request.mutable_node()->CopyFrom(local_info_.node()); } @@ -883,7 +881,7 @@ TEST_F(GrpcMuxImplTest, BadLocalInfoEmptyClusterName) { local_info_, std::unique_ptr(async_client_), dispatcher_, *Protobuf::DescriptorPool::generated_pool()->FindMethodByName( "envoy.service.discovery.v3.AggregatedDiscoveryService.StreamAggregatedResources"), - envoy::config::core::v3::ApiVersion::AUTO, random_, stats_, rate_limit_settings_, true), + random_, stats_, rate_limit_settings_, true), EnvoyException, "ads: node 'id' and 'cluster' are required. Set it either in 'node' config or via " "--service-node and --service-cluster options."); @@ -896,7 +894,7 @@ TEST_F(GrpcMuxImplTest, BadLocalInfoEmptyNodeName) { local_info_, std::unique_ptr(async_client_), dispatcher_, *Protobuf::DescriptorPool::generated_pool()->FindMethodByName( "envoy.service.discovery.v3.AggregatedDiscoveryService.StreamAggregatedResources"), - envoy::config::core::v3::ApiVersion::AUTO, random_, stats_, rate_limit_settings_, true), + random_, stats_, rate_limit_settings_, true), EnvoyException, "ads: node 'id' and 'cluster' are required. Set it either in 'node' config or via " "--service-node and --service-cluster options."); diff --git a/test/common/config/grpc_subscription_test_harness.h b/test/common/config/grpc_subscription_test_harness.h index e6f88cc744f9..5d49e74b2eff 100644 --- a/test/common/config/grpc_subscription_test_harness.h +++ b/test/common/config/grpc_subscription_test_harness.h @@ -11,7 +11,6 @@ #include "source/common/config/api_version.h" #include "source/common/config/grpc_mux_impl.h" #include "source/common/config/grpc_subscription_impl.h" -#include "source/common/config/version_converter.h" #include "test/common/config/subscription_test_harness.h" #include "test/mocks/config/mocks.h" @@ -49,8 +48,7 @@ class GrpcSubscriptionTestHarness : public SubscriptionTestHarness { mux_ = std::make_shared( local_info_, std::unique_ptr(async_client_), dispatcher_, - *method_descriptor_, envoy::config::core::v3::ApiVersion::AUTO, random_, stats_store_, - rate_limit_settings_, true); + *method_descriptor_, random_, stats_store_, rate_limit_settings_, true); subscription_ = std::make_unique( mux_, callbacks_, resource_decoder_, stats_, Config::TypeUrl::get().ClusterLoadAssignment, dispatcher_, init_fetch_timeout, false, SubscriptionOptions()); diff --git a/test/common/config/http_subscription_test_harness.h b/test/common/config/http_subscription_test_harness.h index 0af772f2c3a7..027a65d077e0 100644 --- a/test/common/config/http_subscription_test_harness.h +++ b/test/common/config/http_subscription_test_harness.h @@ -54,8 +54,8 @@ class HttpSubscriptionTestHarness : public SubscriptionTestHarness { subscription_ = std::make_unique( local_info_, cm_, "eds_cluster", dispatcher_, random_gen_, std::chrono::milliseconds(1), std::chrono::milliseconds(1000), *method_descriptor_, - Config::TypeUrl::get().ClusterLoadAssignment, envoy::config::core::v3::ApiVersion::AUTO, - callbacks_, resource_decoder_, stats_, init_fetch_timeout, validation_visitor_); + Config::TypeUrl::get().ClusterLoadAssignment, callbacks_, resource_decoder_, stats_, + init_fetch_timeout, validation_visitor_); } ~HttpSubscriptionTestHarness() override { diff --git a/test/common/config/new_grpc_mux_impl_test.cc b/test/common/config/new_grpc_mux_impl_test.cc index b417e99377ef..6fca22264265 100644 --- a/test/common/config/new_grpc_mux_impl_test.cc +++ b/test/common/config/new_grpc_mux_impl_test.cc @@ -9,7 +9,6 @@ #include "source/common/config/new_grpc_mux_impl.h" #include "source/common/config/protobuf_link_hacks.h" #include "source/common/config/utility.h" -#include "source/common/config/version_converter.h" #include "source/common/config/xds_mux/grpc_mux_impl.h" #include "source/common/protobuf/protobuf.h" @@ -70,8 +69,7 @@ class NewGrpcMuxImplTestBase : public testing::TestWithParam { std::unique_ptr(async_client_), dispatcher_, *Protobuf::DescriptorPool::generated_pool()->FindMethodByName( "envoy.service.discovery.v3.AggregatedDiscoveryService.StreamAggregatedResources"), - envoy::config::core::v3::ApiVersion::AUTO, random_, stats_, rate_limit_settings_, - local_info_); + random_, stats_, rate_limit_settings_, local_info_); } void expectSendMessage(const std::string& type_url, diff --git a/test/common/config/sotw_subscription_state_test.cc b/test/common/config/sotw_subscription_state_test.cc index b7d5b5bae581..8347d511fae6 100644 --- a/test/common/config/sotw_subscription_state_test.cc +++ b/test/common/config/sotw_subscription_state_test.cc @@ -28,9 +28,8 @@ class SotwSubscriptionStateTest : public testing::Test { SotwSubscriptionStateTest() : resource_decoder_("cluster_name") { ttl_timer_ = new Event::MockTimer(&dispatcher_); state_ = std::make_unique( - Config::getTypeUrl( - envoy::config::core::v3::ApiVersion::V3), - callbacks_, dispatcher_, resource_decoder_); + Config::getTypeUrl(), callbacks_, + dispatcher_, resource_decoder_); state_->updateSubscriptionInterest({"name1", "name2", "name3"}, {}); auto cur_request = getNextDiscoveryRequestAckless(); EXPECT_THAT(cur_request->resource_names(), UnorderedElementsAre("name1", "name2", "name3")); @@ -71,8 +70,7 @@ class SotwSubscriptionStateTest : public testing::Test { envoy::service::discovery::v3::DiscoveryResponse response; response.set_version_info(version_info); response.set_nonce(nonce); - response.set_type_url(Config::getTypeUrl( - envoy::config::core::v3::ApiVersion::V3)); + response.set_type_url(Config::getTypeUrl()); for (const auto& resource_name : resource_names) { response.add_resources()->PackFrom(resource(resource_name)); } @@ -87,8 +85,7 @@ class SotwSubscriptionStateTest : public testing::Test { envoy::service::discovery::v3::DiscoveryResponse response; response.set_version_info(version_info); response.set_nonce(nonce); - response.set_type_url(Config::getTypeUrl( - envoy::config::core::v3::ApiVersion::V3)); + response.set_type_url(Config::getTypeUrl()); response.add_resources()->PackFrom(resource); EXPECT_CALL(callbacks_, onConfigUpdate(_, version_info)); return state_->handleResponse(response); diff --git a/test/common/config/version_converter.proto b/test/common/config/version_converter.proto deleted file mode 100644 index d58377665580..000000000000 --- a/test/common/config/version_converter.proto +++ /dev/null @@ -1,78 +0,0 @@ -syntax = "proto3"; - -package test.common.config; - -import "google/protobuf/any.proto"; - -enum PreviousEnum { - PREV_DEFAULT = 0; - PREV_DEPRECATED_VALUE = 1; - PREV_OTHER_VALUE = 2; -} - -enum NextEnum { - NEXT_DEFAULT = 0; - reserved 1; - NEXT_OTHER_VALUE = 2; -} - -message PreviousVersion { - // Singleton scalars. - string string_field = 1; - bytes bytes_field = 2; - int32 int32_field = 3; - int64 int64_field = 4; - uint32 uint32_field = 5; - uint64 uint64_field = 6; - double double_field = 7; - float float_field = 8; - bool bool_field = 9; - PreviousEnum enum_field = 10; - - // Singleton nested message. - message PreviousVersionNested { - google.protobuf.Any any_field = 1; - } - PreviousVersionNested nested_field = 11; - - // Repeated entities. - repeated string repeated_scalar_field = 12; - repeated PreviousVersionNested repeated_nested_field = 13; - - // Deprecations. - uint32 deprecated_field = 14 [deprecated = true]; - PreviousEnum enum_field_with_deprecated_value = 15; -} - -message NextVersion { - // Singleton scalars. - string string_field = 1; - bytes bytes_field = 2; - int32 int32_field = 3; - int64 int64_field = 4; - uint32 uint32_field = 5; - uint64 uint64_field = 6; - double double_field = 7; - float float_field = 8; - bool bool_field = 9; - PreviousEnum enum_field = 10; - - // Singleton nested message. - message NextVersionNested { - google.protobuf.Any any_field = 1; - } - NextVersionNested nested_field = 11; - - // Repeated entities. - repeated string repeated_scalar_field = 12; - repeated NextVersionNested repeated_nested_field = 13; - - // Deprecations. - reserved 14; - NextEnum enum_field_with_deprecated_value = 15; - message NewMessageInThisVerion { - } - - // New message present in this version but not PreviousVersion. - NewMessageInThisVerion new_message_in_this_version = 16; -} diff --git a/test/common/config/version_converter_test.cc b/test/common/config/version_converter_test.cc deleted file mode 100644 index 0b29da956e0b..000000000000 --- a/test/common/config/version_converter_test.cc +++ /dev/null @@ -1,199 +0,0 @@ -#include "envoy/api/v2/cluster.pb.h" -#include "envoy/api/v2/discovery.pb.h" -#include "envoy/config/cluster/v3/cluster.pb.h" -#include "envoy/service/discovery/v3/discovery.pb.h" - -#include "source/common/config/api_version.h" -#include "source/common/config/version_converter.h" -#include "source/common/protobuf/well_known.h" - -#include "test/common/config/version_converter.pb.h" -#include "test/test_common/utility.h" - -#include "gtest/gtest.h" - -namespace Envoy { -namespace Config { -namespace { - -bool hasOriginalTypeInformation(const Protobuf::Message& message) { - const Protobuf::Reflection* reflection = message.GetReflection(); - const auto& unknown_field_set = reflection->GetUnknownFields(message); - for (int i = 0; i < unknown_field_set.field_count(); ++i) { - const auto& unknown_field = unknown_field_set.field(i); - if (unknown_field.number() == ProtobufWellKnown::OriginalTypeFieldNumber) { - return true; - } - } - return false; -} - -// Wire-style upgrading between versions. -TEST(VersionConverterTest, Upgrade) { - // Create a v2 Cluster message with some fields set. - API_NO_BOOST(envoy::api::v2::Cluster) source; - source.mutable_load_assignment()->set_cluster_name("bar"); - source.mutable_eds_cluster_config()->set_service_name("foo"); - source.set_drain_connections_on_host_removal(true); - // Upgrade to a v3 Cluster. - API_NO_BOOST(envoy::config::cluster::v3::Cluster) dst; - VersionConverter::upgrade(source, dst); - // Verify fields in v3 Cluster. - EXPECT_TRUE(hasOriginalTypeInformation(dst)); - EXPECT_EQ("bar", dst.load_assignment().cluster_name()); - EXPECT_FALSE(hasOriginalTypeInformation(dst.load_assignment())); - EXPECT_EQ("foo", dst.eds_cluster_config().service_name()); - EXPECT_TRUE(hasOriginalTypeInformation(dst.eds_cluster_config())); - EXPECT_TRUE(dst.ignore_health_on_host_removal()); - // Recover a v2 Cluster from the v3 Cluster using original type information. - auto original_dynamic_msg = VersionConverter::recoverOriginal(dst); - const auto& original_msg = *original_dynamic_msg->msg_; - EXPECT_EQ("envoy.api.v2.Cluster", original_msg.GetDescriptor()->full_name()); - // Ensure that we erased any original type information and have the original - // message. - EXPECT_THAT(original_msg, ProtoEq(source)); - // Verify that sub-messages work with VersionConverter::recoverOriginal, i.e. - // we are propagating original type information. - auto original_dynamic_sub_msg = VersionConverter::recoverOriginal(dst.eds_cluster_config()); - const auto& original_sub_msg = *original_dynamic_sub_msg->msg_; - EXPECT_THAT(original_sub_msg, ProtoEq(source.eds_cluster_config())); -} - -// Empty upgrade between version_converter.proto entities. TODO(htuch): consider migrating all the -// upgrades in this test to version_converter.proto to reduce dependence on APIs that will be -// removed at `EOY`. -TEST(VersionConverterProto, UpgradeNextVersion) { - test::common::config::PreviousVersion source; - test::common::config::NextVersion dst; - VersionConverter::upgrade(source, dst); -} - -// Validate that even if we pass in a newer proto version that is being passed off as an older -// version (e.g. via a type URL mistake), we don't crash. This is a regression test for -// https://github.com/envoyproxy/envoy/issues/13681. -TEST(VersionConverterProto, UpgradeWithConfusedTypes) { - test::common::config::NextVersion source_next; - source_next.mutable_new_message_in_this_version(); - test::common::config::PreviousVersion source; - ASSERT_TRUE(source.ParseFromString(source_next.SerializeAsString())); - test::common::config::NextVersion dst; - VersionConverter::upgrade(source, dst); -} - -// Bad UTF-8 can fail wire cast during upgrade. -TEST(VersionConverterTest, UpgradeException) { - API_NO_BOOST(envoy::api::v2::Cluster) source; - source.mutable_eds_cluster_config()->set_service_name("UPST128\tAM_HO\001\202\247ST"); - API_NO_BOOST(envoy::config::cluster::v3::Cluster) dst; - EXPECT_THROW_WITH_MESSAGE(VersionConverter::upgrade(source, dst), EnvoyException, - "Unable to deserialize during wireCast()"); -} - -// Verify that VersionUtil::scrubHiddenEnvoyDeprecated recursively scrubs any -// deprecated fields. -TEST(VersionConverterTest, ScrubHiddenEnvoyDeprecated) { - API_NO_BOOST(envoy::config::cluster::v3::Cluster) msg; - msg.set_name("foo"); - msg.mutable_hidden_envoy_deprecated_tls_context(); - EXPECT_TRUE(msg.has_hidden_envoy_deprecated_tls_context()); - msg.mutable_load_balancing_policy()->add_policies()->mutable_hidden_envoy_deprecated_config(); - EXPECT_TRUE(msg.load_balancing_policy().policies(0).has_hidden_envoy_deprecated_config()); - VersionUtil::scrubHiddenEnvoyDeprecated(msg); - EXPECT_EQ("foo", msg.name()); - EXPECT_FALSE(msg.has_hidden_envoy_deprecated_tls_context()); - EXPECT_FALSE(msg.load_balancing_policy().policies(0).has_hidden_envoy_deprecated_config()); -} - -// Validate that we can sensibly provide a JSON wire interpretation of messages -// such as DiscoveryRequest based on transport API version. -TEST(VersionConverter, GetJsonStringFromMessage) { - API_NO_BOOST(envoy::service::discovery::v3::DiscoveryRequest) discovery_request; - discovery_request.mutable_node()->set_hidden_envoy_deprecated_build_version("foo"); - discovery_request.mutable_node()->set_user_agent_name("bar"); - const std::string v2_discovery_request = VersionConverter::getJsonStringFromMessage( - discovery_request, envoy::config::core::v3::ApiVersion::V2); - EXPECT_EQ("{\"node\":{\"build_version\":\"foo\",\"user_agent_name\":\"bar\"}}", - v2_discovery_request); - const std::string auto_discovery_request = VersionConverter::getJsonStringFromMessage( - discovery_request, envoy::config::core::v3::ApiVersion::AUTO); - EXPECT_EQ("{\"node\":{\"build_version\":\"foo\",\"user_agent_name\":\"bar\"}}", - auto_discovery_request); - const std::string v3_discovery_request = VersionConverter::getJsonStringFromMessage( - discovery_request, envoy::config::core::v3::ApiVersion::V3); - EXPECT_EQ("{\"node\":{\"user_agent_name\":\"bar\"}}", v3_discovery_request); -} - -bool hasUnknownFields(const Protobuf::Message& message) { - const Protobuf::Reflection* reflection = message.GetReflection(); - const auto& unknown_field_set = reflection->GetUnknownFields(message); - return !unknown_field_set.empty(); -} - -// Validate that we can sensibly provide a gRPC wire interpretation of messages -// such as DiscoveryRequest based on transport API version. -TEST(VersionConverter, PrepareMessageForGrpcWire) { - API_NO_BOOST(envoy::api::v2::core::Node) v2_node; - v2_node.set_build_version("foo"); - v2_node.set_user_agent_name("bar"); - API_NO_BOOST(envoy::service::discovery::v3::DiscoveryRequest) discovery_request; - discovery_request.mutable_node()->set_hidden_envoy_deprecated_build_version("foo"); - VersionConverter::upgrade(v2_node, *discovery_request.mutable_node()); - { - API_NO_BOOST(envoy::service::discovery::v3::DiscoveryRequest) discovery_request_copy; - discovery_request_copy.MergeFrom(discovery_request); - VersionConverter::prepareMessageForGrpcWire(discovery_request_copy, - envoy::config::core::v3::ApiVersion::V2); - API_NO_BOOST(envoy::api::v2::DiscoveryRequest) v2_discovery_request; - EXPECT_TRUE(v2_discovery_request.ParseFromString(discovery_request_copy.SerializeAsString())); - EXPECT_EQ("foo", v2_discovery_request.node().build_version()); - EXPECT_FALSE(hasUnknownFields(v2_discovery_request.node())); - } - { - API_NO_BOOST(envoy::service::discovery::v3::DiscoveryRequest) discovery_request_copy; - discovery_request_copy.MergeFrom(discovery_request); - VersionConverter::prepareMessageForGrpcWire(discovery_request_copy, - envoy::config::core::v3::ApiVersion::AUTO); - API_NO_BOOST(envoy::api::v2::DiscoveryRequest) auto_discovery_request; - EXPECT_TRUE(auto_discovery_request.ParseFromString(discovery_request_copy.SerializeAsString())); - EXPECT_EQ("foo", auto_discovery_request.node().build_version()); - EXPECT_FALSE(hasUnknownFields(auto_discovery_request.node())); - } - { - API_NO_BOOST(envoy::service::discovery::v3::DiscoveryRequest) discovery_request_copy; - discovery_request_copy.MergeFrom(discovery_request); - VersionConverter::prepareMessageForGrpcWire(discovery_request_copy, - envoy::config::core::v3::ApiVersion::V3); - API_NO_BOOST(envoy::service::discovery::v3::DiscoveryRequest) v3_discovery_request; - EXPECT_TRUE(v3_discovery_request.ParseFromString(discovery_request_copy.SerializeAsString())); - EXPECT_EQ("", v3_discovery_request.node().hidden_envoy_deprecated_build_version()); - EXPECT_FALSE(hasUnknownFields(v3_discovery_request.node())); - } -} - -// Downgrading to an earlier version (where it exists). -TEST(VersionConverterTest, DowngradeEarlier) { - API_NO_BOOST(envoy::config::cluster::v3::Cluster) source; - source.set_ignore_health_on_host_removal(true); - auto downgraded = VersionConverter::downgrade(source); - const Protobuf::Descriptor* desc = downgraded->msg_->GetDescriptor(); - const Protobuf::Reflection* reflection = downgraded->msg_->GetReflection(); - EXPECT_EQ("envoy.api.v2.Cluster", desc->full_name()); - EXPECT_EQ(true, reflection->GetBool(*downgraded->msg_, - desc->FindFieldByName("drain_connections_on_host_removal"))); -} - -// Downgrading is idempotent if no earlier version. -TEST(VersionConverterTest, DowngradeSame) { - API_NO_BOOST(envoy::api::v2::Cluster) source; - source.set_drain_connections_on_host_removal(true); - auto downgraded = VersionConverter::downgrade(source); - const Protobuf::Descriptor* desc = downgraded->msg_->GetDescriptor(); - const Protobuf::Reflection* reflection = downgraded->msg_->GetReflection(); - EXPECT_EQ("envoy.api.v2.Cluster", desc->full_name()); - EXPECT_EQ(true, reflection->GetBool(*downgraded->msg_, - desc->FindFieldByName("drain_connections_on_host_removal"))); -} - -} // namespace -} // namespace Config -} // namespace Envoy diff --git a/test/common/config/xds_grpc_mux_impl_test.cc b/test/common/config/xds_grpc_mux_impl_test.cc index 0e2f40a2256f..70bde3f3fe7c 100644 --- a/test/common/config/xds_grpc_mux_impl_test.cc +++ b/test/common/config/xds_grpc_mux_impl_test.cc @@ -10,7 +10,6 @@ #include "source/common/config/protobuf_link_hacks.h" #include "source/common/config/resource_name.h" #include "source/common/config/utility.h" -#include "source/common/config/version_converter.h" #include "source/common/config/xds_mux/grpc_mux_impl.h" #include "source/common/protobuf/protobuf.h" @@ -80,9 +79,9 @@ class GrpcMuxImplTestBase : public testing::Test { bool first = false, const std::string& nonce = "", const Protobuf::int32 error_code = Grpc::Status::WellKnownGrpcStatus::Ok, const std::string& error_message = "") { - API_NO_BOOST(envoy::api::v2::DiscoveryRequest) expected_request; + envoy::service::discovery::v3::DiscoveryRequest expected_request; if (first) { - expected_request.mutable_node()->CopyFrom(API_DOWNGRADE(local_info_.node())); + expected_request.mutable_node()->CopyFrom(local_info_.node()); } for (const auto& resource : resource_names) { expected_request.add_resource_names(resource); @@ -864,9 +863,7 @@ TEST_F(GrpcMuxImplTest, UnwatchedTypeAcceptsEmptyResources) { TEST_F(GrpcMuxImplTest, UnwatchedTypeAcceptsResources) { setup(); EXPECT_CALL(*async_client_, startRaw(_, _, _, _)).WillOnce(Return(&async_stream_)); - const std::string& type_url = - Config::getTypeUrl( - envoy::config::core::v3::ApiVersion::V3); + const std::string& type_url = Config::TypeUrl::get().ClusterLoadAssignment; grpc_mux_->start(); // subscribe and unsubscribe so that the type is known to envoy diff --git a/test/common/grpc/grpc_client_integration.h b/test/common/grpc/grpc_client_integration.h index 0c559cf69924..00aebe7cefdf 100644 --- a/test/common/grpc/grpc_client_integration.h +++ b/test/common/grpc/grpc_client_integration.h @@ -57,24 +57,6 @@ class GrpcClientIntegrationParamTest ClientType clientType() const override { return std::get<1>(GetParam()); } }; -class VersionedGrpcClientIntegrationParamTest - : public BaseGrpcClientIntegrationParamTest, - public testing::TestWithParam> { -public: - static std::string protocolTestParamsToString( - const ::testing::TestParamInfo>& p) { - return fmt::format("{}_{}_{}", - std::get<0>(p.param) == Network::Address::IpVersion::v4 ? "IPv4" : "IPv6", - std::get<1>(p.param) == ClientType::GoogleGrpc ? "GoogleGrpc" : "EnvoyGrpc", - ApiVersion_Name(std::get<2>(p.param))); - } - Network::Address::IpVersion ipVersion() const override { return std::get<0>(GetParam()); } - ClientType clientType() const override { return std::get<1>(GetParam()); } - envoy::config::core::v3::ApiVersion apiVersion() const { return std::get<2>(GetParam()); } -}; - class DeltaSotwIntegrationParamTest : public BaseGrpcClientIntegrationParamTest, public testing::TestWithParam< @@ -106,26 +88,9 @@ class DeltaSotwIntegrationParamTest return; \ } -// For VersionedGrpcClientIntegrationParamTest, skip when testing with -// ENVOY_DISABLE_DEPRECATED_FEATURES. -#ifdef ENVOY_DISABLE_DEPRECATED_FEATURES -#define XDS_DEPRECATED_FEATURE_TEST_SKIP \ - if (apiVersion() != envoy::config::core::v3::ApiVersion::V3) { \ - return; \ - } -#else -#define XDS_DEPRECATED_FEATURE_TEST_SKIP -#endif // ENVOY_DISABLE_DEPRECATED_FEATURES - #define GRPC_CLIENT_INTEGRATION_PARAMS \ testing::Combine(testing::ValuesIn(TestEnvironment::getIpVersionsForTest()), \ testing::ValuesIn(TestEnvironment::getsGrpcVersionsForTest())) -#define VERSIONED_GRPC_CLIENT_INTEGRATION_PARAMS \ - testing::Combine(testing::ValuesIn(TestEnvironment::getIpVersionsForTest()), \ - testing::ValuesIn(TestEnvironment::getsGrpcVersionsForTest()), \ - testing::Values(envoy::config::core::v3::ApiVersion::V3, \ - envoy::config::core::v3::ApiVersion::V2, \ - envoy::config::core::v3::ApiVersion::AUTO)) #define DELTA_SOTW_GRPC_CLIENT_INTEGRATION_PARAMS \ testing::Combine(testing::ValuesIn(TestEnvironment::getIpVersionsForTest()), \ testing::ValuesIn(TestEnvironment::getsGrpcVersionsForTest()), \ diff --git a/test/common/http/utility_test.cc b/test/common/http/utility_test.cc index 76304a34bfb4..8ffe06fbdfd9 100644 --- a/test/common/http/utility_test.cc +++ b/test/common/http/utility_test.cc @@ -310,10 +310,9 @@ TEST(HttpUtility, createSslRedirectPath) { namespace { -envoy::config::core::v3::Http2ProtocolOptions -parseHttp2OptionsFromV3Yaml(const std::string& yaml, bool avoid_boosting = true) { +envoy::config::core::v3::Http2ProtocolOptions parseHttp2OptionsFromV3Yaml(const std::string& yaml) { envoy::config::core::v3::Http2ProtocolOptions http2_options; - TestUtility::loadFromYamlAndValidate(yaml, http2_options, false, avoid_boosting); + TestUtility::loadFromYamlAndValidate(yaml, http2_options); return ::Envoy::Http2::Utility::initializeAndValidateOptions(http2_options); } diff --git a/test/common/json/json_fuzz_test.cc b/test/common/json/json_fuzz_test.cc index bcc062f3c460..7e2f40b89c6f 100644 --- a/test/common/json/json_fuzz_test.cc +++ b/test/common/json/json_fuzz_test.cc @@ -39,10 +39,10 @@ DEFINE_FUZZER(const uint8_t* buf, size_t len) { // round-trip. std::string yaml = MessageUtil::getYamlStringFromMessage(message); ProtobufWkt::Struct yaml_message; - MessageUtil::loadFromYaml(yaml, yaml_message); + TestUtility::loadFromYaml(yaml, yaml_message); ProtobufWkt::Struct message3; - MessageUtil::loadFromYaml(MessageUtil::getYamlStringFromMessage(yaml_message), message3); + TestUtility::loadFromYaml(MessageUtil::getYamlStringFromMessage(yaml_message), message3); FUZZ_ASSERT(TestUtility::protoEqual(yaml_message, message3)); } catch (const Envoy::EnvoyException& e) { ENVOY_LOG_MISC(debug, "Failed due to {}", e.what()); diff --git a/test/common/protobuf/utility_test.cc b/test/common/protobuf/utility_test.cc index bbb9c9c8a913..3d5875da1b22 100644 --- a/test/common/protobuf/utility_test.cc +++ b/test/common/protobuf/utility_test.cc @@ -184,34 +184,6 @@ TEST_F(ProtobufUtilityTest, MessageUtilHash) { EXPECT_NE(MessageUtil::hash(s), MessageUtil::hash(a1)); } -TEST_F(ProtobufUtilityTest, MessageUtilHashAndEqualToIgnoreOriginalTypeField) { - ProtobufWkt::Struct s; - (*s.mutable_fields())["ab"].set_string_value("fgh"); - EXPECT_EQ(1, s.fields_size()); - envoy::api::v2::core::Metadata mv2; - mv2.mutable_filter_metadata()->insert({"xyz", s}); - EXPECT_EQ(1, mv2.filter_metadata_size()); - - // Add the OriginalTypeFieldNumber as unknown field. - envoy::config::core::v3::Metadata mv3; - Config::VersionConverter::upgrade(mv2, mv3); - - // Add another unknown field. - { - const Protobuf::Reflection* reflection = mv3.GetReflection(); - auto* unknown_field_set = reflection->MutableUnknownFields(&mv3); - auto set_size = unknown_field_set->field_count(); - // 183412668 is the magic number OriginalTypeFieldNumber. The successor number should not be - // occupied. - unknown_field_set->AddFixed32(183412668 + 1, 1); - EXPECT_EQ(set_size + 1, unknown_field_set->field_count()) << "Fail to add an unknown field"; - } - - envoy::config::core::v3::Metadata mv3dup = mv3; - ASSERT_EQ(MessageUtil::hash(mv3), MessageUtil::hash(mv3dup)); - ASSERT(MessageUtil()(mv3, mv3dup)); -} - TEST_F(ProtobufUtilityTest, RepeatedPtrUtilDebugString) { Protobuf::RepeatedPtrField repeated; EXPECT_EQ("[]", RepeatedPtrUtil::debugString(repeated)); @@ -381,15 +353,8 @@ TEST_F(ProtobufUtilityTest, LoadBinaryProtoUnknownFieldFromFile) { source_duration.set_seconds(42); const std::string filename = TestEnvironment::writeStringToFileForTest("proto.pb", source_duration.SerializeAsString()); - // Verify without boosting envoy::config::bootstrap::v3::Bootstrap proto_from_file; - EXPECT_THROW_WITH_MESSAGE(TestUtility::loadFromFile(filename, proto_from_file, *api_, false), - EnvoyException, - "Protobuf message (type envoy.config.bootstrap.v3.Bootstrap with " - "unknown field set {1}) has unknown fields"); - - // Verify with boosting - EXPECT_THROW_WITH_MESSAGE(TestUtility::loadFromFile(filename, proto_from_file, *api_, true), + EXPECT_THROW_WITH_MESSAGE(TestUtility::loadFromFile(filename, proto_from_file, *api_), EnvoyException, "Protobuf message (type envoy.config.bootstrap.v3.Bootstrap with " "unknown field set {1}) has unknown fields"); @@ -446,21 +411,6 @@ TEST_F(ProtobufUtilityTest, LoadJsonFromFileNoBoosting) { EXPECT_TRUE(TestUtility::protoEqual(bootstrap, proto_from_file)); } -TEST_F(ProtobufV2ApiUtilityTest, DEPRECATED_FEATURE_TEST(LoadV2TextProtoFromFile)) { - API_NO_BOOST(envoy::config::bootstrap::v2::Bootstrap) bootstrap; - bootstrap.mutable_node()->set_build_version("foo"); - - std::string bootstrap_text; - ASSERT_TRUE(Protobuf::TextFormat::PrintToString(bootstrap, &bootstrap_text)); - const std::string filename = - TestEnvironment::writeStringToFileForTest("proto.pb_text", bootstrap_text); - - API_NO_BOOST(envoy::config::bootstrap::v3::Bootstrap) proto_from_file; - TestUtility::loadFromFile(filename, proto_from_file, *api_); - EXPECT_GT(runtime_deprecated_feature_use_.value(), 0); - EXPECT_EQ("foo", proto_from_file.node().hidden_envoy_deprecated_build_version()); -} - TEST_F(ProtobufUtilityTest, LoadTextProtoFromFile_Failure) { const std::string filename = TestEnvironment::writeStringToFileForTest("proto.pb_text", "invalid {"); @@ -1416,56 +1366,6 @@ TEST_F(ProtobufUtilityTest, UnpackToSameVersion) { } } -// MessageUtility::unpackTo() with API message works across version. -TEST_F(ProtobufV2ApiUtilityTest, UnpackToNextVersion) { - API_NO_BOOST(envoy::api::v2::Cluster) source; - source.set_drain_connections_on_host_removal(true); - ProtobufWkt::Any source_any; - source_any.PackFrom(source); - API_NO_BOOST(envoy::config::cluster::v3::Cluster) dst; - MessageUtil::unpackTo(source_any, dst); - EXPECT_GT(runtime_deprecated_feature_use_.value(), 0); - EXPECT_TRUE(dst.ignore_health_on_host_removal()); -} - -// MessageUtility::unpackTo() with API message works across version and doesn't register -// deprecations for allowlisted v2 protos. -TEST_F(ProtobufV2ApiUtilityTest, UnpackToNextVersionV2Allowed) { - API_NO_BOOST(envoy::config::health_checker::redis::v2::Redis) source; - source.set_key("foo"); - ProtobufWkt::Any source_any; - source_any.PackFrom(source); - API_NO_BOOST(envoy::extensions::health_checkers::redis::v3::Redis) dst; - MessageUtil::unpackTo(source_any, dst); - EXPECT_EQ(runtime_deprecated_feature_use_.value(), 0); - EXPECT_EQ(dst.key(), "foo"); -} - -// Validate warning messages on v2 upgrades. -TEST_F(ProtobufV2ApiUtilityTest, V2UpgradeWarningLogs) { - API_NO_BOOST(envoy::config::cluster::v3::Cluster) dst; - // First attempt works. - EXPECT_LOG_CONTAINS("warn", "Configuration does not parse cleanly as v3", - MessageUtil::loadFromJson("{drain_connections_on_host_removal: true}", dst, - ProtobufMessage::getNullValidationVisitor())); - // Second attempt immediately after fails. - EXPECT_LOG_NOT_CONTAINS("warn", "Configuration does not parse cleanly as v3", - MessageUtil::loadFromJson("{drain_connections_on_host_removal: true}", - dst, - ProtobufMessage::getNullValidationVisitor())); - // Third attempt works, since this is a different log message. - EXPECT_LOG_CONTAINS("warn", "Configuration does not parse cleanly as v3", - MessageUtil::loadFromJson("{drain_connections_on_host_removal: false}", dst, - ProtobufMessage::getNullValidationVisitor())); - // This is kind of terrible, but it's hard to do dependency injection at - // onVersionUpgradeDeprecation(). - std::this_thread::sleep_for(5s); // NOLINT - // We can log the original warning again. - EXPECT_LOG_CONTAINS("warn", "Configuration does not parse cleanly as v3", - MessageUtil::loadFromJson("{drain_connections_on_host_removal: true}", dst, - ProtobufMessage::getNullValidationVisitor())); -} - // MessageUtility::loadFromJson() throws on garbage JSON. TEST_F(ProtobufUtilityTest, LoadFromJsonGarbage) { envoy::config::cluster::v3::Cluster dst; @@ -1511,42 +1411,10 @@ TEST_F(ProtobufUtilityTest, LoadFromJsonNoBoosting) { envoy::config::cluster::v3::Cluster dst; EXPECT_THROW_WITH_REGEX( MessageUtil::loadFromJson("{drain_connections_on_host_removal: true}", dst, - ProtobufMessage::getStrictValidationVisitor(), false), + ProtobufMessage::getStrictValidationVisitor()), EnvoyException, "INVALID_ARGUMENT:drain_connections_on_host_removal: Cannot find field."); } -// MessageUtility::loadFromJson() with API message works across version. -TEST_F(ProtobufV2ApiUtilityTest, LoadFromJsonNextVersion) { - { - API_NO_BOOST(envoy::config::cluster::v3::Cluster) dst; - MessageUtil::loadFromJson("{use_tcp_for_dns_lookups: true}", dst, - ProtobufMessage::getNullValidationVisitor()); - EXPECT_EQ(0, runtime_deprecated_feature_use_.value()); - EXPECT_TRUE(dst.use_tcp_for_dns_lookups()); - } - { - API_NO_BOOST(envoy::config::cluster::v3::Cluster) dst; - MessageUtil::loadFromJson("{use_tcp_for_dns_lookups: true}", dst, - ProtobufMessage::getStrictValidationVisitor()); - EXPECT_EQ(0, runtime_deprecated_feature_use_.value()); - EXPECT_TRUE(dst.use_tcp_for_dns_lookups()); - } - { - API_NO_BOOST(envoy::config::cluster::v3::Cluster) dst; - MessageUtil::loadFromJson("{drain_connections_on_host_removal: true}", dst, - ProtobufMessage::getNullValidationVisitor()); - EXPECT_GT(runtime_deprecated_feature_use_.value(), 0); - EXPECT_TRUE(dst.ignore_health_on_host_removal()); - } - { - API_NO_BOOST(envoy::config::cluster::v3::Cluster) dst; - MessageUtil::loadFromJson("{drain_connections_on_host_removal: true}", dst, - ProtobufMessage::getStrictValidationVisitor()); - EXPECT_GT(runtime_deprecated_feature_use_.value(), 0); - EXPECT_TRUE(dst.ignore_health_on_host_removal()); - } -} - TEST_F(ProtobufUtilityTest, JsonConvertSuccess) { envoy::config::bootstrap::v3::Bootstrap source; source.set_flags_path("foo"); @@ -1692,27 +1560,14 @@ TEST(DurationUtilTest, OutOfRange) { } } -class DeprecatedFieldsTest : public testing::TestWithParam, protected RuntimeStatsHelper { +class DeprecatedFieldsTest : public testing::Test, protected RuntimeStatsHelper { protected: - DeprecatedFieldsTest() : with_upgrade_(GetParam()) {} - void checkForDeprecation(const Protobuf::Message& message) { - if (with_upgrade_) { - envoy::test::deprecation_test::UpgradedBase upgraded_message; - Config::VersionConverter::upgrade(message, upgraded_message); - MessageUtil::checkForUnexpectedFields(upgraded_message, - ProtobufMessage::getStrictValidationVisitor()); - } else { - MessageUtil::checkForUnexpectedFields(message, ProtobufMessage::getStrictValidationVisitor()); - } + MessageUtil::checkForUnexpectedFields(message, ProtobufMessage::getStrictValidationVisitor()); } - - const bool with_upgrade_; }; -INSTANTIATE_TEST_SUITE_P(Versions, DeprecatedFieldsTest, testing::Values(false, true)); - -TEST_P(DeprecatedFieldsTest, NoCrashIfRuntimeMissing) { +TEST_F(DeprecatedFieldsTest, NoCrashIfRuntimeMissing) { loader_.reset(); envoy::test::deprecation_test::Base base; @@ -1721,7 +1576,7 @@ TEST_P(DeprecatedFieldsTest, NoCrashIfRuntimeMissing) { checkForDeprecation(base); } -TEST_P(DeprecatedFieldsTest, NoErrorWhenDeprecatedFieldsUnused) { +TEST_F(DeprecatedFieldsTest, NoErrorWhenDeprecatedFieldsUnused) { envoy::test::deprecation_test::Base base; base.set_not_deprecated("foo"); // Fatal checks for a non-deprecated field should cause no problem. @@ -1730,7 +1585,7 @@ TEST_P(DeprecatedFieldsTest, NoErrorWhenDeprecatedFieldsUnused) { EXPECT_EQ(0, deprecated_feature_seen_since_process_start_.value()); } -TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(IndividualFieldDeprecatedEmitsError)) { +TEST_F(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(IndividualFieldDeprecatedEmitsError)) { envoy::test::deprecation_test::Base base; base.set_is_deprecated("foo"); // Non-fatal checks for a deprecated field should log rather than throw an exception. @@ -1741,7 +1596,7 @@ TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(IndividualFieldDeprecatedEm EXPECT_EQ(1, deprecated_feature_seen_since_process_start_.value()); } -TEST_P(DeprecatedFieldsTest, IndividualFieldDeprecatedEmitsCrash) { +TEST_F(DeprecatedFieldsTest, IndividualFieldDeprecatedEmitsCrash) { envoy::test::deprecation_test::Base base; base.set_is_deprecated("foo"); // Non-fatal checks for a deprecated field should throw an exception if the @@ -1757,7 +1612,7 @@ TEST_P(DeprecatedFieldsTest, IndividualFieldDeprecatedEmitsCrash) { } // Use of a deprecated and disallowed field should result in an exception. -TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(IndividualFieldDisallowed)) { +TEST_F(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(IndividualFieldDisallowed)) { envoy::test::deprecation_test::Base base; base.set_is_deprecated_fatal("foo"); EXPECT_THROW_WITH_REGEX( @@ -1765,7 +1620,7 @@ TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(IndividualFieldDisallowed)) "Using deprecated option 'envoy.test.deprecation_test.Base.is_deprecated_fatal'"); } -TEST_P(DeprecatedFieldsTest, +TEST_F(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(IndividualFieldDisallowedWithRuntimeOverride)) { envoy::test::deprecation_test::Base base; base.set_is_deprecated_fatal("foo"); @@ -1792,7 +1647,7 @@ TEST_P(DeprecatedFieldsTest, } // Test that a deprecated field is allowed with runtime global override. -TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(IndividualFieldDisallowedWithGlobalOverride)) { +TEST_F(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(IndividualFieldDisallowedWithGlobalOverride)) { envoy::test::deprecation_test::Base base; base.set_is_deprecated_fatal("foo"); @@ -1816,7 +1671,7 @@ TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(IndividualFieldDisallowedWi EXPECT_EQ(1, runtime_deprecated_feature_use_.value()); } -TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(DisallowViaRuntime)) { +TEST_F(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(DisallowViaRuntime)) { envoy::test::deprecation_test::Base base; base.set_is_deprecated("foo"); @@ -1848,7 +1703,7 @@ TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(DisallowViaRuntime)) { // Note that given how Envoy config parsing works, the first time we hit a // 'fatal' error and throw, we won't log future warnings. That said, this tests // the case of the warning occurring before the fatal error. -TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(MixOfFatalAndWarnings)) { +TEST_F(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(MixOfFatalAndWarnings)) { envoy::test::deprecation_test::Base base; base.set_is_deprecated("foo"); base.set_is_deprecated_fatal("foo"); @@ -1861,7 +1716,7 @@ TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(MixOfFatalAndWarnings)) { } // Present (unused) deprecated messages should be detected as deprecated. -TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(MessageDeprecated)) { +TEST_F(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(MessageDeprecated)) { envoy::test::deprecation_test::Base base; base.mutable_deprecated_message(); EXPECT_LOG_CONTAINS( @@ -1870,7 +1725,7 @@ TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(MessageDeprecated)) { EXPECT_EQ(1, runtime_deprecated_feature_use_.value()); } -TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(InnerMessageDeprecated)) { +TEST_F(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(InnerMessageDeprecated)) { envoy::test::deprecation_test::Base base; base.mutable_not_deprecated_message()->set_inner_not_deprecated("foo"); // Checks for a non-deprecated field shouldn't trigger warnings @@ -1885,7 +1740,7 @@ TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(InnerMessageDeprecated)) { } // Check that repeated sub-messages get validated. -TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(SubMessageDeprecated)) { +TEST_F(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(SubMessageDeprecated)) { envoy::test::deprecation_test::Base base; base.add_repeated_message(); base.add_repeated_message()->set_inner_deprecated("foo"); @@ -1899,7 +1754,7 @@ TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(SubMessageDeprecated)) { } // Check that deprecated repeated messages trigger -TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(RepeatedMessageDeprecated)) { +TEST_F(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(RepeatedMessageDeprecated)) { envoy::test::deprecation_test::Base base; base.add_deprecated_repeated_message(); @@ -1911,7 +1766,7 @@ TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(RepeatedMessageDeprecated)) } // Check that deprecated enum values trigger for default values -TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(EnumValuesDeprecatedDefault)) { +TEST_F(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(EnumValuesDeprecatedDefault)) { envoy::test::deprecation_test::Base base; base.mutable_enum_container(); @@ -1925,7 +1780,7 @@ TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(EnumValuesDeprecatedDefault } // Check that deprecated enum values trigger for non-default values -TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(EnumValuesDeprecated)) { +TEST_F(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(EnumValuesDeprecated)) { envoy::test::deprecation_test::Base base; base.mutable_enum_container()->set_deprecated_enum( envoy::test::deprecation_test::Base::DEPRECATED_NOT_DEFAULT); @@ -1940,7 +1795,7 @@ TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(EnumValuesDeprecated)) { // Make sure the runtime overrides for protos work, by checking the non-fatal to // fatal option. -TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(RuntimeOverrideEnumDefault)) { +TEST_F(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(RuntimeOverrideEnumDefault)) { envoy::test::deprecation_test::Base base; base.mutable_enum_container(); @@ -1963,7 +1818,7 @@ TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(RuntimeOverrideEnumDefault) } // Make sure the runtime overrides for allowing fatal enums work. -TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(FatalEnum)) { +TEST_F(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(FatalEnum)) { envoy::test::deprecation_test::Base base; base.mutable_enum_container()->set_deprecated_enum( envoy::test::deprecation_test::Base::DEPRECATED_FATAL); @@ -1984,7 +1839,7 @@ TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(FatalEnum)) { } // Make sure the runtime global override for allowing fatal enums work. -TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(FatalEnumGlobalOverride)) { +TEST_F(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(FatalEnumGlobalOverride)) { envoy::test::deprecation_test::Base base; base.mutable_enum_container()->set_deprecated_enum( envoy::test::deprecation_test::Base::DEPRECATED_FATAL); @@ -2006,7 +1861,7 @@ TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(FatalEnumGlobalOverride)) { // Verify that direct use of a hidden_envoy_deprecated field fails, but upgrade // succeeds -TEST_P(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(ManualDeprecatedFieldAddition)) { +TEST_F(DeprecatedFieldsTest, DEPRECATED_FEATURE_TEST(ManualDeprecatedFieldAddition)) { // Create a base message and insert a deprecated field. When upgrading the // deprecated field should be set as deprecated, and a warning should be logged envoy::test::deprecation_test::Base base_should_warn = diff --git a/test/common/router/BUILD b/test/common/router/BUILD index ed6f767661b5..596a8a86e7a3 100644 --- a/test/common/router/BUILD +++ b/test/common/router/BUILD @@ -153,7 +153,6 @@ envoy_cc_test( "//test/test_common:simulated_time_system_lib", "//test/test_common:utility_lib", "@envoy_api//envoy/admin/v3:pkg_cc_proto", - "@envoy_api//envoy/api/v2:pkg_cc_proto", "@envoy_api//envoy/config/core/v3:pkg_cc_proto", "@envoy_api//envoy/config/route/v3:pkg_cc_proto", "@envoy_api//envoy/extensions/filters/network/http_connection_manager/v3:pkg_cc_proto", diff --git a/test/common/router/config_impl_test.cc b/test/common/router/config_impl_test.cc index dae0573b262b..5d11334d5990 100644 --- a/test/common/router/config_impl_test.cc +++ b/test/common/router/config_impl_test.cc @@ -145,17 +145,7 @@ Http::TestRequestHeaderMapImpl genHeaders(const std::string& host, const std::st envoy::config::route::v3::RouteConfiguration parseRouteConfigurationFromYaml(const std::string& yaml) { envoy::config::route::v3::RouteConfiguration route_config; - // Most tests should be v3 and not boost. - bool avoid_boosting = true; - // If we're under TestDeprecatedV2Api, allow boosting. - auto* runtime = Runtime::LoaderSingleton::getExisting(); - if (runtime != nullptr && runtime->threadsafeSnapshot()->runtimeFeatureEnabled( - "envoy.test_only.broken_in_production.enable_deprecated_v2_api")) { - avoid_boosting = false; - } - // Load the file and keep the annotations (in case of an upgrade) to make sure - // validate() observes the upgrade. - TestUtility::loadFromYaml(yaml, route_config, true, avoid_boosting); + TestUtility::loadFromYaml(yaml, route_config); TestUtility::validate(route_config); return route_config; } @@ -3023,8 +3013,8 @@ TEST_F(RouteMatcherTest, ShadowClusterNotFound) { - match: prefix: "/foo" route: - request_mirror_policy: - cluster: some_cluster + request_mirror_policies: + - cluster: some_cluster cluster: www2 )EOF"; @@ -3169,9 +3159,7 @@ TEST_F(RouteMatcherTest, ClusterNotFoundResponseCodeConfig404) { config.route(headers, 0)->routeEntry()->clusterNotFoundResponseCode()); } -// TODO(dereka) DEPRECATED_FEATURE_TEST can be removed when `request_mirror_policy` is removed. -TEST_F(RouteMatcherTest, DEPRECATED_FEATURE_TEST(Shadow)) { - TestDeprecatedV2Api _deprecated_v2_api; +TEST_F(RouteMatcherTest, RequestMirrorPolicies) { const std::string yaml = R"EOF( virtual_hosts: - name: www2 @@ -3181,19 +3169,19 @@ TEST_F(RouteMatcherTest, DEPRECATED_FEATURE_TEST(Shadow)) { - match: prefix: "/foo" route: - request_mirror_policy: - cluster: some_cluster + request_mirror_policies: + - cluster: some_cluster cluster: www2 - match: prefix: "/bar" route: - request_mirror_policy: - cluster: some_cluster2 - runtime_fraction: - default_value: - numerator: 20 - denominator: HUNDRED - runtime_key: foo + request_mirror_policies: + - cluster: some_cluster2 + runtime_fraction: + default_value: + numerator: 20 + denominator: HUNDRED + runtime_key: foo cluster: www2 - match: prefix: "/baz" @@ -3243,75 +3231,8 @@ TEST_F(RouteMatcherTest, DEPRECATED_FEATURE_TEST(Shadow)) { EXPECT_EQ("foo", boz_shadow_policies[1]->runtimeKey()); } -TEST_F(RouteMatcherTest, DEPRECATED_FEATURE_TEST(ShadowPolicyAndPolicies)) { - TestDeprecatedV2Api _deprecated_v2_api; - const std::string yaml = R"EOF( -virtual_hosts: -- name: www2 - domains: - - www.lyft.com - routes: - - match: - prefix: "/foo" - route: - request_mirror_policy: - cluster: some_cluster - request_mirror_policies: - - cluster: some_other_cluster - cluster: www2 - )EOF"; - - EXPECT_THROW_WITH_MESSAGE( - TestConfigImpl(parseRouteConfigurationFromYaml(yaml), factory_context_, true), EnvoyException, - "Cannot specify both request_mirror_policy and request_mirror_policies"); -} - class RouteConfigurationV2 : public testing::Test, public ConfigImplTestBase {}; -// When removing runtime_key: this test can be removed. -TEST_F(RouteConfigurationV2, DEPRECATED_FEATURE_TEST(RequestMirrorPolicy)) { - TestDeprecatedV2Api _deprecated_v2_api; - const std::string yaml = R"EOF( -virtual_hosts: - - name: mirror - domains: [mirror.lyft.com] - routes: - - match: { prefix: "/"} - route: - cluster: foo - request_mirror_policy: - cluster: foo_mirror - runtime_key: will_be_ignored - runtime_fraction: - default_value: - numerator: 20 - denominator: HUNDRED - runtime_key: mirror_key - - )EOF"; - - factory_context_.cluster_manager_.initializeClusters({"foo", "foo_mirror"}, {}); - TestConfigImpl config(parseRouteConfigurationFromYaml(yaml), factory_context_, true); - - EXPECT_EQ("foo_mirror", config.route(genHeaders("mirror.lyft.com", "/foo", "GET"), 0) - ->routeEntry() - ->shadowPolicies()[0] - ->cluster()); - - // `runtime_fraction` takes precedence over the deprecated `runtime_key` field. - EXPECT_EQ("mirror_key", config.route(genHeaders("mirror.lyft.com", "/foo", "GET"), 0) - ->routeEntry() - ->shadowPolicies()[0] - ->runtimeKey()); - - const auto& default_value = config.route(genHeaders("mirror.lyft.com", "/foo", "GET"), 0) - ->routeEntry() - ->shadowPolicies()[0] - ->defaultValue(); - EXPECT_EQ(20, default_value.numerator()); - EXPECT_EQ(envoy::type::v3::FractionalPercent::HUNDRED, default_value.denominator()); -} - TEST_F(RouteMatcherTest, Retry) { const std::string yaml = R"EOF( virtual_hosts: @@ -5390,8 +5311,7 @@ TEST_F(BadHttpRouteConfigurationsTest, BadRouteEntryConfigMissingPathSpecifier) "RouteValidationError.Match"); } -TEST_F(BadHttpRouteConfigurationsTest, DEPRECATED_FEATURE_TEST(BadRouteEntryConfigPrefixAndRegex)) { - TestDeprecatedV2Api _deprecated_v2_api; +TEST_F(BadHttpRouteConfigurationsTest, BadRouteEntryConfigPrefixAndRegex) { const std::string yaml = R"EOF( virtual_hosts: - name: www2 @@ -5400,7 +5320,9 @@ TEST_F(BadHttpRouteConfigurationsTest, DEPRECATED_FEATURE_TEST(BadRouteEntryConf routes: - match: prefix: "/" - regex: "/[bc]at" + safe_regex: + google_re2: {} + regex: "/[bc]at" route: cluster: www2 )EOF"; @@ -5408,7 +5330,7 @@ TEST_F(BadHttpRouteConfigurationsTest, DEPRECATED_FEATURE_TEST(BadRouteEntryConf #ifndef GTEST_USES_SIMPLE_RE EXPECT_THROW_WITH_REGEX( TestConfigImpl(parseRouteConfigurationFromYaml(yaml), factory_context_, true), EnvoyException, - "invalid value oneof field 'path_specifier' is already set. Cannot set '(prefix|regex)' " + "invalid value oneof field 'path_specifier' is already set. Cannot set '(prefix|safe_regex)' " "for " "type oneof"); #else @@ -5418,7 +5340,7 @@ TEST_F(BadHttpRouteConfigurationsTest, DEPRECATED_FEATURE_TEST(BadRouteEntryConf "already set. Cannot set 'prefix' for " "type oneof"), ::testing::ContainsRegex("invalid value oneof field 'path_specifier' is " - "already set. Cannot set 'regex' for " + "already set. Cannot set 'safe_regex' for " "type oneof"))); #endif } @@ -5439,8 +5361,7 @@ TEST_F(BadHttpRouteConfigurationsTest, BadRouteEntryConfigNoAction) { "caused by field: \"action\", reason: is required"); } -TEST_F(BadHttpRouteConfigurationsTest, DEPRECATED_FEATURE_TEST(BadRouteEntryConfigPathAndRegex)) { - TestDeprecatedV2Api _deprecated_v2_api; +TEST_F(BadHttpRouteConfigurationsTest, BadRouteEntryConfigPathAndRegex) { const std::string yaml = R"EOF( virtual_hosts: - name: www2 @@ -5449,7 +5370,9 @@ TEST_F(BadHttpRouteConfigurationsTest, DEPRECATED_FEATURE_TEST(BadRouteEntryConf routes: - match: path: "/foo" - regex: "/[bc]at" + safe_regex: + google_re2: {} + regex: "/[bc]at" route: cluster: www2 )EOF"; @@ -5457,7 +5380,7 @@ TEST_F(BadHttpRouteConfigurationsTest, DEPRECATED_FEATURE_TEST(BadRouteEntryConf #ifndef GTEST_USES_SIMPLE_RE EXPECT_THROW_WITH_REGEX( TestConfigImpl(parseRouteConfigurationFromYaml(yaml), factory_context_, true), EnvoyException, - "invalid value oneof field 'path_specifier' is already set. Cannot set '(path|regex)' " + "invalid value oneof field 'path_specifier' is already set. Cannot set '(path|safe_regex)' " "for " "type oneof"); #else @@ -5467,7 +5390,7 @@ TEST_F(BadHttpRouteConfigurationsTest, DEPRECATED_FEATURE_TEST(BadRouteEntryConf "already set. Cannot set 'path' for " "type oneof"), ::testing::ContainsRegex("invalid value oneof field 'path_specifier' is " - "already set. Cannot set 'regex' for " + "already set. Cannot set 'safe_regex' for " "type oneof"))); #endif } @@ -5482,7 +5405,9 @@ TEST_F(BadHttpRouteConfigurationsTest, BadRouteEntryConfigPrefixAndPathAndRegex) - match: prefix: "/" path: "/foo" - regex: "/[bc]at" + safe_regex: + google_re2: {} + regex: "/[bc]at" route: cluster: www2 )EOF"; @@ -5730,27 +5655,6 @@ TEST_F(RoutePropertyTest, TestRouteCorsConfig) { EXPECT_EQ(cors_policy->allowCredentials(), true); } -TEST_F(RoutePropertyTest, DEPRECATED_FEATURE_TEST(TestBadCorsConfig)) { - TestDeprecatedV2Api _deprecated_v2_api; - const std::string yaml = R"EOF( -virtual_hosts: -- name: default - domains: - - "*" - routes: - - match: - prefix: "/api" - route: - cluster: ats - cors: - enabled: 0 -)EOF"; - - EXPECT_THROW_WITH_REGEX( - TestConfigImpl(parseRouteConfigurationFromYaml(yaml), factory_context_, true), EnvoyException, - "Unable to parse JSON as proto .*: invalid value 0 for type TYPE_BOOL"); -} - TEST_F(RouteMatcherTest, Decorator) { const std::string yaml = R"EOF( virtual_hosts: diff --git a/test/common/router/header_formatter_test.cc b/test/common/router/header_formatter_test.cc index a14d73e0fe8e..7ae5a6e574b4 100644 --- a/test/common/router/header_formatter_test.cc +++ b/test/common/router/header_formatter_test.cc @@ -38,10 +38,9 @@ using ::testing::Return; using ::testing::ReturnPointee; using ::testing::ReturnRef; -static envoy::config::route::v3::Route parseRouteFromV3Yaml(const std::string& yaml, - bool avoid_boosting = true) { +static envoy::config::route::v3::Route parseRouteFromV3Yaml(const std::string& yaml) { envoy::config::route::v3::Route route; - TestUtility::loadFromYaml(yaml, route, false, avoid_boosting); + TestUtility::loadFromYaml(yaml, route); return route; } diff --git a/test/common/router/rds_impl_test.cc b/test/common/router/rds_impl_test.cc index 6ed9e8f1985f..05aba26966cc 100644 --- a/test/common/router/rds_impl_test.cc +++ b/test/common/router/rds_impl_test.cc @@ -750,9 +750,9 @@ class RouteConfigProviderManagerImplTest : public RdsTestBase { }; envoy::config::route::v3::RouteConfiguration -parseRouteConfigurationFromV3Yaml(const std::string& yaml, bool avoid_boosting = true) { +parseRouteConfigurationFromV3Yaml(const std::string& yaml) { envoy::config::route::v3::RouteConfiguration route_config; - TestUtility::loadFromYaml(yaml, route_config, true, avoid_boosting); + TestUtility::loadFromYaml(yaml, route_config); return route_config; } diff --git a/test/common/router/router_ratelimit_test.cc b/test/common/router/router_ratelimit_test.cc index 5911a5b6d395..370a6a62e827 100644 --- a/test/common/router/router_ratelimit_test.cc +++ b/test/common/router/router_ratelimit_test.cc @@ -28,10 +28,9 @@ namespace Envoy { namespace Router { namespace { -envoy::config::route::v3::RateLimit parseRateLimitFromV3Yaml(const std::string& yaml_string, - bool avoid_boosting = true) { +envoy::config::route::v3::RateLimit parseRateLimitFromV3Yaml(const std::string& yaml_string) { envoy::config::route::v3::RateLimit rate_limit; - TestUtility::loadFromYaml(yaml_string, rate_limit, false, avoid_boosting); + TestUtility::loadFromYaml(yaml_string, rate_limit); TestUtility::validate(rate_limit); return rate_limit; } diff --git a/test/common/router/scoped_rds_test.cc b/test/common/router/scoped_rds_test.cc index 8be75180cec1..f1cb48f1da7b 100644 --- a/test/common/router/scoped_rds_test.cc +++ b/test/common/router/scoped_rds_test.cc @@ -2,7 +2,6 @@ #include "envoy/admin/v3/config_dump.pb.h" #include "envoy/admin/v3/config_dump.pb.validate.h" -#include "envoy/api/v2/route.pb.h" #include "envoy/config/core/v3/config_source.pb.h" #include "envoy/config/route/v3/route.pb.h" #include "envoy/config/route/v3/scoped_route.pb.h" @@ -53,7 +52,7 @@ using ::Envoy::Http::TestRequestHeaderMapImpl; envoy::config::route::v3::ScopedRouteConfiguration parseScopedRouteConfigurationFromYaml(const std::string& yaml) { envoy::config::route::v3::ScopedRouteConfiguration scoped_route_config; - TestUtility::loadFromYaml(yaml, scoped_route_config, true); + TestUtility::loadFromYaml(yaml, scoped_route_config); return scoped_route_config; } @@ -61,7 +60,7 @@ envoy::extensions::filters::network::http_connection_manager::v3::HttpConnection parseHttpConnectionManagerFromYaml(const std::string& config_yaml) { envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager http_connection_manager; - TestUtility::loadFromYaml(config_yaml, http_connection_manager, true); + TestUtility::loadFromYaml(config_yaml, http_connection_manager); return http_connection_manager; } @@ -136,7 +135,7 @@ class ScopedRdsTest : public ScopedRoutesTestBase { subscriptionFromConfigSource( _, Eq(Grpc::Common::typeUrl( - API_NO_BOOST(envoy::api::v2::RouteConfiguration)().GetDescriptor()->full_name())), + envoy::config::route::v3::RouteConfiguration().GetDescriptor()->full_name())), _, _, _, _)) .Times(AnyNumber()) .WillRepeatedly( @@ -820,12 +819,12 @@ stat_prefix: foo - name: foo-scoped-routes scoped_route_configs: - name: foo - "@type": type.googleapis.com/envoy.api.v2.ScopedRouteConfiguration + "@type": type.googleapis.com/envoy.config.route.v3.ScopedRouteConfiguration route_configuration_name: foo-route-config key: fragments: { string_key: "172.10.10.10" } - name: foo2 - "@type": type.googleapis.com/envoy.api.v2.ScopedRouteConfiguration + "@type": type.googleapis.com/envoy.config.route.v3.ScopedRouteConfiguration route_configuration_name: foo-route-config2 key: fragments: { string_key: "172.10.10.20" } @@ -855,12 +854,12 @@ route_configuration_name: dynamic-foo-route-config - name: foo-scoped-routes scoped_route_configs: - name: foo - "@type": type.googleapis.com/envoy.api.v2.ScopedRouteConfiguration + "@type": type.googleapis.com/envoy.config.route.v3.ScopedRouteConfiguration route_configuration_name: foo-route-config key: fragments: { string_key: "172.10.10.10" } - name: foo2 - "@type": type.googleapis.com/envoy.api.v2.ScopedRouteConfiguration + "@type": type.googleapis.com/envoy.config.route.v3.ScopedRouteConfiguration route_configuration_name: foo-route-config2 key: fragments: { string_key: "172.10.10.20" } @@ -871,7 +870,7 @@ route_configuration_name: dynamic-foo-route-config - name: foo_scoped_routes scoped_route_configs: - name: dynamic-foo - "@type": type.googleapis.com/envoy.api.v2.ScopedRouteConfiguration + "@type": type.googleapis.com/envoy.config.route.v3.ScopedRouteConfiguration route_configuration_name: dynamic-foo-route-config key: fragments: { string_key: "172.30.30.10" } @@ -898,7 +897,7 @@ route_configuration_name: dynamic-foo-route-config - name: foo-scoped-routes scoped_route_configs: - name: foo - "@type": type.googleapis.com/envoy.api.v2.ScopedRouteConfiguration + "@type": type.googleapis.com/envoy.config.route.v3.ScopedRouteConfiguration route_configuration_name: foo-route-config key: fragments: { string_key: "172.10.10.10" } @@ -934,7 +933,7 @@ route_configuration_name: dynamic-foo-route-config - name: foo_scoped_routes scoped_route_configs: - name: dynamic-foo - "@type": type.googleapis.com/envoy.api.v2.ScopedRouteConfiguration + "@type": type.googleapis.com/envoy.config.route.v3.ScopedRouteConfiguration route_configuration_name: dynamic-foo-route-config key: fragments: { string_key: "172.30.30.10" } @@ -958,12 +957,12 @@ route_configuration_name: dynamic-foo-route-config - name: foo-scoped-routes scoped_route_configs: - name: foo - "@type": type.googleapis.com/envoy.api.v2.ScopedRouteConfiguration + "@type": type.googleapis.com/envoy.config.route.v3.ScopedRouteConfiguration route_configuration_name: foo-route-config key: fragments: { string_key: "172.10.10.10" } - name: foo2 - "@type": type.googleapis.com/envoy.api.v2.ScopedRouteConfiguration + "@type": type.googleapis.com/envoy.config.route.v3.ScopedRouteConfiguration route_configuration_name: foo-route-config2 key: fragments: { string_key: "172.10.10.20" } diff --git a/test/common/tcp_proxy/config_test.cc b/test/common/tcp_proxy/config_test.cc index d5c49016465c..081306ed231d 100644 --- a/test/common/tcp_proxy/config_test.cc +++ b/test/common/tcp_proxy/config_test.cc @@ -11,7 +11,7 @@ cluster: foo )EOF"; NiceMock factory_context; - Config config_obj(constructConfigFromV3Yaml(yaml, factory_context)); + Config config_obj(constructConfigFromYaml(yaml, factory_context)); EXPECT_EQ(std::chrono::hours(1), config_obj.sharedConfig()->idleTimeout().value()); } @@ -23,7 +23,7 @@ idle_timeout: 0s )EOF"; NiceMock factory_context; - Config config_obj(constructConfigFromV3Yaml(yaml, factory_context)); + Config config_obj(constructConfigFromYaml(yaml, factory_context)); EXPECT_FALSE(config_obj.sharedConfig()->idleTimeout().has_value()); } @@ -35,7 +35,7 @@ idle_timeout: 1s )EOF"; NiceMock factory_context; - Config config_obj(constructConfigFromV3Yaml(yaml, factory_context)); + Config config_obj(constructConfigFromYaml(yaml, factory_context)); EXPECT_EQ(std::chrono::seconds(1), config_obj.sharedConfig()->idleTimeout().value()); } @@ -47,7 +47,7 @@ max_downstream_connection_duration: 10s )EOF"; NiceMock factory_context; - Config config_obj(constructConfigFromV3Yaml(yaml, factory_context)); + Config config_obj(constructConfigFromYaml(yaml, factory_context)); EXPECT_EQ(std::chrono::seconds(10), config_obj.maxDownstreamConnectionDuration().value()); } @@ -60,311 +60,6 @@ TEST(ConfigTest, NoRouteConfig) { EXPECT_THROW(constructConfigFromYaml(yaml, factory_context), EnvoyException); } -TEST(ConfigTest, DEPRECATED_FEATURE_TEST(BadConfig)) { - const std::string yaml_string = R"EOF( - stat_prefix: 1 - cluster: cluster - deprecated_v1: - routes: - - cluster: fake_cluster - )EOF"; - - NiceMock factory_context; - EXPECT_THROW(constructConfigFromYaml(yaml_string, factory_context, false), EnvoyException); -} - -TEST(ConfigTest, DEPRECATED_FEATURE_TEST(EmptyRouteConfig)) { - const std::string yaml = R"EOF( - stat_prefix: name - cluster: cluster - deprecated_v1: - routes: [] - )EOF"; - - NiceMock factory_context_; - EXPECT_THROW(constructConfigFromYaml(yaml, factory_context_, false), EnvoyException); -} - -TEST(ConfigTest, DEPRECATED_FEATURE_TEST(Routes)) { - TestDeprecatedV2Api _deprecated_v2_api; - const std::string yaml = R"EOF( - stat_prefix: name - cluster: cluster - deprecated_v1: - routes: - - destination_ip_list: - - address_prefix: 10.10.10.10 - prefix_len: 32 - - address_prefix: 10.10.11.0 - prefix_len: 24 - - address_prefix: 10.11.0.0 - prefix_len: 16 - - address_prefix: 11.0.0.0 - prefix_len: 8 - - address_prefix: 128.0.0.0 - prefix_len: 1 - cluster: with_destination_ip_list - - destination_ip_list: - - address_prefix: "::1" - prefix_len: 128 - - address_prefix: "2001:abcd::" - prefix_len: 64 - cluster: with_v6_destination - - destination_ports: 1-1024,2048-4096,12345 - cluster: with_destination_ports - - source_ports: '23457,23459' - cluster: with_source_ports - - destination_ip_list: - - address_prefix: "2002::" - prefix_len: 32 - source_ip_list: - - address_prefix: "2003::" - prefix_len: 64 - cluster: with_v6_source_and_destination - - destination_ip_list: - - address_prefix: 10.0.0.0 - prefix_len: 24 - source_ip_list: - - address_prefix: 20.0.0.0 - prefix_len: 24 - destination_ports: '10000' - source_ports: '20000' - cluster: with_everything - - cluster: catch_all - )EOF"; - - NiceMock factory_context_; - Config config_obj(constructConfigFromYaml(yaml, factory_context_, false)); - - { - // hit route with destination_ip (10.10.10.10/32) - NiceMock connection; - connection.stream_info_.downstream_address_provider_->setLocalAddress( - std::make_shared("10.10.10.10")); - EXPECT_EQ(std::string("with_destination_ip_list"), - config_obj.getRouteFromEntries(connection)->clusterName()); - } - - { - // fall-through - NiceMock connection; - connection.stream_info_.downstream_address_provider_->setLocalAddress( - std::make_shared("10.10.10.11")); - connection.stream_info_.downstream_address_provider_->setRemoteAddress( - std::make_shared("0.0.0.0")); - EXPECT_EQ(std::string("catch_all"), config_obj.getRouteFromEntries(connection)->clusterName()); - } - - { - // hit route with destination_ip (10.10.11.0/24) - NiceMock connection; - connection.stream_info_.downstream_address_provider_->setLocalAddress( - std::make_shared("10.10.11.11")); - EXPECT_EQ(std::string("with_destination_ip_list"), - config_obj.getRouteFromEntries(connection)->clusterName()); - } - - { - // fall-through - NiceMock connection; - connection.stream_info_.downstream_address_provider_->setLocalAddress( - std::make_shared("10.10.12.12")); - connection.stream_info_.downstream_address_provider_->setRemoteAddress( - std::make_shared("0.0.0.0")); - EXPECT_EQ(std::string("catch_all"), config_obj.getRouteFromEntries(connection)->clusterName()); - } - - { - // hit route with destination_ip (10.11.0.0/16) - NiceMock connection; - connection.stream_info_.downstream_address_provider_->setLocalAddress( - std::make_shared("10.11.11.11")); - EXPECT_EQ(std::string("with_destination_ip_list"), - config_obj.getRouteFromEntries(connection)->clusterName()); - } - - { - // fall-through - NiceMock connection; - connection.stream_info_.downstream_address_provider_->setLocalAddress( - std::make_shared("10.12.12.12")); - connection.stream_info_.downstream_address_provider_->setRemoteAddress( - std::make_shared("0.0.0.0")); - EXPECT_EQ(std::string("catch_all"), config_obj.getRouteFromEntries(connection)->clusterName()); - } - - { - // hit route with destination_ip (11.0.0.0/8) - NiceMock connection; - connection.stream_info_.downstream_address_provider_->setLocalAddress( - std::make_shared("11.11.11.11")); - EXPECT_EQ(std::string("with_destination_ip_list"), - config_obj.getRouteFromEntries(connection)->clusterName()); - } - - { - // fall-through - NiceMock connection; - connection.stream_info_.downstream_address_provider_->setLocalAddress( - std::make_shared("12.12.12.12")); - connection.stream_info_.downstream_address_provider_->setRemoteAddress( - std::make_shared("0.0.0.0")); - EXPECT_EQ(std::string("catch_all"), config_obj.getRouteFromEntries(connection)->clusterName()); - } - - { - // hit route with destination_ip (128.0.0.0/8) - NiceMock connection; - connection.stream_info_.downstream_address_provider_->setLocalAddress( - std::make_shared("128.255.255.255")); - EXPECT_EQ(std::string("with_destination_ip_list"), - config_obj.getRouteFromEntries(connection)->clusterName()); - } - - { - // hit route with destination port range - NiceMock connection; - connection.stream_info_.downstream_address_provider_->setLocalAddress( - std::make_shared("1.2.3.4", 12345)); - EXPECT_EQ(std::string("with_destination_ports"), - config_obj.getRouteFromEntries(connection)->clusterName()); - } - - { - // fall through - NiceMock connection; - connection.stream_info_.downstream_address_provider_->setLocalAddress( - std::make_shared("1.2.3.4", 23456)); - connection.stream_info_.downstream_address_provider_->setRemoteAddress( - std::make_shared("0.0.0.0")); - EXPECT_EQ(std::string("catch_all"), config_obj.getRouteFromEntries(connection)->clusterName()); - } - - { - // hit route with source port range - NiceMock connection; - connection.stream_info_.downstream_address_provider_->setLocalAddress( - std::make_shared("1.2.3.4", 23456)); - connection.stream_info_.downstream_address_provider_->setRemoteAddress( - std::make_shared("0.0.0.0", 23459)); - EXPECT_EQ(std::string("with_source_ports"), - config_obj.getRouteFromEntries(connection)->clusterName()); - } - - { - // fall through - NiceMock connection; - connection.stream_info_.downstream_address_provider_->setLocalAddress( - std::make_shared("1.2.3.4", 23456)); - connection.stream_info_.downstream_address_provider_->setRemoteAddress( - std::make_shared("0.0.0.0", 23458)); - EXPECT_EQ(std::string("catch_all"), config_obj.getRouteFromEntries(connection)->clusterName()); - } - - { - // hit the route with all criteria present - NiceMock connection; - connection.stream_info_.downstream_address_provider_->setLocalAddress( - std::make_shared("10.0.0.0", 10000)); - connection.stream_info_.downstream_address_provider_->setRemoteAddress( - std::make_shared("20.0.0.0", 20000)); - EXPECT_EQ(std::string("with_everything"), - config_obj.getRouteFromEntries(connection)->clusterName()); - } - - { - // fall through - NiceMock connection; - connection.stream_info_.downstream_address_provider_->setLocalAddress( - std::make_shared("10.0.0.0", 10000)); - connection.stream_info_.downstream_address_provider_->setRemoteAddress( - std::make_shared("30.0.0.0", 20000)); - EXPECT_EQ(std::string("catch_all"), config_obj.getRouteFromEntries(connection)->clusterName()); - } - - { - // hit route with destination_ip (::1/128) - NiceMock connection; - connection.stream_info_.downstream_address_provider_->setLocalAddress( - std::make_shared("::1")); - EXPECT_EQ(std::string("with_v6_destination"), - config_obj.getRouteFromEntries(connection)->clusterName()); - } - - { - // hit route with destination_ip ("2001:abcd/64") - NiceMock connection; - connection.stream_info_.downstream_address_provider_->setLocalAddress( - std::make_shared("2001:abcd:0:0:1::")); - EXPECT_EQ(std::string("with_v6_destination"), - config_obj.getRouteFromEntries(connection)->clusterName()); - } - - { - // hit route with destination_ip ("2002::/32") and source_ip ("2003::/64") - NiceMock connection; - connection.stream_info_.downstream_address_provider_->setLocalAddress( - std::make_shared("2002:0:0:0:0:0::1")); - connection.stream_info_.downstream_address_provider_->setRemoteAddress( - std::make_shared("2003:0:0:0:0::5")); - EXPECT_EQ(std::string("with_v6_source_and_destination"), - config_obj.getRouteFromEntries(connection)->clusterName()); - } - - { - // fall through - NiceMock connection; - connection.stream_info_.downstream_address_provider_->setLocalAddress( - std::make_shared("2004::")); - connection.stream_info_.downstream_address_provider_->setRemoteAddress( - std::make_shared("::")); - EXPECT_EQ(std::string("catch_all"), config_obj.getRouteFromEntries(connection)->clusterName()); - } -} - -// Tests that a deprecated_v1 route gets the top-level endpoint selector. -TEST(ConfigTest, DEPRECATED_FEATURE_TEST(RouteWithTopLevelMetadataMatchConfig)) { - TestDeprecatedV2Api _deprecated_v2_api; - const std::string yaml = R"EOF( - stat_prefix: name - cluster: cluster - deprecated_v1: - routes: - - cluster: catch_all - metadata_match: - filter_metadata: - envoy.lb: - k1: v1 - k2: v2 -)EOF"; - - NiceMock factory_context_; - Config config_obj(constructConfigFromYaml(yaml, factory_context_, false)); - - ProtobufWkt::Value v1, v2; - v1.set_string_value("v1"); - v2.set_string_value("v2"); - HashedValue hv1(v1), hv2(v2); - - NiceMock connection; - const auto route = config_obj.getRouteFromEntries(connection); - EXPECT_NE(nullptr, route); - - EXPECT_EQ("catch_all", route->clusterName()); - - const auto* criteria = route->metadataMatchCriteria(); - EXPECT_NE(nullptr, criteria); - - const auto& criterions = criteria->metadataMatchCriteria(); - EXPECT_EQ(2, criterions.size()); - - EXPECT_EQ("k1", criterions[0]->name()); - EXPECT_EQ(hv1, criterions[0]->value()); - - EXPECT_EQ("k2", criterions[1]->name()); - EXPECT_EQ(hv2, criterions[1]->value()); -} - // Tests that it's not possible to define a weighted cluster with 0 weight. TEST(ConfigTest, WeightedClusterWithZeroWeightConfig) { const std::string yaml = R"EOF( @@ -377,7 +72,7 @@ TEST(ConfigTest, WeightedClusterWithZeroWeightConfig) { )EOF"; NiceMock factory_context; - EXPECT_THROW(constructConfigFromV3Yaml(yaml, factory_context), EnvoyException); + EXPECT_THROW(constructConfigFromYaml(yaml, factory_context), EnvoyException); } // Tests that it is possible to define a list of weighted clusters. @@ -393,7 +88,7 @@ TEST(ConfigTest, WeightedClustersConfig) { )EOF"; NiceMock factory_context; - Config config_obj(constructConfigFromV3Yaml(yaml, factory_context)); + Config config_obj(constructConfigFromYaml(yaml, factory_context)); NiceMock connection; EXPECT_CALL(factory_context.api_.random_, random()).WillOnce(Return(0)); @@ -427,7 +122,7 @@ TEST(ConfigTest, WeightedClustersWithMetadataMatchConfig) { )EOF"; NiceMock factory_context; - Config config_obj(constructConfigFromV3Yaml(yaml, factory_context)); + Config config_obj(constructConfigFromYaml(yaml, factory_context)); { ProtobufWkt::Value v1, v2; @@ -514,7 +209,7 @@ TEST(ConfigTest, WeightedClustersWithMetadataMatchAndTopLevelMetadataMatchConfig )EOF"; NiceMock factory_context; - Config config_obj(constructConfigFromV3Yaml(yaml, factory_context)); + Config config_obj(constructConfigFromYaml(yaml, factory_context)); ProtobufWkt::Value v00, v01, v04; v00.set_string_value("v00"); @@ -605,7 +300,7 @@ TEST(ConfigTest, WeightedClustersWithTopLevelMetadataMatchConfig) { )EOF"; NiceMock factory_context; - Config config_obj(constructConfigFromV3Yaml(yaml, factory_context)); + Config config_obj(constructConfigFromYaml(yaml, factory_context)); ProtobufWkt::Value v1, v2; v1.set_string_value("v1"); @@ -644,7 +339,7 @@ TEST(ConfigTest, TopLevelMetadataMatchConfig) { )EOF"; NiceMock factory_context; - Config config_obj(constructConfigFromV3Yaml(yaml, factory_context)); + Config config_obj(constructConfigFromYaml(yaml, factory_context)); ProtobufWkt::Value v1, v2; v1.set_string_value("v1"); @@ -677,7 +372,7 @@ TEST(ConfigTest, ClusterWithTopLevelMetadataMatchConfig) { )EOF"; NiceMock factory_context; - Config config_obj(constructConfigFromV3Yaml(yaml, factory_context)); + Config config_obj(constructConfigFromYaml(yaml, factory_context)); ProtobufWkt::Value v1, v2; v1.set_string_value("v1"); @@ -716,7 +411,7 @@ TEST(ConfigTest, PerConnectionClusterWithTopLevelMetadataMatchConfig) { )EOF"; NiceMock factory_context; - Config config_obj(constructConfigFromV3Yaml(yaml, factory_context)); + Config config_obj(constructConfigFromYaml(yaml, factory_context)); ProtobufWkt::Value v1, v2; v1.set_string_value("v1"); @@ -755,7 +450,7 @@ TEST(ConfigTest, HashWithSourceIpConfig) { )EOF"; NiceMock factory_context; - Config config_obj(constructConfigFromV3Yaml(yaml, factory_context)); + Config config_obj(constructConfigFromYaml(yaml, factory_context)); EXPECT_NE(nullptr, config_obj.hashPolicy()); } @@ -766,7 +461,7 @@ TEST(ConfigTest, HashWithSourceIpDefaultConfig) { )EOF"; NiceMock factory_context; - Config config_obj(constructConfigFromV3Yaml(yaml, factory_context)); + Config config_obj(constructConfigFromYaml(yaml, factory_context)); EXPECT_EQ(nullptr, config_obj.hashPolicy()); } @@ -796,24 +491,16 @@ TEST(ConfigTest, AccessLogConfig) { EXPECT_EQ(2, config_obj.accessLogs().size()); } -class TcpProxyRoutingTest : public testing::Test { +class TcpProxyNonDeprecatedConfigRoutingTest : public testing::Test { public: - TcpProxyRoutingTest() = default; - - void setup(bool avoid_boosting = true) { + void setup() { const std::string yaml = R"EOF( stat_prefix: name - cluster: fallback_cluster - deprecated_v1: - routes: - - destination_ports: 1-9999 - cluster: fake_cluster + cluster: fake_cluster )EOF"; - factory_context_.cluster_manager_.initializeThreadLocalClusters( - {"fallback_cluster", "fake_cluster"}); - config_ = - std::make_shared(constructConfigFromYaml(yaml, factory_context_, avoid_boosting)); + factory_context_.cluster_manager_.initializeThreadLocalClusters({"fake_cluster"}); + config_ = std::make_shared(constructConfigFromYaml(yaml, factory_context_)); } void initializeFilter() { @@ -823,8 +510,6 @@ class TcpProxyRoutingTest : public testing::Test { filter_->initializeReadFilterCallbacks(filter_callbacks_); } - Event::TestTimeSystem& timeSystem() { return factory_context_.timeSystem(); } - NiceMock factory_context_; ConfigSharedPtr config_; NiceMock connection_; @@ -832,145 +517,6 @@ class TcpProxyRoutingTest : public testing::Test { std::unique_ptr filter_; }; -TEST_F(TcpProxyRoutingTest, DEPRECATED_FEATURE_TEST(NonRoutableConnection)) { - TestDeprecatedV2Api _deprecated_v2_api; - setup(false); - - const uint32_t total_cx = config_->stats().downstream_cx_total_.value(); - const uint32_t non_routable_cx = config_->stats().downstream_cx_no_route_.value(); - - initializeFilter(); - - // Port 10000 is outside the specified destination port range. - connection_.stream_info_.downstream_address_provider_->setLocalAddress( - std::make_shared("1.2.3.4", 10000)); - - // Expect filter to try to open a connection to the fallback cluster. - EXPECT_CALL(factory_context_.cluster_manager_.thread_local_cluster_, tcpConnPool(_, _)) - .WillOnce(Return(absl::nullopt)); - - filter_->onNewConnection(); - - EXPECT_EQ(total_cx + 1, config_->stats().downstream_cx_total_.value()); - EXPECT_EQ(non_routable_cx, config_->stats().downstream_cx_no_route_.value()); -} - -TEST_F(TcpProxyRoutingTest, DEPRECATED_FEATURE_TEST(RoutableConnection)) { - TestDeprecatedV2Api _deprecated_v2_api; - setup(false); - - const uint32_t total_cx = config_->stats().downstream_cx_total_.value(); - const uint32_t non_routable_cx = config_->stats().downstream_cx_no_route_.value(); - - initializeFilter(); - - // Port 9999 is within the specified destination port range. - connection_.stream_info_.downstream_address_provider_->setLocalAddress( - std::make_shared("1.2.3.4", 9999)); - - // Expect filter to try to open a connection to specified cluster. - EXPECT_CALL(factory_context_.cluster_manager_.thread_local_cluster_, tcpConnPool(_, _)) - .WillOnce(Return(absl::nullopt)); - - filter_->onNewConnection(); - - EXPECT_EQ(total_cx + 1, config_->stats().downstream_cx_total_.value()); - EXPECT_EQ(non_routable_cx, config_->stats().downstream_cx_no_route_.value()); -} - -// Test that the tcp proxy uses the cluster from FilterState if set -TEST_F(TcpProxyRoutingTest, DEPRECATED_FEATURE_TEST(UseClusterFromPerConnectionCluster)) { - TestDeprecatedV2Api _deprecated_v2_api; - setup(false); - initializeFilter(); - - factory_context_.cluster_manager_.initializeThreadLocalClusters({"filter_state_cluster"}); - connection_.streamInfo().filterState()->setData( - "envoy.tcp_proxy.cluster", std::make_unique("filter_state_cluster"), - StreamInfo::FilterState::StateType::Mutable, StreamInfo::FilterState::LifeSpan::Connection); - - // Expect filter to try to open a connection to specified cluster. - EXPECT_CALL(factory_context_.cluster_manager_.thread_local_cluster_, tcpConnPool(_, _)) - .WillOnce(Return(absl::nullopt)); - - filter_->onNewConnection(); -} - -// Test that the tcp proxy forwards the requested server name from FilterState if set -TEST_F(TcpProxyRoutingTest, DEPRECATED_FEATURE_TEST(UpstreamServerName)) { - TestDeprecatedV2Api _deprecated_v2_api; - setup(false); - initializeFilter(); - - connection_.streamInfo().filterState()->setData( - "envoy.network.upstream_server_name", - std::make_unique("www.example.com"), - StreamInfo::FilterState::StateType::ReadOnly, StreamInfo::FilterState::LifeSpan::Connection); - - // Expect filter to try to open a connection to a cluster with the transport socket options with - // override-server-name - EXPECT_CALL(factory_context_.cluster_manager_.thread_local_cluster_, tcpConnPool(_, _)) - .WillOnce(Invoke([](Upstream::ResourcePriority, Upstream::LoadBalancerContext* context) { - Network::TransportSocketOptionsConstSharedPtr transport_socket_options = - context->upstreamTransportSocketOptions(); - EXPECT_NE(transport_socket_options, nullptr); - EXPECT_TRUE(transport_socket_options->serverNameOverride().has_value()); - EXPECT_EQ(transport_socket_options->serverNameOverride().value(), "www.example.com"); - return absl::nullopt; - })); - - // Port 9999 is within the specified destination port range. - connection_.stream_info_.downstream_address_provider_->setLocalAddress( - std::make_shared("1.2.3.4", 9999)); - - filter_->onNewConnection(); -} - -// Test that the tcp proxy override ALPN from FilterState if set -TEST_F(TcpProxyRoutingTest, DEPRECATED_FEATURE_TEST(ApplicationProtocols)) { - TestDeprecatedV2Api _deprecated_v2_api; - setup(false); - initializeFilter(); - - connection_.streamInfo().filterState()->setData( - Network::ApplicationProtocols::key(), - std::make_unique(std::vector{"foo", "bar"}), - StreamInfo::FilterState::StateType::ReadOnly, StreamInfo::FilterState::LifeSpan::Connection); - - // Expect filter to try to open a connection to a cluster with the transport socket options with - // override-application-protocol - EXPECT_CALL(factory_context_.cluster_manager_.thread_local_cluster_, tcpConnPool(_, _)) - .WillOnce(Invoke([](Upstream::ResourcePriority, Upstream::LoadBalancerContext* context) { - Network::TransportSocketOptionsConstSharedPtr transport_socket_options = - context->upstreamTransportSocketOptions(); - EXPECT_NE(transport_socket_options, nullptr); - EXPECT_FALSE(transport_socket_options->applicationProtocolListOverride().empty()); - EXPECT_EQ(transport_socket_options->applicationProtocolListOverride().size(), 2); - EXPECT_EQ(transport_socket_options->applicationProtocolListOverride()[0], "foo"); - EXPECT_EQ(transport_socket_options->applicationProtocolListOverride()[1], "bar"); - return absl::nullopt; - })); - - // Port 9999 is within the specified destination port range. - connection_.stream_info_.downstream_address_provider_->setLocalAddress( - std::make_shared("1.2.3.4", 9999)); - - filter_->onNewConnection(); -} - -class TcpProxyNonDeprecatedConfigRoutingTest : public TcpProxyRoutingTest { -public: - void setup() { - const std::string yaml = R"EOF( - stat_prefix: name - cluster: fake_cluster - )EOF"; - - factory_context_.cluster_manager_.initializeThreadLocalClusters({"fake_cluster"}); - config_ = std::make_shared(constructConfigFromYaml(yaml, factory_context_)); - } -}; - TEST_F(TcpProxyNonDeprecatedConfigRoutingTest, ClusterNameSet) { setup(); diff --git a/test/common/tcp_proxy/tcp_proxy_test.cc b/test/common/tcp_proxy/tcp_proxy_test.cc index 7f4e50f541d4..4168ded703d8 100644 --- a/test/common/tcp_proxy/tcp_proxy_test.cc +++ b/test/common/tcp_proxy/tcp_proxy_test.cc @@ -136,15 +136,8 @@ class TcpProxyTest : public TcpProxyTestBase { } }; -TEST_F(TcpProxyTest, DefaultRoutes) { - envoy::extensions::filters::network::tcp_proxy::v3::TcpProxy config = defaultConfig(); - - envoy::extensions::filters::network::tcp_proxy::v3::TcpProxy::WeightedCluster::ClusterWeight* - ignored_cluster = config.mutable_weighted_clusters()->mutable_clusters()->Add(); - ignored_cluster->set_name("ignored_cluster"); - ignored_cluster->set_weight(10); - - configure(config); +TEST_F(TcpProxyTest, ExplicitCluster) { + configure(defaultConfig()); NiceMock connection; EXPECT_EQ(std::string("fake_cluster"), config_->getRouteFromEntries(connection)->clusterName()); diff --git a/test/common/tcp_proxy/tcp_proxy_test_base.h b/test/common/tcp_proxy/tcp_proxy_test_base.h index 37676f5bbced..b6b437b2f38e 100644 --- a/test/common/tcp_proxy/tcp_proxy_test_base.h +++ b/test/common/tcp_proxy/tcp_proxy_test_base.h @@ -51,18 +51,9 @@ using ::testing::SaveArg; } // namespace inline Config constructConfigFromYaml(const std::string& yaml, - Server::Configuration::FactoryContext& context, - bool avoid_boosting = true) { + Server::Configuration::FactoryContext& context) { envoy::extensions::filters::network::tcp_proxy::v3::TcpProxy tcp_proxy; - TestUtility::loadFromYamlAndValidate(yaml, tcp_proxy, false, avoid_boosting); - return Config(tcp_proxy, context); -} - -inline Config constructConfigFromV3Yaml(const std::string& yaml, - Server::Configuration::FactoryContext& context, - bool avoid_boosting = true) { - envoy::extensions::filters::network::tcp_proxy::v3::TcpProxy tcp_proxy; - TestUtility::loadFromYamlAndValidate(yaml, tcp_proxy, false, avoid_boosting); + TestUtility::loadFromYamlAndValidate(yaml, tcp_proxy); return Config(tcp_proxy, context); } @@ -98,8 +89,7 @@ class TcpProxyTestBase : public testing::Test { envoy::extensions::filters::network::tcp_proxy::v3::TcpProxy defaultConfig() { envoy::extensions::filters::network::tcp_proxy::v3::TcpProxy config; config.set_stat_prefix("name"); - auto* route = config.mutable_hidden_envoy_deprecated_deprecated_v1()->mutable_routes()->Add(); - route->set_cluster("fake_cluster"); + config.set_cluster("fake_cluster"); return config; } diff --git a/test/common/upstream/cluster_manager_impl_test.cc b/test/common/upstream/cluster_manager_impl_test.cc index 812ae44e2d8f..652fdac6ba90 100644 --- a/test/common/upstream/cluster_manager_impl_test.cc +++ b/test/common/upstream/cluster_manager_impl_test.cc @@ -59,10 +59,9 @@ using ::testing::SaveArg; using namespace std::chrono_literals; -envoy::config::bootstrap::v3::Bootstrap parseBootstrapFromV3Yaml(const std::string& yaml, - bool avoid_boosting = true) { +envoy::config::bootstrap::v3::Bootstrap parseBootstrapFromV3Yaml(const std::string& yaml) { envoy::config::bootstrap::v3::Bootstrap bootstrap; - TestUtility::loadFromYaml(yaml, bootstrap, true, avoid_boosting); + TestUtility::loadFromYaml(yaml, bootstrap); return bootstrap; } diff --git a/test/common/upstream/eds_speed_test.cc b/test/common/upstream/eds_speed_test.cc index e6da3c12a1ec..0eb5fae8bd60 100644 --- a/test/common/upstream/eds_speed_test.cc +++ b/test/common/upstream/eds_speed_test.cc @@ -39,18 +39,16 @@ namespace Upstream { class EdsSpeedTest { public: - EdsSpeedTest(State& state, bool v2_config) - : state_(state), v2_config_(v2_config), - type_url_(v2_config_ - ? "type.googleapis.com/envoy.api.v2.ClusterLoadAssignment" - : "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment"), + EdsSpeedTest(State& state) + : state_(state), + type_url_("type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment"), subscription_stats_(Config::Utility::generateStats(stats_)), api_(Api::createApiForTest(stats_)), async_client_(new Grpc::MockAsyncClient()), grpc_mux_(new Config::GrpcMuxImpl( local_info_, std::unique_ptr(async_client_), dispatcher_, *Protobuf::DescriptorPool::generated_pool()->FindMethodByName( "envoy.service.endpoint.v3.EndpointDiscoveryService.StreamEndpoints"), - envoy::config::core::v3::ApiVersion::AUTO, random_, stats_, {}, true)) { + random_, stats_, {}, true)) { resetCluster(R"EOF( name: name connect_timeout: 0.25s @@ -129,12 +127,6 @@ class EdsSpeedTest { response->set_version_info(fmt::format("version-{}", version_++)); auto* resource = response->mutable_resources()->Add(); resource->PackFrom(cluster_load_assignment); - if (v2_config_) { - RELEASE_ASSERT(resource->type_url() == - "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment", - ""); - resource->set_type_url("type.googleapis.com/envoy.api.v2.ClusterLoadAssignment"); - } state_.ResumeTiming(); grpc_mux_->grpcStreamForTest().onReceiveMessage(std::move(response)); ASSERT(cluster_->prioritySet().hostSetsPerPriority()[1]->hostsPerLocality().get()[0].size() == @@ -143,7 +135,6 @@ class EdsSpeedTest { TestDeprecatedV2Api _deprecated_v2_api_; State& state_; - const bool v2_config_; const std::string type_url_; uint64_t version_{}; bool initialized_{}; @@ -180,16 +171,16 @@ static void priorityAndLocalityWeighted(State& state) { Envoy::Logger::Context logging_state(spdlog::level::warn, Envoy::Logger::Logger::DEFAULT_LOG_FORMAT, lock, false); for (auto _ : state) { - Envoy::Upstream::EdsSpeedTest speed_test(state, state.range(0)); + Envoy::Upstream::EdsSpeedTest speed_test(state); // if we've been instructed to skip tests, only run once no matter the argument: - uint32_t endpoints = skipExpensiveBenchmarks() ? 1 : state.range(2); + uint32_t endpoints = skipExpensiveBenchmarks() ? 1 : state.range(1); - speed_test.priorityAndLocalityWeightedHelper(state.range(1), endpoints, true); + speed_test.priorityAndLocalityWeightedHelper(state.range(0), endpoints, true); } } BENCHMARK(priorityAndLocalityWeighted) - ->Ranges({{false, true}, {false, true}, {1, 100000}}) + ->Ranges({{false, true}, {1, 100000}}) ->Unit(benchmark::kMillisecond); static void duplicateUpdate(State& state) { @@ -198,7 +189,7 @@ static void duplicateUpdate(State& state) { Envoy::Logger::Logger::DEFAULT_LOG_FORMAT, lock, false); for (auto _ : state) { - Envoy::Upstream::EdsSpeedTest speed_test(state, false); + Envoy::Upstream::EdsSpeedTest speed_test(state); uint32_t endpoints = skipExpensiveBenchmarks() ? 1 : state.range(0); speed_test.priorityAndLocalityWeightedHelper(true, endpoints, true); @@ -213,7 +204,7 @@ static void healthOnlyUpdate(State& state) { Envoy::Logger::Context logging_state(spdlog::level::warn, Envoy::Logger::Logger::DEFAULT_LOG_FORMAT, lock, false); for (auto _ : state) { - Envoy::Upstream::EdsSpeedTest speed_test(state, false); + Envoy::Upstream::EdsSpeedTest speed_test(state); uint32_t endpoints = skipExpensiveBenchmarks() ? 1 : state.range(0); speed_test.priorityAndLocalityWeightedHelper(true, endpoints, true); diff --git a/test/common/upstream/hds_test.cc b/test/common/upstream/hds_test.cc index 7f0801af4a6f..48c673784d2b 100644 --- a/test/common/upstream/hds_test.cc +++ b/test/common/upstream/hds_test.cc @@ -93,8 +93,7 @@ class HdsTest : public testing::Test { .WillRepeatedly(testing::ReturnNew>()); hds_delegate_ = std::make_unique( - stats_store_, Grpc::RawAsyncClientPtr(async_client_), - envoy::config::core::v3::ApiVersion::AUTO, dispatcher_, runtime_, stats_store_, + stats_store_, Grpc::RawAsyncClientPtr(async_client_), dispatcher_, runtime_, stats_store_, ssl_context_manager_, test_factory_, log_manager_, cm_, local_info_, admin_, singleton_manager_, tls_, validation_visitor_, *api_, options_); } diff --git a/test/common/upstream/health_checker_impl_test.cc b/test/common/upstream/health_checker_impl_test.cc index 060148b9aeac..e41010cb3172 100644 --- a/test/common/upstream/health_checker_impl_test.cc +++ b/test/common/upstream/health_checker_impl_test.cc @@ -147,9 +147,9 @@ class HttpHealthCheckerImplTest : public Event::TestUsingSimulatedTime, absl::node_hash_map; - void allocHealthChecker(const std::string& yaml, bool avoid_boosting = true) { + void allocHealthChecker(const std::string& yaml) { health_checker_ = std::make_shared( - *cluster_, parseHealthCheckFromV3Yaml(yaml, avoid_boosting), dispatcher_, runtime_, random_, + *cluster_, parseHealthCheckFromV3Yaml(yaml), dispatcher_, runtime_, random_, HealthCheckEventLoggerPtr(event_logger_storage_.release())); } @@ -2948,9 +2948,9 @@ class TestProdHttpHealthChecker : public ProdHttpHealthCheckerImpl { class ProdHttpHealthCheckerTest : public testing::Test, public HealthCheckerTestBase { public: - void allocHealthChecker(const std::string& yaml, bool avoid_boosting = true) { + void allocHealthChecker(const std::string& yaml) { health_checker_ = std::make_shared( - *cluster_, parseHealthCheckFromV3Yaml(yaml, avoid_boosting), dispatcher_, runtime_, random_, + *cluster_, parseHealthCheckFromV3Yaml(yaml), dispatcher_, runtime_, random_, HealthCheckEventLoggerPtr(event_logger_storage_.release())); } @@ -3025,7 +3025,7 @@ TEST_F(HttpHealthCheckerImplTest, Http1CodecClient) { codec_client_type: Http1 )EOF"; - allocHealthChecker(yaml, false); + allocHealthChecker(yaml); addCompletionCallback(); EXPECT_EQ(Http::CodecType::HTTP1, health_checker_->codecClientType()); } @@ -3045,7 +3045,7 @@ TEST_F(HttpHealthCheckerImplTest, Http2CodecClient) { codec_client_type: Http2 )EOF"; - allocHealthChecker(yaml, false); + allocHealthChecker(yaml); addCompletionCallback(); EXPECT_EQ(Http::CodecType::HTTP2, health_checker_->codecClientType()); } @@ -3370,9 +3370,9 @@ class TcpHealthCheckerImplTest : public testing::Test, public HealthCheckerTestBase, public Event::TestUsingSimulatedTime { public: - void allocHealthChecker(const std::string& yaml, bool avoid_boosting = true) { + void allocHealthChecker(const std::string& yaml) { health_checker_ = std::make_shared( - *cluster_, parseHealthCheckFromV3Yaml(yaml, avoid_boosting), dispatcher_, runtime_, random_, + *cluster_, parseHealthCheckFromV3Yaml(yaml), dispatcher_, runtime_, random_, HealthCheckEventLoggerPtr(event_logger_storage_.release())); } diff --git a/test/common/upstream/load_stats_reporter_test.cc b/test/common/upstream/load_stats_reporter_test.cc index 81edc2ed4377..9790151c2c5e 100644 --- a/test/common/upstream/load_stats_reporter_test.cc +++ b/test/common/upstream/load_stats_reporter_test.cc @@ -45,8 +45,7 @@ class LoadStatsReporterTest : public testing::Test { return response_timer_; })); load_stats_reporter_ = std::make_unique( - local_info_, cm_, stats_store_, Grpc::RawAsyncClientPtr(async_client_), - envoy::config::core::v3::ApiVersion::AUTO, dispatcher_); + local_info_, cm_, stats_store_, Grpc::RawAsyncClientPtr(async_client_), dispatcher_); } void expectSendMessage( diff --git a/test/common/upstream/logical_dns_cluster_test.cc b/test/common/upstream/logical_dns_cluster_test.cc index bd7f0805a7ac..9afdd78e71c9 100644 --- a/test/common/upstream/logical_dns_cluster_test.cc +++ b/test/common/upstream/logical_dns_cluster_test.cc @@ -44,11 +44,10 @@ class LogicalDnsClusterTest : public Event::TestUsingSimulatedTime, public testi protected: LogicalDnsClusterTest() : api_(Api::createApiForTest(stats_store_, random_)) {} - void setupFromV3Yaml(const std::string& yaml, bool avoid_boosting = true) { + void setupFromV3Yaml(const std::string& yaml) { resolve_timer_ = new Event::MockTimer(&dispatcher_); NiceMock cm; - envoy::config::cluster::v3::Cluster cluster_config = - parseClusterFromV3Yaml(yaml, avoid_boosting); + envoy::config::cluster::v3::Cluster cluster_config = parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_store_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); diff --git a/test/common/upstream/original_dst_cluster_test.cc b/test/common/upstream/original_dst_cluster_test.cc index 9b5cb0db5abe..fd5b9d3d237b 100644 --- a/test/common/upstream/original_dst_cluster_test.cc +++ b/test/common/upstream/original_dst_cluster_test.cc @@ -71,9 +71,7 @@ class OriginalDstClusterTest : public Event::TestUsingSimulatedTime, public test : cleanup_timer_(new Event::MockTimer(&dispatcher_)), api_(Api::createApiForTest(stats_store_)) {} - void setupFromYaml(const std::string& yaml, bool avoid_boosting = true) { - setup(parseClusterFromV3Yaml(yaml, avoid_boosting)); - } + void setupFromYaml(const std::string& yaml) { setup(parseClusterFromV3Yaml(yaml)); } void setup(const envoy::config::cluster::v3::Cluster& cluster_config) { NiceMock cm; diff --git a/test/common/upstream/upstream_impl_test.cc b/test/common/upstream/upstream_impl_test.cc index b20fbdea5a43..029b12bc33d8 100644 --- a/test/common/upstream/upstream_impl_test.cc +++ b/test/common/upstream/upstream_impl_test.cc @@ -2405,9 +2405,8 @@ class ClusterInfoImplTest : public testing::Test { public: ClusterInfoImplTest() : api_(Api::createApiForTest(stats_, random_)) {} - std::unique_ptr makeCluster(const std::string& yaml, - bool avoid_boosting = true) { - cluster_config_ = parseClusterFromV3Yaml(yaml, avoid_boosting); + std::unique_ptr makeCluster(const std::string& yaml) { + cluster_config_ = parseClusterFromV3Yaml(yaml); scope_ = stats_.createScope(fmt::format("cluster.{}.", cluster_config_.alt_stat_name().empty() ? cluster_config_.name() : cluster_config_.alt_stat_name())); @@ -2668,7 +2667,7 @@ TEST_F(ClusterInfoImplTest, ExtensionProtocolOptionsForUnknownFilter) { option: "value" )EOF"; - EXPECT_THROW_WITH_MESSAGE(makeCluster(yaml, false), EnvoyException, + EXPECT_THROW_WITH_MESSAGE(makeCluster(yaml), EnvoyException, "Didn't find a registered network or http filter or " "protocol options implementation for name: 'no_such_filter'"); } @@ -2876,7 +2875,7 @@ TEST_F(ClusterInfoImplTest, Timeouts) { } { auto cluster2 = makeCluster(yaml + explicit_timeout_new); - EXPECT_THROW_WITH_REGEX(makeCluster(yaml + explicit_timeout_bad, false), EnvoyException, + EXPECT_THROW_WITH_REGEX(makeCluster(yaml + explicit_timeout_bad), EnvoyException, ".*Proto constraint validation failed.*"); } const std::string no_timeout = R"EOF( @@ -3134,13 +3133,13 @@ TEST_F(ClusterInfoImplTest, ExtensionProtocolOptionsForFilterWithoutOptions) { TestNetworkFilterConfigFactory factory(factoryBase); Registry::InjectFactory registry( factory); - EXPECT_THROW_WITH_MESSAGE(makeCluster(yaml, false), EnvoyException, + EXPECT_THROW_WITH_MESSAGE(makeCluster(yaml), EnvoyException, "filter envoy.test.filter does not support protocol options"); } { TestHttpFilterConfigFactory factory(factoryBase); Registry::InjectFactory registry(factory); - EXPECT_THROW_WITH_MESSAGE(makeCluster(yaml, false), EnvoyException, + EXPECT_THROW_WITH_MESSAGE(makeCluster(yaml), EnvoyException, "filter envoy.test.filter does not support protocol options"); } } diff --git a/test/common/upstream/utility.h b/test/common/upstream/utility.h index e3f3a18a11f7..673d9349d805 100644 --- a/test/common/upstream/utility.h +++ b/test/common/upstream/utility.h @@ -55,23 +55,21 @@ inline std::string defaultStaticClusterJson(const std::string& name) { } inline envoy::config::bootstrap::v3::Bootstrap -parseBootstrapFromV3Json(const std::string& json_string, bool avoid_boosting = true) { +parseBootstrapFromV3Json(const std::string& json_string) { envoy::config::bootstrap::v3::Bootstrap bootstrap; - TestUtility::loadFromJson(json_string, bootstrap, true, avoid_boosting); + TestUtility::loadFromJson(json_string, bootstrap); return bootstrap; } -inline envoy::config::cluster::v3::Cluster parseClusterFromV3Json(const std::string& json_string, - bool avoid_boosting = true) { +inline envoy::config::cluster::v3::Cluster parseClusterFromV3Json(const std::string& json_string) { envoy::config::cluster::v3::Cluster cluster; - TestUtility::loadFromJson(json_string, cluster, true, avoid_boosting); + TestUtility::loadFromJson(json_string, cluster); return cluster; } -inline envoy::config::cluster::v3::Cluster parseClusterFromV3Yaml(const std::string& yaml, - bool avoid_boosting = true) { +inline envoy::config::cluster::v3::Cluster parseClusterFromV3Yaml(const std::string& yaml) { envoy::config::cluster::v3::Cluster cluster; - TestUtility::loadFromYaml(yaml, cluster, true, avoid_boosting); + TestUtility::loadFromYaml(yaml, cluster); return cluster; } @@ -166,9 +164,9 @@ makeLocalityWeights(std::initializer_list locality_weights) { } inline envoy::config::core::v3::HealthCheck -parseHealthCheckFromV3Yaml(const std::string& yaml_string, bool avoid_boosting = true) { +parseHealthCheckFromV3Yaml(const std::string& yaml_string) { envoy::config::core::v3::HealthCheck health_check; - TestUtility::loadFromYamlAndValidate(yaml_string, health_check, false, avoid_boosting); + TestUtility::loadFromYamlAndValidate(yaml_string, health_check); return health_check; } diff --git a/test/config/utility.cc b/test/config/utility.cc index ac21e0fc3164..4c39561331fa 100644 --- a/test/config/utility.cc +++ b/test/config/utility.cc @@ -355,24 +355,19 @@ std::string ConfigHelper::discoveredClustersBootstrap(const std::string& api_typ } // TODO(#6327) cleaner approach to testing with static config. -std::string ConfigHelper::adsBootstrap(const std::string& api_type, - envoy::config::core::v3::ApiVersion resource_api_version, - envoy::config::core::v3::ApiVersion transport_api_version) { +std::string ConfigHelper::adsBootstrap(const std::string& api_type) { // We use this to allow tests to default to having a single API version but override and make // the transport/resource API version distinction when needed. - if (transport_api_version == envoy::config::core::v3::ApiVersion::AUTO) { - transport_api_version = resource_api_version; - } return fmt::format(R"EOF( dynamic_resources: lds_config: - resource_api_version: {1} + resource_api_version: V3 ads: {{}} cds_config: - resource_api_version: {1} + resource_api_version: V3 ads: {{}} ads_config: - transport_api_version: {2} + transport_api_version: V3 api_type: {0} set_node_on_first_message_only: true static_resources: @@ -401,16 +396,13 @@ std::string ConfigHelper::adsBootstrap(const std::string& api_type, - name: envoy.access_loggers.file typed_config: "@type": type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog - path: "{3}" + path: "{1}" address: socket_address: address: 127.0.0.1 port_value: 0 )EOF", - api_type, - resource_api_version == envoy::config::core::v3::ApiVersion::V2 ? "V2" : "V3", - transport_api_version == envoy::config::core::v3::ApiVersion::V2 ? "V2" : "V3", - Platform::null_device_path); + api_type, Platform::null_device_path); } // TODO(samflattery): bundle this up with buildCluster @@ -440,9 +432,8 @@ ConfigHelper::buildStaticCluster(const std::string& name, int port, const std::s address, port)); } -envoy::config::cluster::v3::Cluster -ConfigHelper::buildCluster(const std::string& name, const std::string& lb_policy, - envoy::config::core::v3::ApiVersion api_version) { +envoy::config::cluster::v3::Cluster ConfigHelper::buildCluster(const std::string& name, + const std::string& lb_policy) { API_NO_BOOST(envoy::config::cluster::v3::Cluster) cluster; TestUtility::loadFromYaml(fmt::format(R"EOF( name: {} @@ -450,7 +441,7 @@ ConfigHelper::buildCluster(const std::string& name, const std::string& lb_policy type: EDS eds_cluster_config: eds_config: - resource_api_version: {} + resource_api_version: V3 ads: {{}} lb_policy: {} typed_extension_protocol_options: @@ -459,14 +450,13 @@ ConfigHelper::buildCluster(const std::string& name, const std::string& lb_policy explicit_http_config: http2_protocol_options: {{}} )EOF", - name, apiVersionStr(api_version), lb_policy), - cluster, shouldBoost(api_version)); + name, lb_policy), + cluster); return cluster; } -envoy::config::cluster::v3::Cluster -ConfigHelper::buildTlsCluster(const std::string& name, const std::string& lb_policy, - envoy::config::core::v3::ApiVersion api_version) { +envoy::config::cluster::v3::Cluster ConfigHelper::buildTlsCluster(const std::string& name, + const std::string& lb_policy) { API_NO_BOOST(envoy::config::cluster::v3::Cluster) cluster; TestUtility::loadFromYaml( fmt::format(R"EOF( @@ -475,7 +465,7 @@ ConfigHelper::buildTlsCluster(const std::string& name, const std::string& lb_pol type: EDS eds_cluster_config: eds_config: - resource_api_version: {} + resource_api_version: V3 ads: {{}} transport_socket: name: envoy.transport_sockets.tls @@ -492,17 +482,16 @@ ConfigHelper::buildTlsCluster(const std::string& name, const std::string& lb_pol explicit_http_config: http2_protocol_options: {{}} )EOF", - name, apiVersionStr(api_version), + name, TestEnvironment::runfilesPath("test/config/integration/certs/upstreamcacert.pem"), lb_policy), - cluster, shouldBoost(api_version)); + cluster); return cluster; } envoy::config::endpoint::v3::ClusterLoadAssignment ConfigHelper::buildClusterLoadAssignment(const std::string& name, const std::string& address, - uint32_t port, - envoy::config::core::v3::ApiVersion api_version) { + uint32_t port) { API_NO_BOOST(envoy::config::endpoint::v3::ClusterLoadAssignment) cluster_load_assignment; TestUtility::loadFromYaml(fmt::format(R"EOF( cluster_name: {} @@ -515,14 +504,13 @@ ConfigHelper::buildClusterLoadAssignment(const std::string& name, const std::str port_value: {} )EOF", name, address, port), - cluster_load_assignment, shouldBoost(api_version)); + cluster_load_assignment); return cluster_load_assignment; } envoy::config::listener::v3::Listener ConfigHelper::buildBaseListener(const std::string& name, const std::string& address, - const std::string& filter_chains, - envoy::config::core::v3::ApiVersion api_version) { + const std::string& filter_chains) { API_NO_BOOST(envoy::config::listener::v3::Listener) listener; TestUtility::loadFromYaml(fmt::format( R"EOF( @@ -535,14 +523,14 @@ ConfigHelper::buildBaseListener(const std::string& name, const std::string& addr {} )EOF", name, address, filter_chains), - listener, shouldBoost(api_version)); + listener); return listener; } -envoy::config::listener::v3::Listener -ConfigHelper::buildListener(const std::string& name, const std::string& route_config, - const std::string& address, const std::string& stat_prefix, - envoy::config::core::v3::ApiVersion api_version) { +envoy::config::listener::v3::Listener ConfigHelper::buildListener(const std::string& name, + const std::string& route_config, + const std::string& address, + const std::string& stat_prefix) { std::string hcm = fmt::format( R"EOF( filters: @@ -554,17 +542,16 @@ ConfigHelper::buildListener(const std::string& name, const std::string& route_co rds: route_config_name: {} config_source: - resource_api_version: {} + resource_api_version: V3 ads: {{}} http_filters: [{{ name: envoy.filters.http.router }}] )EOF", - stat_prefix, route_config, apiVersionStr(api_version)); - return buildBaseListener(name, address, hcm, api_version); + stat_prefix, route_config); + return buildBaseListener(name, address, hcm); } envoy::config::route::v3::RouteConfiguration -ConfigHelper::buildRouteConfig(const std::string& name, const std::string& cluster, - envoy::config::core::v3::ApiVersion api_version) { +ConfigHelper::buildRouteConfig(const std::string& name, const std::string& cluster) { API_NO_BOOST(envoy::config::route::v3::RouteConfiguration) route; TestUtility::loadFromYaml(fmt::format(R"EOF( name: "{}" @@ -576,7 +563,7 @@ ConfigHelper::buildRouteConfig(const std::string& name, const std::string& clust route: {{ cluster: "{}" }} )EOF", name, cluster), - route, shouldBoost(api_version)); + route); return route; } diff --git a/test/config/utility.h b/test/config/utility.h index cdfdc80eeb8b..06865cc36518 100644 --- a/test/config/utility.h +++ b/test/config/utility.h @@ -144,39 +144,32 @@ class ConfigHelper { // Configuration for L7 proxying, with clusters cluster_1 and cluster_2 meant to be added via CDS. // api_type should be REST, GRPC, or DELTA_GRPC. static std::string discoveredClustersBootstrap(const std::string& api_type); - static std::string adsBootstrap(const std::string& api_type, - envoy::config::core::v3::ApiVersion resource_api_version, - envoy::config::core::v3::ApiVersion transport_api_version = - envoy::config::core::v3::ApiVersion::AUTO); + static std::string adsBootstrap(const std::string& api_type); // Builds a standard Cluster config fragment, with a single endpoint (at address:port). static envoy::config::cluster::v3::Cluster buildStaticCluster(const std::string& name, int port, const std::string& address); // ADS configurations - static envoy::config::cluster::v3::Cluster buildCluster( - const std::string& name, const std::string& lb_policy = "ROUND_ROBIN", - envoy::config::core::v3::ApiVersion api_version = envoy::config::core::v3::ApiVersion::V3); + static envoy::config::cluster::v3::Cluster + buildCluster(const std::string& name, const std::string& lb_policy = "ROUND_ROBIN"); - static envoy::config::cluster::v3::Cluster buildTlsCluster( - const std::string& name, const std::string& lb_policy = "ROUND_ROBIN", - envoy::config::core::v3::ApiVersion api_version = envoy::config::core::v3::ApiVersion::V3); + static envoy::config::cluster::v3::Cluster + buildTlsCluster(const std::string& name, const std::string& lb_policy = "ROUND_ROBIN"); - static envoy::config::endpoint::v3::ClusterLoadAssignment buildClusterLoadAssignment( - const std::string& name, const std::string& ip_version, uint32_t port, - envoy::config::core::v3::ApiVersion api_version = envoy::config::core::v3::ApiVersion::V3); + static envoy::config::endpoint::v3::ClusterLoadAssignment + buildClusterLoadAssignment(const std::string& name, const std::string& ip_version, uint32_t port); - static envoy::config::listener::v3::Listener buildBaseListener( - const std::string& name, const std::string& address, const std::string& filter_chains = "", - envoy::config::core::v3::ApiVersion api_version = envoy::config::core::v3::ApiVersion::V3); + static envoy::config::listener::v3::Listener + buildBaseListener(const std::string& name, const std::string& address, + const std::string& filter_chains = ""); - static envoy::config::listener::v3::Listener buildListener( - const std::string& name, const std::string& route_config, const std::string& address, - const std::string& stat_prefix, - envoy::config::core::v3::ApiVersion api_version = envoy::config::core::v3::ApiVersion::V3); + static envoy::config::listener::v3::Listener buildListener(const std::string& name, + const std::string& route_config, + const std::string& address, + const std::string& stat_prefix); - static envoy::config::route::v3::RouteConfiguration buildRouteConfig( - const std::string& name, const std::string& cluster, - envoy::config::core::v3::ApiVersion api_version = envoy::config::core::v3::ApiVersion::V3); + static envoy::config::route::v3::RouteConfiguration buildRouteConfig(const std::string& name, + const std::string& cluster); // Builds a standard Endpoint suitable for population by finalize(). static envoy::config::endpoint::v3::Endpoint buildEndpoint(const std::string& address); @@ -338,14 +331,6 @@ class ConfigHelper { size_t http3_max_stream_receive_window); private: - static bool shouldBoost(envoy::config::core::v3::ApiVersion api_version) { - return api_version == envoy::config::core::v3::ApiVersion::V2; - } - - static std::string apiVersionStr(envoy::config::core::v3::ApiVersion api_version) { - return api_version == envoy::config::core::v3::ApiVersion::V2 ? "V2" : "V3"; - } - // Load the first HCM struct from the first listener into a parsed proto. bool loadHttpConnectionManager(HttpConnectionManager& hcm); // Take the contents of the provided HCM proto and stuff them into the first HCM diff --git a/test/config_test/config_test.cc b/test/config_test/config_test.cc index 5dc666dd6f47..876a501bd56a 100644 --- a/test/config_test/config_test.cc +++ b/test/config_test/config_test.cc @@ -99,7 +99,7 @@ class ConfigTest { envoy::config::bootstrap::v3::Bootstrap bootstrap; Server::InstanceUtil::loadBootstrapConfig( bootstrap, options_, server_.messageValidationContext().staticValidationVisitor(), *api_); - Server::Configuration::InitialImpl initial_config(bootstrap, options); + Server::Configuration::InitialImpl initial_config(bootstrap); Server::Configuration::MainImpl main_config; cluster_manager_factory_ = std::make_unique( @@ -230,16 +230,12 @@ uint32_t run(const std::string& directory) { } void loadVersionedBootstrapFile(const std::string& filename, - envoy::config::bootstrap::v3::Bootstrap& bootstrap_message, - absl::optional bootstrap_version) { + envoy::config::bootstrap::v3::Bootstrap& bootstrap_message) { Api::ApiPtr api = Api::createApiForTest(); OptionsImpl options( Envoy::Server::createTestOptionsImpl(filename, "", Network::Address::IpVersion::v6)); // Avoid contention issues with other tests over the hot restart domain socket. options.setHotRestartDisabled(true); - if (bootstrap_version.has_value()) { - options.setBootstrapVersion(*bootstrap_version); - } Server::InstanceUtil::loadBootstrapConfig(bootstrap_message, options, ProtobufMessage::getStrictValidationVisitor(), *api); } diff --git a/test/config_test/config_test.h b/test/config_test/config_test.h index 551fffadce33..e4ee26501fcc 100644 --- a/test/config_test/config_test.h +++ b/test/config_test/config_test.h @@ -27,8 +27,7 @@ void testMerge(); * given bootstrap protobuf message using the server's loadBootstrapConfig. */ void loadVersionedBootstrapFile(const std::string& filename, - envoy::config::bootstrap::v3::Bootstrap& bootstrap_message, - absl::optional bootstrap_version = absl::nullopt); + envoy::config::bootstrap::v3::Bootstrap& bootstrap_message); /** * Loads the given bootstrap proto into the given bootstrap protobuf message diff --git a/test/extensions/access_loggers/common/grpc_access_logger_test.cc b/test/extensions/access_loggers/common/grpc_access_logger_test.cc index 57f5f2278624..f2e125df17e0 100644 --- a/test/extensions/access_loggers/common/grpc_access_logger_test.cc +++ b/test/extensions/access_loggers/common/grpc_access_logger_test.cc @@ -33,14 +33,12 @@ namespace { constexpr std::chrono::milliseconds FlushInterval(10); constexpr char MOCK_HTTP_LOG_FIELD_NAME[] = "http_log_entry"; constexpr char MOCK_TCP_LOG_FIELD_NAME[] = "tcp_log_entry"; -constexpr auto TRANSPORT_API_VERSION = envoy::config::core::v3::ApiVersion::AUTO; const Protobuf::MethodDescriptor& mockMethodDescriptor() { // The mock logger doesn't have its own API, but we only care about the method descriptor so we // use the ALS protos. - return Grpc::VersionedMethods("envoy.service.accesslog.v3.AccessLogService.StreamAccessLogs", - "envoy.service.accesslog.v2.AccessLogService.StreamAccessLogs") - .getMethodDescriptorForVersion(TRANSPORT_API_VERSION); + return *Protobuf::DescriptorPool::generated_pool()->FindMethodByName( + "envoy.service.accesslog.v3.AccessLogService.StreamAccessLogs"); } // We don't care about the actual log entries, as this logger just adds them to the proto, but we @@ -54,11 +52,9 @@ class MockGrpcAccessLoggerImpl std::chrono::milliseconds buffer_flush_interval_msec, uint64_t max_buffer_size_bytes, Event::Dispatcher& dispatcher, Stats::Scope& scope, std::string access_log_prefix, - const Protobuf::MethodDescriptor& service_method, - envoy::config::core::v3::ApiVersion transport_api_version) + const Protobuf::MethodDescriptor& service_method) : GrpcAccessLogger(std::move(client), buffer_flush_interval_msec, max_buffer_size_bytes, - dispatcher, scope, access_log_prefix, service_method, - transport_api_version) {} + dispatcher, scope, access_log_prefix, service_method) {} int numInits() const { return num_inits_; } @@ -121,8 +117,7 @@ class GrpcAccessLogTest : public testing::Test { EXPECT_CALL(*timer_, enableTimer(buffer_flush_interval_msec, _)); logger_ = std::make_unique( Grpc::RawAsyncClientPtr{async_client_}, buffer_flush_interval_msec, buffer_size_bytes, - dispatcher_, stats_store_, "mock_access_log_prefix.", mockMethodDescriptor(), - TRANSPORT_API_VERSION); + dispatcher_, stats_store_, "mock_access_log_prefix.", mockMethodDescriptor()); } void expectStreamStart(MockAccessLogStream& stream, AccessLogCallbacks** callbacks_to_set) { @@ -324,13 +319,13 @@ class MockGrpcAccessLoggerCache private: // Common::GrpcAccessLoggerCache MockGrpcAccessLoggerImpl::SharedPtr - createLogger(const envoy::extensions::access_loggers::grpc::v3::CommonGrpcAccessLogConfig& config, - envoy::config::core::v3::ApiVersion, const Grpc::RawAsyncClientSharedPtr& client, + createLogger(const envoy::extensions::access_loggers::grpc::v3::CommonGrpcAccessLogConfig&, + const Grpc::RawAsyncClientSharedPtr& client, std::chrono::milliseconds buffer_flush_interval_msec, uint64_t max_buffer_size_bytes, Event::Dispatcher& dispatcher, Stats::Scope& scope) override { return std::make_shared( std::move(client), buffer_flush_interval_msec, max_buffer_size_bytes, dispatcher, scope, - "mock_access_log_prefix.", mockMethodDescriptor(), config.transport_api_version()); + "mock_access_log_prefix.", mockMethodDescriptor()); } }; @@ -366,36 +361,31 @@ TEST_F(GrpcAccessLoggerCacheTest, Deduplication) { config.mutable_grpc_service()->mutable_envoy_grpc()->set_cluster_name("cluster-1"); expectClientCreation(); - MockGrpcAccessLoggerImpl::SharedPtr logger1 = logger_cache_.getOrCreateLogger( - config, envoy::config::core::v3::ApiVersion::V3, Common::GrpcAccessLoggerType::HTTP, scope); + MockGrpcAccessLoggerImpl::SharedPtr logger1 = + logger_cache_.getOrCreateLogger(config, Common::GrpcAccessLoggerType::HTTP, scope); EXPECT_EQ(logger1, - logger_cache_.getOrCreateLogger(config, envoy::config::core::v3::ApiVersion::V3, - Common::GrpcAccessLoggerType::HTTP, scope)); + logger_cache_.getOrCreateLogger(config, Common::GrpcAccessLoggerType::HTTP, scope)); // Do not deduplicate different types of logger expectClientCreation(); EXPECT_NE(logger1, - logger_cache_.getOrCreateLogger(config, envoy::config::core::v3::ApiVersion::V3, - Common::GrpcAccessLoggerType::TCP, scope)); + logger_cache_.getOrCreateLogger(config, Common::GrpcAccessLoggerType::TCP, scope)); // Changing log name leads to another logger. config.set_log_name("log-2"); expectClientCreation(); EXPECT_NE(logger1, - logger_cache_.getOrCreateLogger(config, envoy::config::core::v3::ApiVersion::V3, - Common::GrpcAccessLoggerType::HTTP, scope)); + logger_cache_.getOrCreateLogger(config, Common::GrpcAccessLoggerType::HTTP, scope)); config.set_log_name("log-1"); EXPECT_EQ(logger1, - logger_cache_.getOrCreateLogger(config, envoy::config::core::v3::ApiVersion::V3, - Common::GrpcAccessLoggerType::HTTP, scope)); + logger_cache_.getOrCreateLogger(config, Common::GrpcAccessLoggerType::HTTP, scope)); // Changing cluster name leads to another logger. config.mutable_grpc_service()->mutable_envoy_grpc()->set_cluster_name("cluster-2"); expectClientCreation(); EXPECT_NE(logger1, - logger_cache_.getOrCreateLogger(config, envoy::config::core::v3::ApiVersion::V3, - Common::GrpcAccessLoggerType::HTTP, scope)); + logger_cache_.getOrCreateLogger(config, Common::GrpcAccessLoggerType::HTTP, scope)); } } // namespace diff --git a/test/extensions/access_loggers/grpc/grpc_access_log_impl_test.cc b/test/extensions/access_loggers/grpc/grpc_access_log_impl_test.cc index eec260b9c347..3e5e4f58f900 100644 --- a/test/extensions/access_loggers/grpc/grpc_access_log_impl_test.cc +++ b/test/extensions/access_loggers/grpc/grpc_access_log_impl_test.cc @@ -72,7 +72,7 @@ class GrpcAccessLoggerImplTest : public testing::Test { EXPECT_CALL(*timer_, enableTimer(_, _)); logger_ = std::make_unique( Grpc::RawAsyncClientPtr{async_client_}, "test_log_name", FlushInterval, BUFFER_SIZE_BYTES, - dispatcher_, local_info_, stats_store_, envoy::config::core::v3::ApiVersion::AUTO); + dispatcher_, local_info_, stats_store_); } Grpc::MockAsyncClient* async_client_; @@ -155,8 +155,8 @@ TEST_F(GrpcAccessLoggerCacheImplTest, LoggerCreation) { // Force a flush for every log entry. config.mutable_buffer_size_bytes()->set_value(BUFFER_SIZE_BYTES); - GrpcAccessLoggerSharedPtr logger = logger_cache_.getOrCreateLogger( - config, envoy::config::core::v3::ApiVersion::V3, Common::GrpcAccessLoggerType::HTTP, scope_); + GrpcAccessLoggerSharedPtr logger = + logger_cache_.getOrCreateLogger(config, Common::GrpcAccessLoggerType::HTTP, scope_); // Note that the local info node() method is mocked, so the node is not really configurable. grpc_access_logger_impl_test_helper_.expectStreamMessage(R"EOF( identifier: diff --git a/test/extensions/access_loggers/grpc/http_grpc_access_log_impl_test.cc b/test/extensions/access_loggers/grpc/http_grpc_access_log_impl_test.cc index e09fcd1f0918..9ce367303392 100644 --- a/test/extensions/access_loggers/grpc/http_grpc_access_log_impl_test.cc +++ b/test/extensions/access_loggers/grpc/http_grpc_access_log_impl_test.cc @@ -45,8 +45,7 @@ class MockGrpcAccessLoggerCache : public GrpcCommon::GrpcAccessLoggerCache { // GrpcAccessLoggerCache MOCK_METHOD(GrpcCommon::GrpcAccessLoggerSharedPtr, getOrCreateLogger, (const envoy::extensions::access_loggers::grpc::v3::CommonGrpcAccessLogConfig& config, - envoy::config::core::v3::ApiVersion, Common::GrpcAccessLoggerType logger_type, - Stats::Scope& scope)); + Common::GrpcAccessLoggerType logger_type, Stats::Scope& scope)); }; class HttpGrpcAccessLogTest : public testing::Test { @@ -59,12 +58,11 @@ class HttpGrpcAccessLogTest : public testing::Test { config_.mutable_common_config()->add_filter_state_objects_to_log("serialized"); config_.mutable_common_config()->set_transport_api_version( envoy::config::core::v3::ApiVersion::V3); - EXPECT_CALL(*logger_cache_, getOrCreateLogger(_, _, _, _)) + EXPECT_CALL(*logger_cache_, getOrCreateLogger(_, _, _)) .WillOnce( [this](const envoy::extensions::access_loggers::grpc::v3::CommonGrpcAccessLogConfig& config, - envoy::config::core::v3::ApiVersion, Common::GrpcAccessLoggerType logger_type, - Stats::Scope&) { + Common::GrpcAccessLoggerType logger_type, Stats::Scope&) { EXPECT_EQ(config.DebugString(), config_.common_config().DebugString()); EXPECT_EQ(Common::GrpcAccessLoggerType::HTTP, logger_type); return logger_; diff --git a/test/extensions/access_loggers/grpc/http_grpc_access_log_integration_test.cc b/test/extensions/access_loggers/grpc/http_grpc_access_log_integration_test.cc index 0699fc5e81f9..75b064169115 100644 --- a/test/extensions/access_loggers/grpc/http_grpc_access_log_integration_test.cc +++ b/test/extensions/access_loggers/grpc/http_grpc_access_log_integration_test.cc @@ -19,7 +19,7 @@ using testing::AssertionResult; namespace Envoy { namespace { -class AccessLogIntegrationTest : public Grpc::VersionedGrpcClientIntegrationParamTest, +class AccessLogIntegrationTest : public Grpc::GrpcClientIntegrationParamTest, public HttpIntegrationTest { public: AccessLogIntegrationTest() : HttpIntegrationTest(Http::CodecType::HTTP1, ipVersion()) {} @@ -30,9 +30,6 @@ class AccessLogIntegrationTest : public Grpc::VersionedGrpcClientIntegrationPara } void initialize() override { - if (apiVersion() != envoy::config::core::v3::ApiVersion::V3) { - config_helper_.enableDeprecatedV2Api(); - } config_helper_.addConfigModifier([](envoy::config::bootstrap::v3::Bootstrap& bootstrap) { auto* accesslog_cluster = bootstrap.mutable_static_resources()->add_clusters(); accesslog_cluster->MergeFrom(bootstrap.static_resources().clusters()[0]); @@ -50,7 +47,7 @@ class AccessLogIntegrationTest : public Grpc::VersionedGrpcClientIntegrationPara envoy::extensions::access_loggers::grpc::v3::HttpGrpcAccessLogConfig config; auto* common_config = config.mutable_common_config(); common_config->set_log_name("foo"); - common_config->set_transport_api_version(apiVersion()); + common_config->set_transport_api_version(envoy::config::core::v3::ApiVersion::V3); setGrpcService(*common_config->mutable_grpc_service(), "accesslog", fake_upstreams_.back()->localAddress()); access_log->mutable_typed_config()->PackFrom(config); @@ -59,14 +56,6 @@ class AccessLogIntegrationTest : public Grpc::VersionedGrpcClientIntegrationPara HttpIntegrationTest::initialize(); } - static ProtobufTypes::MessagePtr scrubHiddenEnvoyDeprecated(const Protobuf::Message& message) { - ProtobufTypes::MessagePtr mutable_clone; - mutable_clone.reset(message.New()); - mutable_clone->MergeFrom(message); - Config::VersionUtil::scrubHiddenEnvoyDeprecated(*mutable_clone); - return mutable_clone; - } - ABSL_MUST_USE_RESULT AssertionResult waitForAccessLogConnection() { return fake_upstreams_[1]->waitForHttpConnection(*dispatcher_, fake_access_log_connection_); @@ -82,8 +71,7 @@ class AccessLogIntegrationTest : public Grpc::VersionedGrpcClientIntegrationPara envoy::service::accesslog::v3::StreamAccessLogsMessage request_msg; VERIFY_ASSERTION(access_log_request_->waitForGrpcMessage(*dispatcher_, request_msg)); EXPECT_EQ("POST", access_log_request_->headers().getMethodValue()); - EXPECT_EQ(TestUtility::getVersionedMethodPath("envoy.service.accesslog.{}.AccessLogService", - "StreamAccessLogs", apiVersion()), + EXPECT_EQ("/envoy.service.accesslog.v3.AccessLogService/StreamAccessLogs", access_log_request_->headers().getPathValue()); EXPECT_EQ("application/grpc", access_log_request_->headers().getContentTypeValue()); @@ -105,8 +93,6 @@ class AccessLogIntegrationTest : public Grpc::VersionedGrpcClientIntegrationPara node->clear_extensions(); node->clear_user_agent_build_version(); } - Config::VersionUtil::scrubHiddenEnvoyDeprecated(request_msg); - Config::VersionUtil::scrubHiddenEnvoyDeprecated(expected_request_msg); EXPECT_THAT(request_msg, ProtoEq(expected_request_msg)); return AssertionSuccess(); } @@ -125,12 +111,11 @@ class AccessLogIntegrationTest : public Grpc::VersionedGrpcClientIntegrationPara }; INSTANTIATE_TEST_SUITE_P(IpVersionsCientType, AccessLogIntegrationTest, - VERSIONED_GRPC_CLIENT_INTEGRATION_PARAMS, - Grpc::VersionedGrpcClientIntegrationParamTest::protocolTestParamsToString); + GRPC_CLIENT_INTEGRATION_PARAMS, + Grpc::GrpcClientIntegrationParamTest::protocolTestParamsToString); // Test a basic full access logging flow. TEST_P(AccessLogIntegrationTest, BasicAccessLogFlow) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; testRouterNotFound(); ASSERT_TRUE(waitForAccessLogConnection()); ASSERT_TRUE(waitForAccessLogStream()); diff --git a/test/extensions/access_loggers/grpc/tcp_grpc_access_log_integration_test.cc b/test/extensions/access_loggers/grpc/tcp_grpc_access_log_integration_test.cc index 2bec4fd81fcc..63ddc3f70937 100644 --- a/test/extensions/access_loggers/grpc/tcp_grpc_access_log_integration_test.cc +++ b/test/extensions/access_loggers/grpc/tcp_grpc_access_log_integration_test.cc @@ -24,7 +24,7 @@ void clearPort(envoy::config::core::v3::Address& address) { address.mutable_socket_address()->clear_port_specifier(); } -class TcpGrpcAccessLogIntegrationTest : public Grpc::VersionedGrpcClientIntegrationParamTest, +class TcpGrpcAccessLogIntegrationTest : public Grpc::GrpcClientIntegrationParamTest, public BaseIntegrationTest { public: TcpGrpcAccessLogIntegrationTest() @@ -38,9 +38,6 @@ class TcpGrpcAccessLogIntegrationTest : public Grpc::VersionedGrpcClientIntegrat } void initialize() override { - if (apiVersion() != envoy::config::core::v3::ApiVersion::V3) { - config_helper_.enableDeprecatedV2Api(); - } config_helper_.renameListener("tcp_proxy"); config_helper_.addConfigModifier([](envoy::config::bootstrap::v3::Bootstrap& bootstrap) { auto* accesslog_cluster = bootstrap.mutable_static_resources()->add_clusters(); @@ -56,7 +53,7 @@ class TcpGrpcAccessLogIntegrationTest : public Grpc::VersionedGrpcClientIntegrat envoy::extensions::access_loggers::grpc::v3::TcpGrpcAccessLogConfig access_log_config; auto* common_config = access_log_config.mutable_common_config(); common_config->set_log_name("foo"); - common_config->set_transport_api_version(apiVersion()); + common_config->set_transport_api_version(envoy::config::core::v3::ApiVersion::V3); setGrpcService(*common_config->mutable_grpc_service(), "accesslog", fake_upstreams_.back()->localAddress()); access_log->mutable_typed_config()->PackFrom(access_log_config); @@ -79,8 +76,7 @@ class TcpGrpcAccessLogIntegrationTest : public Grpc::VersionedGrpcClientIntegrat envoy::service::accesslog::v3::StreamAccessLogsMessage request_msg; VERIFY_ASSERTION(access_log_request_->waitForGrpcMessage(*dispatcher_, request_msg)); EXPECT_EQ("POST", access_log_request_->headers().getMethodValue()); - EXPECT_EQ(TestUtility::getVersionedMethodPath("envoy.service.accesslog.{}.AccessLogService", - "StreamAccessLogs", apiVersion()), + EXPECT_EQ("/envoy.service.accesslog.v3.AccessLogService/StreamAccessLogs", access_log_request_->headers().getPathValue()); EXPECT_EQ("application/grpc", access_log_request_->headers().getContentTypeValue()); @@ -103,8 +99,6 @@ class TcpGrpcAccessLogIntegrationTest : public Grpc::VersionedGrpcClientIntegrat node->clear_extensions(); node->clear_user_agent_build_version(); } - Config::VersionUtil::scrubHiddenEnvoyDeprecated(request_msg); - Config::VersionUtil::scrubHiddenEnvoyDeprecated(expected_request_msg); EXPECT_TRUE(TestUtility::protoEqual(request_msg, expected_request_msg, /*ignore_repeated_field_ordering=*/false)); @@ -126,12 +120,11 @@ class TcpGrpcAccessLogIntegrationTest : public Grpc::VersionedGrpcClientIntegrat }; INSTANTIATE_TEST_SUITE_P(IpVersionsCientType, TcpGrpcAccessLogIntegrationTest, - VERSIONED_GRPC_CLIENT_INTEGRATION_PARAMS, - Grpc::VersionedGrpcClientIntegrationParamTest::protocolTestParamsToString); + GRPC_CLIENT_INTEGRATION_PARAMS, + Grpc::GrpcClientIntegrationParamTest::protocolTestParamsToString); // Test a basic full access logging flow. TEST_P(TcpGrpcAccessLogIntegrationTest, BasicAccessLogFlow) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initialize(); IntegrationTcpClientPtr tcp_client = makeTcpConnection(lookupPort("tcp_proxy")); diff --git a/test/extensions/access_loggers/open_telemetry/access_log_impl_test.cc b/test/extensions/access_loggers/open_telemetry/access_log_impl_test.cc index d169f040f3b9..f815e3a3bd98 100644 --- a/test/extensions/access_loggers/open_telemetry/access_log_impl_test.cc +++ b/test/extensions/access_loggers/open_telemetry/access_log_impl_test.cc @@ -52,8 +52,7 @@ class MockGrpcAccessLoggerCache : public GrpcAccessLoggerCache { // GrpcAccessLoggerCache MOCK_METHOD(GrpcAccessLoggerSharedPtr, getOrCreateLogger, (const envoy::extensions::access_loggers::grpc::v3::CommonGrpcAccessLogConfig& config, - envoy::config::core::v3::ApiVersion, Common::GrpcAccessLoggerType logger_type, - Stats::Scope& scope)); + Common::GrpcAccessLoggerType logger_type, Stats::Scope& scope)); }; class AccessLogTest : public testing::Test { @@ -83,12 +82,11 @@ string_value: "x-request-header: %REQ(x-request-header)%, protocol: %PROTOCOL%" config_.mutable_common_config()->set_log_name("test_log"); config_.mutable_common_config()->set_transport_api_version( envoy::config::core::v3::ApiVersion::V3); - EXPECT_CALL(*logger_cache_, getOrCreateLogger(_, _, _, _)) + EXPECT_CALL(*logger_cache_, getOrCreateLogger(_, _, _)) .WillOnce( [this](const envoy::extensions::access_loggers::grpc::v3::CommonGrpcAccessLogConfig& config, - envoy::config::core::v3::ApiVersion, Common::GrpcAccessLoggerType logger_type, - Stats::Scope&) { + Common::GrpcAccessLoggerType logger_type, Stats::Scope&) { EXPECT_EQ(config.DebugString(), config_.common_config().DebugString()); EXPECT_EQ(Common::GrpcAccessLoggerType::HTTP, logger_type); return logger_; diff --git a/test/extensions/access_loggers/open_telemetry/access_log_integration_test.cc b/test/extensions/access_loggers/open_telemetry/access_log_integration_test.cc index 66c62fccf311..ce52155a6dc9 100644 --- a/test/extensions/access_loggers/open_telemetry/access_log_integration_test.cc +++ b/test/extensions/access_loggers/open_telemetry/access_log_integration_test.cc @@ -46,7 +46,7 @@ constexpr char EXPECTED_REQUEST_MESSAGE[] = R"EOF( namespace Envoy { namespace { -class AccessLogIntegrationTest : public Grpc::VersionedGrpcClientIntegrationParamTest, +class AccessLogIntegrationTest : public Grpc::GrpcClientIntegrationParamTest, public HttpIntegrationTest { public: AccessLogIntegrationTest() : HttpIntegrationTest(Http::CodecType::HTTP1, ipVersion()) {} @@ -57,9 +57,6 @@ class AccessLogIntegrationTest : public Grpc::VersionedGrpcClientIntegrationPara } void initialize() override { - if (apiVersion() != envoy::config::core::v3::ApiVersion::V3) { - config_helper_.enableDeprecatedV2Api(); - } config_helper_.addConfigModifier([](envoy::config::bootstrap::v3::Bootstrap& bootstrap) { auto* accesslog_cluster = bootstrap.mutable_static_resources()->add_clusters(); accesslog_cluster->MergeFrom(bootstrap.static_resources().clusters()[0]); @@ -78,7 +75,7 @@ class AccessLogIntegrationTest : public Grpc::VersionedGrpcClientIntegrationPara config; auto* common_config = config.mutable_common_config(); common_config->set_log_name("foo"); - common_config->set_transport_api_version(apiVersion()); + common_config->set_transport_api_version(envoy::config::core::v3::ApiVersion::V3); setGrpcService(*common_config->mutable_grpc_service(), "accesslog", fake_upstreams_.back()->localAddress()); auto* body_config = config.mutable_body(); @@ -93,14 +90,6 @@ class AccessLogIntegrationTest : public Grpc::VersionedGrpcClientIntegrationPara HttpIntegrationTest::initialize(); } - static ProtobufTypes::MessagePtr scrubHiddenEnvoyDeprecated(const Protobuf::Message& message) { - ProtobufTypes::MessagePtr mutable_clone; - mutable_clone.reset(message.New()); - mutable_clone->MergeFrom(message); - Config::VersionUtil::scrubHiddenEnvoyDeprecated(*mutable_clone); - return mutable_clone; - } - ABSL_MUST_USE_RESULT AssertionResult waitForAccessLogConnection() { return fake_upstreams_[1]->waitForHttpConnection(*dispatcher_, fake_access_log_connection_); @@ -128,8 +117,6 @@ class AccessLogIntegrationTest : public Grpc::VersionedGrpcClientIntegrationPara ->mutable_logs(0) ->clear_time_unix_nano(); - Config::VersionUtil::scrubHiddenEnvoyDeprecated(request_msg); - Config::VersionUtil::scrubHiddenEnvoyDeprecated(expected_request_msg); EXPECT_TRUE(TestUtility::protoEqual(request_msg, expected_request_msg, /*ignore_repeated_field_ordering=*/false)); return AssertionSuccess(); @@ -149,12 +136,11 @@ class AccessLogIntegrationTest : public Grpc::VersionedGrpcClientIntegrationPara }; INSTANTIATE_TEST_SUITE_P(IpVersionsCientType, AccessLogIntegrationTest, - VERSIONED_GRPC_CLIENT_INTEGRATION_PARAMS, - Grpc::VersionedGrpcClientIntegrationParamTest::protocolTestParamsToString); + GRPC_CLIENT_INTEGRATION_PARAMS, + Grpc::GrpcClientIntegrationParamTest::protocolTestParamsToString); // Test a basic full access logging flow. TEST_P(AccessLogIntegrationTest, BasicAccessLogFlow) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; testRouterNotFound(); ASSERT_TRUE(waitForAccessLogConnection()); ASSERT_TRUE(waitForAccessLogStream()); diff --git a/test/extensions/access_loggers/open_telemetry/grpc_access_log_impl_test.cc b/test/extensions/access_loggers/open_telemetry/grpc_access_log_impl_test.cc index ecd8d6b96a83..850ae1dfa4cd 100644 --- a/test/extensions/access_loggers/open_telemetry/grpc_access_log_impl_test.cc +++ b/test/extensions/access_loggers/open_telemetry/grpc_access_log_impl_test.cc @@ -81,7 +81,7 @@ class GrpcAccessLoggerImplTest : public testing::Test { EXPECT_CALL(*timer_, enableTimer(_, _)); logger_ = std::make_unique( Grpc::RawAsyncClientPtr{async_client_}, "test_log_name", FlushInterval, BUFFER_SIZE_BYTES, - dispatcher_, local_info_, stats_store_, envoy::config::core::v3::ApiVersion::V3); + dispatcher_, local_info_, stats_store_); } Grpc::MockAsyncClient* async_client_; @@ -178,8 +178,8 @@ TEST_F(GrpcAccessLoggerCacheImplTest, LoggerCreation) { // Force a flush for every log entry. config.mutable_buffer_size_bytes()->set_value(BUFFER_SIZE_BYTES); - GrpcAccessLoggerSharedPtr logger = logger_cache_.getOrCreateLogger( - config, envoy::config::core::v3::ApiVersion::V3, Common::GrpcAccessLoggerType::HTTP, scope_); + GrpcAccessLoggerSharedPtr logger = + logger_cache_.getOrCreateLogger(config, Common::GrpcAccessLoggerType::HTTP, scope_); grpc_access_logger_impl_test_helper_.expectStreamMessage(R"EOF( resource_logs: resource: diff --git a/test/extensions/clusters/dynamic_forward_proxy/cluster_test.cc b/test/extensions/clusters/dynamic_forward_proxy/cluster_test.cc index 595be9f596d8..6f9a68db1dce 100644 --- a/test/extensions/clusters/dynamic_forward_proxy/cluster_test.cc +++ b/test/extensions/clusters/dynamic_forward_proxy/cluster_test.cc @@ -203,9 +203,9 @@ TEST_F(ClusterTest, PopulatedCache) { class ClusterFactoryTest : public testing::Test { protected: - void createCluster(const std::string& yaml_config, bool avoid_boosting = true) { + void createCluster(const std::string& yaml_config) { envoy::config::cluster::v3::Cluster cluster_config = - Upstream::parseClusterFromV3Yaml(yaml_config, avoid_boosting); + Upstream::parseClusterFromV3Yaml(yaml_config); Upstream::ClusterFactoryContextImpl cluster_factory_context( cm_, stats_store_, tls_, nullptr, ssl_context_manager_, runtime_, dispatcher_, log_manager_, local_info_, admin_, singleton_manager_, nullptr, true, validation_visitor_, *api_, diff --git a/test/extensions/clusters/redis/redis_cluster_test.cc b/test/extensions/clusters/redis/redis_cluster_test.cc index 526c10a3039f..e2b037bb182c 100644 --- a/test/extensions/clusters/redis/redis_cluster_test.cc +++ b/test/extensions/clusters/redis/redis_cluster_test.cc @@ -95,11 +95,10 @@ class RedisClusterTest : public testing::Test, return addresses; } - void setupFromV3Yaml(const std::string& yaml, bool avoid_boosting = true) { + void setupFromV3Yaml(const std::string& yaml) { expectRedisSessionCreated(); NiceMock cm; - envoy::config::cluster::v3::Cluster cluster_config = - Upstream::parseClusterFromV3Yaml(yaml, avoid_boosting); + envoy::config::cluster::v3::Cluster cluster_config = Upstream::parseClusterFromV3Yaml(yaml); Envoy::Stats::ScopePtr scope = stats_store_.createScope(fmt::format( "cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name() : cluster_config.alt_stat_name())); diff --git a/test/extensions/filters/common/ext_authz/ext_authz_grpc_impl_test.cc b/test/extensions/filters/common/ext_authz/ext_authz_grpc_impl_test.cc index f771573698d1..8d776a73b061 100644 --- a/test/extensions/filters/common/ext_authz/ext_authz_grpc_impl_test.cc +++ b/test/extensions/filters/common/ext_authz/ext_authz_grpc_impl_test.cc @@ -31,14 +31,12 @@ namespace ExtAuthz { using Params = std::tuple; -class ExtAuthzGrpcClientTest : public testing::TestWithParam { +class ExtAuthzGrpcClientTest : public testing::Test { public: ExtAuthzGrpcClientTest() : async_client_(new Grpc::MockAsyncClient()), timeout_(10) {} - void initialize(const Params& param) { - api_version_ = std::get<0>(param); - client_ = std::make_unique(Grpc::RawAsyncClientPtr{async_client_}, timeout_, - api_version_); + void initialize() { + client_ = std::make_unique(Grpc::RawAsyncClientPtr{async_client_}, timeout_); } void expectCallSend(envoy::service::auth::v3::CheckRequest& request) { @@ -48,9 +46,7 @@ class ExtAuthzGrpcClientTest : public testing::TestWithParam { Invoke([this](absl::string_view service_full_name, absl::string_view method_name, Buffer::InstancePtr&&, Grpc::RawAsyncRequestCallbacks&, Tracing::Span&, const Http::AsyncClient::RequestOptions& options) -> Grpc::AsyncRequest* { - EXPECT_EQ(TestUtility::getVersionedServiceFullName( - "envoy.service.auth.{}.Authorization", api_version_), - service_full_name); + EXPECT_EQ("envoy.service.auth.v3.Authorization", service_full_name); EXPECT_EQ("Check", method_name); EXPECT_EQ(timeout_->count(), options.timeout->count()); return &async_request_; @@ -67,14 +63,9 @@ class ExtAuthzGrpcClientTest : public testing::TestWithParam { envoy::config::core::v3::ApiVersion api_version_; }; -INSTANTIATE_TEST_SUITE_P(Parameterized, ExtAuthzGrpcClientTest, - Values(Params(envoy::config::core::v3::ApiVersion::AUTO), - Params(envoy::config::core::v3::ApiVersion::V2), - Params(envoy::config::core::v3::ApiVersion::V3))); - // Test the client when an ok response is received. -TEST_P(ExtAuthzGrpcClientTest, AuthorizationOk) { - initialize(GetParam()); +TEST_F(ExtAuthzGrpcClientTest, AuthorizationOk) { + initialize(); auto check_response = std::make_unique(); auto status = check_response->mutable_status(); @@ -111,8 +102,8 @@ TEST_P(ExtAuthzGrpcClientTest, AuthorizationOk) { } // Test the client when an ok response is received. -TEST_P(ExtAuthzGrpcClientTest, AuthorizationOkWithAllAtributes) { - initialize(GetParam()); +TEST_F(ExtAuthzGrpcClientTest, AuthorizationOkWithAllAtributes) { + initialize(); const std::string empty_body{}; const auto expected_headers = TestCommon::makeHeaderValueOption({{"foo", "bar", false}}); @@ -138,8 +129,8 @@ TEST_P(ExtAuthzGrpcClientTest, AuthorizationOkWithAllAtributes) { } // Test the client when a denied response is received. -TEST_P(ExtAuthzGrpcClientTest, AuthorizationDenied) { - initialize(GetParam()); +TEST_F(ExtAuthzGrpcClientTest, AuthorizationDenied) { + initialize(); auto check_response = std::make_unique(); auto status = check_response->mutable_status(); @@ -162,8 +153,8 @@ TEST_P(ExtAuthzGrpcClientTest, AuthorizationDenied) { } // Test the client when a gRPC status code unknown is received from the authorization server. -TEST_P(ExtAuthzGrpcClientTest, AuthorizationDeniedGrpcUnknownStatus) { - initialize(GetParam()); +TEST_F(ExtAuthzGrpcClientTest, AuthorizationDeniedGrpcUnknownStatus) { + initialize(); auto check_response = std::make_unique(); auto status = check_response->mutable_status(); @@ -186,8 +177,8 @@ TEST_P(ExtAuthzGrpcClientTest, AuthorizationDeniedGrpcUnknownStatus) { } // Test the client when a denied response with additional HTTP attributes is received. -TEST_P(ExtAuthzGrpcClientTest, AuthorizationDeniedWithAllAttributes) { - initialize(GetParam()); +TEST_F(ExtAuthzGrpcClientTest, AuthorizationDeniedWithAllAttributes) { + initialize(); const std::string expected_body{"test"}; const auto expected_headers = @@ -215,8 +206,8 @@ TEST_P(ExtAuthzGrpcClientTest, AuthorizationDeniedWithAllAttributes) { } // Test the client when an unknown error occurs. -TEST_P(ExtAuthzGrpcClientTest, UnknownError) { - initialize(GetParam()); +TEST_F(ExtAuthzGrpcClientTest, UnknownError) { + initialize(); envoy::service::auth::v3::CheckRequest request; expectCallSend(request); @@ -228,8 +219,8 @@ TEST_P(ExtAuthzGrpcClientTest, UnknownError) { } // Test the client when the request is canceled. -TEST_P(ExtAuthzGrpcClientTest, CancelledAuthorizationRequest) { - initialize(GetParam()); +TEST_F(ExtAuthzGrpcClientTest, CancelledAuthorizationRequest) { + initialize(); envoy::service::auth::v3::CheckRequest request; EXPECT_CALL(*async_client_, sendRaw(_, _, _, _, _, _)).WillOnce(Return(&async_request_)); @@ -240,8 +231,8 @@ TEST_P(ExtAuthzGrpcClientTest, CancelledAuthorizationRequest) { } // Test the client when the request times out. -TEST_P(ExtAuthzGrpcClientTest, AuthorizationRequestTimeout) { - initialize(GetParam()); +TEST_F(ExtAuthzGrpcClientTest, AuthorizationRequestTimeout) { + initialize(); envoy::service::auth::v3::CheckRequest request; expectCallSend(request); @@ -253,8 +244,8 @@ TEST_P(ExtAuthzGrpcClientTest, AuthorizationRequestTimeout) { } // Test the client when an OK response is received with dynamic metadata in that OK response. -TEST_P(ExtAuthzGrpcClientTest, AuthorizationOkWithDynamicMetadata) { - initialize(GetParam()); +TEST_F(ExtAuthzGrpcClientTest, AuthorizationOkWithDynamicMetadata) { + initialize(); auto check_response = std::make_unique(); auto status = check_response->mutable_status(); diff --git a/test/extensions/filters/common/ratelimit/ratelimit_impl_test.cc b/test/extensions/filters/common/ratelimit/ratelimit_impl_test.cc index 00c87f500904..20c63eba80f1 100644 --- a/test/extensions/filters/common/ratelimit/ratelimit_impl_test.cc +++ b/test/extensions/filters/common/ratelimit/ratelimit_impl_test.cc @@ -54,8 +54,8 @@ class RateLimitGrpcClientTest : public testing::Test { public: RateLimitGrpcClientTest() : async_client_(new Grpc::MockAsyncClient()), - client_(Grpc::RawAsyncClientPtr{async_client_}, absl::optional(), - envoy::config::core::v3::ApiVersion::AUTO) {} + client_(Grpc::RawAsyncClientPtr{async_client_}, + absl::optional()) {} Grpc::MockAsyncClient* async_client_; Grpc::MockAsyncRequest async_request_; @@ -77,7 +77,7 @@ TEST_F(RateLimitGrpcClientTest, Basic) { Invoke([this](absl::string_view service_full_name, absl::string_view method_name, Buffer::InstancePtr&&, Grpc::RawAsyncRequestCallbacks&, Tracing::Span&, const Http::AsyncClient::RequestOptions&) -> Grpc::AsyncRequest* { - std::string service_name = "envoy.service.ratelimit.v2.RateLimitService"; + std::string service_name = "envoy.service.ratelimit.v3.RateLimitService"; EXPECT_EQ(service_name, service_full_name); EXPECT_EQ("ShouldRateLimit", method_name); return &async_request_; diff --git a/test/extensions/filters/http/common/fuzz/uber_filter.cc b/test/extensions/filters/http/common/fuzz/uber_filter.cc index 748c84b311cc..7a4c5e0a915e 100644 --- a/test/extensions/filters/http/common/fuzz/uber_filter.cc +++ b/test/extensions/filters/http/common/fuzz/uber_filter.cc @@ -1,7 +1,6 @@ #include "test/extensions/filters/http/common/fuzz/uber_filter.h" #include "source/common/config/utility.h" -#include "source/common/config/version_converter.h" #include "source/common/http/message_impl.h" #include "source/common/http/utility.h" #include "source/common/protobuf/protobuf.h" diff --git a/test/extensions/filters/http/ext_authz/config_test.cc b/test/extensions/filters/http/ext_authz/config_test.cc index b071c514ab75..25f626a7747b 100644 --- a/test/extensions/filters/http/ext_authz/config_test.cc +++ b/test/extensions/filters/http/ext_authz/config_test.cc @@ -21,18 +21,10 @@ namespace HttpFilters { namespace ExtAuthz { namespace { -void expectCorrectProtoGrpc(envoy::config::core::v3::ApiVersion api_version, - std::string const& grpc_service_yaml) { - std::unique_ptr _deprecated_v2_api; - if (api_version != envoy::config::core::v3::ApiVersion::V3) { - _deprecated_v2_api = std::make_unique(); - } - +void expectCorrectProtoGrpc(std::string const& grpc_service_yaml) { ExtAuthzFilterConfig factory; ProtobufTypes::MessagePtr proto_config = factory.createEmptyConfigProto(); - TestUtility::loadFromYaml( - fmt::format(grpc_service_yaml, TestUtility::getVersionStringFromApiVersion(api_version)), - *proto_config); + TestUtility::loadFromYaml(grpc_service_yaml, *proto_config); testing::StrictMock context; testing::StrictMock server_context; @@ -81,13 +73,9 @@ TEST(HttpExtAuthzConfigTest, CorrectProtoGoogleGrpc) { target_uri: ext_authz_server stat_prefix: google failure_mode_allow: false - transport_api_version: {} + transport_api_version: V3 )EOF"; -#ifndef ENVOY_DISABLE_DEPRECATED_FEATURES - // TODO(chaoqin-li1123): clean this up when we move AUTO to V3 by default. - expectCorrectProtoGrpc(envoy::config::core::v3::ApiVersion::AUTO, google_grpc_service_yaml); -#endif - expectCorrectProtoGrpc(envoy::config::core::v3::ApiVersion::V3, google_grpc_service_yaml); + expectCorrectProtoGrpc(google_grpc_service_yaml); } TEST(HttpExtAuthzConfigTest, CorrectProtoEnvoyGrpc) { @@ -97,13 +85,9 @@ TEST(HttpExtAuthzConfigTest, CorrectProtoEnvoyGrpc) { envoy_grpc: cluster_name: ext_authz_server failure_mode_allow: false - transport_api_version: {} + transport_api_version: V3 )EOF"; -#ifndef ENVOY_DISABLE_DEPRECATED_FEATURES - // TODO(chaoqin-li1123): clean this up when we move AUTO to V3 by default. - expectCorrectProtoGrpc(envoy::config::core::v3::ApiVersion::AUTO, envoy_grpc_service_yaml); -#endif - expectCorrectProtoGrpc(envoy::config::core::v3::ApiVersion::V3, envoy_grpc_service_yaml); + expectCorrectProtoGrpc(envoy_grpc_service_yaml); } TEST(HttpExtAuthzConfigTest, CorrectProtoHttp) { diff --git a/test/extensions/filters/http/ext_authz/ext_authz_integration_test.cc b/test/extensions/filters/http/ext_authz/ext_authz_integration_test.cc index 32e4e54dbbe6..4709c66a9165 100644 --- a/test/extensions/filters/http/ext_authz/ext_authz_integration_test.cc +++ b/test/extensions/filters/http/ext_authz/ext_authz_integration_test.cc @@ -23,7 +23,7 @@ namespace Envoy { using Headers = std::vector>; -class ExtAuthzGrpcIntegrationTest : public Grpc::VersionedGrpcClientIntegrationParamTest, +class ExtAuthzGrpcIntegrationTest : public Grpc::GrpcClientIntegrationParamTest, public HttpIntegrationTest { public: ExtAuthzGrpcIntegrationTest() : HttpIntegrationTest(Http::CodecType::HTTP1, ipVersion()) {} @@ -34,9 +34,6 @@ class ExtAuthzGrpcIntegrationTest : public Grpc::VersionedGrpcClientIntegrationP } void initializeConfig(bool disable_with_metadata = false) { - if (apiVersion() != envoy::config::core::v3::ApiVersion::V3) { - config_helper_.enableDeprecatedV2Api(); - } config_helper_.addConfigModifier([this, disable_with_metadata]( envoy::config::bootstrap::v3::Bootstrap& bootstrap) { auto* ext_authz_cluster = bootstrap.mutable_static_resources()->add_clusters(); @@ -60,7 +57,7 @@ class ExtAuthzGrpcIntegrationTest : public Grpc::VersionedGrpcClientIntegrationP } proto_config_.mutable_deny_at_disable()->set_runtime_key("envoy.ext_authz.deny_at_disable"); proto_config_.mutable_deny_at_disable()->mutable_default_value()->set_value(false); - proto_config_.set_transport_api_version(apiVersion()); + proto_config_.set_transport_api_version(envoy::config::core::v3::ApiVersion::V3); // Add labels and verify they are passed. std::map labels; @@ -142,8 +139,7 @@ class ExtAuthzGrpcIntegrationTest : public Grpc::VersionedGrpcClientIntegrationP RELEASE_ASSERT(result, result.message()); EXPECT_EQ("POST", ext_authz_request_->headers().getMethodValue()); - EXPECT_EQ(TestUtility::getVersionedMethodPath("envoy.service.auth.{}.Authorization", "Check", - apiVersion()), + EXPECT_EQ("/envoy.service.auth.v3.Authorization/Check", ext_authz_request_->headers().getPathValue()); EXPECT_EQ("application/grpc", ext_authz_request_->headers().getContentTypeValue()); @@ -590,34 +586,30 @@ class ExtAuthzHttpIntegrationTest : public HttpIntegrationTest, }; INSTANTIATE_TEST_SUITE_P(IpVersionsCientType, ExtAuthzGrpcIntegrationTest, - VERSIONED_GRPC_CLIENT_INTEGRATION_PARAMS, - Grpc::VersionedGrpcClientIntegrationParamTest::protocolTestParamsToString); + GRPC_CLIENT_INTEGRATION_PARAMS, + Grpc::GrpcClientIntegrationParamTest::protocolTestParamsToString); // Verifies that the request body is included in the CheckRequest when the downstream protocol is // HTTP/1.1. TEST_P(ExtAuthzGrpcIntegrationTest, HTTP1DownstreamRequestWithBody) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; expectCheckRequestWithBody(Http::CodecType::HTTP1, 4); } // Verifies that the request body is included in the CheckRequest when the downstream protocol is // HTTP/1.1 and the size of the request body is larger than max_request_bytes. TEST_P(ExtAuthzGrpcIntegrationTest, HTTP1DownstreamRequestWithLargeBody) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; expectCheckRequestWithBody(Http::CodecType::HTTP1, 2048); } // Verifies that the request body is included in the CheckRequest when the downstream protocol is // HTTP/2. TEST_P(ExtAuthzGrpcIntegrationTest, HTTP2DownstreamRequestWithBody) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; expectCheckRequestWithBody(Http::CodecType::HTTP2, 4); } // Verifies that the request body is included in the CheckRequest when the downstream protocol is // HTTP/2 and the size of the request body is larger than max_request_bytes. TEST_P(ExtAuthzGrpcIntegrationTest, HTTP2DownstreamRequestWithLargeBody) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; expectCheckRequestWithBody(Http::CodecType::HTTP2, 2048); } @@ -625,7 +617,6 @@ TEST_P(ExtAuthzGrpcIntegrationTest, HTTP2DownstreamRequestWithLargeBody) { // server returns headers_to_add, response_headers_to_add, and headers_to_append in OkResponse // message. TEST_P(ExtAuthzGrpcIntegrationTest, SendHeadersToAddAndToAppendToUpstream) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; expectCheckRequestWithBodyWithHeaders( Http::CodecType::HTTP1, 4, /*headers_to_add=*/Headers{{"header1", "header1"}}, @@ -638,27 +629,22 @@ TEST_P(ExtAuthzGrpcIntegrationTest, SendHeadersToAddAndToAppendToUpstream) { } TEST_P(ExtAuthzGrpcIntegrationTest, AllowAtDisable) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; expectFilterDisableCheck(/*deny_at_disable=*/false, /*disable_with_metadata=*/false, "200"); } TEST_P(ExtAuthzGrpcIntegrationTest, AllowAtDisableWithMetadata) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; expectFilterDisableCheck(/*deny_at_disable=*/false, /*disable_with_metadata=*/true, "200"); } TEST_P(ExtAuthzGrpcIntegrationTest, DenyAtDisable) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; expectFilterDisableCheck(/*deny_at_disable=*/true, /*disable_with_metadata=*/false, "403"); } TEST_P(ExtAuthzGrpcIntegrationTest, DenyAtDisableWithMetadata) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; expectFilterDisableCheck(/*deny_at_disable=*/true, /*disable_with_metadata=*/true, "403"); } TEST_P(ExtAuthzGrpcIntegrationTest, DownstreamHeadersOnSuccess) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; // Set up ext_authz filter. initializeConfig(); @@ -853,7 +839,6 @@ TEST_P(ExtAuthzLocalReplyIntegrationTest, DeniedHeaderTest) { } TEST_P(ExtAuthzGrpcIntegrationTest, GoogleAsyncClientCreation) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initializeConfig(); setDownstreamProtocol(Http::CodecType::HTTP2); HttpIntegrationTest::initialize(); @@ -889,8 +874,7 @@ TEST_P(ExtAuthzGrpcIntegrationTest, GoogleAsyncClientCreation) { RELEASE_ASSERT(result, result.message()); EXPECT_EQ("POST", ext_authz_request_->headers().getMethodValue()); - EXPECT_EQ(TestUtility::getVersionedMethodPath("envoy.service.auth.{}.Authorization", "Check", - apiVersion()), + EXPECT_EQ("/envoy.service.auth.v3.Authorization/Check", ext_authz_request_->headers().getPathValue()); EXPECT_EQ("application/grpc", ext_authz_request_->headers().getContentTypeValue()); result = ext_authz_request_->waitForEndStream(*dispatcher_); diff --git a/test/extensions/filters/http/lua/lua_integration_test.cc b/test/extensions/filters/http/lua/lua_integration_test.cc index 118af6ae224b..a1ec02924953 100644 --- a/test/extensions/filters/http/lua/lua_integration_test.cc +++ b/test/extensions/filters/http/lua/lua_integration_test.cc @@ -78,9 +78,7 @@ class LuaIntegrationTest : public testing::TestWithParamadd_clusters(); ratelimit_cluster->MergeFrom(bootstrap.static_resources().clusters()[0]); @@ -62,7 +56,8 @@ class RatelimitIntegrationTest : public Grpc::VersionedGrpcClientIntegrationPara proto_config_.set_disable_x_envoy_ratelimited_header(disable_x_envoy_ratelimited_header_); setGrpcService(*proto_config_.mutable_rate_limit_service()->mutable_grpc_service(), "ratelimit", fake_upstreams_.back()->localAddress()); - proto_config_.mutable_rate_limit_service()->set_transport_api_version(apiVersion()); + proto_config_.mutable_rate_limit_service()->set_transport_api_version( + envoy::config::core::v3::ApiVersion::V3); envoy::config::listener::v3::Filter ratelimit_filter; ratelimit_filter.set_name("envoy.filters.http.ratelimit"); @@ -111,8 +106,7 @@ class RatelimitIntegrationTest : public Grpc::VersionedGrpcClientIntegrationPara result = ratelimit_requests_[i]->waitForEndStream(*dispatcher_); RELEASE_ASSERT(result, result.message()); EXPECT_EQ("POST", ratelimit_requests_[i]->headers().getMethodValue()); - EXPECT_EQ(TestUtility::getVersionedMethodPath("envoy.service.ratelimit.{}.RateLimitService", - "ShouldRateLimit", apiVersion()), + EXPECT_EQ("/envoy.service.ratelimit.v3.RateLimitService/ShouldRateLimit", ratelimit_requests_[i]->headers().getPathValue()); EXPECT_EQ("application/grpc", ratelimit_requests_[i]->headers().getContentTypeValue()); @@ -238,26 +232,22 @@ class RatelimitFilterEnvoyRatelimitedHeaderDisabledIntegrationTest }; INSTANTIATE_TEST_SUITE_P(IpVersionsClientType, RatelimitIntegrationTest, - VERSIONED_GRPC_CLIENT_INTEGRATION_PARAMS, - Grpc::VersionedGrpcClientIntegrationParamTest::protocolTestParamsToString); + GRPC_CLIENT_INTEGRATION_PARAMS, + Grpc::GrpcClientIntegrationParamTest::protocolTestParamsToString); INSTANTIATE_TEST_SUITE_P(IpVersionsClientType, RatelimitFailureModeIntegrationTest, - VERSIONED_GRPC_CLIENT_INTEGRATION_PARAMS, - Grpc::VersionedGrpcClientIntegrationParamTest::protocolTestParamsToString); + GRPC_CLIENT_INTEGRATION_PARAMS, + Grpc::GrpcClientIntegrationParamTest::protocolTestParamsToString); INSTANTIATE_TEST_SUITE_P(IpVersionsClientType, RatelimitFilterHeadersEnabledIntegrationTest, - VERSIONED_GRPC_CLIENT_INTEGRATION_PARAMS, - Grpc::VersionedGrpcClientIntegrationParamTest::protocolTestParamsToString); + GRPC_CLIENT_INTEGRATION_PARAMS, + Grpc::GrpcClientIntegrationParamTest::protocolTestParamsToString); INSTANTIATE_TEST_SUITE_P(IpVersionsClientType, RatelimitFilterEnvoyRatelimitedHeaderDisabledIntegrationTest, - VERSIONED_GRPC_CLIENT_INTEGRATION_PARAMS, - Grpc::VersionedGrpcClientIntegrationParamTest::protocolTestParamsToString); + GRPC_CLIENT_INTEGRATION_PARAMS, + Grpc::GrpcClientIntegrationParamTest::protocolTestParamsToString); -TEST_P(RatelimitIntegrationTest, Ok) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; - basicFlow(); -} +TEST_P(RatelimitIntegrationTest, Ok) { basicFlow(); } TEST_P(RatelimitIntegrationTest, OkWithHeaders) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initiateClientConnection(); waitForRatelimitRequest(); Http::TestResponseHeaderMapImpl ratelimit_response_headers{{"x-ratelimit-limit", "1000"}, @@ -282,7 +272,6 @@ TEST_P(RatelimitIntegrationTest, OkWithHeaders) { } TEST_P(RatelimitIntegrationTest, OverLimit) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initiateClientConnection(); waitForRatelimitRequest(); sendRateLimitResponse(envoy::service::ratelimit::v3::RateLimitResponse::OVER_LIMIT, {}, @@ -301,7 +290,6 @@ TEST_P(RatelimitIntegrationTest, OverLimit) { } TEST_P(RatelimitIntegrationTest, OverLimitWithHeaders) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initiateClientConnection(); waitForRatelimitRequest(); Http::TestResponseHeaderMapImpl ratelimit_response_headers{ @@ -329,7 +317,6 @@ TEST_P(RatelimitIntegrationTest, OverLimitWithHeaders) { } TEST_P(RatelimitIntegrationTest, Error) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initiateClientConnection(); waitForRatelimitRequest(); ratelimit_requests_[0]->encodeHeaders(Http::TestResponseHeaderMapImpl{{":status", "404"}}, true); @@ -344,7 +331,6 @@ TEST_P(RatelimitIntegrationTest, Error) { } TEST_P(RatelimitIntegrationTest, Timeout) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initiateClientConnection(); waitForRatelimitRequest(); switch (clientType()) { @@ -368,7 +354,6 @@ TEST_P(RatelimitIntegrationTest, Timeout) { } TEST_P(RatelimitIntegrationTest, ConnectImmediateDisconnect) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initiateClientConnection(); ASSERT_TRUE(fake_upstreams_[1]->waitForHttpConnection(*dispatcher_, fake_ratelimit_connection_)); ASSERT_TRUE(fake_ratelimit_connection_->close()); @@ -380,7 +365,6 @@ TEST_P(RatelimitIntegrationTest, ConnectImmediateDisconnect) { } TEST_P(RatelimitIntegrationTest, FailedConnect) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; // Do not reset the fake upstream for the ratelimiter, but have it stop listening. // If we reset, the Envoy will continue to send H2 to the original rate limiter port, which may // be used by another test, and data sent to that port "unexpectedly" will cause problems for @@ -393,7 +377,6 @@ TEST_P(RatelimitIntegrationTest, FailedConnect) { } TEST_P(RatelimitFailureModeIntegrationTest, ErrorWithFailureModeOff) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initiateClientConnection(); waitForRatelimitRequest(); ratelimit_requests_[0]->encodeHeaders(Http::TestResponseHeaderMapImpl{{":status", "503"}}, true); @@ -408,7 +391,6 @@ TEST_P(RatelimitFailureModeIntegrationTest, ErrorWithFailureModeOff) { } TEST_P(RatelimitFilterHeadersEnabledIntegrationTest, OkWithFilterHeaders) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initiateClientConnection(); waitForRatelimitRequest(); @@ -444,7 +426,6 @@ TEST_P(RatelimitFilterHeadersEnabledIntegrationTest, OkWithFilterHeaders) { } TEST_P(RatelimitFilterHeadersEnabledIntegrationTest, OverLimitWithFilterHeaders) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initiateClientConnection(); waitForRatelimitRequest(); @@ -482,7 +463,6 @@ TEST_P(RatelimitFilterHeadersEnabledIntegrationTest, OverLimitWithFilterHeaders) TEST_P(RatelimitFilterEnvoyRatelimitedHeaderDisabledIntegrationTest, OverLimitWithoutEnvoyRatelimitedHeader) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initiateClientConnection(); waitForRatelimitRequest(); sendRateLimitResponse(envoy::service::ratelimit::v3::RateLimitResponse::OVER_LIMIT, {}, @@ -500,7 +480,6 @@ TEST_P(RatelimitFilterEnvoyRatelimitedHeaderDisabledIntegrationTest, } TEST_P(RatelimitIntegrationTest, OverLimitAndOK) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; const int num_requests = 4; setNumRequests(num_requests); diff --git a/test/extensions/filters/http/router/config_test.cc b/test/extensions/filters/http/router/config_test.cc index af752c3192d4..65d3f85544e7 100644 --- a/test/extensions/filters/http/router/config_test.cc +++ b/test/extensions/filters/http/router/config_test.cc @@ -27,7 +27,7 @@ TEST(RouterFilterConfigTest, SimpleRouterFilterConfig) { )EOF"; envoy::extensions::filters::http::router::v3::Router proto_config; - TestUtility::loadFromYaml(yaml_string, proto_config, false, true); + TestUtility::loadFromYaml(yaml_string, proto_config); NiceMock context; RouterFilterConfig factory; Http::FilterFactoryCb cb = factory.createFilterFactoryFromProto(proto_config, "stats.", context); @@ -43,8 +43,8 @@ TEST(RouterFilterConfigTest, BadRouterFilterConfig) { )EOF"; envoy::extensions::filters::http::router::v3::Router proto_config; - EXPECT_THROW_WITH_REGEX(TestUtility::loadFromYaml(yaml_string, proto_config, false, true), - EnvoyException, "route: Cannot find field"); + EXPECT_THROW_WITH_REGEX(TestUtility::loadFromYaml(yaml_string, proto_config), EnvoyException, + "route: Cannot find field"); } TEST(RouterFilterConfigTest, RouterFilterWithUnsupportedStrictHeaderCheck) { @@ -54,7 +54,7 @@ TEST(RouterFilterConfigTest, RouterFilterWithUnsupportedStrictHeaderCheck) { )EOF"; envoy::extensions::filters::http::router::v3::Router router_config; - TestUtility::loadFromYaml(yaml, router_config, false, true); + TestUtility::loadFromYaml(yaml, router_config); NiceMock context; RouterFilterConfig factory; diff --git a/test/extensions/filters/network/common/fuzz/uber_readfilter.cc b/test/extensions/filters/network/common/fuzz/uber_readfilter.cc index 2179484abcda..ca021727c2d1 100644 --- a/test/extensions/filters/network/common/fuzz/uber_readfilter.cc +++ b/test/extensions/filters/network/common/fuzz/uber_readfilter.cc @@ -1,7 +1,6 @@ #include "test/extensions/filters/network/common/fuzz/uber_readfilter.h" #include "source/common/config/utility.h" -#include "source/common/config/version_converter.h" #include "source/common/network/address_impl.h" using testing::Return; diff --git a/test/extensions/filters/network/common/fuzz/uber_writefilter.cc b/test/extensions/filters/network/common/fuzz/uber_writefilter.cc index da4979656e82..6772fe995e22 100644 --- a/test/extensions/filters/network/common/fuzz/uber_writefilter.cc +++ b/test/extensions/filters/network/common/fuzz/uber_writefilter.cc @@ -1,7 +1,6 @@ #include "test/extensions/filters/network/common/fuzz/uber_writefilter.h" #include "source/common/config/utility.h" -#include "source/common/config/version_converter.h" using testing::_; using testing::Return; diff --git a/test/extensions/filters/network/dubbo_proxy/config_test.cc b/test/extensions/filters/network/dubbo_proxy/config_test.cc index e10262aa646b..c525e3638c3a 100644 --- a/test/extensions/filters/network/dubbo_proxy/config_test.cc +++ b/test/extensions/filters/network/dubbo_proxy/config_test.cc @@ -22,9 +22,9 @@ using DubboProxyProto = envoy::extensions::filters::network::dubbo_proxy::v3::Du namespace { -DubboProxyProto parseDubboProxyFromV3Yaml(const std::string& yaml, bool avoid_boosting = true) { +DubboProxyProto parseDubboProxyFromV3Yaml(const std::string& yaml) { DubboProxyProto dubbo_proxy; - TestUtility::loadFromYaml(yaml, dubbo_proxy, false, avoid_boosting); + TestUtility::loadFromYaml(yaml, dubbo_proxy); return dubbo_proxy; } diff --git a/test/extensions/filters/network/ext_authz/config_test.cc b/test/extensions/filters/network/ext_authz/config_test.cc index 470026c43da1..2d26fc050621 100644 --- a/test/extensions/filters/network/ext_authz/config_test.cc +++ b/test/extensions/filters/network/ext_authz/config_test.cc @@ -21,11 +21,7 @@ namespace NetworkFilters { namespace ExtAuthz { namespace { -void expectCorrectProto(envoy::config::core::v3::ApiVersion api_version) { - std::unique_ptr _deprecated_v2_api; - if (api_version != envoy::config::core::v3::ApiVersion::V3) { - _deprecated_v2_api = std::make_unique(); - } +void expectCorrectProto() { std::string yaml = R"EOF( grpc_service: google_grpc: @@ -33,13 +29,12 @@ void expectCorrectProto(envoy::config::core::v3::ApiVersion api_version) { stat_prefix: google failure_mode_allow: false stat_prefix: name - transport_api_version: {} + transport_api_version: V3 )EOF"; ExtAuthzConfigFactory factory; ProtobufTypes::MessagePtr proto_config = factory.createEmptyConfigProto(); - TestUtility::loadFromYaml( - fmt::format(yaml, TestUtility::getVersionStringFromApiVersion(api_version)), *proto_config); + TestUtility::loadFromYaml(yaml, *proto_config); NiceMock context; testing::StrictMock server_context; @@ -67,13 +62,7 @@ TEST(ExtAuthzFilterConfigTest, ValidateFail) { ProtoValidationException); } -TEST(ExtAuthzFilterConfigTest, ExtAuthzCorrectProto) { -#ifndef ENVOY_DISABLE_DEPRECATED_FEATURES - expectCorrectProto(envoy::config::core::v3::ApiVersion::AUTO); - expectCorrectProto(envoy::config::core::v3::ApiVersion::V2); -#endif - expectCorrectProto(envoy::config::core::v3::ApiVersion::V3); -} +TEST(ExtAuthzFilterConfigTest, ExtAuthzCorrectProto) { expectCorrectProto(); } // Test that the deprecated extension name still functions. TEST(ExtAuthzConfigTest, DEPRECATED_FEATURE_TEST(DeprecatedExtensionFilterName)) { diff --git a/test/extensions/filters/network/http_connection_manager/config_test.cc b/test/extensions/filters/network/http_connection_manager/config_test.cc index d650301d5976..eb19cc514de3 100644 --- a/test/extensions/filters/network/http_connection_manager/config_test.cc +++ b/test/extensions/filters/network/http_connection_manager/config_test.cc @@ -143,10 +143,7 @@ stat_prefix: router "chain."); } -// When deprecating v2, remove the old style "operation_name: egress" config -// but retain the rest of the test. -TEST_F(HttpConnectionManagerConfigTest, DEPRECATED_FEATURE_TEST(MiscConfig)) { - TestDeprecatedV2Api _deprecated_v2_api; +TEST_F(HttpConnectionManagerConfigTest, MiscConfig) { const std::string yaml_string = R"EOF( codec_type: http1 server_name: foo @@ -162,14 +159,13 @@ stat_prefix: router route: cluster: cluster tracing: - operation_name: egress max_path_tag_length: 128 http_filters: - name: envoy.filters.http.router )EOF"; - HttpConnectionManagerConfig config(parseHttpConnectionManagerFromYaml(yaml_string, false), - context_, date_provider_, route_config_provider_manager_, + HttpConnectionManagerConfig config(parseHttpConnectionManagerFromYaml(yaml_string), context_, + date_provider_, route_config_provider_manager_, scoped_routes_config_provider_manager_, http_tracer_manager_, filter_config_provider_manager_); @@ -455,8 +451,8 @@ stat_prefix: router EXPECT_CALL(http_tracer_manager_, getOrCreateHttpTracer(Pointee(ProtoEq(inlined_tracing_config)))) .WillOnce(Return(http_tracer_)); - HttpConnectionManagerConfig config(parseHttpConnectionManagerFromYaml(yaml_string, false), - context_, date_provider_, route_config_provider_manager_, + HttpConnectionManagerConfig config(parseHttpConnectionManagerFromYaml(yaml_string), context_, + date_provider_, route_config_provider_manager_, scoped_routes_config_provider_manager_, http_tracer_manager_, filter_config_provider_manager_); @@ -511,8 +507,8 @@ TEST_F(HttpConnectionManagerConfigTest, SamplingDefault) { - name: envoy.filters.http.router )EOF"; - HttpConnectionManagerConfig config(parseHttpConnectionManagerFromYaml(yaml_string, false), - context_, date_provider_, route_config_provider_manager_, + HttpConnectionManagerConfig config(parseHttpConnectionManagerFromYaml(yaml_string), context_, + date_provider_, route_config_provider_manager_, scoped_routes_config_provider_manager_, http_tracer_manager_, filter_config_provider_manager_); @@ -546,8 +542,8 @@ TEST_F(HttpConnectionManagerConfigTest, SamplingConfigured) { - name: envoy.filters.http.router )EOF"; - HttpConnectionManagerConfig config(parseHttpConnectionManagerFromYaml(yaml_string, false), - context_, date_provider_, route_config_provider_manager_, + HttpConnectionManagerConfig config(parseHttpConnectionManagerFromYaml(yaml_string), context_, + date_provider_, route_config_provider_manager_, scoped_routes_config_provider_manager_, http_tracer_manager_, filter_config_provider_manager_); @@ -580,8 +576,8 @@ TEST_F(HttpConnectionManagerConfigTest, FractionalSamplingConfigured) { - name: envoy.filters.http.router )EOF"; - HttpConnectionManagerConfig config(parseHttpConnectionManagerFromYaml(yaml_string, false), - context_, date_provider_, route_config_provider_manager_, + HttpConnectionManagerConfig config(parseHttpConnectionManagerFromYaml(yaml_string), context_, + date_provider_, route_config_provider_manager_, scoped_routes_config_provider_manager_, http_tracer_manager_, filter_config_provider_manager_); @@ -614,8 +610,8 @@ TEST_F(HttpConnectionManagerConfigTest, OverallSampling) { - name: envoy.filters.http.router )EOF"; - HttpConnectionManagerConfig config(parseHttpConnectionManagerFromYaml(yaml_string, false), - context_, date_provider_, route_config_provider_manager_, + HttpConnectionManagerConfig config(parseHttpConnectionManagerFromYaml(yaml_string), context_, + date_provider_, route_config_provider_manager_, scoped_routes_config_provider_manager_, http_tracer_manager_, filter_config_provider_manager_); @@ -2451,7 +2447,7 @@ TEST_F(HttpConnectionManagerMobileConfigTest, Mobile) { envoy::extensions::filters::network::http_connection_manager::v3::EnvoyMobileHttpConnectionManager config; - TestUtility::loadFromYamlAndValidate(yaml_string, config, false, true); + TestUtility::loadFromYamlAndValidate(yaml_string, config); MobileHttpConnectionManagerFilterConfigFactory factory; Network::FilterFactoryCb create_hcm_cb = factory.createFilterFactoryFromProto(config, context_); diff --git a/test/extensions/filters/network/http_connection_manager/config_test_base.h b/test/extensions/filters/network/http_connection_manager/config_test_base.h index bc26f1aaad5c..995cb9842e14 100644 --- a/test/extensions/filters/network/http_connection_manager/config_test_base.h +++ b/test/extensions/filters/network/http_connection_manager/config_test_base.h @@ -24,10 +24,10 @@ namespace NetworkFilters { namespace HttpConnectionManager { envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager -parseHttpConnectionManagerFromYaml(const std::string& yaml, bool avoid_boosting = true) { +parseHttpConnectionManagerFromYaml(const std::string& yaml) { envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager http_connection_manager; - TestUtility::loadFromYamlAndValidate(yaml, http_connection_manager, false, avoid_boosting); + TestUtility::loadFromYamlAndValidate(yaml, http_connection_manager); return http_connection_manager; } diff --git a/test/extensions/filters/network/ratelimit/ratelimit_test.cc b/test/extensions/filters/network/ratelimit/ratelimit_test.cc index c59ba01e37a1..3be03981d489 100644 --- a/test/extensions/filters/network/ratelimit/ratelimit_test.cc +++ b/test/extensions/filters/network/ratelimit/ratelimit_test.cc @@ -41,7 +41,7 @@ class RateLimitFilterTest : public testing::Test { .WillByDefault(Return(true)); envoy::extensions::filters::network::ratelimit::v3::RateLimit proto_config{}; - TestUtility::loadFromYaml(yaml, proto_config, false, true); + TestUtility::loadFromYaml(yaml, proto_config); config_ = std::make_shared(proto_config, stats_store_, runtime_); client_ = new Filters::Common::RateLimit::MockClient(); filter_ = std::make_unique(config_, Filters::Common::RateLimit::ClientPtr{client_}); diff --git a/test/extensions/filters/network/tcp_proxy/config_test.cc b/test/extensions/filters/network/tcp_proxy/config_test.cc index 201379a7ce6b..4fabbeadcf22 100644 --- a/test/extensions/filters/network/tcp_proxy/config_test.cc +++ b/test/extensions/filters/network/tcp_proxy/config_test.cc @@ -19,94 +19,6 @@ namespace Extensions { namespace NetworkFilters { namespace TcpProxy { -class RouteIpListConfigTest : public testing::TestWithParam {}; - -INSTANTIATE_TEST_SUITE_P(IpList, RouteIpListConfigTest, - ::testing::Values(R"EOF("destination_ip_list": [ - { - "address_prefix": "192.168.1.1", - "prefix_len": 32 - }, - { - "address_prefix": "192.168.1.0", - "prefix_len": 24 - } - ], - "source_ip_list": [ - { - "address_prefix": "192.168.0.0", - "prefix_len": 16 - }, - { - "address_prefix": "192.0.0.0", - "prefix_len": 8 - }, - { - "address_prefix": "127.0.0.0", - "prefix_len": 8 - } - ],)EOF", - R"EOF("destination_ip_list": [ - { - "address_prefix": "2001:abcd::", - "prefix_len": 64 - }, - { - "address_prefix": "2002:ffff::", - "prefix_len": 32 - } - ], - "source_ip_list": [ - { - "address_prefix": "ffee::", - "prefix_len": 128 - }, - { - "address_prefix": "2001::abcd", - "prefix_len": 64 - }, - { - "address_prefix": "1234::5678", - "prefix_len": 128 - } - ],)EOF")); - -TEST_P(RouteIpListConfigTest, DEPRECATED_FEATURE_TEST(TcpProxy)) { - TestDeprecatedV2Api _deprecated_v2_api; - const std::string json_string = R"EOF( - { - "stat_prefix": "my_stat_prefix", - "cluster": "foobar", - "deprecated_v1": { - "routes": [ - {)EOF" + GetParam() + - R"EOF("destination_ports": "1-1024,2048-4096,12345", - "cluster": "fake_cluster" - }, - { - "source_ports": "23457,23459", - "cluster": "fake_cluster2" - } - ] - } - } - )EOF"; - - envoy::extensions::filters::network::tcp_proxy::v3::TcpProxy proto_config; - TestUtility::loadFromJson(json_string, proto_config, true, false); - - NiceMock context; - ConfigFactory factory; - Network::FilterFactoryCb cb = factory.createFilterFactoryFromProto(proto_config, context); - Network::MockConnection connection; - NiceMock readFilterCallback; - EXPECT_CALL(connection, addReadFilter(_)) - .WillRepeatedly(Invoke([&readFilterCallback](Network::ReadFilterSharedPtr filter) { - filter->initializeReadFilterCallbacks(readFilterCallback); - })); - cb(connection); -} - TEST(ConfigTest, ValidateFail) { NiceMock context; EXPECT_THROW(ConfigFactory().createFilterFactoryFromProto( diff --git a/test/extensions/filters/network/thrift_proxy/filters/ratelimit/config_test.cc b/test/extensions/filters/network/thrift_proxy/filters/ratelimit/config_test.cc index a41499d5f0af..4e8c596a0647 100644 --- a/test/extensions/filters/network/thrift_proxy/filters/ratelimit/config_test.cc +++ b/test/extensions/filters/network/thrift_proxy/filters/ratelimit/config_test.cc @@ -19,9 +19,9 @@ namespace RateLimitFilter { namespace { envoy::extensions::filters::network::thrift_proxy::filters::ratelimit::v3::RateLimit -parseRateLimitFromV3Yaml(const std::string& yaml, bool avoid_boosting = true) { +parseRateLimitFromV3Yaml(const std::string& yaml) { envoy::extensions::filters::network::thrift_proxy::filters::ratelimit::v3::RateLimit rate_limit; - TestUtility::loadFromYaml(yaml, rate_limit, false, avoid_boosting); + TestUtility::loadFromYaml(yaml, rate_limit); return rate_limit; } diff --git a/test/extensions/filters/network/thrift_proxy/filters/ratelimit/ratelimit_test.cc b/test/extensions/filters/network/thrift_proxy/filters/ratelimit/ratelimit_test.cc index 88ff099bce75..8e386fff3bc2 100644 --- a/test/extensions/filters/network/thrift_proxy/filters/ratelimit/ratelimit_test.cc +++ b/test/extensions/filters/network/thrift_proxy/filters/ratelimit/ratelimit_test.cc @@ -53,7 +53,7 @@ class ThriftRateLimitFilterTest : public testing::Test { void setupTest(const std::string& yaml) { envoy::extensions::filters::network::thrift_proxy::filters::ratelimit::v3::RateLimit proto_config{}; - TestUtility::loadFromYaml(yaml, proto_config, false, true); + TestUtility::loadFromYaml(yaml, proto_config); config_ = std::make_shared(proto_config, local_info_, stats_store_, runtime_, cm_); diff --git a/test/extensions/filters/network/thrift_proxy/route_matcher_test.cc b/test/extensions/filters/network/thrift_proxy/route_matcher_test.cc index 8e19060b27e7..4368eab78d72 100644 --- a/test/extensions/filters/network/thrift_proxy/route_matcher_test.cc +++ b/test/extensions/filters/network/thrift_proxy/route_matcher_test.cc @@ -20,9 +20,9 @@ namespace Router { namespace { envoy::extensions::filters::network::thrift_proxy::v3::RouteConfiguration -parseRouteConfigurationFromV3Yaml(const std::string& yaml, bool avoid_boosting = true) { +parseRouteConfigurationFromV3Yaml(const std::string& yaml) { envoy::extensions::filters::network::thrift_proxy::v3::RouteConfiguration route_config; - TestUtility::loadFromYaml(yaml, route_config, false, avoid_boosting); + TestUtility::loadFromYaml(yaml, route_config); TestUtility::validate(route_config); return route_config; } diff --git a/test/extensions/filters/network/thrift_proxy/router_ratelimit_test.cc b/test/extensions/filters/network/thrift_proxy/router_ratelimit_test.cc index cb44c2df4134..d7be72660e9a 100644 --- a/test/extensions/filters/network/thrift_proxy/router_ratelimit_test.cc +++ b/test/extensions/filters/network/thrift_proxy/router_ratelimit_test.cc @@ -31,9 +31,9 @@ namespace { class ThriftRateLimitConfigurationTest : public testing::Test { public: - void initialize(const std::string& yaml, bool avoid_boosting = true) { + void initialize(const std::string& yaml) { envoy::extensions::filters::network::thrift_proxy::v3::ThriftProxy config; - TestUtility::loadFromYaml(yaml, config, false, avoid_boosting); + TestUtility::loadFromYaml(yaml, config); initialize(config); } diff --git a/test/extensions/filters/network/zookeeper_proxy/config_test.cc b/test/extensions/filters/network/zookeeper_proxy/config_test.cc index e88dbacd1ab0..a465c5c47eff 100644 --- a/test/extensions/filters/network/zookeeper_proxy/config_test.cc +++ b/test/extensions/filters/network/zookeeper_proxy/config_test.cc @@ -49,7 +49,7 @@ stat_prefix: test_prefix )EOF"; ZooKeeperProxyProtoConfig proto_config; - TestUtility::loadFromYamlAndValidate(yaml, proto_config, false, true); + TestUtility::loadFromYamlAndValidate(yaml, proto_config); testing::NiceMock context; ZooKeeperConfigFactory factory; diff --git a/test/extensions/health_checkers/redis/config_test.cc b/test/extensions/health_checkers/redis/config_test.cc index fbd5db3ee52e..644bf0538e26 100644 --- a/test/extensions/health_checkers/redis/config_test.cc +++ b/test/extensions/health_checkers/redis/config_test.cc @@ -21,31 +21,6 @@ namespace { using CustomRedisHealthChecker = Extensions::HealthCheckers::RedisHealthChecker::RedisHealthChecker; -TEST(HealthCheckerFactoryTest, DEPRECATED_FEATURE_TEST(CreateRedisDeprecated)) { - TestDeprecatedV2Api _deprecated_v2_api; - const std::string yaml = R"EOF( - timeout: 1s - interval: 1s - no_traffic_interval: 5s - interval_jitter: 1s - unhealthy_threshold: 1 - healthy_threshold: 1 - custom_health_check: - name: envoy.health_checkers.redis - config: - key: foo - )EOF"; - - NiceMock context; - - RedisHealthCheckerFactory factory; - EXPECT_NE(nullptr, dynamic_cast( - factory - .createCustomHealthChecker( - Upstream::parseHealthCheckFromV3Yaml(yaml, false), context) - .get())); -} - TEST(HealthCheckerFactoryTest, CreateRedis) { const std::string yaml = R"EOF( timeout: 1s @@ -71,30 +46,6 @@ TEST(HealthCheckerFactoryTest, CreateRedis) { .get())); } -TEST(HealthCheckerFactoryTest, DEPRECATED_FEATURE_TEST(CreateRedisWithoutKeyDeprecated)) { - TestDeprecatedV2Api _deprecated_v2_api; - const std::string yaml = R"EOF( - timeout: 1s - interval: 1s - no_traffic_interval: 5s - interval_jitter: 1s - unhealthy_threshold: 1 - healthy_threshold: 1 - custom_health_check: - name: envoy.health_checkers.redis - config: - )EOF"; - - NiceMock context; - - RedisHealthCheckerFactory factory; - EXPECT_NE(nullptr, dynamic_cast( - factory - .createCustomHealthChecker( - Upstream::parseHealthCheckFromV3Yaml(yaml, false), context) - .get())); -} - TEST(HealthCheckerFactoryTest, CreateRedisWithoutKey) { const std::string yaml = R"EOF( timeout: 1s diff --git a/test/extensions/rate_limit_descriptors/expr/config_test.cc b/test/extensions/rate_limit_descriptors/expr/config_test.cc index 57094c6805e6..805a45bf5fc4 100644 --- a/test/extensions/rate_limit_descriptors/expr/config_test.cc +++ b/test/extensions/rate_limit_descriptors/expr/config_test.cc @@ -26,7 +26,7 @@ class RateLimitPolicyEntryTest : public testing::Test { public: void setupTest(const std::string& yaml) { envoy::config::route::v3::RateLimit rate_limit; - TestUtility::loadFromYaml(yaml, rate_limit, false, true); + TestUtility::loadFromYaml(yaml, rate_limit); TestUtility::validate(rate_limit); rate_limit_entry_ = std::make_unique( rate_limit, ProtobufMessage::getStrictValidationVisitor()); diff --git a/test/extensions/stats_sinks/metrics_service/grpc_metrics_service_impl_test.cc b/test/extensions/stats_sinks/metrics_service/grpc_metrics_service_impl_test.cc index 5f1a6724dc8e..136b4b83d85c 100644 --- a/test/extensions/stats_sinks/metrics_service/grpc_metrics_service_impl_test.cc +++ b/test/extensions/stats_sinks/metrics_service/grpc_metrics_service_impl_test.cc @@ -32,8 +32,7 @@ class GrpcMetricsStreamerImplTest : public testing::Test { GrpcMetricsStreamerImplTest() { streamer_ = std::make_unique( - Grpc::RawAsyncClientSharedPtr{async_client_}, local_info_, - envoy::config::core::v3::ApiVersion::AUTO); + Grpc::RawAsyncClientSharedPtr{async_client_}, local_info_); } void expectStreamStart(MockMetricsStream& stream, MetricsServiceCallbacks** callbacks_to_set) { diff --git a/test/extensions/stats_sinks/metrics_service/metrics_service_integration_test.cc b/test/extensions/stats_sinks/metrics_service/metrics_service_integration_test.cc index 2f43d87e8cc7..8c7d8a16a854 100644 --- a/test/extensions/stats_sinks/metrics_service/metrics_service_integration_test.cc +++ b/test/extensions/stats_sinks/metrics_service/metrics_service_integration_test.cc @@ -18,7 +18,7 @@ using testing::AssertionResult; namespace Envoy { namespace { -class MetricsServiceIntegrationTest : public Grpc::VersionedGrpcClientIntegrationParamTest, +class MetricsServiceIntegrationTest : public Grpc::GrpcClientIntegrationParamTest, public HttpIntegrationTest { public: MetricsServiceIntegrationTest() : HttpIntegrationTest(Http::CodecType::HTTP1, ipVersion()) {} @@ -29,9 +29,6 @@ class MetricsServiceIntegrationTest : public Grpc::VersionedGrpcClientIntegratio } void initialize() override { - if (apiVersion() != envoy::config::core::v3::ApiVersion::V3) { - config_helper_.enableDeprecatedV2Api(); - } config_helper_.addConfigModifier([this](envoy::config::bootstrap::v3::Bootstrap& bootstrap) { // metrics_service cluster for Envoy gRPC. auto* metrics_service_cluster = bootstrap.mutable_static_resources()->add_clusters(); @@ -44,7 +41,7 @@ class MetricsServiceIntegrationTest : public Grpc::VersionedGrpcClientIntegratio envoy::config::metrics::v3::MetricsServiceConfig config; setGrpcService(*config.mutable_grpc_service(), "metrics_service", fake_upstreams_.back()->localAddress()); - config.set_transport_api_version(apiVersion()); + config.set_transport_api_version(envoy::config::core::v3::ApiVersion::V3); metrics_sink->mutable_typed_config()->PackFrom(config); // Shrink reporting period down to 1s to make test not take forever. bootstrap.mutable_stats_flush_interval()->CopyFrom( @@ -82,8 +79,7 @@ class MetricsServiceIntegrationTest : public Grpc::VersionedGrpcClientIntegratio envoy::service::metrics::v3::StreamMetricsMessage request_msg; VERIFY_ASSERTION(metrics_service_request_->waitForGrpcMessage(*dispatcher_, request_msg)); EXPECT_EQ("POST", metrics_service_request_->headers().getMethodValue()); - EXPECT_EQ(TestUtility::getVersionedMethodPath("envoy.service.metrics.{}.MetricsService", - "StreamMetrics", apiVersion()), + EXPECT_EQ("/envoy.service.metrics.v3.MetricsService/StreamMetrics", metrics_service_request_->headers().getPathValue()); EXPECT_EQ("application/grpc", metrics_service_request_->headers().getContentTypeValue()); EXPECT_TRUE(request_msg.envoy_metrics_size() > 0); @@ -149,12 +145,11 @@ class MetricsServiceIntegrationTest : public Grpc::VersionedGrpcClientIntegratio }; INSTANTIATE_TEST_SUITE_P(IpVersionsClientType, MetricsServiceIntegrationTest, - VERSIONED_GRPC_CLIENT_INTEGRATION_PARAMS, - Grpc::VersionedGrpcClientIntegrationParamTest::protocolTestParamsToString); + GRPC_CLIENT_INTEGRATION_PARAMS, + Grpc::GrpcClientIntegrationParamTest::protocolTestParamsToString); // Test a basic metric service flow. TEST_P(MetricsServiceIntegrationTest, BasicFlow) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initialize(); // Send an empty request so that histogram values merged for cluster_0. codec_client_ = makeHttpConnection(makeClientConnection(lookupPort("http"))); diff --git a/test/extensions/transport_sockets/tls/context_impl_test.cc b/test/extensions/transport_sockets/tls/context_impl_test.cc index 659df517e6d2..5e2de45ee381 100644 --- a/test/extensions/transport_sockets/tls/context_impl_test.cc +++ b/test/extensions/transport_sockets/tls/context_impl_test.cc @@ -699,10 +699,9 @@ class SslServerContextImplTicketTest : public SslContextImplTest { loadConfig(server_context_config); } - void loadConfigYaml(const std::string& yaml, bool avoid_boosting = true) { + void loadConfigYaml(const std::string& yaml) { envoy::extensions::transport_sockets::tls::v3::DownstreamTlsContext tls_context; - TestUtility::loadFromYaml(TestEnvironment::substitute(yaml), tls_context, false, - avoid_boosting); + TestUtility::loadFromYaml(TestEnvironment::substitute(yaml), tls_context); ServerContextConfigImpl cfg(tls_context, factory_context_); loadConfig(cfg); } diff --git a/test/integration/BUILD b/test/integration/BUILD index 0fff55f40d0a..d388d15b1d25 100644 --- a/test/integration/BUILD +++ b/test/integration/BUILD @@ -32,7 +32,6 @@ envoy_cc_test_library( ":http_integration_lib", "//source/common/common:matchers_lib", "//source/common/config:protobuf_link_hacks", - "//source/common/config:version_converter_lib", "//source/common/protobuf:utility_lib", "//source/common/version:version_lib", "//source/extensions/filters/network/redis_proxy:config", @@ -750,7 +749,6 @@ envoy_cc_test_library( ":integration_tcp_client_lib", ":utility_lib", "//source/common/config:api_version_lib", - "//source/common/config:version_converter_lib", "//source/extensions/transport_sockets/tls:context_config_lib", "//source/extensions/transport_sockets/tls:context_lib", "//source/extensions/transport_sockets/tls:ssl_socket_lib", @@ -886,7 +884,6 @@ envoy_cc_test_library( "//source/common/common:basic_resource_lib", "//source/common/common:minimal_logger_lib", "//source/common/config:api_version_lib", - "//source/common/config:version_converter_lib", "//source/common/event:dispatcher_lib", "//source/common/grpc:codec_lib", "//source/common/grpc:common_lib", diff --git a/test/integration/ads_integration.cc b/test/integration/ads_integration.cc index f356c7cd6cc2..53716bfa5e7d 100644 --- a/test/integration/ads_integration.cc +++ b/test/integration/ads_integration.cc @@ -21,17 +21,14 @@ using testing::AssertionResult; namespace Envoy { -AdsIntegrationTest::AdsIntegrationTest(envoy::config::core::v3::ApiVersion resource_api_version, - envoy::config::core::v3::ApiVersion transport_api_version) +AdsIntegrationTest::AdsIntegrationTest() : HttpIntegrationTest(Http::CodecType::HTTP2, ipVersion(), ConfigHelper::adsBootstrap( - sotwOrDelta() == Grpc::SotwOrDelta::Sotw ? "GRPC" : "DELTA_GRPC", - resource_api_version, transport_api_version)) { + sotwOrDelta() == Grpc::SotwOrDelta::Sotw ? "GRPC" : "DELTA_GRPC")) { use_lds_ = false; create_xds_upstream_ = true; tls_xds_upstream_ = true; sotw_or_delta_ = sotwOrDelta(); - api_version_ = resource_api_version; setUpstreamProtocol(Http::CodecType::HTTP2); } @@ -39,36 +36,35 @@ void AdsIntegrationTest::TearDown() { cleanUpXdsConnection(); } envoy::config::cluster::v3::Cluster AdsIntegrationTest::buildCluster(const std::string& name, const std::string& lb_policy) { - return ConfigHelper::buildCluster(name, lb_policy, api_version_); + return ConfigHelper::buildCluster(name, lb_policy); } envoy::config::cluster::v3::Cluster AdsIntegrationTest::buildTlsCluster(const std::string& name) { - return ConfigHelper::buildTlsCluster(name, "ROUND_ROBIN", api_version_); + return ConfigHelper::buildTlsCluster(name, "ROUND_ROBIN"); } envoy::config::cluster::v3::Cluster AdsIntegrationTest::buildRedisCluster(const std::string& name) { - return ConfigHelper::buildCluster(name, "MAGLEV", api_version_); + return ConfigHelper::buildCluster(name, "MAGLEV"); } envoy::config::endpoint::v3::ClusterLoadAssignment AdsIntegrationTest::buildClusterLoadAssignment(const std::string& name) { return ConfigHelper::buildClusterLoadAssignment( name, Network::Test::getLoopbackAddressString(ipVersion()), - fake_upstreams_[0]->localAddress()->ip()->port(), api_version_); + fake_upstreams_[0]->localAddress()->ip()->port()); } envoy::config::endpoint::v3::ClusterLoadAssignment AdsIntegrationTest::buildTlsClusterLoadAssignment(const std::string& name) { return ConfigHelper::buildClusterLoadAssignment( - name, Network::Test::getLoopbackAddressString(ipVersion()), 8443, api_version_); + name, Network::Test::getLoopbackAddressString(ipVersion()), 8443); } envoy::config::listener::v3::Listener AdsIntegrationTest::buildListener(const std::string& name, const std::string& route_config, const std::string& stat_prefix) { - return ConfigHelper::buildListener(name, route_config, - Network::Test::getLoopbackAddressString(ipVersion()), - stat_prefix, api_version_); + return ConfigHelper::buildListener( + name, route_config, Network::Test::getLoopbackAddressString(ipVersion()), stat_prefix); } envoy::config::listener::v3::Listener @@ -88,12 +84,12 @@ AdsIntegrationTest::buildRedisListener(const std::string& name, const std::strin )EOF", name, cluster); return ConfigHelper::buildBaseListener(name, Network::Test::getLoopbackAddressString(ipVersion()), - redis, api_version_); + redis); } envoy::config::route::v3::RouteConfiguration AdsIntegrationTest::buildRouteConfig(const std::string& name, const std::string& cluster) { - return ConfigHelper::buildRouteConfig(name, cluster, api_version_); + return ConfigHelper::buildRouteConfig(name, cluster); } void AdsIntegrationTest::makeSingleRequest() { @@ -130,9 +126,6 @@ void AdsIntegrationTest::initializeAds(const bool rate_limiting) { ads_cluster->mutable_transport_socket()->set_name("envoy.transport_sockets.tls"); ads_cluster->mutable_transport_socket()->mutable_typed_config()->PackFrom(context); }); - if (api_version_ == envoy::config::core::v3::ApiVersion::V2 && !fatal_by_default_v2_override_) { - config_helper_.enableDeprecatedV2Api(); - } HttpIntegrationTest::initialize(); if (xds_stream_ == nullptr) { createXdsConnection(); diff --git a/test/integration/ads_integration.h b/test/integration/ads_integration.h index 18468f975d79..adc0a66ffe02 100644 --- a/test/integration/ads_integration.h +++ b/test/integration/ads_integration.h @@ -17,10 +17,7 @@ namespace Envoy { class AdsIntegrationTest : public Grpc::DeltaSotwIntegrationParamTest, public HttpIntegrationTest { public: - AdsIntegrationTest(envoy::config::core::v3::ApiVersion resource_api_version, - envoy::config::core::v3::ApiVersion transport_api_version = - envoy::config::core::v3::ApiVersion::AUTO); - AdsIntegrationTest() : AdsIntegrationTest(envoy::config::core::v3::ApiVersion::V3) {} + AdsIntegrationTest(); void TearDown() override; @@ -57,11 +54,6 @@ class AdsIntegrationTest : public Grpc::DeltaSotwIntegrationParamTest, public Ht envoy::admin::v3::ClustersConfigDump getClustersConfigDump(); envoy::admin::v3::ListenersConfigDump getListenersConfigDump(); envoy::admin::v3::RoutesConfigDump getRoutesConfigDump(); - - // If API version is v2, fatal-by-default is disabled unless fatal_by_default_v2_override_ is set. - envoy::config::core::v3::ApiVersion api_version_; - // Set to force fatal-by-default v2 even if API version is v2. - bool fatal_by_default_v2_override_{false}; }; } // namespace Envoy diff --git a/test/integration/ads_integration_test.cc b/test/integration/ads_integration_test.cc index 26405c9ac966..f2d0edad3ca8 100644 --- a/test/integration/ads_integration_test.cc +++ b/test/integration/ads_integration_test.cc @@ -7,7 +7,6 @@ #include "envoy/grpc/status.h" #include "source/common/config/protobuf_link_hacks.h" -#include "source/common/config/version_converter.h" #include "source/common/protobuf/protobuf.h" #include "source/common/protobuf/utility.h" #include "source/common/version/version.h" @@ -39,19 +38,18 @@ TEST_P(AdsIntegrationTest, Basic) { // Basic CDS/EDS update that warms and makes active a single cluster. TEST_P(AdsIntegrationTest, BasicClusterInitialWarming) { initialize(); - const auto cds_type_url = Config::getTypeUrl( - envoy::config::core::v3::ApiVersion::V3); - const auto eds_type_url = Config::getTypeUrl( - envoy::config::core::v3::ApiVersion::V3); + const auto cds_type_url = Config::getTypeUrl(); + const auto eds_type_url = + Config::getTypeUrl(); EXPECT_TRUE(compareDiscoveryRequest(cds_type_url, "", {}, {}, {}, true)); sendDiscoveryResponse( - cds_type_url, {buildCluster("cluster_0")}, {buildCluster("cluster_0")}, {}, "1", false); + cds_type_url, {buildCluster("cluster_0")}, {buildCluster("cluster_0")}, {}, "1"); test_server_->waitForGaugeEq("cluster_manager.warming_clusters", 1); EXPECT_TRUE(compareDiscoveryRequest(eds_type_url, "", {"cluster_0"}, {"cluster_0"}, {})); sendDiscoveryResponse( eds_type_url, {buildClusterLoadAssignment("cluster_0")}, - {buildClusterLoadAssignment("cluster_0")}, {}, "1", false); + {buildClusterLoadAssignment("cluster_0")}, {}, "1"); test_server_->waitForGaugeEq("cluster_manager.warming_clusters", 0); test_server_->waitForGaugeGe("cluster_manager.active_clusters", 2); @@ -61,23 +59,22 @@ TEST_P(AdsIntegrationTest, BasicClusterInitialWarming) { // manager as a whole is not initialized. TEST_P(AdsIntegrationTest, ClusterInitializationUpdateTheOnlyWarmingCluster) { initialize(); - const auto cds_type_url = Config::getTypeUrl( - envoy::config::core::v3::ApiVersion::V3); - const auto eds_type_url = Config::getTypeUrl( - envoy::config::core::v3::ApiVersion::V3); + const auto cds_type_url = Config::getTypeUrl(); + const auto eds_type_url = + Config::getTypeUrl(); EXPECT_TRUE(compareDiscoveryRequest(cds_type_url, "", {}, {}, {}, true)); sendDiscoveryResponse( - cds_type_url, {buildCluster("cluster_0")}, {buildCluster("cluster_0")}, {}, "1", false); + cds_type_url, {buildCluster("cluster_0")}, {buildCluster("cluster_0")}, {}, "1"); test_server_->waitForGaugeEq("cluster_manager.warming_clusters", 1); // Update lb policy to MAGLEV so that cluster update is not skipped due to the same hash. sendDiscoveryResponse( cds_type_url, {buildCluster("cluster_0", "MAGLEV")}, {buildCluster("cluster_0", "MAGLEV")}, - {}, "2", false); + {}, "2"); EXPECT_TRUE(compareDiscoveryRequest(eds_type_url, "", {"cluster_0"}, {"cluster_0"}, {})); sendDiscoveryResponse( eds_type_url, {buildClusterLoadAssignment("cluster_0")}, - {buildClusterLoadAssignment("cluster_0")}, {}, "1", false); + {buildClusterLoadAssignment("cluster_0")}, {}, "1"); test_server_->waitForGaugeEq("cluster_manager.warming_clusters", 0); test_server_->waitForGaugeGe("cluster_manager.active_clusters", 2); @@ -87,8 +84,7 @@ TEST_P(AdsIntegrationTest, ClusterInitializationUpdateTheOnlyWarmingCluster) { // config and verify that all the clusters are initialized. TEST_P(AdsIntegrationTest, TestPrimaryClusterWarmClusterInitialization) { initialize(); - const auto cds_type_url = Config::getTypeUrl( - envoy::config::core::v3::ApiVersion::V3); + const auto cds_type_url = Config::getTypeUrl(); auto loopback = Network::Test::getLoopbackAddressString(ipVersion()); addFakeUpstream(Http::CodecType::HTTP2); auto port = fake_upstreams_.back()->localAddress()->ip()->port(); @@ -115,7 +111,7 @@ TEST_P(AdsIntegrationTest, TestPrimaryClusterWarmClusterInitialization) { EXPECT_TRUE(compareDiscoveryRequest(cds_type_url, "", {}, {}, {}, true)); sendDiscoveryResponse(cds_type_url, {warming_cluster}, - {warming_cluster}, {}, "1", false); + {warming_cluster}, {}, "1"); FakeRawConnectionPtr fake_upstream_connection; ASSERT_TRUE(fake_upstreams_.back()->waitForRawConnection(fake_upstream_connection)); @@ -125,7 +121,7 @@ TEST_P(AdsIntegrationTest, TestPrimaryClusterWarmClusterInitialization) { // Now replace the warming cluster by the config which will turn ready immediately. sendDiscoveryResponse(cds_type_url, {active_cluster}, - {active_cluster}, {}, "2", false); + {active_cluster}, {}, "2"); // All clusters are ready. test_server_->waitForGaugeEq("cluster_manager.warming_clusters", 0); @@ -135,10 +131,9 @@ TEST_P(AdsIntegrationTest, TestPrimaryClusterWarmClusterInitialization) { // Two cluster warming, update one of them. Verify that the clusters are eventually initialized. TEST_P(AdsIntegrationTest, ClusterInitializationUpdateOneOfThe2Warming) { initialize(); - const auto cds_type_url = Config::getTypeUrl( - envoy::config::core::v3::ApiVersion::V3); - const auto eds_type_url = Config::getTypeUrl( - envoy::config::core::v3::ApiVersion::V3); + const auto cds_type_url = Config::getTypeUrl(); + const auto eds_type_url = + Config::getTypeUrl(); EXPECT_TRUE(compareDiscoveryRequest(cds_type_url, "", {}, {}, {}, true)); sendDiscoveryResponse( @@ -147,7 +142,7 @@ TEST_P(AdsIntegrationTest, ClusterInitializationUpdateOneOfThe2Warming) { buildCluster("cluster_0"), buildCluster("cluster_1")}, {ConfigHelper::buildStaticCluster("primary_cluster", 8000, "127.0.0.1"), buildCluster("cluster_0"), buildCluster("cluster_1")}, - {}, "1", false); + {}, "1"); test_server_->waitForGaugeEq("cluster_manager.warming_clusters", 2); @@ -158,14 +153,13 @@ TEST_P(AdsIntegrationTest, ClusterInitializationUpdateOneOfThe2Warming) { buildCluster("cluster_0", "MAGLEV"), buildCluster("cluster_1")}, {ConfigHelper::buildStaticCluster("primary_cluster", 8000, "127.0.0.1"), buildCluster("cluster_0", "MAGLEV"), buildCluster("cluster_1")}, - {}, "2", false); + {}, "2"); EXPECT_TRUE(compareDiscoveryRequest(eds_type_url, "", {"cluster_0", "cluster_1"}, {"cluster_0", "cluster_1"}, {})); sendDiscoveryResponse( eds_type_url, {buildClusterLoadAssignment("cluster_0"), buildClusterLoadAssignment("cluster_1")}, - {buildClusterLoadAssignment("cluster_0"), buildClusterLoadAssignment("cluster_1")}, {}, "1", - false); + {buildClusterLoadAssignment("cluster_0"), buildClusterLoadAssignment("cluster_1")}, {}, "1"); test_server_->waitForGaugeEq("cluster_manager.warming_clusters", 0); test_server_->waitForGaugeGe("cluster_manager.active_clusters", 4); @@ -176,11 +170,9 @@ TEST_P(AdsIntegrationTest, ClusterInitializationUpdateOneOfThe2Warming) { // This is a regression test of #11120. TEST_P(AdsIntegrationTest, ClusterSharingSecretWarming) { initialize(); - const auto cds_type_url = Config::getTypeUrl( - envoy::config::core::v3::ApiVersion::V3); + const auto cds_type_url = Config::getTypeUrl(); const auto sds_type_url = - Config::getTypeUrl( - envoy::config::core::v3::ApiVersion::V3); + Config::getTypeUrl(); envoy::config::core::v3::TransportSocket sds_transport_socket; TestUtility::loadFromYaml(R"EOF( @@ -204,8 +196,8 @@ TEST_P(AdsIntegrationTest, ClusterSharingSecretWarming) { cluster_1.set_name("cluster_1"); EXPECT_TRUE(compareDiscoveryRequest(cds_type_url, "", {}, {}, {}, true)); - sendDiscoveryResponse( - cds_type_url, {cluster_0, cluster_1}, {cluster_0, cluster_1}, {}, "1", false); + sendDiscoveryResponse(cds_type_url, {cluster_0, cluster_1}, + {cluster_0, cluster_1}, {}, "1"); EXPECT_TRUE(compareDiscoveryRequest(sds_type_url, "", {"validation_context"}, {"validation_context"}, {})); @@ -1058,8 +1050,7 @@ class AdsFailIntegrationTest : public Grpc::DeltaSotwIntegrationParamTest, AdsFailIntegrationTest() : HttpIntegrationTest(Http::CodecType::HTTP2, ipVersion(), ConfigHelper::adsBootstrap( - sotwOrDelta() == Grpc::SotwOrDelta::Sotw ? "GRPC" : "DELTA_GRPC", - envoy::config::core::v3::ApiVersion::V3)) { + sotwOrDelta() == Grpc::SotwOrDelta::Sotw ? "GRPC" : "DELTA_GRPC")) { create_xds_upstream_ = true; use_lds_ = false; sotw_or_delta_ = sotwOrDelta(); @@ -1099,8 +1090,7 @@ class AdsConfigIntegrationTest : public Grpc::DeltaSotwIntegrationParamTest, AdsConfigIntegrationTest() : HttpIntegrationTest(Http::CodecType::HTTP2, ipVersion(), ConfigHelper::adsBootstrap( - sotwOrDelta() == Grpc::SotwOrDelta::Sotw ? "GRPC" : "DELTA_GRPC", - envoy::config::core::v3::ApiVersion::V3)) { + sotwOrDelta() == Grpc::SotwOrDelta::Sotw ? "GRPC" : "DELTA_GRPC")) { create_xds_upstream_ = true; use_lds_ = false; sotw_or_delta_ = sotwOrDelta(); @@ -1248,7 +1238,7 @@ TEST_P(AdsIntegrationTest, NodeMessage) { node = &delta_request.node(); } envoy::config::core::v3::BuildVersion build_version_msg; - Config::VersionConverter::upgrade(node->user_agent_build_version(), build_version_msg); + build_version_msg.MergeFrom(node->user_agent_build_version()); EXPECT_THAT(build_version_msg, ProtoEq(VersionInfo::buildVersion())); EXPECT_GE(node->extensions().size(), 0); EXPECT_EQ(0, node->client_features().size()); @@ -1285,8 +1275,7 @@ class AdsClusterFromFileIntegrationTest : public Grpc::DeltaSotwIntegrationParam AdsClusterFromFileIntegrationTest() : HttpIntegrationTest(Http::CodecType::HTTP2, ipVersion(), ConfigHelper::adsBootstrap( - sotwOrDelta() == Grpc::SotwOrDelta::Sotw ? "GRPC" : "DELTA_GRPC", - envoy::config::core::v3::ApiVersion::V3)) { + sotwOrDelta() == Grpc::SotwOrDelta::Sotw ? "GRPC" : "DELTA_GRPC")) { create_xds_upstream_ = true; use_lds_ = false; sotw_or_delta_ = sotwOrDelta(); @@ -1667,219 +1656,4 @@ TEST_P(XdsTpAdsIntegrationTest, Basic) { makeSingleRequest(); } -// Some v2 ADS integration tests, these validate basic v2 support but are not complete, they reflect -// tests that have historically been worth validating on both v2 and v3. They will be removed in Q1. -class AdsClusterV2Test : public AdsIntegrationTest { -public: - AdsClusterV2Test() : AdsIntegrationTest(envoy::config::core::v3::ApiVersion::V2) {} - void initialize() override { - config_helper_.addConfigModifier([](envoy::config::bootstrap::v3::Bootstrap& bootstrap) { - auto* cluster0 = bootstrap.mutable_static_resources()->mutable_clusters(0); - cluster0->mutable_typed_extension_protocol_options()->clear(); - cluster0->mutable_http2_protocol_options(); - }); - AdsIntegrationTest::initialize(); - } -}; - -INSTANTIATE_TEST_SUITE_P(IpVersionsClientTypeDelta, AdsClusterV2Test, - DELTA_SOTW_GRPC_CLIENT_INTEGRATION_PARAMS); - -// Basic CDS/EDS update that warms and makes active a single cluster (v2 API). -TEST_P(AdsClusterV2Test, DEPRECATED_FEATURE_TEST(BasicClusterInitialWarming)) { - initialize(); - const auto cds_type_url = Config::getTypeUrl( - envoy::config::core::v3::ApiVersion::V2); - const auto eds_type_url = Config::getTypeUrl( - envoy::config::core::v3::ApiVersion::V2); - - EXPECT_TRUE(compareDiscoveryRequest(cds_type_url, "", {}, {}, {}, true)); - sendDiscoveryResponse( - cds_type_url, {buildCluster("cluster_0")}, {buildCluster("cluster_0")}, {}, "1", true); - test_server_->waitForGaugeEq("cluster_manager.warming_clusters", 1); - EXPECT_TRUE(compareDiscoveryRequest(eds_type_url, "", {"cluster_0"}, {"cluster_0"}, {})); - sendDiscoveryResponse( - eds_type_url, {buildClusterLoadAssignment("cluster_0")}, - {buildClusterLoadAssignment("cluster_0")}, {}, "1", true); - - test_server_->waitForGaugeEq("cluster_manager.warming_clusters", 0); - test_server_->waitForGaugeGe("cluster_manager.active_clusters", 2); -} - -// Verify CDS is paused during cluster warming. -TEST_P(AdsClusterV2Test, DEPRECATED_FEATURE_TEST(CdsPausedDuringWarming)) { - initialize(); - - const auto cds_type_url = Config::getTypeUrl( - envoy::config::core::v3::ApiVersion::V2); - const auto eds_type_url = Config::getTypeUrl( - envoy::config::core::v3::ApiVersion::V2); - const auto lds_type_url = Config::getTypeUrl( - envoy::config::core::v3::ApiVersion::V2); - const auto rds_type_url = Config::getTypeUrl( - envoy::config::core::v3::ApiVersion::V2); - - // Send initial configuration, validate we can process a request. - EXPECT_TRUE(compareDiscoveryRequest(cds_type_url, "", {}, {}, {}, true)); - sendDiscoveryResponse( - cds_type_url, {buildCluster("cluster_0")}, {buildCluster("cluster_0")}, {}, "1", true); - EXPECT_TRUE(compareDiscoveryRequest(eds_type_url, "", {"cluster_0"}, {"cluster_0"}, {})); - - sendDiscoveryResponse( - eds_type_url, {buildClusterLoadAssignment("cluster_0")}, - {buildClusterLoadAssignment("cluster_0")}, {}, "1", true); - - EXPECT_TRUE(compareDiscoveryRequest(cds_type_url, "1", {}, {}, {})); - EXPECT_TRUE(compareDiscoveryRequest(lds_type_url, "", {}, {}, {})); - sendDiscoveryResponse( - lds_type_url, {buildListener("listener_0", "route_config_0")}, - {buildListener("listener_0", "route_config_0")}, {}, "1", true); - - EXPECT_TRUE(compareDiscoveryRequest(eds_type_url, "1", {"cluster_0"}, {}, {})); - EXPECT_TRUE( - compareDiscoveryRequest(rds_type_url, "", {"route_config_0"}, {"route_config_0"}, {})); - sendDiscoveryResponse( - rds_type_url, {buildRouteConfig("route_config_0", "cluster_0")}, - {buildRouteConfig("route_config_0", "cluster_0")}, {}, "1", true); - - EXPECT_TRUE(compareDiscoveryRequest(lds_type_url, "1", {}, {}, {})); - EXPECT_TRUE(compareDiscoveryRequest(rds_type_url, "1", {"route_config_0"}, {}, {})); - - test_server_->waitForCounterGe("listener_manager.listener_create_success", 1); - makeSingleRequest(); - - // Send the first warming cluster. - sendDiscoveryResponse( - cds_type_url, {buildCluster("warming_cluster_1")}, {buildCluster("warming_cluster_1")}, - {"cluster_0"}, "2", true); - - test_server_->waitForGaugeEq("cluster_manager.warming_clusters", 1); - - EXPECT_TRUE(compareDiscoveryRequest(eds_type_url, "1", {"warming_cluster_1"}, - {"warming_cluster_1"}, {"cluster_0"})); - - // Send the second warming cluster. - sendDiscoveryResponse( - cds_type_url, {buildCluster("warming_cluster_1"), buildCluster("warming_cluster_2")}, - {buildCluster("warming_cluster_1"), buildCluster("warming_cluster_2")}, {}, "3", true); - test_server_->waitForGaugeEq("cluster_manager.warming_clusters", 2); - // We would've got a Cluster discovery request with version 2 here, had the CDS not been paused. - - EXPECT_TRUE(compareDiscoveryRequest(eds_type_url, "1", {"warming_cluster_2", "warming_cluster_1"}, - {"warming_cluster_2"}, {})); - - // Finish warming the clusters. - sendDiscoveryResponse( - eds_type_url, - {buildClusterLoadAssignment("warming_cluster_1"), - buildClusterLoadAssignment("warming_cluster_2")}, - {buildClusterLoadAssignment("warming_cluster_1"), - buildClusterLoadAssignment("warming_cluster_2")}, - {"cluster_0"}, "2", true); - - // Validate that clusters are warmed. - test_server_->waitForGaugeEq("cluster_manager.warming_clusters", 0); - - // CDS is resumed and EDS response was acknowledged. - if (sotw_or_delta_ == Grpc::SotwOrDelta::Delta) { - // Envoy will ACK both Cluster messages. Since they arrived while CDS was paused, they aren't - // sent until CDS is unpaused. Since version 3 has already arrived by the time the version 2 - // ACK goes out, they're both acknowledging version 3. - EXPECT_TRUE(compareDiscoveryRequest(cds_type_url, "3", {}, {}, {})); - } - EXPECT_TRUE(compareDiscoveryRequest(cds_type_url, "3", {}, {}, {})); - EXPECT_TRUE(compareDiscoveryRequest(eds_type_url, "2", {"warming_cluster_2", "warming_cluster_1"}, - {}, {})); -} - -// Validates that the initial xDS request batches all resources referred to in static config -TEST_P(AdsClusterV2Test, DEPRECATED_FEATURE_TEST(XdsBatching)) { - config_helper_.addConfigModifier([this](envoy::config::bootstrap::v3::Bootstrap& bootstrap) { - bootstrap.mutable_dynamic_resources()->clear_cds_config(); - bootstrap.mutable_dynamic_resources()->clear_lds_config(); - - auto static_resources = bootstrap.mutable_static_resources(); - static_resources->add_clusters()->MergeFrom(buildCluster("eds_cluster")); - static_resources->add_clusters()->MergeFrom(buildCluster("eds_cluster2")); - - static_resources->add_listeners()->MergeFrom(buildListener("rds_listener", "route_config")); - static_resources->add_listeners()->MergeFrom(buildListener("rds_listener2", "route_config2")); - }); - - on_server_init_function_ = [this]() { - createXdsConnection(); - ASSERT_TRUE(xds_connection_->waitForNewStream(*dispatcher_, xds_stream_)); - xds_stream_->startGrpcStream(); - - const auto eds_type_url = - Config::getTypeUrl( - envoy::config::core::v3::ApiVersion::V2); - const auto rds_type_url = Config::getTypeUrl( - envoy::config::core::v3::ApiVersion::V2); - - EXPECT_TRUE(compareDiscoveryRequest(eds_type_url, "", {"eds_cluster2", "eds_cluster"}, - {"eds_cluster2", "eds_cluster"}, {}, true)); - sendDiscoveryResponse( - eds_type_url, - {buildClusterLoadAssignment("eds_cluster"), buildClusterLoadAssignment("eds_cluster2")}, - {buildClusterLoadAssignment("eds_cluster"), buildClusterLoadAssignment("eds_cluster2")}, {}, - "1", true); - - EXPECT_TRUE(compareDiscoveryRequest(rds_type_url, "", {"route_config2", "route_config"}, - {"route_config2", "route_config"}, {})); - sendDiscoveryResponse( - rds_type_url, - {buildRouteConfig("route_config2", "eds_cluster2"), - buildRouteConfig("route_config", "dummy_cluster")}, - {buildRouteConfig("route_config2", "eds_cluster2"), - buildRouteConfig("route_config", "dummy_cluster")}, - {}, "1", true); - }; - - initialize(); -} - -// Regression test for https://github.com/envoyproxy/envoy/issues/13681. -TEST_P(AdsClusterV2Test, DEPRECATED_FEATURE_TEST(TypeUrlAnnotationRegression)) { - initialize(); - const auto cds_type_url = Config::getTypeUrl( - envoy::config::core::v3::ApiVersion::V2); - - EXPECT_TRUE(compareDiscoveryRequest(cds_type_url, "", {}, {}, {}, true)); - auto cluster = buildCluster("cluster_0"); - auto* bias = cluster.mutable_least_request_lb_config()->mutable_active_request_bias(); - bias->set_default_value(1.1); - bias->set_runtime_key("foo"); - sendDiscoveryResponse(cds_type_url, {cluster}, {cluster}, {}, - "1", true); - - test_server_->waitForCounterGe("cluster_manager.cds.update_rejected", 1); -} - -// Validate v2 resource are rejected by default. -class AdsV2ResourceRejectTest : public AdsIntegrationTest { -public: - // We need to use a v3 transport as we're not going to set the v2 allow overrides. - AdsV2ResourceRejectTest() - : AdsIntegrationTest(envoy::config::core::v3::ApiVersion::V2, - envoy::config::core::v3::ApiVersion::V3) {} -}; - -INSTANTIATE_TEST_SUITE_P(IpVersionsClientTypeDelta, AdsV2ResourceRejectTest, - DELTA_SOTW_GRPC_CLIENT_INTEGRATION_PARAMS); - -// If we attempt to use v2 APIs by default, the configuration should be rejected. -TEST_P(AdsV2ResourceRejectTest, DEPRECATED_FEATURE_TEST(RejectV2ConfigByDefault)) { - fatal_by_default_v2_override_ = true; - initialize(); - const auto cds_type_url = Config::getTypeUrl( - envoy::config::core::v3::ApiVersion::V2); - - EXPECT_TRUE(compareDiscoveryRequest(cds_type_url, "", {}, {}, {}, true)); - sendDiscoveryResponse( - cds_type_url, {buildCluster("cluster_0")}, {buildCluster("cluster_0")}, {}, "1", true); - test_server_->waitForCounterGe("cluster_manager.cds.update_rejected", 1); - EXPECT_EQ(1, test_server_->gauge("runtime.deprecated_feature_seen_since_process_start")->value()); -} - } // namespace Envoy diff --git a/test/integration/base_integration_test.cc b/test/integration/base_integration_test.cc index 26c12716cfcb..f2f74de840e8 100644 --- a/test/integration/base_integration_test.cc +++ b/test/integration/base_integration_test.cc @@ -334,8 +334,7 @@ void BaseIntegrationTest::createGeneratedApiTestServer( test_server_ = IntegrationTestServer::create( bootstrap_path, version_, on_server_ready_function_, on_server_init_function_, deterministic_, timeSystem(), *api_, defer_listener_finalization_, process_object_, validator_config, - concurrency_, drain_time_, drain_strategy_, proxy_buffer_factory_, use_real_stats_, - v2_bootstrap_); + concurrency_, drain_time_, drain_strategy_, proxy_buffer_factory_, use_real_stats_); if (config_helper_.bootstrap().static_resources().listeners_size() > 0 && !defer_listener_finalization_) { diff --git a/test/integration/base_integration_test.h b/test/integration/base_integration_test.h index 18b8b02c8899..d629b0572ff3 100644 --- a/test/integration/base_integration_test.h +++ b/test/integration/base_integration_test.h @@ -9,7 +9,6 @@ #include "envoy/service/discovery/v3/discovery.pb.h" #include "source/common/config/api_version.h" -#include "source/common/config/version_converter.h" #include "source/extensions/transport_sockets/tls/context_manager_impl.h" #include "test/common/grpc/grpc_client_integration.h" @@ -143,12 +142,11 @@ class BaseIntegrationTest : protected Logger::Loggable { template void sendDiscoveryResponse(const std::string& type_url, const std::vector& state_of_the_world, const std::vector& added_or_updated, - const std::vector& removed, const std::string& version, - const bool api_downgrade = false) { + const std::vector& removed, const std::string& version) { if (sotw_or_delta_ == Grpc::SotwOrDelta::Sotw) { - sendSotwDiscoveryResponse(type_url, state_of_the_world, version, api_downgrade); + sendSotwDiscoveryResponse(type_url, state_of_the_world, version); } else { - sendDeltaDiscoveryResponse(type_url, added_or_updated, removed, version, api_downgrade); + sendDeltaDiscoveryResponse(type_url, added_or_updated, removed, version); } } @@ -178,16 +176,12 @@ class BaseIntegrationTest : protected Logger::Loggable { template void sendSotwDiscoveryResponse(const std::string& type_url, const std::vector& messages, - const std::string& version, const bool api_downgrade = false) { + const std::string& version) { envoy::service::discovery::v3::DiscoveryResponse discovery_response; discovery_response.set_version_info(version); discovery_response.set_type_url(type_url); for (const auto& message : messages) { - if (api_downgrade) { - discovery_response.add_resources()->PackFrom(API_DOWNGRADE(message)); - } else { - discovery_response.add_resources()->PackFrom(message); - } + discovery_response.add_resources()->PackFrom(message); } static int next_nonce_counter = 0; discovery_response.set_nonce(absl::StrCat("nonce", next_nonce_counter++)); @@ -195,21 +189,18 @@ class BaseIntegrationTest : protected Logger::Loggable { } template - void sendDeltaDiscoveryResponse(const std::string& type_url, - const std::vector& added_or_updated, - const std::vector& removed, - const std::string& version, const bool api_downgrade = false) { - sendDeltaDiscoveryResponse(type_url, added_or_updated, removed, version, xds_stream_, {}, - api_downgrade); + void + sendDeltaDiscoveryResponse(const std::string& type_url, const std::vector& added_or_updated, + const std::vector& removed, const std::string& version) { + sendDeltaDiscoveryResponse(type_url, added_or_updated, removed, version, xds_stream_, {}); } template void sendDeltaDiscoveryResponse(const std::string& type_url, const std::vector& added_or_updated, const std::vector& removed, const std::string& version, - FakeStreamPtr& stream, const std::vector& aliases = {}, - const bool api_downgrade = false) { - auto response = createDeltaDiscoveryResponse(type_url, added_or_updated, removed, version, - aliases, api_downgrade); + FakeStreamPtr& stream, const std::vector& aliases = {}) { + auto response = + createDeltaDiscoveryResponse(type_url, added_or_updated, removed, version, aliases); stream->sendGrpcMessage(response); } @@ -217,22 +208,15 @@ class BaseIntegrationTest : protected Logger::Loggable { envoy::service::discovery::v3::DeltaDiscoveryResponse createDeltaDiscoveryResponse(const std::string& type_url, const std::vector& added_or_updated, const std::vector& removed, const std::string& version, - const std::vector& aliases, - const bool api_downgrade = false) { - + const std::vector& aliases) { envoy::service::discovery::v3::DeltaDiscoveryResponse response; response.set_system_version_info("system_version_info_this_is_a_test"); response.set_type_url(type_url); for (const auto& message : added_or_updated) { auto* resource = response.add_resources(); ProtobufWkt::Any temp_any; - if (api_downgrade) { - temp_any.PackFrom(API_DOWNGRADE(message)); - resource->mutable_resource()->PackFrom(API_DOWNGRADE(message)); - } else { - temp_any.PackFrom(message); - resource->mutable_resource()->PackFrom(message); - } + temp_any.PackFrom(message); + resource->mutable_resource()->PackFrom(message); resource->set_name(intResourceName(message)); resource->set_version(version); for (const auto& alias : aliases) { @@ -442,9 +426,6 @@ class BaseIntegrationTest : protected Logger::Loggable { // This override exists for tests measuring stats memory. bool use_real_stats_{}; - // Use a v2 bootstrap. - bool v2_bootstrap_{false}; - private: // Configuration for the fake upstream. FakeUpstreamConfig upstream_config_{time_system_}; diff --git a/test/integration/hds_integration_test.cc b/test/integration/hds_integration_test.cc index b7938878f035..72a43322c88f 100644 --- a/test/integration/hds_integration_test.cc +++ b/test/integration/hds_integration_test.cc @@ -27,8 +27,7 @@ namespace Envoy { namespace { // TODO(jmarantz): switch this to simulated-time after debugging flakes. -class HdsIntegrationTest : public Grpc::VersionedGrpcClientIntegrationParamTest, - public HttpIntegrationTest { +class HdsIntegrationTest : public Grpc::GrpcClientIntegrationParamTest, public HttpIntegrationTest { public: HdsIntegrationTest() : HttpIntegrationTest(Http::CodecType::HTTP1, ipVersion()) {} @@ -38,17 +37,13 @@ class HdsIntegrationTest : public Grpc::VersionedGrpcClientIntegrationParamTest, HttpIntegrationTest::createUpstreams(); } void initialize() override { - if (apiVersion() != envoy::config::core::v3::ApiVersion::V3) { - config_helper_.enableDeprecatedV2Api(); - } setUpstreamCount(upstream_endpoints_); - config_helper_.addConfigModifier([this](envoy::config::bootstrap::v3::Bootstrap& bootstrap) { + config_helper_.addConfigModifier([](envoy::config::bootstrap::v3::Bootstrap& bootstrap) { // Setup hds and corresponding gRPC cluster. auto* hds_config = bootstrap.mutable_hds_config(); hds_config->set_api_type(envoy::config::core::v3::ApiConfigSource::GRPC); hds_config->set_transport_api_version(envoy::config::core::v3::ApiVersion::V3); hds_config->add_grpc_services()->mutable_envoy_grpc()->set_cluster_name("hds_cluster"); - hds_config->set_transport_api_version(apiVersion()); auto* hds_cluster = bootstrap.mutable_static_resources()->add_clusters(); hds_cluster->MergeFrom(bootstrap.static_resources().clusters()[0]); hds_cluster->mutable_circuit_breakers()->Clear(); @@ -278,9 +273,7 @@ class HdsIntegrationTest : public Grpc::VersionedGrpcClientIntegrationParamTest, healthy, host_upstream_->localAddress())) { ASSERT_TRUE(hds_stream_->waitForGrpcMessage(*dispatcher_, response_)); EXPECT_EQ("POST", hds_stream_->headers().getMethodValue()); - EXPECT_EQ(TestUtility::getVersionedMethodPath("envoy.service.{1}.{0}.HealthDiscoveryService", - "StreamHealthCheck", apiVersion(), - serviceNamespace()), + EXPECT_EQ("/envoy.service.health.v3.HealthDiscoveryService/StreamHealthCheck", hds_stream_->headers().getPathValue()); EXPECT_EQ("application/grpc", hds_stream_->headers().getContentTypeValue()); } @@ -333,9 +326,7 @@ class HdsIntegrationTest : public Grpc::VersionedGrpcClientIntegrationParamTest, } EXPECT_EQ("POST", hds_stream_->headers().getMethodValue()); - EXPECT_EQ(TestUtility::getVersionedMethodPath("envoy.service.{1}.{0}.HealthDiscoveryService", - "StreamHealthCheck", apiVersion(), - serviceNamespace()), + EXPECT_EQ("/envoy.service.health.v3.HealthDiscoveryService/StreamHealthCheck", hds_stream_->headers().getPathValue()); EXPECT_EQ("application/grpc", hds_stream_->headers().getContentTypeValue()); } @@ -343,19 +334,6 @@ class HdsIntegrationTest : public Grpc::VersionedGrpcClientIntegrationParamTest, return true; } - const std::string serviceNamespace() const { - switch (apiVersion()) { - case envoy::config::core::v3::ApiVersion::AUTO: - FALLTHRU; - case envoy::config::core::v3::ApiVersion::V2: - return "discovery"; - case envoy::config::core::v3::ApiVersion::V3: - return "health"; - default: - NOT_REACHED_GCOVR_EXCL_LINE; - } - } - static constexpr uint32_t upstream_endpoints_ = 0; FakeHttpConnectionPtr hds_fake_connection_; @@ -379,14 +357,12 @@ class HdsIntegrationTest : public Grpc::VersionedGrpcClientIntegrationParamTest, envoy::service::health::v3::HealthCheckSpecifier server_health_check_specifier_; }; -INSTANTIATE_TEST_SUITE_P(IpVersionsClientType, HdsIntegrationTest, - VERSIONED_GRPC_CLIENT_INTEGRATION_PARAMS, - Grpc::VersionedGrpcClientIntegrationParamTest::protocolTestParamsToString); +INSTANTIATE_TEST_SUITE_P(IpVersionsClientType, HdsIntegrationTest, GRPC_CLIENT_INTEGRATION_PARAMS, + Grpc::GrpcClientIntegrationParamTest::protocolTestParamsToString); // Tests Envoy HTTP health checking a single healthy endpoint and reporting that it is // indeed healthy to the server. TEST_P(HdsIntegrationTest, SingleEndpointHealthyHttp) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initialize(); // Server <--> Envoy @@ -422,7 +398,6 @@ TEST_P(HdsIntegrationTest, SingleEndpointHealthyHttp) { // Tests Envoy HTTP health checking a single endpoint that times out and reporting // that it is unhealthy to the server. TEST_P(HdsIntegrationTest, SingleEndpointTimeoutHttp) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initialize(); server_health_check_specifier_ = makeHttpHealthCheckSpecifier(envoy::type::v3::CodecClientType::HTTP1, false); @@ -464,7 +439,6 @@ TEST_P(HdsIntegrationTest, SingleEndpointTimeoutHttp) { // Tests Envoy HTTP health checking a single unhealthy endpoint and reporting that it is // indeed unhealthy to the server. TEST_P(HdsIntegrationTest, SingleEndpointUnhealthyHttp) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initialize(); server_health_check_specifier_ = makeHttpHealthCheckSpecifier(envoy::type::v3::CodecClientType::HTTP1, false); @@ -498,7 +472,6 @@ TEST_P(HdsIntegrationTest, SingleEndpointUnhealthyHttp) { // Tests Envoy TCP health checking an endpoint that doesn't respond and reporting that it is // unhealthy to the server. TEST_P(HdsIntegrationTest, SingleEndpointTimeoutTcp) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initialize(); // Server <--> Envoy @@ -539,7 +512,6 @@ TEST_P(HdsIntegrationTest, SingleEndpointTimeoutTcp) { // Tests Envoy TCP health checking a single healthy endpoint and reporting that it is // indeed healthy to the server. TEST_P(HdsIntegrationTest, SingleEndpointHealthyTcp) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initialize(); // Server <--> Envoy @@ -570,7 +542,6 @@ TEST_P(HdsIntegrationTest, SingleEndpointHealthyTcp) { // Tests Envoy TCP health checking a single unhealthy endpoint and reporting that it is // indeed unhealthy to the server. TEST_P(HdsIntegrationTest, SingleEndpointUnhealthyTcp) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initialize(); // Server <--> Envoy @@ -605,7 +576,6 @@ TEST_P(HdsIntegrationTest, SingleEndpointUnhealthyTcp) { // Tests that Envoy can HTTP health check two hosts that are in the same cluster, and // the same locality and report back the correct health statuses. TEST_P(HdsIntegrationTest, TwoEndpointsSameLocality) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initialize(); server_health_check_specifier_ = @@ -665,7 +635,6 @@ TEST_P(HdsIntegrationTest, TwoEndpointsSameLocality) { // Tests that Envoy can HTTP health check two hosts that are in the same cluster, and // different localities and report back the correct health statuses. TEST_P(HdsIntegrationTest, TwoEndpointsDifferentLocality) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initialize(); server_health_check_specifier_ = makeHttpHealthCheckSpecifier(envoy::type::v3::CodecClientType::HTTP1, false); @@ -734,7 +703,6 @@ TEST_P(HdsIntegrationTest, TwoEndpointsDifferentLocality) { // Tests that Envoy can HTTP health check two hosts that are in different clusters, and // report back the correct health statuses. TEST_P(HdsIntegrationTest, TwoEndpointsDifferentClusters) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initialize(); server_health_check_specifier_ = makeHttpHealthCheckSpecifier(envoy::type::v3::CodecClientType::HTTP1, false); @@ -803,7 +771,6 @@ TEST_P(HdsIntegrationTest, TwoEndpointsDifferentClusters) { // Tests Envoy HTTP health checking a single endpoint, receiving an update // message from the management server and health checking a new endpoint TEST_P(HdsIntegrationTest, TestUpdateMessage) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initialize(); // Server <--> Envoy @@ -885,7 +852,6 @@ TEST_P(HdsIntegrationTest, TestUpdateMessage) { // Tests Envoy HTTP health checking a single endpoint, receiving an update // message from the management server and reporting in a new interval TEST_P(HdsIntegrationTest, TestUpdateChangesTimer) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initialize(); // Server <--> Envoy @@ -926,7 +892,6 @@ TEST_P(HdsIntegrationTest, TestUpdateChangesTimer) { // Tests Envoy HTTP health checking a single endpoint when interval hasn't been defined TEST_P(HdsIntegrationTest, TestDefaultTimer) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initialize(); // Server <--> Envoy @@ -954,7 +919,6 @@ TEST_P(HdsIntegrationTest, TestDefaultTimer) { // Health checks a single endpoint over TLS with HTTP/2 TEST_P(HdsIntegrationTest, SingleEndpointHealthyTlsHttp2) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; // Change member variable to specify host streams to have tls transport socket. tls_hosts_ = true; @@ -995,7 +959,6 @@ TEST_P(HdsIntegrationTest, SingleEndpointHealthyTlsHttp2) { // Health checks a single endpoint over TLS with HTTP/1 TEST_P(HdsIntegrationTest, SingleEndpointHealthyTlsHttp1) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; // Change member variable to specify host streams to have tls transport socket. tls_hosts_ = true; @@ -1033,7 +996,6 @@ TEST_P(HdsIntegrationTest, SingleEndpointHealthyTlsHttp1) { // Attempts to health check a TLS endpoint over plaintext, which should fail. TEST_P(HdsIntegrationTest, SingleEndpointUnhealthyTlsMissingSocketMatch) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; // Make the endpoints expect communication over TLS. tls_hosts_ = true; @@ -1074,7 +1036,6 @@ TEST_P(HdsIntegrationTest, SingleEndpointUnhealthyTlsMissingSocketMatch) { } TEST_P(HdsIntegrationTest, UpdateEndpoints) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initialize(); server_health_check_specifier_ = makeHttpHealthCheckSpecifier(envoy::type::v3::CodecClientType::HTTP1, false); @@ -1195,7 +1156,6 @@ TEST_P(HdsIntegrationTest, UpdateEndpoints) { // Tests Envoy HTTP health checking a custom healthy endpoint and reporting it is healthy TEST_P(HdsIntegrationTest, SingleEndpointHealthyHttpCustomPort) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initialize(); // Server <--> Envoy @@ -1239,7 +1199,6 @@ TEST_P(HdsIntegrationTest, SingleEndpointHealthyHttpCustomPort) { // Tests Envoy HTTP health checking a single unhealthy endpoint and reporting that it is // indeed unhealthy to the server. TEST_P(HdsIntegrationTest, SingleEndpointUnhealthyHttpCustomPort) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initialize(); server_health_check_specifier_ = @@ -1281,7 +1240,6 @@ TEST_P(HdsIntegrationTest, SingleEndpointUnhealthyHttpCustomPort) { // Tests Envoy keeps sending EndpointHealthResponses after the HDS server reconnection TEST_P(HdsIntegrationTest, SingleEndpointHealthyHttpHdsReconnect) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initialize(); // Server <--> Envoy diff --git a/test/integration/integration_admin_test.cc b/test/integration/integration_admin_test.cc index b694e98c55ec..578017e30111 100644 --- a/test/integration/integration_admin_test.cc +++ b/test/integration/integration_admin_test.cc @@ -573,7 +573,6 @@ TEST_P(StatsMatcherIntegrationTest, ExcludePrefixServerDot) { } TEST_P(StatsMatcherIntegrationTest, DEPRECATED_FEATURE_TEST(DISABLED_ExcludeRequests)) { - v2_bootstrap_ = true; stats_matcher_.mutable_exclusion_list()->add_patterns()->MergeFrom( TestUtility::createRegexMatcher(".*requests.*")); initialize(); @@ -589,7 +588,6 @@ TEST_P(StatsMatcherIntegrationTest, DEPRECATED_FEATURE_TEST(ExcludeExact)) { } TEST_P(StatsMatcherIntegrationTest, DEPRECATED_FEATURE_TEST(DISABLED_ExcludeMultipleExact)) { - v2_bootstrap_ = true; stats_matcher_.mutable_exclusion_list()->add_patterns()->set_exact("server.concurrency"); stats_matcher_.mutable_exclusion_list()->add_patterns()->MergeFrom( TestUtility::createRegexMatcher(".*live")); diff --git a/test/integration/listener_lds_integration_test.cc b/test/integration/listener_lds_integration_test.cc index 1582060b53be..47d7859bf5f0 100644 --- a/test/integration/listener_lds_integration_test.cc +++ b/test/integration/listener_lds_integration_test.cc @@ -9,7 +9,6 @@ #include "envoy/service/discovery/v3/discovery.pb.h" #include "source/common/config/api_version.h" -#include "source/common/config/version_converter.h" #include "test/common/grpc/grpc_client_integration.h" #include "test/config/v2_link_hacks.h" diff --git a/test/integration/load_stats_integration_test.cc b/test/integration/load_stats_integration_test.cc index 630db2261904..213622cc8cf5 100644 --- a/test/integration/load_stats_integration_test.cc +++ b/test/integration/load_stats_integration_test.cc @@ -17,7 +17,7 @@ namespace Envoy { namespace { -class LoadStatsIntegrationTest : public Grpc::VersionedGrpcClientIntegrationParamTest, +class LoadStatsIntegrationTest : public Grpc::GrpcClientIntegrationParamTest, public HttpIntegrationTest { public: LoadStatsIntegrationTest() : HttpIntegrationTest(Http::CodecType::HTTP1, ipVersion()) { @@ -105,16 +105,13 @@ class LoadStatsIntegrationTest : public Grpc::VersionedGrpcClientIntegrationPara } void initialize() override { - if (apiVersion() != envoy::config::core::v3::ApiVersion::V3) { - config_helper_.enableDeprecatedV2Api(); - } setUpstreamCount(upstream_endpoints_); config_helper_.addConfigModifier([this](envoy::config::bootstrap::v3::Bootstrap& bootstrap) { // Setup load reporting and corresponding gRPC cluster. auto* loadstats_config = bootstrap.mutable_cluster_manager()->mutable_load_stats_config(); loadstats_config->set_api_type(envoy::config::core::v3::ApiConfigSource::GRPC); loadstats_config->add_grpc_services()->mutable_envoy_grpc()->set_cluster_name("load_report"); - loadstats_config->set_transport_api_version(apiVersion()); + loadstats_config->set_transport_api_version(envoy::config::core::v3::ApiVersion::V3); auto* load_report_cluster = bootstrap.mutable_static_resources()->add_clusters(); load_report_cluster->MergeFrom(bootstrap.static_resources().clusters()[0]); load_report_cluster->mutable_circuit_breakers()->Clear(); @@ -288,10 +285,8 @@ class LoadStatsIntegrationTest : public Grpc::VersionedGrpcClientIntegrationPara mergeLoadStats(loadstats_request, local_loadstats_request); EXPECT_EQ("POST", loadstats_stream_->headers().getMethodValue()); - EXPECT_EQ( - TestUtility::getVersionedMethodPath("envoy.service.load_stats.{}.LoadReportingService", - "StreamLoadStats", apiVersion()), - loadstats_stream_->headers().getPathValue()); + EXPECT_EQ("/envoy.service.load_stats.v3.LoadReportingService/StreamLoadStats", + loadstats_stream_->headers().getPathValue()); EXPECT_EQ("application/grpc", loadstats_stream_->headers().getContentTypeValue()); if (!bound.withinBound()) { return TestUtility::assertRepeatedPtrFieldEqual(expected_cluster_stats, @@ -390,13 +385,12 @@ class LoadStatsIntegrationTest : public Grpc::VersionedGrpcClientIntegrationPara }; INSTANTIATE_TEST_SUITE_P(IpVersionsClientType, LoadStatsIntegrationTest, - VERSIONED_GRPC_CLIENT_INTEGRATION_PARAMS, - Grpc::VersionedGrpcClientIntegrationParamTest::protocolTestParamsToString); + GRPC_CLIENT_INTEGRATION_PARAMS, + Grpc::GrpcClientIntegrationParamTest::protocolTestParamsToString); // Validate the load reports for successful requests as cluster membership // changes. TEST_P(LoadStatsIntegrationTest, Success) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initialize(); waitForLoadStatsStream(); @@ -504,7 +498,6 @@ TEST_P(LoadStatsIntegrationTest, Success) { // weighted LB. This serves as a de facto integration test for locality weighted // LB. TEST_P(LoadStatsIntegrationTest, LocalityWeighted) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; locality_weighted_lb_ = true; initialize(); @@ -540,7 +533,6 @@ TEST_P(LoadStatsIntegrationTest, LocalityWeighted) { // Validate the load reports for requests when all endpoints are non-local. TEST_P(LoadStatsIntegrationTest, NoLocalLocality) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; sub_zone_ = "summer"; initialize(); @@ -575,7 +567,6 @@ TEST_P(LoadStatsIntegrationTest, NoLocalLocality) { // Validate the load reports for successful/error requests make sense. TEST_P(LoadStatsIntegrationTest, Error) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initialize(); waitForLoadStatsStream(); @@ -602,7 +593,6 @@ TEST_P(LoadStatsIntegrationTest, Error) { // Validate the load reports for in-progress make sense. TEST_P(LoadStatsIntegrationTest, InProgress) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; initialize(); waitForLoadStatsStream(); @@ -626,7 +616,6 @@ TEST_P(LoadStatsIntegrationTest, InProgress) { // Validate the load reports for dropped requests make sense. TEST_P(LoadStatsIntegrationTest, Dropped) { - XDS_DEPRECATED_FEATURE_TEST_SKIP; config_helper_.addConfigModifier([](envoy::config::bootstrap::v3::Bootstrap& bootstrap) { auto* cluster_0 = bootstrap.mutable_static_resources()->mutable_clusters(0); auto* thresholds = cluster_0->mutable_circuit_breakers()->add_thresholds(); diff --git a/test/integration/scoped_rds_integration_test.cc b/test/integration/scoped_rds_integration_test.cc index 11184f160f4d..c1a96010e6c5 100644 --- a/test/integration/scoped_rds_integration_test.cc +++ b/test/integration/scoped_rds_integration_test.cc @@ -7,7 +7,6 @@ #include "envoy/service/discovery/v3/discovery.pb.h" #include "source/common/config/api_version.h" -#include "source/common/config/version_converter.h" #include "test/common/grpc/grpc_client_integration.h" #include "test/config/v2_link_hacks.h" diff --git a/test/integration/server.cc b/test/integration/server.cc index 2325ccc592b6..baa79e3f083c 100644 --- a/test/integration/server.cc +++ b/test/integration/server.cc @@ -31,7 +31,7 @@ OptionsImpl createTestOptionsImpl(const std::string& config_path, const std::str Network::Address::IpVersion ip_version, FieldValidationConfig validation_config, uint32_t concurrency, std::chrono::seconds drain_time, - Server::DrainStrategy drain_strategy, bool v2_bootstrap) { + Server::DrainStrategy drain_strategy) { OptionsImpl test_options("cluster_name", "node_name", "zone_name", spdlog::level::info); test_options.setConfigPath(config_path); @@ -46,9 +46,6 @@ OptionsImpl createTestOptionsImpl(const std::string& config_path, const std::str test_options.setIgnoreUnknownFieldsDynamic(validation_config.ignore_unknown_dynamic_fields); test_options.setConcurrency(concurrency); test_options.setHotRestartDisabled(true); - if (v2_bootstrap) { - test_options.setBootstrapVersion(2); - } return test_options; } @@ -62,7 +59,7 @@ IntegrationTestServerPtr IntegrationTestServer::create( Event::TestTimeSystem& time_system, Api::Api& api, bool defer_listener_finalization, ProcessObjectOptRef process_object, Server::FieldValidationConfig validation_config, uint32_t concurrency, std::chrono::seconds drain_time, Server::DrainStrategy drain_strategy, - Buffer::WatermarkFactorySharedPtr watermark_factory, bool use_real_stats, bool v2_bootstrap) { + Buffer::WatermarkFactorySharedPtr watermark_factory, bool use_real_stats) { IntegrationTestServerPtr server{ std::make_unique(time_system, api, config_path, use_real_stats)}; if (server_ready_function != nullptr) { @@ -70,7 +67,7 @@ IntegrationTestServerPtr IntegrationTestServer::create( } server->start(version, on_server_init_function, deterministic, defer_listener_finalization, process_object, validation_config, concurrency, drain_time, drain_strategy, - watermark_factory, v2_bootstrap); + watermark_factory); return server; } @@ -98,20 +95,22 @@ void IntegrationTestServer::unsetDynamicContextParam(absl::string_view resource_ }); } -void IntegrationTestServer::start( - const Network::Address::IpVersion version, std::function on_server_init_function, - bool deterministic, bool defer_listener_finalization, ProcessObjectOptRef process_object, - Server::FieldValidationConfig validator_config, uint32_t concurrency, - std::chrono::seconds drain_time, Server::DrainStrategy drain_strategy, - Buffer::WatermarkFactorySharedPtr watermark_factory, bool v2_bootstrap) { +void IntegrationTestServer::start(const Network::Address::IpVersion version, + std::function on_server_init_function, bool deterministic, + bool defer_listener_finalization, + ProcessObjectOptRef process_object, + Server::FieldValidationConfig validator_config, + uint32_t concurrency, std::chrono::seconds drain_time, + Server::DrainStrategy drain_strategy, + Buffer::WatermarkFactorySharedPtr watermark_factory) { ENVOY_LOG(info, "starting integration test server"); ASSERT(!thread_); - thread_ = api_.threadFactory().createThread( - [version, deterministic, process_object, validator_config, concurrency, drain_time, - drain_strategy, watermark_factory, v2_bootstrap, this]() -> void { - threadRoutine(version, deterministic, process_object, validator_config, concurrency, - drain_time, drain_strategy, watermark_factory, v2_bootstrap); - }); + thread_ = api_.threadFactory().createThread([version, deterministic, process_object, + validator_config, concurrency, drain_time, + drain_strategy, watermark_factory, this]() -> void { + threadRoutine(version, deterministic, process_object, validator_config, concurrency, drain_time, + drain_strategy, watermark_factory); + }); // If any steps need to be done prior to workers starting, do them now. E.g., xDS pre-init. // Note that there is no synchronization guaranteeing this happens either @@ -188,11 +187,9 @@ void IntegrationTestServer::threadRoutine(const Network::Address::IpVersion vers Server::FieldValidationConfig validation_config, uint32_t concurrency, std::chrono::seconds drain_time, Server::DrainStrategy drain_strategy, - Buffer::WatermarkFactorySharedPtr watermark_factory, - bool v2_bootstrap) { + Buffer::WatermarkFactorySharedPtr watermark_factory) { OptionsImpl options(Server::createTestOptionsImpl(config_path_, "", version, validation_config, - concurrency, drain_time, drain_strategy, - v2_bootstrap)); + concurrency, drain_time, drain_strategy)); Thread::MutexBasicLockable lock; Random::RandomGeneratorPtr random_generator; diff --git a/test/integration/server.h b/test/integration/server.h index 7e5ddd9fa93d..94d5f79504cb 100644 --- a/test/integration/server.h +++ b/test/integration/server.h @@ -45,8 +45,7 @@ createTestOptionsImpl(const std::string& config_path, const std::string& config_ FieldValidationConfig validation_config = FieldValidationConfig(), uint32_t concurrency = 1, std::chrono::seconds drain_time = std::chrono::seconds(1), - Server::DrainStrategy drain_strategy = Server::DrainStrategy::Gradual, - bool v2_bootstrap = false); + Server::DrainStrategy drain_strategy = Server::DrainStrategy::Gradual); class TestComponentFactory : public ComponentFactory { public: @@ -398,18 +397,16 @@ class IntegrationTestServer : public Logger::Loggable, public IntegrationTestServerStats, public Server::ComponentFactory { public: - static IntegrationTestServerPtr - create(const std::string& config_path, const Network::Address::IpVersion version, - std::function on_server_ready_function, - std::function on_server_init_function, bool deterministic, - Event::TestTimeSystem& time_system, Api::Api& api, - bool defer_listener_finalization = false, - ProcessObjectOptRef process_object = absl::nullopt, - Server::FieldValidationConfig validation_config = Server::FieldValidationConfig(), - uint32_t concurrency = 1, std::chrono::seconds drain_time = std::chrono::seconds(1), - Server::DrainStrategy drain_strategy = Server::DrainStrategy::Gradual, - Buffer::WatermarkFactorySharedPtr watermark_factory = nullptr, bool use_real_stats = false, - bool v2_bootstrap = false); + static IntegrationTestServerPtr create( + const std::string& config_path, const Network::Address::IpVersion version, + std::function on_server_ready_function, + std::function on_server_init_function, bool deterministic, + Event::TestTimeSystem& time_system, Api::Api& api, bool defer_listener_finalization = false, + ProcessObjectOptRef process_object = absl::nullopt, + Server::FieldValidationConfig validation_config = Server::FieldValidationConfig(), + uint32_t concurrency = 1, std::chrono::seconds drain_time = std::chrono::seconds(1), + Server::DrainStrategy drain_strategy = Server::DrainStrategy::Gradual, + Buffer::WatermarkFactorySharedPtr watermark_factory = nullptr, bool use_real_stats = false); // Note that the derived class is responsible for tearing down the server in its // destructor. ~IntegrationTestServer() override; @@ -437,7 +434,7 @@ class IntegrationTestServer : public Logger::Loggable, bool defer_listener_finalization, ProcessObjectOptRef process_object, Server::FieldValidationConfig validation_config, uint32_t concurrency, std::chrono::seconds drain_time, Server::DrainStrategy drain_strategy, - Buffer::WatermarkFactorySharedPtr watermark_factory, bool v2_bootstrap); + Buffer::WatermarkFactorySharedPtr watermark_factory); void waitForCounterEq(const std::string& name, uint64_t value, std::chrono::milliseconds timeout = TestUtility::DefaultTimeout, @@ -545,7 +542,7 @@ class IntegrationTestServer : public Logger::Loggable, ProcessObjectOptRef process_object, Server::FieldValidationConfig validation_config, uint32_t concurrency, std::chrono::seconds drain_time, Server::DrainStrategy drain_strategy, - Buffer::WatermarkFactorySharedPtr watermark_factory, bool v2_bootstrap); + Buffer::WatermarkFactorySharedPtr watermark_factory); Event::TestTimeSystem& time_system_; Api::Api& api_; diff --git a/test/integration/tcp_proxy_integration_test.cc b/test/integration/tcp_proxy_integration_test.cc index 8062772d73e3..691bcd8df611 100644 --- a/test/integration/tcp_proxy_integration_test.cc +++ b/test/integration/tcp_proxy_integration_test.cc @@ -867,27 +867,6 @@ TEST_P(TcpProxyMetadataMatchIntegrationTest, expectEndpointToMatchRoute(); } -// Test subset load balancing for a deprecated_v1 route when endpoint selector is defined at the top -// level. -TEST_P(TcpProxyMetadataMatchIntegrationTest, - DEPRECATED_FEATURE_TEST(EndpointShouldMatchRouteWithTopLevelMetadataMatch)) { - tcp_proxy_.set_stat_prefix("tcp_stats"); - tcp_proxy_.set_cluster("fallback"); - tcp_proxy_.mutable_hidden_envoy_deprecated_deprecated_v1()->add_routes()->set_cluster( - "cluster_0"); - tcp_proxy_.mutable_metadata_match()->MergeFrom( - lbMetadata({{"role", "primary"}, {"version", "v1"}, {"stage", "prod"}})); - - endpoint_metadata_ = lbMetadata({{"role", "primary"}, {"version", "v1"}, {"stage", "prod"}}); - - config_helper_.addRuntimeOverride("envoy.deprecated_features:envoy.extensions.filters.network." - "tcp_proxy.v3.TcpProxy.hidden_envoy_deprecated_deprecated_v1", - "true"); - initialize(); - - expectEndpointToMatchRoute(); -} - // Test subset load balancing for a weighted cluster when endpoint selector is defined on a weighted // cluster. TEST_P(TcpProxyMetadataMatchIntegrationTest, EndpointShouldMatchWeightedClusterWithMetadataMatch) { @@ -958,27 +937,6 @@ TEST_P(TcpProxyMetadataMatchIntegrationTest, expectEndpointNotToMatchRoute(); } -// Test subset load balancing for a deprecated_v1 route when endpoint selector is defined at the top -// level. -TEST_P(TcpProxyMetadataMatchIntegrationTest, - DEPRECATED_FEATURE_TEST(EndpointShouldNotMatchRouteWithTopLevelMetadataMatch)) { - tcp_proxy_.set_stat_prefix("tcp_stats"); - tcp_proxy_.set_cluster("fallback"); - tcp_proxy_.mutable_hidden_envoy_deprecated_deprecated_v1()->add_routes()->set_cluster( - "cluster_0"); - tcp_proxy_.mutable_metadata_match()->MergeFrom( - lbMetadata({{"role", "primary"}, {"version", "v1"}, {"stage", "prod"}})); - - endpoint_metadata_ = lbMetadata({{"role", "replica"}, {"version", "v1"}, {"stage", "prod"}}); - - config_helper_.addRuntimeOverride("envoy.deprecated_features:envoy.extensions.filters.network." - "tcp_proxy.v3.TcpProxy.hidden_envoy_deprecated_deprecated_v1", - "true"); - initialize(); - - expectEndpointNotToMatchRoute(); -} - // Test subset load balancing for a weighted cluster when endpoint selector is defined on a weighted // cluster. TEST_P(TcpProxyMetadataMatchIntegrationTest, diff --git a/test/mocks/server/options.cc b/test/mocks/server/options.cc index 09409e2772c5..8c48e026f81d 100644 --- a/test/mocks/server/options.cc +++ b/test/mocks/server/options.cc @@ -18,7 +18,6 @@ MockOptions::MockOptions(const std::string& config_path) : config_path_(config_p ON_CALL(*this, configPath()).WillByDefault(ReturnRef(config_path_)); ON_CALL(*this, configProto()).WillByDefault(ReturnRef(config_proto_)); ON_CALL(*this, configYaml()).WillByDefault(ReturnRef(config_yaml_)); - ON_CALL(*this, bootstrapVersion()).WillByDefault(ReturnRef(bootstrap_version_)); ON_CALL(*this, allowUnknownStaticFields()).WillByDefault(Invoke([this] { return allow_unknown_static_fields_; })); diff --git a/test/mocks/server/options.h b/test/mocks/server/options.h index 9bc6e721ea68..35bc8ff5c26a 100644 --- a/test/mocks/server/options.h +++ b/test/mocks/server/options.h @@ -22,7 +22,6 @@ class MockOptions : public Options { MOCK_METHOD(const std::string&, configPath, (), (const)); MOCK_METHOD(const envoy::config::bootstrap::v3::Bootstrap&, configProto, (), (const)); MOCK_METHOD(const std::string&, configYaml, (), (const)); - MOCK_METHOD(const absl::optional&, bootstrapVersion, (), (const)); MOCK_METHOD(bool, allowUnknownStaticFields, (), (const)); MOCK_METHOD(bool, rejectUnknownDynamicFields, (), (const)); MOCK_METHOD(bool, ignoreUnknownDynamicFields, (), (const)); diff --git a/test/per_file_coverage.sh b/test/per_file_coverage.sh index 8b66a61aaef6..49446ee5dc29 100755 --- a/test/per_file_coverage.sh +++ b/test/per_file_coverage.sh @@ -12,7 +12,7 @@ declare -a KNOWN_LOW_COVERAGE=( "source/common/filesystem/posix:96.2" "source/common/json:90.9" "source/common/network:95.0" # Flaky, `activateFileEvents`, `startSecureTransport` and `ioctl` do not always report LCOV -"source/common/protobuf:94.8" +"source/common/protobuf:94.7" "source/common/signal:84.5" # Death tests don't report LCOV "source/common/singleton:95.8" "source/common/thread:0.0" # Death tests don't report LCOV diff --git a/test/server/config_validation/xds_fuzz.cc b/test/server/config_validation/xds_fuzz.cc index 653acd8db012..06bb9d1f387b 100644 --- a/test/server/config_validation/xds_fuzz.cc +++ b/test/server/config_validation/xds_fuzz.cc @@ -12,26 +12,25 @@ namespace Envoy { // Helper functions to build API responses. envoy::config::cluster::v3::Cluster XdsFuzzTest::buildCluster(const std::string& name) { - return ConfigHelper::buildCluster(name, "ROUND_ROBIN", api_version_); + return ConfigHelper::buildCluster(name, "ROUND_ROBIN"); }; envoy::config::endpoint::v3::ClusterLoadAssignment XdsFuzzTest::buildClusterLoadAssignment(const std::string& name) { return ConfigHelper::buildClusterLoadAssignment( name, Network::Test::getLoopbackAddressString(ip_version_), - fake_upstreams_[0]->localAddress()->ip()->port(), api_version_); + fake_upstreams_[0]->localAddress()->ip()->port()); } envoy::config::listener::v3::Listener XdsFuzzTest::buildListener(const std::string& listener_name, const std::string& route_name) { - return ConfigHelper::buildListener(listener_name, route_name, - Network::Test::getLoopbackAddressString(ip_version_), - "ads_test", api_version_); + return ConfigHelper::buildListener( + listener_name, route_name, Network::Test::getLoopbackAddressString(ip_version_), "ads_test"); } envoy::config::route::v3::RouteConfiguration XdsFuzzTest::buildRouteConfig(const std::string& route_name) { - return ConfigHelper::buildRouteConfig(route_name, "cluster_0", api_version_); + return ConfigHelper::buildRouteConfig(route_name, "cluster_0"); } // Helper functions to send API responses. @@ -55,17 +54,15 @@ void XdsFuzzTest::updateRoute( std::to_string(version_)); } -XdsFuzzTest::XdsFuzzTest(const test::server::config_validation::XdsTestCase& input, - envoy::config::core::v3::ApiVersion api_version) +XdsFuzzTest::XdsFuzzTest(const test::server::config_validation::XdsTestCase& input) : HttpIntegrationTest( Http::CodecType::HTTP2, TestEnvironment::getIpVersionsForTest()[0], ConfigHelper::adsBootstrap(input.config().sotw_or_delta() == test::server::config_validation::Config::SOTW ? "GRPC" - : "DELTA_GRPC", - api_version)), + : "DELTA_GRPC")), verifier_(input.config().sotw_or_delta()), actions_(input.actions()), version_(1), - api_version_(api_version), ip_version_(TestEnvironment::getIpVersionsForTest()[0]) { + ip_version_(TestEnvironment::getIpVersionsForTest()[0]) { use_lds_ = false; create_xds_upstream_ = true; tls_xds_upstream_ = false; diff --git a/test/server/config_validation/xds_fuzz.h b/test/server/config_validation/xds_fuzz.h index 602c312ee8a0..42c23959ccb7 100644 --- a/test/server/config_validation/xds_fuzz.h +++ b/test/server/config_validation/xds_fuzz.h @@ -22,8 +22,7 @@ namespace Envoy { class XdsFuzzTest : public HttpIntegrationTest { public: - XdsFuzzTest(const test::server::config_validation::XdsTestCase& input, - envoy::config::core::v3::ApiVersion api_version); + XdsFuzzTest(const test::server::config_validation::XdsTestCase& input); envoy::config::cluster::v3::Cluster buildCluster(const std::string& name); @@ -77,7 +76,6 @@ class XdsFuzzTest : public HttpIntegrationTest { std::vector listeners_; uint64_t version_; - envoy::config::core::v3::ApiVersion api_version_; Network::Address::IpVersion ip_version_; diff --git a/test/server/config_validation/xds_fuzz_test.cc b/test/server/config_validation/xds_fuzz_test.cc index 5b41d4a01bbb..231100d2972b 100644 --- a/test/server/config_validation/xds_fuzz_test.cc +++ b/test/server/config_validation/xds_fuzz_test.cc @@ -12,7 +12,7 @@ DEFINE_PROTO_FUZZER(const test::server::config_validation::XdsTestCase& input) { ENVOY_LOG_MISC(debug, "ProtoValidationException: {}", e.what()); return; } - XdsFuzzTest test(input, envoy::config::core::v3::ApiVersion::V3); + XdsFuzzTest test(input); test.replay(); } diff --git a/test/server/config_validation/xds_verifier_test.cc b/test/server/config_validation/xds_verifier_test.cc index 3e65220687e7..f0cbef7fdc6b 100644 --- a/test/server/config_validation/xds_verifier_test.cc +++ b/test/server/config_validation/xds_verifier_test.cc @@ -7,13 +7,11 @@ namespace Envoy { envoy::config::listener::v3::Listener buildListener(const std::string& listener_name, const std::string& route_name) { - return ConfigHelper::buildListener(listener_name, route_name, "", "ads_test", - envoy::config::core::v3::ApiVersion::V3); + return ConfigHelper::buildListener(listener_name, route_name, "", "ads_test"); } envoy::config::route::v3::RouteConfiguration buildRoute(const std::string& route_name) { - return ConfigHelper::buildRouteConfig(route_name, "cluster_0", - envoy::config::core::v3::ApiVersion::V3); + return ConfigHelper::buildRouteConfig(route_name, "cluster_0"); } // Add, warm, drain and remove a listener. diff --git a/test/server/configuration_impl_test.cc b/test/server/configuration_impl_test.cc index f2f02f385bc0..8862f46df622 100644 --- a/test/server/configuration_impl_test.cc +++ b/test/server/configuration_impl_test.cc @@ -612,9 +612,8 @@ TEST(InitialImplTest, LayeredRuntime) { admin_layer: {} )EOF"; const auto bootstrap = TestUtility::parseYaml(yaml); - NiceMock options; NiceMock server; - InitialImpl config(bootstrap, options); + InitialImpl config(bootstrap); EXPECT_THAT(config.runtime(), ProtoEq(bootstrap.layered_runtime())); } @@ -625,9 +624,8 @@ TEST(InitialImplTest, EmptyLayeredRuntime) { )EOF"; const auto bootstrap = TestUtility::parseYaml(bootstrap_yaml); - NiceMock options; NiceMock server; - InitialImpl config(bootstrap, options); + InitialImpl config(bootstrap); const std::string expected_yaml = R"EOF( layers: @@ -676,9 +674,8 @@ TEST_F(ConfigurationImplTest, AdminSocketOptions) { )EOF"; auto bootstrap = Upstream::parseBootstrapFromV3Json(json); - NiceMock options; NiceMock server; - InitialImpl config(bootstrap, options); + InitialImpl config(bootstrap); config.initAdminAccessLog(bootstrap, server_); Network::MockListenSocket socket_mock; @@ -717,9 +714,8 @@ TEST_F(ConfigurationImplTest, FileAccessLogOutput) { )EOF"; auto bootstrap = Upstream::parseBootstrapFromV3Json(json); - NiceMock options; NiceMock server; - InitialImpl config(bootstrap, options); + InitialImpl config(bootstrap); config.initAdminAccessLog(bootstrap, server_); Network::MockListenSocket socket_mock; @@ -1041,9 +1037,8 @@ TEST_F(ConfigurationImplTest, DEPRECATED_FEATURE_TEST(DeprecatedAccessLogPathWit )EOF"; auto bootstrap = Upstream::parseBootstrapFromV3Json(json); - NiceMock options; NiceMock server; - InitialImpl config(bootstrap, options); + InitialImpl config(bootstrap); config.initAdminAccessLog(bootstrap, server_); Network::MockListenSocket socket_mock; @@ -1078,8 +1073,7 @@ TEST_F(ConfigurationImplTest, AccessLogWithFilter) { )EOF"; auto bootstrap = Upstream::parseBootstrapFromV3Json(json); - NiceMock options; - InitialImpl config(bootstrap, options); + InitialImpl config(bootstrap); config.initAdminAccessLog(bootstrap, server_); ASSERT_EQ(config.admin().accessLogs().size(), 1); @@ -1114,8 +1108,7 @@ TEST_F(ConfigurationImplTest, DEPRECATED_FEATURE_TEST(DeprecatedAccessLogPathWit )EOF"; auto bootstrap = Upstream::parseBootstrapFromV3Json(json); - NiceMock options; - InitialImpl config(bootstrap, options); + InitialImpl config(bootstrap); config.initAdminAccessLog(bootstrap, server_); ASSERT_EQ(config.admin().accessLogs().size(), 2); @@ -1129,8 +1122,7 @@ TEST_F(ConfigurationImplTest, EmptyAdmin) { )EOF"; auto bootstrap = Upstream::parseBootstrapFromV3Json(json); - NiceMock options; - InitialImpl config(bootstrap, options); + InitialImpl config(bootstrap); config.initAdminAccessLog(bootstrap, server_); ASSERT_EQ(config.admin().accessLogs().size(), 0); @@ -1152,9 +1144,8 @@ TEST_F(ConfigurationImplTest, DEPRECATED_FEATURE_TEST(DeprecatedAccessLogPath)) )EOF"; auto bootstrap = Upstream::parseBootstrapFromV3Json(json); - NiceMock options; NiceMock server; - InitialImpl config(bootstrap, options); + InitialImpl config(bootstrap); config.initAdminAccessLog(bootstrap, server_); Network::MockListenSocket socket_mock; diff --git a/test/server/listener_manager_impl_test.cc b/test/server/listener_manager_impl_test.cc index a329447fbf67..26fa91df69d5 100644 --- a/test/server/listener_manager_impl_test.cc +++ b/test/server/listener_manager_impl_test.cc @@ -258,44 +258,6 @@ TEST_F(ListenerManagerImplWithRealFiltersTest, TlsTransportSocket) { EXPECT_TRUE(filter_chain->transportSocketFactory().implementsSecureTransport()); } -TEST_F(ListenerManagerImplWithRealFiltersTest, - DEPRECATED_FEATURE_TEST(TlsTransportSocketLegacyConfig)) { - TestDeprecatedV2Api _deprecated_v2_api; - const std::string yaml = TestEnvironment::substitute(R"EOF( -address: - socket_address: - address: 127.0.0.1 - port_value: 1234 -filter_chains: -- filters: [] - transport_socket: - name: tls - typed_config: - "@type": type.googleapis.com/envoy.api.v2.auth.DownstreamTlsContext - common_tls_context: - tls_certificates: - - certificate_chain: - filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/san_uri_cert.pem" - private_key: - filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/san_uri_key.pem" - validation_context: - trusted_ca: - filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/ca_cert.pem" - verify_subject_alt_name: - - localhost - - 127.0.0.1 - )EOF", - Network::Address::IpVersion::v4); - - EXPECT_CALL(listener_factory_, createListenSocket(_, _, _, default_bind_type, 0)); - manager_->addOrUpdateListener(parseListenerFromV3Yaml(yaml), "", true); - EXPECT_EQ(1U, manager_->listeners().size()); - - auto filter_chain = findFilterChain(1234, "127.0.0.1", "", "tls", {}, "8.8.8.8", 111); - ASSERT_NE(filter_chain, nullptr); - EXPECT_TRUE(filter_chain->transportSocketFactory().implementsSecureTransport()); -} - TEST_F(ListenerManagerImplWithRealFiltersTest, TransportSocketConnectTimeout) { const std::string yaml = R"EOF( address: diff --git a/test/server/options_impl_test.cc b/test/server/options_impl_test.cc index b0c744cfde56..07c5659aece2 100644 --- a/test/server/options_impl_test.cc +++ b/test/server/options_impl_test.cc @@ -635,24 +635,5 @@ TEST(DisableExtensions, DEPRECATED_FEATURE_TEST(IsDisabled)) { nullptr); } -TEST(FactoryByTypeTest, EarlierVersionConfigType) { - envoy::config::filter::http::buffer::v2::Buffer v2_config; - auto factory = Registry::FactoryRegistry:: - getFactoryByType(v2_config.GetDescriptor()->full_name()); - EXPECT_NE(factory, nullptr); - EXPECT_EQ(factory->name(), "envoy.filters.http.buffer"); - - envoy::extensions::filters::http::buffer::v3::Buffer v3_config; - factory = Registry::FactoryRegistry:: - getFactoryByType(v3_config.GetDescriptor()->full_name()); - EXPECT_NE(factory, nullptr); - EXPECT_EQ(factory->name(), "envoy.filters.http.buffer"); - - ProtobufWkt::Any non_api_type; - factory = Registry::FactoryRegistry:: - getFactoryByType(non_api_type.GetDescriptor()->full_name()); - EXPECT_EQ(factory, nullptr); -} - } // namespace } // namespace Envoy diff --git a/test/server/server_test.cc b/test/server/server_test.cc index 7410ee5595bd..01da09885acc 100644 --- a/test/server/server_test.cc +++ b/test/server/server_test.cc @@ -679,17 +679,6 @@ TEST_P(ServerInstanceImplTest, ShutdownBeforeWorkersStarted) { server_thread->join(); } -TEST_P(ServerInstanceImplTest, V2ConfigOnly) { - options_.service_cluster_name_ = "some_cluster_name"; - options_.service_node_name_ = "some_node_name"; - try { - initialize("test/server/test_data/server/unparseable_bootstrap.yaml"); - FAIL(); - } catch (const EnvoyException& e) { - EXPECT_THAT(e.what(), HasSubstr("Unable to parse JSON as proto")); - } -} - TEST_P(ServerInstanceImplTest, Stats) { options_.service_cluster_name_ = "some_cluster_name"; options_.service_node_name_ = "some_node_name"; @@ -789,7 +778,6 @@ TEST_P(ServerStatsTest, FlushStats) { TEST_P(ServerInstanceImplTest, FlushStatsOnAdmin) { CustomStatsSinkFactory factory; Registry::InjectFactory registered(factory); - options_.bootstrap_version_ = 3; auto server_thread = startTestServer("test/server/test_data/server/stats_sink_manual_flush_bootstrap.yaml", true); EXPECT_TRUE(server_->statsConfig().flushOnAdmin()); @@ -816,7 +804,6 @@ TEST_P(ServerInstanceImplTest, FlushStatsOnAdmin) { TEST_P(ServerInstanceImplTest, ConcurrentFlushes) { CustomStatsSinkFactory factory; Registry::InjectFactory registered(factory); - options_.bootstrap_version_ = 3; bool workers_started = false; absl::Notification workers_started_fired; @@ -925,21 +912,6 @@ TEST_P(ServerInstanceImplTest, ValidationAllowStaticRejectDynamic) { EXPECT_EQ(0, TestUtility::findCounter(stats_store_, "server.dynamic_unknown_fields")->value()); } -// Validate server localInfo() from bootstrap Node. -// Deprecated testing of the envoy.api.v2.core.Node.build_version field -TEST_P(ServerInstanceImplTest, DEPRECATED_FEATURE_TEST(BootstrapNodeDeprecated)) { - initialize("test/server/test_data/server/node_bootstrap.yaml"); - EXPECT_EQ("bootstrap_zone", server_->localInfo().zoneName()); - EXPECT_EQ("bootstrap_cluster", server_->localInfo().clusterName()); - EXPECT_EQ("bootstrap_id", server_->localInfo().nodeName()); - EXPECT_EQ("bootstrap_sub_zone", server_->localInfo().node().locality().sub_zone()); - EXPECT_EQ(VersionInfo::version(), - server_->localInfo().node().hidden_envoy_deprecated_build_version()); - EXPECT_EQ("envoy", server_->localInfo().node().user_agent_name()); - EXPECT_TRUE(server_->localInfo().node().has_user_agent_build_version()); - expectCorrectBuildVersion(server_->localInfo().node().user_agent_build_version()); -} - // Validate server localInfo() from bootstrap Node. TEST_P(ServerInstanceImplTest, BootstrapNode) { initialize("test/server/test_data/server/node_bootstrap.yaml"); @@ -977,126 +949,6 @@ TEST_P(ServerInstanceImplTest, UserAgentOverrideFromNode) { EXPECT_EQ(7, server_->localInfo().node().user_agent_build_version().version().patch()); } -// Validate deprecated user agent version field from bootstrap Node. -TEST_P(ServerInstanceImplTest, DEPRECATED_FEATURE_TEST(UserAgentBuildDeprecatedOverrideFromNode)) { - initialize("test/server/test_data/server/node_bootstrap_agent_deprecated_override.yaml"); - EXPECT_EQ("test-ci-user-agent", server_->localInfo().node().user_agent_name()); - EXPECT_EQ("test", server_->localInfo().node().hidden_envoy_deprecated_build_version()); -} - -// Validate that bootstrap with v2 dynamic transport is rejected when --bootstrap-version is not -// set. -TEST_P(ServerInstanceImplTest, - DEPRECATED_FEATURE_TEST(FailToLoadV2TransportWithoutExplicitVersion)) { - EXPECT_THROW_WITH_REGEX(initialize("test/server/test_data/server/dynamic_v2.yaml"), - DeprecatedMajorVersionException, - "V2 .and AUTO. xDS transport protocol versions are deprecated in.*"); -} - -// Validate that bootstrap with v2 ADS transport is rejected when --bootstrap-version is not -// set. -TEST_P(ServerInstanceImplTest, - DEPRECATED_FEATURE_TEST(FailToLoadV2AdsTransportWithoutExplicitVersion)) { - EXPECT_THROW_WITH_REGEX(initialize("test/server/test_data/server/ads_v2.yaml"), - DeprecatedMajorVersionException, - "V2 .and AUTO. xDS transport protocol versions are deprecated in.*"); -} - -// Validate that bootstrap with v2 HDS transport is rejected when --bootstrap-version is not -// set. -TEST_P(ServerInstanceImplTest, - DEPRECATED_FEATURE_TEST(FailToLoadV2HdsTransportWithoutExplicitVersion)) { - // HDS cluster initialization happens through callbacks after runtime initialization. Exceptions - // are caught and will result in server shutdown. - EXPECT_LOG_CONTAINS("warn", - "Skipping initialization of HDS cluster: V2 (and AUTO) xDS transport " - "protocol versions are deprecated", - initialize("test/server/test_data/server/hds_v2.yaml")); -} - -// Validate that bootstrap v2 is rejected when --bootstrap-version is not set. -TEST_P(ServerInstanceImplTest, - DEPRECATED_FEATURE_TEST(FailToLoadV2BootstrapWithoutExplicitVersion)) { - EXPECT_THROW_WITH_REGEX( - initialize("test/server/test_data/server/valid_v2_but_invalid_v3_bootstrap.pb_text"), - DeprecatedMajorVersionException, - "Support for v2 will be removed from Envoy at the start of Q1 2021."); -} - -// Validate that bootstrap v2 pb_text with deprecated fields loads when --bootstrap-version is set. -TEST_P(ServerInstanceImplTest, - DEPRECATED_FEATURE_TEST(DISABLED_LoadsV2BootstrapWithExplicitVersionFromPbText)) { - options_.bootstrap_version_ = 2; - initialize("test/server/test_data/server/valid_v2_but_invalid_v3_bootstrap.pb_text"); - EXPECT_FALSE(server_->localInfo().node().hidden_envoy_deprecated_build_version().empty()); -} - -// Validate that bootstrap v2 pb_text with deprecated fields fails to load when -// --bootstrap-version is not set. -TEST_P(ServerInstanceImplTest, DEPRECATED_FEATURE_TEST(FailToLoadV2BootstrapFromPbText)) { - EXPECT_THROW_WITH_REGEX( - initialize("test/server/test_data/server/valid_v2_but_invalid_v3_bootstrap.pb_text"), - EnvoyException, "The v2 xDS major version is deprecated and disabled by default."); -} - -// Validate that bootstrap v2 YAML with deprecated fields loads when --bootstrap-version is set. -TEST_P(ServerInstanceImplTest, - DEPRECATED_FEATURE_TEST(DISABLED_LoadsV2BootstrapWithExplicitVersionFromYaml)) { - options_.bootstrap_version_ = 2; - EXPECT_LOG_CONTAINS( - "trace", "Configuration does not parse cleanly as v3", - initialize("test/server/test_data/server/valid_v2_but_invalid_v3_bootstrap.yaml")); - EXPECT_FALSE(server_->localInfo().node().hidden_envoy_deprecated_build_version().empty()); -} - -// Validate that bootstrap v2 YAML with deprecated fields fails to load when -// --bootstrap-version is not set. -TEST_P(ServerInstanceImplTest, DEPRECATED_FEATURE_TEST(FailsToLoadV2BootstrapFromYaml)) { - EXPECT_THROW_WITH_REGEX( - initialize("test/server/test_data/server/valid_v2_but_invalid_v3_bootstrap.yaml"), - EnvoyException, "The v2 xDS major version is deprecated and disabled by default."); -} - -// Validate that bootstrap v3 pb_text with new fields loads fails if V2 config is specified. -TEST_P(ServerInstanceImplTest, DISABLED_FailToLoadV3ConfigWhenV2SelectedFromPbText) { - options_.bootstrap_version_ = 2; - - EXPECT_THROW_WITH_REGEX( - initialize("test/server/test_data/server/valid_v3_but_invalid_v2_bootstrap.pb_text"), - EnvoyException, "Unable to parse file"); -} - -// Validate that bootstrap v3 YAML with new fields loads fails if V2 config is specified. -TEST_P(ServerInstanceImplTest, DISABLED_FailToLoadV3ConfigWhenV2SelectedFromYaml) { - options_.bootstrap_version_ = 2; - - EXPECT_THROW_WITH_REGEX( - initialize("test/server/test_data/server/valid_v3_but_invalid_v2_bootstrap.yaml"), - EnvoyException, "has unknown fields"); -} - -// Validate that we correctly parse a V2 pb_text file when configured to do so. -TEST_P(ServerInstanceImplTest, - DEPRECATED_FEATURE_TEST(DISABLED_LoadsV2ConfigWhenV2SelectedFromPbText)) { - options_.bootstrap_version_ = 2; - - EXPECT_LOG_CONTAINS( - "trace", "Configuration does not parse cleanly as v3", - initialize("test/server/test_data/server/valid_v2_but_invalid_v3_bootstrap.pb_text")); - EXPECT_EQ(server_->localInfo().node().id(), "bootstrap_id"); -} - -// Validate that we correctly parse a V2 YAML file when configured to do so. -TEST_P(ServerInstanceImplTest, - DEPRECATED_FEATURE_TEST(DISABLED_LoadsV2ConfigWhenV2SelectedFromYaml)) { - options_.bootstrap_version_ = 2; - - EXPECT_LOG_CONTAINS( - "trace", "Configuration does not parse cleanly as v3", - initialize("test/server/test_data/server/valid_v2_but_invalid_v3_bootstrap.yaml")); - EXPECT_EQ(server_->localInfo().node().id(), "bootstrap_id"); -} - // Validate that we correctly parse a V3 pb_text file without explicit version configuration. TEST_P(ServerInstanceImplTest, LoadsV3ConfigFromPbText) { EXPECT_LOG_NOT_CONTAINS( @@ -1113,8 +965,6 @@ TEST_P(ServerInstanceImplTest, LoadsV3ConfigFromYaml) { // Validate that we correctly parse a V3 pb_text file when configured to do so. TEST_P(ServerInstanceImplTest, LoadsV3ConfigWhenV3SelectedFromPbText) { - options_.bootstrap_version_ = 3; - EXPECT_LOG_NOT_CONTAINS( "trace", "Configuration does not parse cleanly as v3", initialize("test/server/test_data/server/valid_v3_but_invalid_v2_bootstrap.pb_text")); @@ -1122,52 +972,11 @@ TEST_P(ServerInstanceImplTest, LoadsV3ConfigWhenV3SelectedFromPbText) { // Validate that we correctly parse a V3 YAML file when configured to do so. TEST_P(ServerInstanceImplTest, LoadsV3ConfigWhenV3SelectedFromYaml) { - options_.bootstrap_version_ = 3; - EXPECT_LOG_NOT_CONTAINS( "trace", "Configuration does not parse cleanly as v3", initialize("test/server/test_data/server/valid_v3_but_invalid_v2_bootstrap.yaml")); } -// Validate that bootstrap v2 pb_text with deprecated fields loads fails if V3 config is specified. -TEST_P(ServerInstanceImplTest, FailToLoadV2ConfigWhenV3SelectedFromPbText) { - options_.bootstrap_version_ = 3; - - EXPECT_THROW_WITH_REGEX( - initialize("test/server/test_data/server/valid_v2_but_invalid_v3_bootstrap.pb_text"), - EnvoyException, "Unable to parse file"); -} - -// Validate that bootstrap v2 YAML with deprecated fields loads fails if V3 config is specified. -TEST_P(ServerInstanceImplTest, DEPRECATED_FEATURE_TEST(FailToLoadV2ConfigWhenV3SelectedFromYaml)) { - options_.bootstrap_version_ = 3; - - EXPECT_THROW_WITH_REGEX( - initialize("test/server/test_data/server/valid_v2_but_invalid_v3_bootstrap.yaml"), - EnvoyException, "has unknown fields"); -} - -// Validate that bootstrap with v2 dynamic transport loads when --bootstrap-version is set. -TEST_P(ServerInstanceImplTest, - DEPRECATED_FEATURE_TEST(DISABLED_LoadsV2TransportWithoutExplicitVersion)) { - options_.bootstrap_version_ = 2; - initialize("test/server/test_data/server/dynamic_v2.yaml"); -} - -// Validate that bootstrap with v2 ADS transport loads when --bootstrap-version is set. -TEST_P(ServerInstanceImplTest, - DEPRECATED_FEATURE_TEST(DISABLED_LoadsV2AdsTransportWithoutExplicitVersion)) { - options_.bootstrap_version_ = 2; - initialize("test/server/test_data/server/ads_v2.yaml"); -} - -// Validate that bootstrap with v2 HDS transport loads when --bootstrap-version is set. -TEST_P(ServerInstanceImplTest, - DEPRECATED_FEATURE_TEST(DISABLED_LoadsV2HdsTransportWithoutExplicitVersion)) { - options_.bootstrap_version_ = 2; - initialize("test/server/test_data/server/hds_v2.yaml"); -} - // Validate that bootstrap pb_text loads. TEST_P(ServerInstanceImplTest, LoadsBootstrapFromPbText) { EXPECT_LOG_NOT_CONTAINS("trace", "Configuration does not parse cleanly as v3", @@ -1175,15 +984,6 @@ TEST_P(ServerInstanceImplTest, LoadsBootstrapFromPbText) { EXPECT_EQ("bootstrap_id", server_->localInfo().node().id()); } -// Validate that we blow up on invalid version number. -TEST_P(ServerInstanceImplTest, InvalidBootstrapVersion) { - options_.bootstrap_version_ = 1; - - EXPECT_THROW_WITH_REGEX( - initialize("test/server/test_data/server/valid_v2_but_invalid_v3_bootstrap.pb_text"), - EnvoyException, "Unknown bootstrap version 1."); -} - TEST_P(ServerInstanceImplTest, LoadsBootstrapFromConfigProtoOptions) { options_.config_proto_.mutable_node()->set_id("foo"); initialize("test/server/test_data/server/node_bootstrap.yaml"); @@ -1258,13 +1058,6 @@ TEST_P(ServerInstanceImplTest, BootstrapRtdsThroughAdsViaEdsFails) { EnvoyException, "Unknown gRPC client cluster"); } -TEST_P(ServerInstanceImplTest, DEPRECATED_FEATURE_TEST(DISABLED_InvalidLegacyBootstrapRuntime)) { - options_.bootstrap_version_ = 2; - EXPECT_THROW_WITH_MESSAGE( - initialize("test/server/test_data/server/invalid_legacy_runtime_bootstrap.yaml"), - EnvoyException, "Invalid runtime entry value for foo"); -} - // Validate invalid runtime in bootstrap is rejected. TEST_P(ServerInstanceImplTest, InvalidBootstrapRuntime) { EXPECT_THROW_WITH_MESSAGE( @@ -1517,7 +1310,6 @@ TEST_P(ServerInstanceImplTest, NoHttpTracing) { TEST_P(ServerInstanceImplTest, DEPRECATED_FEATURE_TEST(DISABLED_ZipkinHttpTracingEnabled)) { options_.service_cluster_name_ = "some_cluster_name"; options_.service_node_name_ = "some_node_name"; - options_.bootstrap_version_ = 2; EXPECT_NO_THROW(initialize("test/server/test_data/server/zipkin_tracing_deprecated_config.yaml")); EXPECT_EQ("zipkin", server_->httpContext().defaultTracingConfig().http().name()); } diff --git a/test/server/test_data/server/ads_v2.yaml b/test/server/test_data/server/ads_v2.yaml deleted file mode 100644 index 03e5693b75cb..000000000000 --- a/test/server/test_data/server/ads_v2.yaml +++ /dev/null @@ -1,14 +0,0 @@ -node: - id: bootstrap_id - cluster: bootstrap_cluster -static_resources: - clusters: - - name: dummy_cluster - connect_timeout: 1s -dynamic_resources: - ads_config: - api_type: GRPC - transport_api_version: V2 - grpc_services: - envoy_grpc: - cluster_name: "dummy_cluster" diff --git a/test/server/test_data/server/dynamic_v2.yaml b/test/server/test_data/server/dynamic_v2.yaml deleted file mode 100644 index bf924ec1639e..000000000000 --- a/test/server/test_data/server/dynamic_v2.yaml +++ /dev/null @@ -1,16 +0,0 @@ -node: - id: bootstrap_id - cluster: bootstrap_cluster -static_resources: - clusters: - - name: dummy_cluster - connect_timeout: 1s -dynamic_resources: - lds_config: - resource_api_version: V3 - api_config_source: - api_type: GRPC - transport_api_version: V2 - grpc_services: - envoy_grpc: - cluster_name: "dummy_cluster" diff --git a/test/server/test_data/server/hds_v2.yaml b/test/server/test_data/server/hds_v2.yaml deleted file mode 100644 index fb87f8239e63..000000000000 --- a/test/server/test_data/server/hds_v2.yaml +++ /dev/null @@ -1,13 +0,0 @@ -node: - id: bootstrap_id - cluster: bootstrap_cluster -static_resources: - clusters: - - name: dummy_cluster - connect_timeout: 1s -hds_config: - api_type: GRPC - transport_api_version: V2 - grpc_services: - envoy_grpc: - cluster_name: "dummy_cluster" diff --git a/test/server/test_data/server/invalid_legacy_runtime_bootstrap.yaml b/test/server/test_data/server/invalid_legacy_runtime_bootstrap.yaml deleted file mode 100644 index 99c67b7d2d9c..000000000000 --- a/test/server/test_data/server/invalid_legacy_runtime_bootstrap.yaml +++ /dev/null @@ -1,4 +0,0 @@ -runtime: - base: - foo: - - bar: baz diff --git a/test/server/test_data/server/node_bootstrap.pb_text b/test/server/test_data/server/node_bootstrap.pb_text index f47df39a8351..7fa148fc6a30 100644 --- a/test/server/test_data/server/node_bootstrap.pb_text +++ b/test/server/test_data/server/node_bootstrap.pb_text @@ -7,7 +7,6 @@ node { } } admin { - access_log_path: "{{ null_device_path }}" address { socket_address { address: "{{ ntop_ip_loopback_address }}" diff --git a/test/server/test_data/server/node_bootstrap.yaml b/test/server/test_data/server/node_bootstrap.yaml index f662534dfeb4..c47464b5e7d5 100644 --- a/test/server/test_data/server/node_bootstrap.yaml +++ b/test/server/test_data/server/node_bootstrap.yaml @@ -5,7 +5,6 @@ node: zone: bootstrap_zone sub_zone: bootstrap_sub_zone admin: - access_log_path: "{{ null_device_path }}" address: socket_address: address: "{{ ntop_ip_loopback_address }}" diff --git a/test/server/test_data/server/node_bootstrap_agent_deprecated_override.yaml b/test/server/test_data/server/node_bootstrap_agent_deprecated_override.yaml index 1b466cd4a887..bcbf7c334e52 100644 --- a/test/server/test_data/server/node_bootstrap_agent_deprecated_override.yaml +++ b/test/server/test_data/server/node_bootstrap_agent_deprecated_override.yaml @@ -4,7 +4,6 @@ node: user_agent_name: test-ci-user-agent user_agent_version: test admin: - access_log_path: "{{ null_device_path }}" address: socket_address: address: "{{ ntop_ip_loopback_address }}" diff --git a/test/server/test_data/server/node_bootstrap_agent_override.yaml b/test/server/test_data/server/node_bootstrap_agent_override.yaml index bfd5dae1cf00..b7e9c189826f 100644 --- a/test/server/test_data/server/node_bootstrap_agent_override.yaml +++ b/test/server/test_data/server/node_bootstrap_agent_override.yaml @@ -8,7 +8,6 @@ node: minor_number: 8 patch: 7 admin: - access_log_path: "{{ null_device_path }}" address: socket_address: address: "{{ ntop_ip_loopback_address }}" diff --git a/test/server/test_data/server/valid_v2_but_invalid_v3_bootstrap.pb_text b/test/server/test_data/server/valid_v2_but_invalid_v3_bootstrap.pb_text deleted file mode 100644 index 93ce0b49473b..000000000000 --- a/test/server/test_data/server/valid_v2_but_invalid_v3_bootstrap.pb_text +++ /dev/null @@ -1,4 +0,0 @@ -node { - id: "bootstrap_id" - build_version: "foo" -} diff --git a/test/server/test_data/server/valid_v2_but_invalid_v3_bootstrap.yaml b/test/server/test_data/server/valid_v2_but_invalid_v3_bootstrap.yaml deleted file mode 100644 index f8ff1b6a9375..000000000000 --- a/test/server/test_data/server/valid_v2_but_invalid_v3_bootstrap.yaml +++ /dev/null @@ -1,3 +0,0 @@ -node: - id: "bootstrap_id" - build_version: "foo" diff --git a/test/server/utility.h b/test/server/utility.h index fc5139fff0a1..bb3b2590ffcb 100644 --- a/test/server/utility.h +++ b/test/server/utility.h @@ -13,10 +13,9 @@ namespace Envoy { namespace Server { namespace { -inline envoy::config::listener::v3::Listener parseListenerFromV3Yaml(const std::string& yaml, - bool avoid_boosting = true) { +inline envoy::config::listener::v3::Listener parseListenerFromV3Yaml(const std::string& yaml) { envoy::config::listener::v3::Listener listener; - TestUtility::loadFromYamlAndValidate(yaml, listener, true, avoid_boosting); + TestUtility::loadFromYamlAndValidate(yaml, listener); return listener; } diff --git a/test/test_common/BUILD b/test/test_common/BUILD index 97475f1e989d..9e4ecbdeee86 100644 --- a/test/test_common/BUILD +++ b/test/test_common/BUILD @@ -124,7 +124,6 @@ envoy_cc_test_library( "//source/common/common:utility_lib", "//source/common/config:decoded_resource_lib", "//source/common/config:opaque_resource_decoder_lib", - "//source/common/config:version_converter_lib", "//source/common/filesystem:directory_lib", "//source/common/filesystem:filesystem_lib", "//source/common/http:header_map_lib", diff --git a/test/test_common/utility.h b/test/test_common/utility.h index 2cc5f948d83a..c355b5064339 100644 --- a/test/test_common/utility.h +++ b/test/test_common/utility.h @@ -21,7 +21,6 @@ #include "source/common/common/thread.h" #include "source/common/config/decoded_resource_impl.h" #include "source/common/config/opaque_resource_decoder_impl.h" -#include "source/common/config/version_converter.h" #include "source/common/http/header_map_impl.h" #include "source/common/protobuf/message_validator_impl.h" #include "source/common/protobuf/utility.h" @@ -601,34 +600,20 @@ class TestUtility { static std::string nonZeroedGauges(const std::vector& gauges); // Strict variants of Protobuf::MessageUtil - static void loadFromJson(const std::string& json, Protobuf::Message& message, - bool preserve_original_type = false, bool avoid_boosting = false) { - MessageUtil::loadFromJson(json, message, ProtobufMessage::getStrictValidationVisitor(), - !avoid_boosting); - if (!preserve_original_type) { - Config::VersionConverter::eraseOriginalTypeInformation(message); - } + static void loadFromJson(const std::string& json, Protobuf::Message& message) { + MessageUtil::loadFromJson(json, message, ProtobufMessage::getStrictValidationVisitor()); } static void loadFromJson(const std::string& json, ProtobufWkt::Struct& message) { MessageUtil::loadFromJson(json, message); } - static void loadFromYaml(const std::string& yaml, Protobuf::Message& message, - bool preserve_original_type = false, bool avoid_boosting = false) { - MessageUtil::loadFromYaml(yaml, message, ProtobufMessage::getStrictValidationVisitor(), - !avoid_boosting); - if (!preserve_original_type) { - Config::VersionConverter::eraseOriginalTypeInformation(message); - } + static void loadFromYaml(const std::string& yaml, Protobuf::Message& message) { + MessageUtil::loadFromYaml(yaml, message, ProtobufMessage::getStrictValidationVisitor()); } - static void loadFromFile(const std::string& path, Protobuf::Message& message, Api::Api& api, - bool preserve_original_type = false) { + static void loadFromFile(const std::string& path, Protobuf::Message& message, Api::Api& api) { MessageUtil::loadFromFile(path, message, ProtobufMessage::getStrictValidationVisitor(), api); - if (!preserve_original_type) { - Config::VersionConverter::eraseOriginalTypeInformation(message); - } } template @@ -637,14 +622,9 @@ class TestUtility { } template - static void loadFromYamlAndValidate(const std::string& yaml, MessageType& message, - bool preserve_original_type = false, - bool avoid_boosting = false) { - MessageUtil::loadFromYamlAndValidate( - yaml, message, ProtobufMessage::getStrictValidationVisitor(), avoid_boosting); - if (!preserve_original_type) { - Config::VersionConverter::eraseOriginalTypeInformation(message); - } + static void loadFromYamlAndValidate(const std::string& yaml, MessageType& message) { + MessageUtil::loadFromYamlAndValidate(yaml, message, + ProtobufMessage::getStrictValidationVisitor()); } template static void validate(const MessageType& message) { @@ -776,50 +756,6 @@ class TestUtility { NOT_REACHED_GCOVR_EXCL_LINE; } } - - /** - * Returns the fully-qualified name of a service, rendered from service_full_name_template. - * - * @param service_full_name_template the service fully-qualified name template. - * @param api_version version of a service. - * @param service_namespace to override the service namespace. - * @return std::string full path of a service method. - */ - static std::string - getVersionedServiceFullName(const std::string& service_full_name_template, - envoy::config::core::v3::ApiVersion api_version, - const std::string& service_namespace = EMPTY_STRING) { - switch (api_version) { - case envoy::config::core::v3::ApiVersion::AUTO: - FALLTHRU; - case envoy::config::core::v3::ApiVersion::V2: - return fmt::format(service_full_name_template, "v2", service_namespace); - - case envoy::config::core::v3::ApiVersion::V3: - return fmt::format(service_full_name_template, "v3", service_namespace); - default: - NOT_REACHED_GCOVR_EXCL_LINE; - } - } - - /** - * Returns the full path of a service method. - * - * @param service_full_name_template the service fully-qualified name template. - * @param method_name the method name. - * @param api_version version of a service method. - * @param service_namespace to override the service namespace. - * @return std::string full path of a service method. - */ - static std::string getVersionedMethodPath(const std::string& service_full_name_template, - absl::string_view method_name, - envoy::config::core::v3::ApiVersion api_version, - const std::string& service_namespace = EMPTY_STRING) { - return absl::StrCat( - "/", - getVersionedServiceFullName(service_full_name_template, api_version, service_namespace), - "/", method_name); - } }; /** diff --git a/tools/code_format/check_format.py b/tools/code_format/check_format.py index 2b65d6b904db..858d50c7591e 100755 --- a/tools/code_format/check_format.py +++ b/tools/code_format/check_format.py @@ -68,11 +68,9 @@ # Files in these paths can use MessageLite::SerializeAsString SERIALIZE_AS_STRING_ALLOWLIST = ( - "./source/common/config/version_converter.cc", "./source/common/protobuf/utility.cc", "./source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.cc", "./test/common/protobuf/utility_test.cc", - "./test/common/config/version_converter_test.cc", "./test/common/grpc/codec_test.cc", "./test/common/grpc/codec_fuzz_test.cc", "./test/extensions/filters/common/expr/context_test.cc",