Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2 to v3 changes for function constructConfigFromV2Yaml #12072

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions test/common/tcp_proxy/tcp_proxy_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ Config constructConfigFromYaml(const std::string& yaml,
return Config(tcp_proxy, context);
}

Config constructConfigFromV2Yaml(const std::string& yaml,
Server::Configuration::FactoryContext& context) {
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);
TestUtility::loadFromYamlAndValidate(yaml, tcp_proxy, false, avoid_boosting);
return Config(tcp_proxy, context);
}

Expand All @@ -76,7 +77,7 @@ cluster: foo
)EOF";

NiceMock<Server::Configuration::MockFactoryContext> factory_context;
Config config_obj(constructConfigFromV2Yaml(yaml, factory_context));
Config config_obj(constructConfigFromV3Yaml(yaml, factory_context));
EXPECT_EQ(std::chrono::hours(1), config_obj.sharedConfig()->idleTimeout().value());
}

Expand All @@ -88,7 +89,7 @@ idle_timeout: 0s
)EOF";

NiceMock<Server::Configuration::MockFactoryContext> factory_context;
Config config_obj(constructConfigFromV2Yaml(yaml, factory_context));
Config config_obj(constructConfigFromV3Yaml(yaml, factory_context));
EXPECT_FALSE(config_obj.sharedConfig()->idleTimeout().has_value());
}

Expand All @@ -100,7 +101,7 @@ idle_timeout: 1s
)EOF";

NiceMock<Server::Configuration::MockFactoryContext> factory_context;
Config config_obj(constructConfigFromV2Yaml(yaml, factory_context));
Config config_obj(constructConfigFromV3Yaml(yaml, factory_context));
EXPECT_EQ(std::chrono::seconds(1), config_obj.sharedConfig()->idleTimeout().value());
}

Expand Down Expand Up @@ -403,7 +404,7 @@ TEST(ConfigTest, WeightedClusterWithZeroWeightConfig) {
)EOF";

NiceMock<Server::Configuration::MockFactoryContext> factory_context;
EXPECT_THROW(constructConfigFromV2Yaml(yaml, factory_context), EnvoyException);
EXPECT_THROW(constructConfigFromV3Yaml(yaml, factory_context), EnvoyException);
}

// Tests that it is possible to define a list of weighted clusters.
Expand All @@ -419,7 +420,7 @@ TEST(ConfigTest, WeightedClustersConfig) {
)EOF";

NiceMock<Server::Configuration::MockFactoryContext> factory_context;
Config config_obj(constructConfigFromV2Yaml(yaml, factory_context));
Config config_obj(constructConfigFromV3Yaml(yaml, factory_context));

NiceMock<Network::MockConnection> connection;
EXPECT_CALL(factory_context.random_, random()).WillOnce(Return(0));
Expand Down Expand Up @@ -453,7 +454,7 @@ TEST(ConfigTest, WeightedClustersWithMetadataMatchConfig) {
)EOF";

NiceMock<Server::Configuration::MockFactoryContext> factory_context;
Config config_obj(constructConfigFromV2Yaml(yaml, factory_context));
Config config_obj(constructConfigFromV3Yaml(yaml, factory_context));

{
ProtobufWkt::Value v1, v2;
Expand Down Expand Up @@ -540,7 +541,7 @@ TEST(ConfigTest, WeightedClustersWithMetadataMatchAndTopLevelMetadataMatchConfig
)EOF";

NiceMock<Server::Configuration::MockFactoryContext> factory_context;
Config config_obj(constructConfigFromV2Yaml(yaml, factory_context));
Config config_obj(constructConfigFromV3Yaml(yaml, factory_context));

ProtobufWkt::Value v00, v01, v04;
v00.set_string_value("v00");
Expand Down Expand Up @@ -631,7 +632,7 @@ TEST(ConfigTest, WeightedClustersWithTopLevelMetadataMatchConfig) {
)EOF";

NiceMock<Server::Configuration::MockFactoryContext> factory_context;
Config config_obj(constructConfigFromV2Yaml(yaml, factory_context));
Config config_obj(constructConfigFromV3Yaml(yaml, factory_context));

ProtobufWkt::Value v1, v2;
v1.set_string_value("v1");
Expand Down Expand Up @@ -670,7 +671,7 @@ TEST(ConfigTest, TopLevelMetadataMatchConfig) {
)EOF";

NiceMock<Server::Configuration::MockFactoryContext> factory_context;
Config config_obj(constructConfigFromV2Yaml(yaml, factory_context));
Config config_obj(constructConfigFromV3Yaml(yaml, factory_context));

ProtobufWkt::Value v1, v2;
v1.set_string_value("v1");
Expand Down Expand Up @@ -703,7 +704,7 @@ TEST(ConfigTest, ClusterWithTopLevelMetadataMatchConfig) {
)EOF";

NiceMock<Server::Configuration::MockFactoryContext> factory_context;
Config config_obj(constructConfigFromV2Yaml(yaml, factory_context));
Config config_obj(constructConfigFromV3Yaml(yaml, factory_context));

ProtobufWkt::Value v1, v2;
v1.set_string_value("v1");
Expand Down Expand Up @@ -742,7 +743,7 @@ TEST(ConfigTest, PerConnectionClusterWithTopLevelMetadataMatchConfig) {
)EOF";

NiceMock<Server::Configuration::MockFactoryContext> factory_context;
Config config_obj(constructConfigFromV2Yaml(yaml, factory_context));
Config config_obj(constructConfigFromV3Yaml(yaml, factory_context));

ProtobufWkt::Value v1, v2;
v1.set_string_value("v1");
Expand Down Expand Up @@ -781,7 +782,7 @@ TEST(ConfigTest, HashWithSourceIpConfig) {
)EOF";

NiceMock<Server::Configuration::MockFactoryContext> factory_context;
Config config_obj(constructConfigFromV2Yaml(yaml, factory_context));
Config config_obj(constructConfigFromV3Yaml(yaml, factory_context));
EXPECT_NE(nullptr, config_obj.hashPolicy());
}

Expand All @@ -792,7 +793,7 @@ TEST(ConfigTest, HashWithSourceIpDefaultConfig) {
)EOF";

NiceMock<Server::Configuration::MockFactoryContext> factory_context;
Config config_obj(constructConfigFromV2Yaml(yaml, factory_context));
Config config_obj(constructConfigFromV3Yaml(yaml, factory_context));
EXPECT_EQ(nullptr, config_obj.hashPolicy());
}

Expand Down