Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
40 changes: 18 additions & 22 deletions test/extensions/filters/network/mysql_proxy/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,24 @@ envoy_extension_cc_test(
],
)

# See https://github.com/envoyproxy/envoy/issues/6162.
#
# TODO(venilnoronha, #6162): uncomment this once this works on all platforms.
#
# envoy_extension_cc_test(
# name = "mysql_integration_test",
# srcs = [
# "mysql_integration_test.cc",
# ],
# data = [
# "mysql_test_config.yaml",
# ],
# extension_name = "envoy.filters.network.mysql_proxy",
# deps = [
# ":mysql_test_utils_lib",
# "//source/common/tcp_proxy",
# "//source/extensions/filters/network/mysql_proxy:config",
# "//source/extensions/filters/network/mysql_proxy:proxy_lib",
# "//source/extensions/filters/network/tcp_proxy:config",
# "//test/integration:integration_lib",
# ],
# )
envoy_extension_cc_test(
name = "mysql_integration_test",
srcs = [
"mysql_integration_test.cc",
],
data = [
"mysql_test_config.yaml",
],
extension_name = "envoy.filters.network.mysql_proxy",
deps = [
":mysql_test_utils_lib",
"//source/common/tcp_proxy",
"//source/extensions/filters/network/mysql_proxy:config",
"//source/extensions/filters/network/mysql_proxy:proxy_lib",
"//source/extensions/filters/network/tcp_proxy:config",
"//test/integration:integration_lib",
],
)

envoy_extension_cc_test(
name = "mysql_command_tests",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ class MySQLIntegrationTest : public testing::TestWithParam<Network::Address::IpV
public MySQLTestUtils,
public BaseIntegrationTest {
std::string mysqlConfig() {
return TestEnvironment::readFileToStringForTest(TestEnvironment::runfilesPath(
"test/extensions/filters/network/mysql_proxy/mysql_test_config.yaml"));
return fmt::format(TestEnvironment::readFileToStringForTest(TestEnvironment::runfilesPath(
"test/extensions/filters/network/mysql_proxy/mysql_test_config.yaml")),
Network::Test::getLoopbackAddressString(GetParam()),
Network::Test::getLoopbackAddressString(GetParam()),
Network::Test::getAnyAddressString(GetParam()));
}

public:
Expand Down Expand Up @@ -74,8 +77,8 @@ TEST_P(MySQLIntegrationTest, MySQLStatsNewSessionTest) {
* - correct number of attempts
* - no failures
*/
TEST_P(MySQLIntegrationTest, MysqLoginTest) {
std::string str;
TEST_P(MySQLIntegrationTest, MySQLLoginTest) {
std::string str = "";
Comment thread
venilnoronha marked this conversation as resolved.
Outdated
std::string rcvd_data;
std::string user = "user1";

Expand All @@ -86,7 +89,9 @@ TEST_P(MySQLIntegrationTest, MysqLoginTest) {
// greeting
std::string greeting = encodeServerGreeting(MYSQL_PROTOCOL_10);
ASSERT_TRUE(fake_upstream_connection->write(greeting));
tcp_client->waitForData(str);

str.append(greeting);
tcp_client->waitForData(str, true);

// Client username/password and capabilities
std::string login = encodeClientLogin(MYSQL_CLIENT_CAPAB_41VS320, user, CHALLENGE_SEQ_NUM);
Expand All @@ -97,7 +102,9 @@ TEST_P(MySQLIntegrationTest, MysqLoginTest) {
// Server response OK to username/password
std::string loginok = encodeClientLoginResp(MYSQL_RESP_OK);
ASSERT_TRUE(fake_upstream_connection->write(loginok));
tcp_client->waitForData(str);

str.append(loginok);
tcp_client->waitForData(str, true);

tcp_client->close();
ASSERT_TRUE(fake_upstream_connection->waitForDisconnect());
Expand All @@ -116,9 +123,9 @@ TEST_P(MySQLIntegrationTest, MysqLoginTest) {
TEST_P(MySQLIntegrationTest, MySQLUnitTestMultiClientsLoop) {
int idx;
std::string rcvd_data;
std::string str;

for (idx = 0; idx < CLIENT_NUM; idx++) {
std::string str = "";
Comment thread
venilnoronha marked this conversation as resolved.
Outdated
std::string user("user");
user.append(std::to_string(idx));

Expand All @@ -129,7 +136,9 @@ TEST_P(MySQLIntegrationTest, MySQLUnitTestMultiClientsLoop) {
// greeting
std::string greeting = encodeServerGreeting(MYSQL_PROTOCOL_10);
ASSERT_TRUE(fake_upstream_connection->write(greeting));
tcp_client->waitForData(str);

str.append(greeting);
tcp_client->waitForData(str, true);

// Client username/password and capabilities
std::string login = encodeClientLogin(MYSQL_CLIENT_CAPAB_41VS320, user, CHALLENGE_SEQ_NUM);
Expand All @@ -140,7 +149,9 @@ TEST_P(MySQLIntegrationTest, MySQLUnitTestMultiClientsLoop) {
// Server response OK to username/password
std::string loginok = encodeClientLoginResp(MYSQL_RESP_OK);
ASSERT_TRUE(fake_upstream_connection->write(loginok));
tcp_client->waitForData(str);

str.append(loginok);
tcp_client->waitForData(str, true);

tcp_client->close();
ASSERT_TRUE(fake_upstream_connection->waitForDisconnect());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ admin:
access_log_path: /dev/null

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Why are we using this config vs. just using the default config and config modifiers? Would that have made it easier to prevent this issue?

@venilnoronha venilnoronha Mar 13, 2019

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could have done it either way. However, @gvalentinivmw might know more. We could have still run into this issue as the config modifiers don't constrain IP addresses AFAIK.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK that's fine. It's not a big deal either way, though I think in general it's better to use the stock config in case that changes in the future.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the record, I think the problem here is related to a bug I reported a while back: #5556

it'd be nice to make tests that do not care about ports not have to specify anything about them, or care about ipv6 vs ipv4.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, that'd definitely be helpful.

address:
socket_address:
address: 127.0.0.1
address: "{}"
port_value: 0
static_resources:
clusters:
Expand All @@ -15,13 +15,13 @@ static_resources:
- endpoint:
address:
socket_address:
address: 127.0.0.1
address: "{}"
port_value: 0
listeners:
name: listener_0
address:
socket_address:
address: 0.0.0.0
address: "{}"
port_value: 0
filter_chains:
- filters:
Expand Down