Skip to content

Commit

Permalink
Remove updating port
Browse files Browse the repository at this point in the history
  • Loading branch information
justing-bq committed Apr 25, 2023
1 parent 7ea3d3d commit 58c8e25
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
7 changes: 0 additions & 7 deletions driver/failover_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ const std::regex IPV6_COMPRESSED_PATTERN(
R"#(^(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})?)::(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})?)$)#");

const char* MYSQL_READONLY_QUERY = "SELECT @@innodb_read_only AS is_reader";

const unsigned int MYSQL_PROXY_PORT = 8666;
} // namespace

FAILOVER_HANDLER::FAILOVER_HANDLER(DBC* dbc, DataSource* ds)
Expand Down Expand Up @@ -371,11 +369,6 @@ bool FAILOVER_HANDLER::should_connect_to_new_writer(const char* host) {
ds_set_wstrnattr(&ds->server, (SQLWCHAR*)writer_host_wstr.c_str(), writer_host_wstr.size());
ds_set_strnattr(&ds->server8, (SQLCHAR*)writer_host.c_str(), writer_host.size());

// If we are updating to a proxied server, we need to also update the port to the proxy port.
if (writer_host.compare(writer_host.length() - 8, 8, ".proxied") == 0) {
ds->port = MYSQL_PROXY_PORT;
}

return true;
}

Expand Down
6 changes: 6 additions & 0 deletions integration/base_failover_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,12 @@ class BaseFailoverIntegrationTest : public testing::Test {
}

void test_connection(const SQLHDBC dbc, const std::string& test_server, const int test_port) {
sprintf(reinterpret_cast<char*>(conn_in), "%sSERVER=%s;PORT=%d;", get_default_config().c_str(), test_server.c_str(), test_port);
EXPECT_EQ(SQL_SUCCESS, SQLDriverConnect(dbc, nullptr, conn_in, SQL_NTS, conn_out, MAX_NAME_LEN, &len, SQL_DRIVER_NOPROMPT));
EXPECT_EQ(SQL_SUCCESS, SQLDisconnect(dbc));
}

void test_connection_with_host_pattern(const SQLHDBC dbc, const std::string& test_server, const int test_port) {
sprintf(reinterpret_cast<char*>(conn_in), "%sSERVER=%s;PORT=%d;", get_default_proxied_config().c_str(), test_server.c_str(), test_port);
EXPECT_EQ(SQL_SUCCESS, SQLDriverConnect(dbc, nullptr, conn_in, SQL_NTS, conn_out, MAX_NAME_LEN, &len, SQL_DRIVER_NOPROMPT));
EXPECT_EQ(SQL_SUCCESS, SQLDisconnect(dbc));
Expand Down
6 changes: 3 additions & 3 deletions integration/network_failover_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ class NetworkFailoverIntegrationTest : public BaseFailoverIntegrationTest {

TEST_F(NetworkFailoverIntegrationTest, connection_test) {
test_connection(dbc, MYSQL_INSTANCE_1_URL, MYSQL_PORT);
test_connection(dbc, MYSQL_INSTANCE_1_URL + PROXIED_DOMAIN_NAME_SUFFIX, MYSQL_PROXY_PORT);
test_connection_with_host_pattern(dbc, MYSQL_INSTANCE_1_URL + PROXIED_DOMAIN_NAME_SUFFIX, MYSQL_PROXY_PORT);
test_connection(dbc, MYSQL_CLUSTER_URL, MYSQL_PORT);
test_connection(dbc, MYSQL_CLUSTER_URL + PROXIED_DOMAIN_NAME_SUFFIX, MYSQL_PROXY_PORT);
test_connection_with_host_pattern(dbc, MYSQL_CLUSTER_URL + PROXIED_DOMAIN_NAME_SUFFIX, MYSQL_PROXY_PORT);
test_connection(dbc, MYSQL_RO_CLUSTER_URL, MYSQL_PORT);
test_connection(dbc, MYSQL_RO_CLUSTER_URL + PROXIED_DOMAIN_NAME_SUFFIX, MYSQL_PROXY_PORT);
test_connection_with_host_pattern(dbc, MYSQL_RO_CLUSTER_URL + PROXIED_DOMAIN_NAME_SUFFIX, MYSQL_PROXY_PORT);
}

TEST_F(NetworkFailoverIntegrationTest, lost_connection_to_writer) {
Expand Down

0 comments on commit 58c8e25

Please sign in to comment.