Skip to content

Commit

Permalink
V2 TO V3 fragment changes for extension and server directory under test/
Browse files Browse the repository at this point in the history
Signed-off-by: Abhay Narayan Katare <[email protected]>
  • Loading branch information
ankatare committed Jul 18, 2020
1 parent b8996dd commit 588b1aa
Show file tree
Hide file tree
Showing 15 changed files with 259 additions and 251 deletions.
11 changes: 6 additions & 5 deletions test/extensions/clusters/redis/redis_cluster_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ class RedisClusterTest : public testing::Test,
return addresses;
}

void setupFromV3Yaml(const std::string& yaml) {
void setupFromV3Yaml(const std::string& yaml, bool avoid_boosting = true) {
expectRedisSessionCreated();
NiceMock<Upstream::MockClusterManager> cm;
envoy::config::cluster::v3::Cluster cluster_config = Upstream::parseClusterFromV3Yaml(yaml);
envoy::config::cluster::v3::Cluster cluster_config =
Upstream::parseClusterFromV3Yaml(yaml, avoid_boosting);
Envoy::Stats::ScopePtr scope = stats_store_.createScope(fmt::format(
"cluster.{}.", cluster_config.alt_stat_name().empty() ? cluster_config.name()
: cluster_config.alt_stat_name()));
Expand Down Expand Up @@ -121,7 +122,7 @@ class RedisClusterTest : public testing::Test,
});
}

void setupFactoryFromV2Yaml(const std::string& yaml) {
void setupFactoryFromV3Yaml(const std::string& yaml) {
NiceMock<Upstream::MockClusterManager> cm;
envoy::config::cluster::v3::Cluster cluster_config = Upstream::parseClusterFromV3Yaml(yaml);
Envoy::Stats::ScopePtr scope = stats_store_.createScope(fmt::format(
Expand Down Expand Up @@ -793,12 +794,12 @@ TEST_F(RedisClusterTest, FactoryInitNotRedisClusterTypeFailure) {
cluster_refresh_timeout: 0.25s
)EOF";

EXPECT_THROW_WITH_MESSAGE(setupFactoryFromV2Yaml(basic_yaml_hosts), EnvoyException,
EXPECT_THROW_WITH_MESSAGE(setupFactoryFromV3Yaml(basic_yaml_hosts), EnvoyException,
"Redis cluster can only created with redis cluster type.");
}

TEST_F(RedisClusterTest, FactoryInitRedisClusterTypeSuccess) {
setupFactoryFromV2Yaml(BasicConfig);
setupFactoryFromV3Yaml(BasicConfig);
}

TEST_F(RedisClusterTest, RedisErrorResponse) {
Expand Down
8 changes: 4 additions & 4 deletions test/extensions/filters/http/router/config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ TEST(RouterFilterConfigTest, SimpleRouterFilterConfig) {
)EOF";

envoy::extensions::filters::http::router::v3::Router proto_config;
TestUtility::loadFromYaml(yaml_string, proto_config);
TestUtility::loadFromYaml(yaml_string, proto_config, false, true);
NiceMock<Server::Configuration::MockFactoryContext> context;
RouterFilterConfig factory;
Http::FilterFactoryCb cb = factory.createFilterFactoryFromProto(proto_config, "stats.", context);
Expand All @@ -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), EnvoyException,
"route: Cannot find field");
EXPECT_THROW_WITH_REGEX(TestUtility::loadFromYaml(yaml_string, proto_config, false, true),
EnvoyException, "route: Cannot find field");
}

TEST(RouterFilterConfigTest, RouterFilterWithUnsupportedStrictHeaderCheck) {
Expand All @@ -54,7 +54,7 @@ TEST(RouterFilterConfigTest, RouterFilterWithUnsupportedStrictHeaderCheck) {
)EOF";

envoy::extensions::filters::http::router::v3::Router router_config;
TestUtility::loadFromYaml(yaml, router_config);
TestUtility::loadFromYaml(yaml, router_config, false, true);

NiceMock<Server::Configuration::MockFactoryContext> context;
RouterFilterConfig factory;
Expand Down
12 changes: 6 additions & 6 deletions test/extensions/filters/network/dubbo_proxy/config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ using DubboProxyProto = envoy::extensions::filters::network::dubbo_proxy::v3::Du

namespace {

DubboProxyProto parseDubboProxyFromV2Yaml(const std::string& yaml) {
DubboProxyProto parseDubboProxyFromV3Yaml(const std::string& yaml, bool avoid_boosting = true) {
DubboProxyProto dubbo_proxy;
TestUtility::loadFromYaml(yaml, dubbo_proxy);
TestUtility::loadFromYaml(yaml, dubbo_proxy, false, avoid_boosting);
return dubbo_proxy;
}

Expand Down Expand Up @@ -92,7 +92,7 @@ TEST_F(DubboFilterConfigTest, DubboProxyWithExplicitRouterConfig) {
- name: envoy.filters.dubbo.router
)EOF";

DubboProxyProto config = parseDubboProxyFromV2Yaml(yaml);
DubboProxyProto config = parseDubboProxyFromV3Yaml(yaml);
testConfig(config);
}

Expand All @@ -107,7 +107,7 @@ TEST_F(DubboFilterConfigTest, DubboProxyWithUnknownFilter) {
- name: envoy.filters.dubbo.router
)EOF";

DubboProxyProto config = parseDubboProxyFromV2Yaml(yaml);
DubboProxyProto config = parseDubboProxyFromV3Yaml(yaml);

EXPECT_THROW_WITH_REGEX(factory_.createFilterFactoryFromProto(config, context_), EnvoyException,
"no_such_filter");
Expand All @@ -131,7 +131,7 @@ TEST_F(DubboFilterConfigTest, DubboProxyWithMultipleFilters) {
DubboFilters::MockFilterConfigFactory factory;
Registry::InjectFactory<DubboFilters::NamedDubboFilterConfigFactory> registry(factory);

DubboProxyProto config = parseDubboProxyFromV2Yaml(yaml);
DubboProxyProto config = parseDubboProxyFromV3Yaml(yaml);
testConfig(config);

EXPECT_EQ(1, factory.config_struct_.fields_size());
Expand All @@ -156,7 +156,7 @@ TEST_F(DubboFilterConfigTest, CreateFilterChain) {
DubboFilters::MockFilterConfigFactory factory;
Registry::InjectFactory<DubboFilters::NamedDubboFilterConfigFactory> registry(factory);

DubboProxyProto dubbo_config = parseDubboProxyFromV2Yaml(yaml);
DubboProxyProto dubbo_config = parseDubboProxyFromV3Yaml(yaml);

NiceMock<Server::Configuration::MockFactoryContext> context;
DubboFilters::MockFilterChainFactoryCallbacks callbacks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class RateLimitFilterTest : public testing::Test {
.WillByDefault(Return(true));

envoy::extensions::filters::network::ratelimit::v3::RateLimit proto_config{};
TestUtility::loadFromYaml(yaml, proto_config);
TestUtility::loadFromYaml(yaml, proto_config, false, true);
config_ = std::make_shared<Config>(proto_config, stats_store_, runtime_);
client_ = new Filters::Common::RateLimit::MockClient();
filter_ = std::make_unique<Filter>(config_, Filters::Common::RateLimit::ClientPtr{client_});
Expand Down
9 changes: 5 additions & 4 deletions test/extensions/filters/network/rocketmq_proxy/config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ namespace RocketmqProxy {

using RocketmqProxyProto = envoy::extensions::filters::network::rocketmq_proxy::v3::RocketmqProxy;

RocketmqProxyProto parseRocketmqProxyFromV2Yaml(const std::string& yaml) {
RocketmqProxyProto parseRocketmqProxyFromV3Yaml(const std::string& yaml,
bool avoid_boosting = true) {
RocketmqProxyProto rocketmq_proxy;
TestUtility::loadFromYaml(yaml, rocketmq_proxy);
TestUtility::loadFromYaml(yaml, rocketmq_proxy, false, avoid_boosting);
return rocketmq_proxy;
}

Expand Down Expand Up @@ -86,7 +87,7 @@ TEST_F(RocketmqFilterConfigTest, RocketmqProxyWithFullConfig) {
transient_object_life_span:
seconds: 30
)EOF";
RocketmqProxyProto config = parseRocketmqProxyFromV2Yaml(yaml);
RocketmqProxyProto config = parseRocketmqProxyFromV3Yaml(yaml);
testConfig(config);
}

Expand Down Expand Up @@ -168,4 +169,4 @@ TEST_F(RocketmqFilterConfigTest, ProxyAddressWithNonIpType) {
} // namespace RocketmqProxy
} // namespace NetworkFilters
} // namespace Extensions
} // namespace Envoy
} // namespace Envoy
2 changes: 1 addition & 1 deletion test/extensions/filters/network/tcp_proxy/config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ TEST_P(RouteIpListConfigTest, DEPRECATED_FEATURE_TEST(TcpProxy)) {
)EOF";

envoy::extensions::filters::network::tcp_proxy::v3::TcpProxy proto_config;
TestUtility::loadFromJson(json_string, proto_config, true);
TestUtility::loadFromJson(json_string, proto_config, true, false);

NiceMock<Server::Configuration::MockFactoryContext> context;
ConfigFactory factory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ namespace RateLimitFilter {
namespace {

envoy::extensions::filters::network::thrift_proxy::filters::ratelimit::v3::RateLimit
parseRateLimitFromV2Yaml(const std::string& yaml) {
parseRateLimitFromV3Yaml(const std::string& yaml, bool avoid_boosting = true) {
envoy::extensions::filters::network::thrift_proxy::filters::ratelimit::v3::RateLimit rate_limit;
TestUtility::loadFromYaml(yaml, rate_limit);
TestUtility::loadFromYaml(yaml, rate_limit, false, avoid_boosting);
return rate_limit;
}

Expand All @@ -46,7 +46,7 @@ timeout: "1.337s"
cluster_name: ratelimit_cluster
)EOF";

auto proto_config = parseRateLimitFromV2Yaml(yaml_string);
auto proto_config = parseRateLimitFromV3Yaml(yaml_string);

NiceMock<Server::Configuration::MockFactoryContext> context;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
TestUtility::loadFromYaml(yaml, proto_config, false, true);

config_ = std::make_shared<Config>(proto_config, local_info_, stats_store_, runtime_, cm_);

Expand Down
44 changes: 22 additions & 22 deletions test/extensions/filters/network/thrift_proxy/route_matcher_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ namespace Router {
namespace {

envoy::extensions::filters::network::thrift_proxy::v3::RouteConfiguration
parseRouteConfigurationFromV2Yaml(const std::string& yaml) {
parseRouteConfigurationFromV3Yaml(const std::string& yaml, bool avoid_boosting = true) {
envoy::extensions::filters::network::thrift_proxy::v3::RouteConfiguration route_config;
TestUtility::loadFromYaml(yaml, route_config);
TestUtility::loadFromYaml(yaml, route_config, false, avoid_boosting);
TestUtility::validate(route_config);
return route_config;
}
Expand All @@ -41,7 +41,7 @@ name: config
)EOF";

envoy::extensions::filters::network::thrift_proxy::v3::RouteConfiguration config =
parseRouteConfigurationFromV2Yaml(yaml);
parseRouteConfigurationFromV3Yaml(yaml);

RouteMatcher matcher(config);
MessageMetadata metadata;
Expand Down Expand Up @@ -78,7 +78,7 @@ name: config
)EOF";

envoy::extensions::filters::network::thrift_proxy::v3::RouteConfiguration config =
parseRouteConfigurationFromV2Yaml(yaml);
parseRouteConfigurationFromV3Yaml(yaml);

RouteMatcher matcher(config);
MessageMetadata metadata;
Expand Down Expand Up @@ -121,7 +121,7 @@ name: config
)EOF";

envoy::extensions::filters::network::thrift_proxy::v3::RouteConfiguration config =
parseRouteConfigurationFromV2Yaml(yaml);
parseRouteConfigurationFromV3Yaml(yaml);

RouteMatcher matcher(config);

Expand Down Expand Up @@ -158,7 +158,7 @@ name: config
)EOF";

envoy::extensions::filters::network::thrift_proxy::v3::RouteConfiguration config =
parseRouteConfigurationFromV2Yaml(yaml);
parseRouteConfigurationFromV3Yaml(yaml);

EXPECT_THROW(new RouteMatcher(config), EnvoyException);
}
Expand All @@ -178,7 +178,7 @@ name: config
)EOF";

envoy::extensions::filters::network::thrift_proxy::v3::RouteConfiguration config =
parseRouteConfigurationFromV2Yaml(yaml);
parseRouteConfigurationFromV3Yaml(yaml);

RouteMatcher matcher(config);
MessageMetadata metadata;
Expand Down Expand Up @@ -215,7 +215,7 @@ name: config
)EOF";

envoy::extensions::filters::network::thrift_proxy::v3::RouteConfiguration config =
parseRouteConfigurationFromV2Yaml(yaml);
parseRouteConfigurationFromV3Yaml(yaml);

RouteMatcher matcher(config);
MessageMetadata metadata;
Expand Down Expand Up @@ -258,7 +258,7 @@ name: config
)EOF";

envoy::extensions::filters::network::thrift_proxy::v3::RouteConfiguration config =
parseRouteConfigurationFromV2Yaml(yaml);
parseRouteConfigurationFromV3Yaml(yaml);

RouteMatcher matcher(config);

Expand Down Expand Up @@ -295,7 +295,7 @@ name: config
)EOF";

envoy::extensions::filters::network::thrift_proxy::v3::RouteConfiguration config =
parseRouteConfigurationFromV2Yaml(yaml);
parseRouteConfigurationFromV3Yaml(yaml);

EXPECT_THROW(new RouteMatcher(config), EnvoyException);
}
Expand All @@ -314,7 +314,7 @@ name: config
)EOF";

envoy::extensions::filters::network::thrift_proxy::v3::RouteConfiguration config =
parseRouteConfigurationFromV2Yaml(yaml);
parseRouteConfigurationFromV3Yaml(yaml);

RouteMatcher matcher(config);
MessageMetadata metadata;
Expand Down Expand Up @@ -347,7 +347,7 @@ name: config
)EOF";

envoy::extensions::filters::network::thrift_proxy::v3::RouteConfiguration config =
parseRouteConfigurationFromV2Yaml(yaml);
parseRouteConfigurationFromV3Yaml(yaml);

RouteMatcher matcher(config);
MessageMetadata metadata;
Expand Down Expand Up @@ -385,7 +385,7 @@ name: config
)EOF";

envoy::extensions::filters::network::thrift_proxy::v3::RouteConfiguration config =
parseRouteConfigurationFromV2Yaml(yaml);
parseRouteConfigurationFromV3Yaml(yaml);

RouteMatcher matcher(config);
MessageMetadata metadata;
Expand Down Expand Up @@ -421,7 +421,7 @@ name: config
)EOF";

envoy::extensions::filters::network::thrift_proxy::v3::RouteConfiguration config =
parseRouteConfigurationFromV2Yaml(yaml);
parseRouteConfigurationFromV3Yaml(yaml);

RouteMatcher matcher(config);
MessageMetadata metadata;
Expand Down Expand Up @@ -458,7 +458,7 @@ name: config
)EOF";

envoy::extensions::filters::network::thrift_proxy::v3::RouteConfiguration config =
parseRouteConfigurationFromV2Yaml(yaml);
parseRouteConfigurationFromV3Yaml(yaml);

RouteMatcher matcher(config);
MessageMetadata metadata;
Expand Down Expand Up @@ -494,7 +494,7 @@ name: config
)EOF";

envoy::extensions::filters::network::thrift_proxy::v3::RouteConfiguration config =
parseRouteConfigurationFromV2Yaml(yaml);
parseRouteConfigurationFromV3Yaml(yaml);

RouteMatcher matcher(config);
MessageMetadata metadata;
Expand Down Expand Up @@ -532,7 +532,7 @@ name: config
)EOF";

envoy::extensions::filters::network::thrift_proxy::v3::RouteConfiguration config =
parseRouteConfigurationFromV2Yaml(yaml);
parseRouteConfigurationFromV3Yaml(yaml);

RouteMatcher matcher(config);
MessageMetadata metadata;
Expand Down Expand Up @@ -588,7 +588,7 @@ name: config
)EOF";

envoy::extensions::filters::network::thrift_proxy::v3::RouteConfiguration config =
parseRouteConfigurationFromV2Yaml(yaml);
parseRouteConfigurationFromV3Yaml(yaml);
RouteMatcher matcher(config);
MessageMetadata metadata;

Expand Down Expand Up @@ -632,7 +632,7 @@ name: config
)EOF";

const envoy::extensions::filters::network::thrift_proxy::v3::RouteConfiguration config =
parseRouteConfigurationFromV2Yaml(yaml);
parseRouteConfigurationFromV3Yaml(yaml);
EXPECT_THROW(RouteMatcher m(config), EnvoyException);
}

Expand All @@ -656,7 +656,7 @@ name: config
)EOF";

const envoy::extensions::filters::network::thrift_proxy::v3::RouteConfiguration config =
parseRouteConfigurationFromV2Yaml(yaml);
parseRouteConfigurationFromV3Yaml(yaml);
RouteMatcher matcher(config);
MessageMetadata metadata;

Expand Down Expand Up @@ -728,7 +728,7 @@ name: config
)EOF";

const envoy::extensions::filters::network::thrift_proxy::v3::RouteConfiguration config =
parseRouteConfigurationFromV2Yaml(yaml);
parseRouteConfigurationFromV3Yaml(yaml);
RouteMatcher matcher(config);
MessageMetadata metadata;
metadata.setMethodName("method1");
Expand Down Expand Up @@ -815,7 +815,7 @@ name: config
)EOF";

const envoy::extensions::filters::network::thrift_proxy::v3::RouteConfiguration config =
parseRouteConfigurationFromV2Yaml(yaml);
parseRouteConfigurationFromV3Yaml(yaml);
RouteMatcher matcher(config);
MessageMetadata metadata;
metadata.setMethodName("method1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ namespace {

class ThriftRateLimitConfigurationTest : public testing::Test {
public:
void initialize(const std::string& yaml) {
void initialize(const std::string& yaml, bool avoid_boosting = true) {
envoy::extensions::filters::network::thrift_proxy::v3::ThriftProxy config;
TestUtility::loadFromYaml(yaml, config);
TestUtility::loadFromYaml(yaml, config, false, avoid_boosting);
config_ = std::make_unique<ThriftProxy::ConfigImpl>(config, factory_context_);
}

Expand Down
Loading

0 comments on commit 588b1aa

Please sign in to comment.