Skip to content

Commit 05e9dc4

Browse files
committed
test: fix integration tests
1 parent 2205f79 commit 05e9dc4

18 files changed

+2541
-2462
lines changed

common/lib/wrapper_property.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,6 @@ export interface AwsClientConfig {
106106
clusterInstanceHostPattern?: string;
107107
/** Set to true if you are providing a connection string with multiple comma-delimited hosts and your cluster has only one writer. The writer must be the first host in the connection string */
108108
singleWriterConnectionString?: boolean;
109-
/** Enables replacing a green host name with the original hostname after a blue/green switchover and the green name no longer resolves. */
110-
enableGreenHostReplacement?: boolean;
111109
/** The strategy that should be used to select a new reader host. */
112110
readerHostSelectorStrategy?: string;
113111
/** Maximum allowed time for the retries opening a connection. */
@@ -170,6 +168,8 @@ export interface AwsClientConfig {
170168
customEndpointMonitorExpirationMs?: number;
171169
/** The region of the cluster's custom endpoints. If not specified, the region will be parsed from the URL. */
172170
customEndpointRegion?: string;
171+
/** Enables replacing a green host name with the original hostname after a blue/green switchover and the green name no longer resolves. */
172+
enableGreenHostReplacement?: boolean;
173173
/** Connect timeout in milliseconds during Blue/Green Deployment switchover. */
174174
bgConnectTimeoutMs?: number;
175175
/** Blue/Green Deployment ID */

mysql/lib/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import { MySQLClient, MySQLPoolClient } from "./mysql_client";
4444
import { DriverConnectionProvider } from "../../common/lib/driver_connection_provider";
4545
import { AwsClientConfig } from "../../common/lib/wrapper_property";
4646

47-
export interface AwsMysQLClientConfig extends ConnectionOptions, AwsClientConfig {}
47+
export interface AwsMySQLClientConfig extends ConnectionOptions, AwsClientConfig {}
4848

4949
class BaseAwsMySQLClient extends AwsClient implements MySQLClient {
5050
private static readonly knownDialectsByCode: Map<string, DatabaseDialect> = new Map([
@@ -54,7 +54,7 @@ class BaseAwsMySQLClient extends AwsClient implements MySQLClient {
5454
[DatabaseDialectCodes.RDS_MULTI_AZ_MYSQL, new RdsMultiAZClusterMySQLDatabaseDialect()]
5555
]);
5656

57-
constructor(config: AwsMysQLClientConfig, connectionProvider?: ConnectionProvider) {
57+
constructor(config: AwsMySQLClientConfig, connectionProvider?: ConnectionProvider) {
5858
super(
5959
config,
6060
DatabaseType.MYSQL,

package.json

Lines changed: 63 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
"@babel/cli": "^7.27.2",
5757
"@babel/core": "^7.26.10",
5858
"@babel/node": "^7.27.1",
59-
6059
"@types/i18n": "^0.13.12",
6160
"@types/jest": "^29.5.13",
6261
"@types/lodash": "^4.17.20",
@@ -65,7 +64,6 @@
6564
"@types/pg": "^8.15.2",
6665
"@types/tough-cookie": "^4.0.5",
6766
"@typescript-eslint/eslint-plugin": "^8.31.0",
68-
6967
"babel-plugin-transform-rewrite-imports": "^1.5.3",
7068
"benny": "^3.7.1",
7169
"copyfiles": "^2.4.1",
@@ -128,27 +126,69 @@
128126
"pg": "^8.16.0"
129127
},
130128
"peerDependenciesMeta": {
131-
"@aws-sdk/client-rds": { "optional": true },
132-
"@aws-sdk/client-secrets-manager": { "optional": true },
133-
"@aws-sdk/client-sts": { "optional": true },
134-
"@aws-sdk/client-xray": { "optional": true },
135-
"@aws-sdk/credential-providers": { "optional": true },
136-
"@aws-sdk/rds-signer": { "optional": true },
137-
"@opentelemetry/exporter-metrics-otlp-grpc": { "optional": true },
138-
"@opentelemetry/exporter-trace-otlp-grpc": { "optional": true },
139-
"@opentelemetry/id-generator-aws-xray": { "optional": true },
140-
"@opentelemetry/instrumentation-aws-sdk": { "optional": true },
141-
"@opentelemetry/instrumentation-http": { "optional": true },
142-
"@opentelemetry/propagator-aws-xray": { "optional": true },
143-
"@opentelemetry/sdk-metrics": { "optional": true },
144-
"@opentelemetry/sdk-node": { "optional": true },
145-
"aws-xray-sdk": { "optional": true },
146-
"axios": { "optional": true },
147-
"axios-cookiejar-support": { "optional": true },
148-
"entities": { "optional": true },
149-
"mysql2": { "optional": true },
150-
"node-fetch": { "optional": true },
151-
"pg": { "optional": true }
129+
"@aws-sdk/client-rds": {
130+
"optional": true
131+
},
132+
"@aws-sdk/client-secrets-manager": {
133+
"optional": true
134+
},
135+
"@aws-sdk/client-sts": {
136+
"optional": true
137+
},
138+
"@aws-sdk/client-xray": {
139+
"optional": true
140+
},
141+
"@aws-sdk/credential-providers": {
142+
"optional": true
143+
},
144+
"@aws-sdk/rds-signer": {
145+
"optional": true
146+
},
147+
"@opentelemetry/exporter-metrics-otlp-grpc": {
148+
"optional": true
149+
},
150+
"@opentelemetry/exporter-trace-otlp-grpc": {
151+
"optional": true
152+
},
153+
"@opentelemetry/id-generator-aws-xray": {
154+
"optional": true
155+
},
156+
"@opentelemetry/instrumentation-aws-sdk": {
157+
"optional": true
158+
},
159+
"@opentelemetry/instrumentation-http": {
160+
"optional": true
161+
},
162+
"@opentelemetry/propagator-aws-xray": {
163+
"optional": true
164+
},
165+
"@opentelemetry/sdk-metrics": {
166+
"optional": true
167+
},
168+
"@opentelemetry/sdk-node": {
169+
"optional": true
170+
},
171+
"aws-xray-sdk": {
172+
"optional": true
173+
},
174+
"axios": {
175+
"optional": true
176+
},
177+
"axios-cookiejar-support": {
178+
"optional": true
179+
},
180+
"entities": {
181+
"optional": true
182+
},
183+
"mysql2": {
184+
"optional": true
185+
},
186+
"node-fetch": {
187+
"optional": true
188+
},
189+
"pg": {
190+
"optional": true
191+
}
152192
},
153193
"overrides": {
154194
"braces": "^3.0.3",

tests/integration/container/tests/aurora_failover.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const itIf =
4040
: it.skip;
4141
const itIfTwoInstance = instanceCount == 2 ? itIf : it.skip;
4242
const itIfThreeInstanceAuroraCluster =
43-
instanceCount == 3 && !features.includes(TestEnvironmentFeatures.RDS_MULTI_AZ_CLUSTER_SUPPORTED) ? it : it.skip;
43+
instanceCount == 3 && !features.includes(TestEnvironmentFeatures.RDS_MULTI_AZ_SUPPORTED) ? it : it.skip;
4444

4545
let env: TestEnvironment;
4646
let driver;

tests/integration/container/tests/basic_connectivity.test.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,21 @@ import { AuroraTestUtility } from "./utils/aurora_test_utility";
2121
import { logger } from "../../../../common/logutils";
2222
import { DatabaseEngine } from "./utils/database_engine";
2323
import { TestEnvironmentFeatures } from "./utils/test_environment_features";
24-
import { features } from "./config";
24+
import { features, instanceCount } from "./config";
2525
import { DatabaseEngineDeployment } from "./utils/database_engine_deployment";
2626
import { PluginManager } from "../../../../index";
2727

2828
const itIf =
2929
!features.includes(TestEnvironmentFeatures.PERFORMANCE) && !features.includes(TestEnvironmentFeatures.RUN_AUTOSCALING_TESTS_ONLY) ? it : it.skip;
30+
const itIfMinTwoInstance = instanceCount >= 2 ? itIf : it.skip;
3031

3132
let client: any;
3233
let auroraTestUtility: AuroraTestUtility;
3334

34-
async function executeInstanceQuery(client: any, engine: DatabaseEngine, deployment: DatabaseEngineDeployment, props: any): Promise<void> {
35+
async function executeSelect1(client: any, engine: DatabaseEngine, deployment: DatabaseEngineDeployment, props: any): Promise<void> {
3536
await client.connect();
3637

37-
const res = await DriverHelper.executeInstanceQuery(engine, deployment, client);
38+
const res = await DriverHelper.executeQuery(engine, client, "SELECT 1", 10000);
3839

3940
expect(res).not.toBeNull();
4041
}
@@ -59,8 +60,8 @@ afterEach(async () => {
5960
logger.info(`Test finished: ${expect.getState().currentTestName}`);
6061
}, 1320000);
6162

62-
describe("basic_connectivity", () => {
63-
itIf(
63+
describe("basic connectivity", () => {
64+
itIfMinTwoInstance(
6465
"wrapper with failover plugins read only endpoint",
6566
async () => {
6667
const env = await TestEnvironment.getCurrent();
@@ -82,12 +83,12 @@ describe("basic_connectivity", () => {
8283
props = DriverHelper.addDriverSpecificConfiguration(props, env.engine);
8384
client = initClientFunc(props);
8485

85-
await executeInstanceQuery(client, env.engine, env.deployment, props);
86+
await executeSelect1(client, env.engine, env.deployment, props);
8687
},
8788
1320000
8889
);
8990

90-
itIf(
91+
itIfMinTwoInstance(
9192
"wrapper with failover plugins cluster endpoint",
9293
async () => {
9394
const env = await TestEnvironment.getCurrent();
@@ -109,7 +110,7 @@ describe("basic_connectivity", () => {
109110
props = DriverHelper.addDriverSpecificConfiguration(props, env.engine);
110111

111112
client = initClientFunc(props);
112-
await executeInstanceQuery(client, env.engine, env.deployment, props);
113+
await executeSelect1(client, env.engine, env.deployment, props);
113114
},
114115
1320000
115116
);
@@ -136,7 +137,7 @@ describe("basic_connectivity", () => {
136137
props = DriverHelper.addDriverSpecificConfiguration(props, env.engine);
137138

138139
client = initClientFunc(props);
139-
await executeInstanceQuery(client, env.engine, env.deployment, props);
140+
await executeSelect1(client, env.engine, env.deployment, props);
140141
},
141142
1320000
142143
);
@@ -165,15 +166,15 @@ describe("basic_connectivity", () => {
165166
client = initClientFunc(props);
166167
await client.connect();
167168

168-
const res = await DriverHelper.executeInstanceQuery(env.engine, env.deployment, client);
169+
const res = await executeSelect1(client, env.engine, env.deployment, props);
169170

170171
expect(res).not.toBeNull();
171172
},
172173
1320000
173174
);
174175

175176
itIf(
176-
"wrapper_proxy",
177+
"wrapper proxy",
177178
async () => {
178179
const env = await TestEnvironment.getCurrent();
179180
const driver = DriverHelper.getDriverForDatabaseEngine(env.engine);

tests/integration/container/tests/custom_endpoint.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const itIf =
4545
: it.skip;
4646

4747
// Custom endpoint is not compatible with multi-az clusters.
48-
const describeIf = !features.includes(TestEnvironmentFeatures.RDS_MULTI_AZ_CLUSTER_SUPPORTED) ? describe : describe.skip;
48+
const describeIf = !features.includes(TestEnvironmentFeatures.RDS_MULTI_AZ_SUPPORTED) ? describe : describe.skip;
4949

5050
const endpointId1 = `test-endpoint-1-${randomUUID()}`;
5151
const endpointId2 = `test-endpoint-2-${randomUUID()}`;

tests/integration/container/tests/parameterized_queries.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { features } from "./config";
2222
import { AwsPoolConfig, InternalPooledConnectionProvider, PluginManager } from "../../../../index";
2323
import { AwsPgPoolClient } from "../../../../pg";
2424
import { AwsMySQLPoolClient } from "../../../../mysql";
25+
import { readFileSync } from "fs";
2526

2627
const itIf =
2728
!features.includes(TestEnvironmentFeatures.PERFORMANCE) && !features.includes(TestEnvironmentFeatures.RUN_AUTOSCALING_TESTS_ONLY) ? it : it.skip;
@@ -39,6 +40,10 @@ async function createConnection(plugins: string = "failover"): Promise<any> {
3940
database: env.databaseInfo.defaultDbName,
4041
password: env.databaseInfo.password,
4142
port: env.databaseInfo.instanceEndpointPort,
43+
ssl: {
44+
rejectUnauthorized: false,
45+
ca: readFileSync("/app/global-bundle.pem").toString()
46+
},
4247
plugins
4348
};
4449
const configuredProps = DriverHelper.addDriverSpecificConfiguration(props, env.engine);
@@ -56,6 +61,10 @@ async function createAwsPGPool(plugins: string = "failover"): Promise<AwsPgPoolC
5661
database: env.databaseInfo.defaultDbName,
5762
password: env.databaseInfo.password,
5863
port: env.databaseInfo.instanceEndpointPort,
64+
ssl: {
65+
rejectUnauthorized: false,
66+
ca: readFileSync("/app/global-bundle.pem").toString()
67+
},
5968
plugins
6069
};
6170
const poolConfig = new AwsPoolConfig({
@@ -80,6 +89,10 @@ async function createAwsPGPoolWithICP(plugins: string = "failover"): Promise<Aws
8089
database: env.databaseInfo.defaultDbName,
8190
password: env.databaseInfo.password,
8291
port: env.databaseInfo.instanceEndpointPort,
92+
ssl: {
93+
rejectUnauthorized: false,
94+
ca: readFileSync("/app/global-bundle.pem").toString()
95+
},
8396
plugins,
8497
provider: provider
8598
};

tests/integration/container/tests/pg_pool.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
import { DriverHelper } from "./utils/driver_helper";
2929
import { AuroraTestUtility } from "./utils/aurora_test_utility";
3030
import { sleep } from "../../../../common/lib/utils/utils";
31+
import { readFileSync } from "fs";
3132

3233
const itIf =
3334
!features.includes(TestEnvironmentFeatures.PERFORMANCE) && !features.includes(TestEnvironmentFeatures.RUN_AUTOSCALING_TESTS_ONLY) ? it : it.skip;
@@ -48,6 +49,10 @@ async function createPool(plugins: string = "efm2,failover2"): Promise<any> {
4849
database: env.databaseInfo.defaultDbName,
4950
password: env.databaseInfo.password,
5051
port: env.databaseInfo.instanceEndpointPort,
52+
ssl: {
53+
rejectUnauthorized: false,
54+
ca: readFileSync("/app/global-bundle.pem").toString()
55+
},
5156
plugins
5257
};
5358
const poolConfig = new AwsPoolConfig({

0 commit comments

Comments
 (0)