Skip to content

Commit 1f8cfe6

Browse files
committed
test: mysql inte tests
1 parent 2c0d5b2 commit 1f8cfe6

File tree

7 files changed

+377
-208
lines changed

7 files changed

+377
-208
lines changed

.github/workflows/integration_test.yaml

Lines changed: 341 additions & 189 deletions
Large diffs are not rendered by default.

driver/dialect/dialect_aurora_mysql.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
class DialectAuroraMySql : virtual public Dialect {
2727
public:
28-
int GetDefaultPort() override { return DEFAULT_POSTGRES_PORT; };
28+
int GetDefaultPort() override { return DEFAULT_MYSQL_PORT; };
2929
std::string GetTopologyQuery() override { return TOPOLOGY_QUERY; };
3030
std::string GetWriterIdQuery() override { return WRITER_ID_QUERY; };
3131
std::string GetNodeIdQuery() override { return NODE_ID_QUERY; };
@@ -46,7 +46,7 @@ class DialectAuroraMySql : virtual public Dialect {
4646
};
4747

4848
private:
49-
const int DEFAULT_POSTGRES_PORT = 3306;
49+
const int DEFAULT_MYSQL_PORT = 3306;
5050
const std::string TOPOLOGY_QUERY =
5151
"SELECT SERVER_ID, CASE WHEN SESSION_ID = 'MASTER_SESSION_ID' THEN TRUE ELSE FALSE END, \
5252
CPU, REPLICA_LAG_IN_MILLISECONDS, LAST_UPDATE_TIMESTAMP \

scripts/aws_rds_helper_unix.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function add_ip_to_db_sg {
4242
cidrBlock="$LocalIp/32"
4343

4444
# Allow inbound traffic from the local IP address to the DB security group using AWS CLI
45-
aws ec2 authorize-security-group-ingress --group-id $securityGroupId --protocol tcp --cidr $cidrBlock --port 5432 --region $Region || true
45+
aws ec2 authorize-security-group-ingress --group-id $securityGroupId --protocol tcp --cidr $cidrBlock --port 0-65535 --region $Region || true
4646

4747
# Sleep to ensure IP is added and propagated to DBs before moving onto next step
4848
sleep 60
@@ -76,7 +76,7 @@ function remove_ip_from_db_sg {
7676
cidrBlock="$LocalIp/32"
7777

7878
# Revoke Inbound traffic
79-
aws ec2 revoke-security-group-ingress --group-id $securityGroupId --protocol tcp --cidr $cidrBlock --port 5432 --region $Region || true
79+
aws ec2 revoke-security-group-ingress --group-id $securityGroupId --protocol tcp --cidr $cidrBlock --port 0-65565 --region $Region || true
8080

8181
# Check if revoked successfully
8282
if [ $? -eq 0 ]; then

scripts/aws_rds_helper_win.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ function Add-Ip-To-Db-Sg {
226226
$cidrBlock = "$localIp/32"
227227

228228
# Allow inbound traffic from the local IP address to the DB security group using AWS CLI
229-
$authorizeResult = aws ec2 authorize-security-group-ingress --group-id $securityGroupId --protocol tcp --cidr $cidrBlock --port 5432 --region $Region
229+
$authorizeResult = aws ec2 authorize-security-group-ingress --group-id $securityGroupId --protocol tcp --cidr $cidrBlock --port 0-65535 --region $Region
230230

231231
# Check if the ingress rule was successfully added
232232
if ($?) {

test/integration/CMakeLists.txt

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,20 +157,17 @@ ENDIF()
157157
# ODBC Unix DSN ---------------------------------------------------------------------------------------------
158158
SET(ODBC_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../resources/)
159159

160-
# Common Settings
160+
# DSN Settings
161161
SET(THREADING "0")
162-
SET(TEST_SERVER ${TEST_SERVER},${TEST_PORT})
163-
SET(TEST_DATABASE ${TEST_DATABASE})
164-
165-
# Test Driver
166-
SET(TEST_DSN ${TEST_DSN})
167-
SET(TEST_DRIVER_NAME "aws-odbc-wrapper")
168-
SET(TEST_DRIVER_PATH ${TEST_DRIVER_PATH})
169-
170-
# Base PG Driver
171-
SET(BASE_PG_DSN "pg-dsn")
172-
SET(BASE_PG_DRIVER_NAME "community-pg")
173-
SET(BASE_PG_DRIVER_PATH ${BASE_PG_DRIVER_PATH})
162+
163+
# To be set via flags
164+
# -D TEST_DRIVER_PATH
165+
# -D PG_DRIVER_PATH
166+
# -D PG_SERVER
167+
# -D PG_DATABASE
168+
# -D MYSQL_DRIVER_PATH
169+
# -D MYSQL_SERVER
170+
# -D MYSQL_DATABASE
174171

175172
CONFIGURE_FILE(
176173
${ODBC_PATH}/odbcinst.ini.in

test/integration/base_failover_integration_test.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@ class BaseFailoverIntegrationTest : public BaseConnectionTest {
8484
// Test Queries
8585
std::string DROP_TABLE_QUERY = "DROP TABLE IF EXISTS failover_transaction";
8686
std::string CREATE_TABLE_QUERY = "CREATE TABLE failover_transaction (id INT NOT NULL PRIMARY KEY, failover_transaction_field VARCHAR(255) NOT NULL)";
87-
std::string SERVER_ID_QUERY = "SELECT aurora_db_instance_identifier()";
8887
std::string COUNT_FAILOVER_TRANSACTION_ROWS_QUERY = "SELECT count(*) FROM failover_transaction";
88+
// Based off of dialect
89+
std::string SERVER_ID_QUERY = "";
8990

9091
static void SetUpTestSuite() {
9192
BaseConnectionTest::SetUpTestSuite();
@@ -112,6 +113,14 @@ class BaseFailoverIntegrationTest : public BaseConnectionTest {
112113
test_server.substr(cluster_id_prefix_index + cluster_prefix.size(), test_server.size());
113114
db_conn_str_suffix = "." + instance_endpoint;
114115
cluster_ro_url = ".cluster-ro-" + instance_endpoint;
116+
117+
if ("AURORA_POSTGRESQL" == test_dialect) {
118+
SERVER_ID_QUERY = "SELECT pg_catalog.aurora_db_instance_identifier();";
119+
} else if ("AURORA_MYSQL" == test_dialect) {
120+
SERVER_ID_QUERY = "SELECT @@aurora_server_id";
121+
} else {
122+
GTEST_SKIP() << "Failover requires database dialect to know which query to call.";
123+
}
115124
}
116125

117126
void TearDown() override {

test/resources/odbc.ini.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,14 @@ SERVER = @PG_SERVER@
1919
Driver = @MYSQL_DRIVER_PATH@
2020
DATABASE = @MYSQL_DATABASE@
2121
SERVER = @MYSQL_SERVER@
22+
23+
[inte-wrapper-dsn]
24+
Driver = @TEST_DRIVER_PATH@
25+
DATABASE = @TEST_DATABASE@
26+
SERVER = @TEST_SERVER@
27+
BASE_DRIVER = @BASE_DRIVER_PATH@
28+
29+
[inte-base-dsn]
30+
Driver = @BASE_DRIVER_PATH@
31+
DATABASE = @TEST_DATABASE@
32+
SERVER = @TEST_SERVER@

0 commit comments

Comments
 (0)