Skip to content

Commit ca87a8d

Browse files
authored
chore: add integration tests for multi-az support (#928)
1 parent 6178402 commit ca87a8d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+895
-237
lines changed

.github/workflows/run-integration-tests-latest.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ on:
66
branches:
77
- main
88

9-
concurrency:
10-
group: ${{ github.workflow }}-${{ github.ref }}
11-
cancel-in-progress: true
12-
139
jobs:
1410
all-integration-tests-latest:
15-
name: 'Run Aurora integration tests with latest'
11+
name: Run Aurora integration tests with latest
1612
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
dbEngine: [ "mysql-aurora", "mysql-multi-az", "pg-aurora", "pg-multi-az" ]
1717
steps:
1818
- name: 'Clone repository'
1919
uses: actions/checkout@v4
@@ -45,7 +45,7 @@ jobs:
4545
echo "TEMP_AWS_SESSION_TOKEN=${creds[2]}" >> $GITHUB_ENV
4646
- name: Run integration tests
4747
run: |
48-
./gradlew --no-parallel --no-daemon test-all-aurora
48+
./gradlew --no-parallel --no-daemon test-all-${{ matrix.dbEngine }}
4949
env:
5050
AURORA_CLUSTER_DOMAIN: ${{ secrets.DB_CONN_SUFFIX }}
5151
AURORA_DB_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
@@ -54,17 +54,17 @@ jobs:
5454
AWS_SESSION_TOKEN: ${{ env.TEMP_AWS_SESSION_TOKEN }}
5555
AURORA_MYSQL_DB_ENGINE_VERSION: "latest"
5656
AURORA_PG_ENGINE_VERSION: "latest"
57-
- name: 'Archive junit results'
57+
- name: Archive junit results for ${{ matrix.dbEngine }}
5858
if: always()
5959
uses: actions/upload-artifact@v4
6060
with:
61-
name: junit-report-latest
61+
name: junit-report-latest-${{ matrix.dbEngine }}
6262
path: ./wrapper/build/test-results
6363
retention-days: 5
64-
- name: 'Archive html summary report'
64+
- name: Archive html summary report for ${{ matrix.dbEngine }}
6565
if: always()
6666
uses: actions/upload-artifact@v4
6767
with:
68-
name: html-summary-report-latest
68+
name: html-summary-report-latest-${{ matrix.dbEngine }}
6969
path: ./wrapper/build/report
7070
retention-days: 5

.github/workflows/run-integration-tests-lts.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ on:
66
branches:
77
- main
88

9-
concurrency:
10-
group: ${{ github.workflow }}-${{ github.ref }}
11-
cancel-in-progress: true
12-
139
jobs:
1410
all-integration-tests-lts:
1511
name: 'Run Aurora integration tests with LTS'
1612
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
dbEngine: [ "mysql-aurora", "mysql-multi-az", "pg-aurora", "pg-multi-az" ]
1717
steps:
1818
- name: 'Clone repository'
1919
uses: actions/checkout@v4
@@ -45,7 +45,7 @@ jobs:
4545
echo "TEMP_AWS_SESSION_TOKEN=${creds[2]}" >> $GITHUB_ENV
4646
- name: Run integration tests
4747
run: |
48-
./gradlew --no-parallel --no-daemon test-all-aurora
48+
./gradlew --no-parallel --no-daemon test-all-${{ matrix.dbEngine }}
4949
env:
5050
AURORA_CLUSTER_DOMAIN: ${{ secrets.DB_CONN_SUFFIX }}
5151
AURORA_DB_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
@@ -54,17 +54,17 @@ jobs:
5454
AWS_SESSION_TOKEN: ${{ env.TEMP_AWS_SESSION_TOKEN }}
5555
AURORA_MYSQL_DB_ENGINE_VERSION: "lts"
5656
AURORA_PG_ENGINE_VERSION: "lts"
57-
- name: 'Archive junit results'
57+
- name: Archive junit results for ${{ matrix.dbEngine }}
5858
if: always()
5959
uses: actions/upload-artifact@v4
6060
with:
61-
name: junit-report-lts
61+
name: junit-report-lts-${{ matrix.dbEngine }}
6262
path: ./wrapper/build/test-results
6363
retention-days: 5
64-
- name: 'Archive html summary report'
64+
- name: Archive html summary report for ${{ matrix.dbEngine }}
6565
if: always()
6666
uses: actions/upload-artifact@v4
6767
with:
68-
name: html-summary-report-lts
68+
name: html-summary-report-lts-${{ matrix.dbEngine }}
6969
path: ./wrapper/build/report
7070
retention-days: 5

docs/development-guide/IntegrationTests.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ If the environment variable `REUSE_AURORA_CLUSTER` is set to true, the integrati
3737
| `DB_USERNAME` | Yes | The username to access the database. | `admin` |
3838
| `DB_PASSWORD` | Yes | The database cluster password. | `password` |
3939
| `DB_DATABASE_NAME` | No | Name of the database that will be used by the tests. The default database name is test. | `test_db_name` |
40-
| `AURORA_CLUSTER_NAME` | Yes | The database identifier for your Aurora cluster. Must be a unique value to avoid conflicting with existing clusters. | `db-identifier` |
41-
| `AURORA_CLUSTER_DOMAIN` | No | The existing database connection suffix. Use this variable to run against an existing database. | `XYZ.us-east-2.rds.amazonaws.com` |
40+
| `RDS_CLUSTER_NAME` | Yes | The database identifier for your Aurora or RDS cluster. Must be a unique value to avoid conflicting with existing clusters. | `db-identifier` |
41+
| `RDS_CLUSTER_DOMAIN` | No | The existing database connection suffix. Use this variable to run against an existing database. | `XYZ.us-east-2.rds.amazonaws.com` |
4242
| `IAM_USER` | No | User within the database that is identified with AWSAuthenticationPlugin. This is used for AWS IAM Authentication and is optional | `example_user_name` |
4343
| `AWS_ACCESS_KEY_ID` | Yes | An AWS access key associated with an IAM user or role with RDS permissions. | `ASIAIOSFODNN7EXAMPLE` |
4444
| `AWS_SECRET_ACCESS_KEY` | Yes | The secret key associated with the provided AWS_ACCESS_KEY_ID. | `wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY` |
4545
| `AWS_SESSION_TOKEN` | No | AWS Session Token for CLI, SDK, & API access. This value is for MFA credentials only. See: [temporary AWS credentials](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_use-resources.html). | `AQoDYXdzEJr...<remainder of session token>` | |
46-
| `REUSE_AURORA_CLUSTER` | Yes | Set to true if you would like to use an existing cluster for your tests. | `false` |
47-
| `AURORA_DB_REGION` | Yes | The database region. | `us-east-2` |
46+
| `REUSE_RDS_CLUSTER` | Yes | Set to true if you would like to use an existing cluster for your tests. | `false` |
47+
| `RDS_DB_REGION` | Yes | The database region. | `us-east-2` |
4848

4949
### Running the Integration Tests
5050

examples/ReadWriteSplittingSample/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ dependencies {
2222
}
2323

2424
tasks.withType<JavaExec> {
25-
systemProperty("java.util.logging.config.file", "${project.buildDir}/resources/main/logging.properties")
25+
systemProperty("java.util.logging.config.file", "${project.layout.buildDirectory.get()}/resources/main/logging.properties")
2626
}

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ aws-advanced-jdbc-wrapper.version.minor=3
1717
aws-advanced-jdbc-wrapper.version.subminor=6
1818
snapshot=false
1919
nexus.publish=true
20+
21+
org.gradle.jvmargs=-Xmx4096m

wrapper/build.gradle.kts

Lines changed: 73 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,14 @@ spotbugs {
152152
tasks.spotbugsMain {
153153
reports.create("html") {
154154
required.set(true)
155-
outputLocation.set(file("$buildDir/reports/spotbugsMain.html"))
155+
outputLocation.set(file("${layout.buildDirectory.get()}/reports/spotbugsMain.html"))
156156
setStylesheet("fancy-hist.xsl")
157157
}
158158
}
159159
tasks.spotbugsTest {
160160
reports.create("html") {
161161
required.set(true)
162-
outputLocation.set(file("$buildDir/reports/spotbugsTest.html"))
162+
outputLocation.set(file("${layout.buildDirectory.get()}/reports/spotbugsTest.html"))
163163
setStylesheet("fancy-hist.xsl")
164164
}
165165
}
@@ -210,7 +210,7 @@ tasks.jar {
210210
into("META-INF/")
211211
}
212212

213-
from("${buildDir}/META-INF/services/") {
213+
from("${layout.buildDirectory.get()}/META-INF/services/") {
214214
into("META-INF/services/")
215215
}
216216

@@ -233,8 +233,8 @@ tasks.jar {
233233
}
234234

235235
doFirst {
236-
mkdir("${buildDir}/META-INF/services/")
237-
val driverFile = File("${buildDir}/META-INF/services/java.sql.Driver")
236+
mkdir("${layout.buildDirectory.get()}/META-INF/services/")
237+
val driverFile = File("${layout.buildDirectory.get()}/META-INF/services/java.sql.Driver")
238238
if (driverFile.createNewFile()) {
239239
driverFile.writeText("software.amazon.jdbc.Driver")
240240
}
@@ -280,13 +280,13 @@ tasks.withType<Test> {
280280
reports.junitXml.required.set(true)
281281
reports.html.required.set(false)
282282

283-
systemProperty("java.util.logging.config.file", "${project.buildDir}/resources/test/logging-test.properties")
283+
systemProperty("java.util.logging.config.file", "${project.layout.buildDirectory.get()}/resources/test/logging-test.properties")
284284

285285
if (!name.contains("performance")) {
286286
finalizedBy("junitHtmlReport")
287287
}
288288

289-
val testReportsPath = "${buildDir}/test-results"
289+
val testReportsPath = "${layout.buildDirectory.get()}/test-results"
290290
val testReportsDir: File = file(testReportsPath)
291291
doFirst {
292292
testReportsDir.deleteRecursively()
@@ -306,6 +306,7 @@ tasks.register<Test>("test-all-docker") {
306306
filter.includeTestsMatching("integration.host.TestRunner.runTests")
307307
doFirst {
308308
systemProperty("test-no-aurora", "true")
309+
systemProperty("test-no-multi-az", "true")
309310
systemProperty("test-no-performance", "true")
310311
}
311312
}
@@ -315,6 +316,7 @@ tasks.register<Test>("test-hibernate-only") {
315316
filter.includeTestsMatching("integration.host.TestRunner.runTests")
316317
doFirst {
317318
systemProperty("test-no-aurora", "true")
319+
systemProperty("test-no-multi-az", "true")
318320
systemProperty("test-no-performance", "true")
319321
systemProperty("test-no-mariadb-driver", "true")
320322
systemProperty("test-no-mariadb-engine", "true")
@@ -329,6 +331,23 @@ tasks.register<Test>("test-all-aurora") {
329331
doFirst {
330332
systemProperty("test-no-docker", "true")
331333
systemProperty("test-no-performance", "true")
334+
systemProperty("test-no-mariadb-engine", "true")
335+
systemProperty("test-no-graalvm", "true")
336+
systemProperty("test-no-openjdk8", "true")
337+
systemProperty("test-no-multi-az", "true")
338+
}
339+
}
340+
341+
tasks.register<Test>("test-all-multi-az") {
342+
group = "verification"
343+
filter.includeTestsMatching("integration.host.TestRunner.runTests")
344+
doFirst {
345+
systemProperty("test-no-docker", "true")
346+
systemProperty("test-no-performance", "true")
347+
systemProperty("test-no-mariadb-engine", "true")
348+
systemProperty("test-no-graalvm", "true")
349+
systemProperty("test-no-openjdk8", "true")
350+
systemProperty("test-no-aurora", "true")
332351
}
333352
}
334353

@@ -342,6 +361,25 @@ tasks.register<Test>("test-all-pg-aurora") {
342361
systemProperty("test-no-mysql-engine", "true")
343362
systemProperty("test-no-mariadb-driver", "true")
344363
systemProperty("test-no-mariadb-engine", "true")
364+
systemProperty("test-no-multi-az", "true")
365+
systemProperty("test-no-graalvm", "true")
366+
systemProperty("test-no-openjdk8", "true")
367+
}
368+
}
369+
370+
tasks.register<Test>("test-all-pg-multi-az") {
371+
group = "verification"
372+
filter.includeTestsMatching("integration.host.TestRunner.runTests")
373+
doFirst {
374+
systemProperty("test-no-docker", "true")
375+
systemProperty("test-no-performance", "true")
376+
systemProperty("test-no-mysql-driver", "true")
377+
systemProperty("test-no-mysql-engine", "true")
378+
systemProperty("test-no-mariadb-driver", "true")
379+
systemProperty("test-no-mariadb-engine", "true")
380+
systemProperty("test-no-graalvm", "true")
381+
systemProperty("test-no-openjdk8", "true")
382+
systemProperty("test-no-aurora", "true")
345383
}
346384
}
347385

@@ -353,6 +391,25 @@ tasks.register<Test>("test-all-mysql-aurora") {
353391
systemProperty("test-no-performance", "true")
354392
systemProperty("test-no-pg-driver", "true")
355393
systemProperty("test-no-pg-engine", "true")
394+
systemProperty("test-no-mariadb-engine", "true")
395+
systemProperty("test-no-graalvm", "true")
396+
systemProperty("test-no-openjdk8", "true")
397+
systemProperty("test-no-multi-az", "true")
398+
}
399+
}
400+
401+
tasks.register<Test>("test-all-mysql-multi-az") {
402+
group = "verification"
403+
filter.includeTestsMatching("integration.host.TestRunner.runTests")
404+
doFirst {
405+
systemProperty("test-no-docker", "true")
406+
systemProperty("test-no-performance", "true")
407+
systemProperty("test-no-pg-driver", "true")
408+
systemProperty("test-no-pg-engine", "true")
409+
systemProperty("test-no-mariadb-engine", "true")
410+
systemProperty("test-no-graalvm", "true")
411+
systemProperty("test-no-openjdk8", "true")
412+
systemProperty("test-no-aurora", "true")
356413
}
357414
}
358415

@@ -371,6 +428,7 @@ tasks.register<Test>("debug-all-docker") {
371428
filter.includeTestsMatching("integration.host.TestRunner.debugTests")
372429
doFirst {
373430
systemProperty("test-no-aurora", "true")
431+
systemProperty("test-no-multi-az", "true")
374432
systemProperty("test-no-performance", "true")
375433
}
376434
}
@@ -389,6 +447,7 @@ tasks.register<Test>("debug-hibernate-only") {
389447
filter.includeTestsMatching("integration.host.TestRunner.debugTests")
390448
doFirst {
391449
systemProperty("test-no-aurora", "true")
450+
systemProperty("test-no-multi-az", "true")
392451
systemProperty("test-no-performance", "true")
393452
systemProperty("test-no-mariadb-driver", "true")
394453
systemProperty("test-no-mariadb-engine", "true")
@@ -403,6 +462,7 @@ tasks.register<Test>("test-all-aurora-performance") {
403462
filter.includeTestsMatching("integration.host.TestRunner.runTests")
404463
doFirst {
405464
systemProperty("test-no-docker", "true")
465+
systemProperty("test-no-multi-az", "true")
406466
systemProperty("test-no-iam", "true")
407467
systemProperty("test-no-hikari", "true")
408468
systemProperty("test-no-secrets-manager", "true")
@@ -419,6 +479,7 @@ tasks.register<Test>("test-aurora-pg-performance") {
419479
filter.includeTestsMatching("integration.host.TestRunner.runTests")
420480
doFirst {
421481
systemProperty("test-no-docker", "true")
482+
systemProperty("test-no-multi-az", "true")
422483
systemProperty("test-no-iam", "true")
423484
systemProperty("test-no-hikari", "true")
424485
systemProperty("test-no-secrets-manager", "true")
@@ -439,6 +500,7 @@ tasks.register<Test>("debug-aurora-pg-performance") {
439500
filter.includeTestsMatching("integration.host.TestRunner.debugTests")
440501
doFirst {
441502
systemProperty("test-no-docker", "true")
503+
systemProperty("test-no-multi-az", "true")
442504
systemProperty("test-no-iam", "true")
443505
systemProperty("test-no-hikari", "true")
444506
systemProperty("test-no-secrets-manager", "true")
@@ -459,6 +521,7 @@ tasks.register<Test>("test-aurora-mysql-performance") {
459521
filter.includeTestsMatching("integration.host.TestRunner.runTests")
460522
doFirst {
461523
systemProperty("test-no-docker", "true")
524+
systemProperty("test-no-multi-az", "true")
462525
systemProperty("test-no-iam", "true")
463526
systemProperty("test-no-hikari", "true")
464527
systemProperty("test-no-secrets-manager", "true")
@@ -479,6 +542,7 @@ tasks.register<Test>("debug-aurora-mysql-performance") {
479542
filter.includeTestsMatching("integration.host.TestRunner.debugTests")
480543
doFirst {
481544
systemProperty("test-no-docker", "true")
545+
systemProperty("test-no-multi-az", "true")
482546
systemProperty("test-no-iam", "true")
483547
systemProperty("test-no-hikari", "true")
484548
systemProperty("test-no-secrets-manager", "true")
@@ -499,6 +563,7 @@ tasks.register<Test>("test-aurora-pg-advanced-performance") {
499563
filter.includeTestsMatching("integration.host.TestRunner.runTests")
500564
doFirst {
501565
systemProperty("test-no-docker", "true")
566+
systemProperty("test-no-multi-az", "true")
502567
systemProperty("test-no-iam", "true")
503568
systemProperty("test-no-hikari", "true")
504569
systemProperty("test-no-secrets-manager", "true")
@@ -519,6 +584,7 @@ tasks.register<Test>("test-aurora-mysql-advanced-performance") {
519584
filter.includeTestsMatching("integration.host.TestRunner.runTests")
520585
doFirst {
521586
systemProperty("test-no-docker", "true")
587+
systemProperty("test-no-multi-az", "true")
522588
systemProperty("test-no-iam", "true")
523589
systemProperty("test-no-hikari", "true")
524590
systemProperty("test-no-secrets-manager", "true")

wrapper/src/main/java/software/amazon/jdbc/dialect/Dialect.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
package software.amazon.jdbc.dialect;
1818

1919
import java.sql.Connection;
20+
import java.util.EnumSet;
2021
import java.util.List;
2122
import java.util.Properties;
2223
import org.checkerframework.checker.nullness.qual.NonNull;
2324
import software.amazon.jdbc.HostSpec;
2425
import software.amazon.jdbc.exceptions.ExceptionHandler;
26+
import software.amazon.jdbc.plugin.failover.FailoverRestriction;
2527

2628
public interface Dialect {
2729
int getDefaultPort();
@@ -40,4 +42,6 @@ public interface Dialect {
4042

4143
void prepareConnectProperties(
4244
final @NonNull Properties connectProperties, final @NonNull String protocol, final @NonNull HostSpec hostSpec);
45+
46+
EnumSet<FailoverRestriction> getFailoverRestrictions();
4347
}

0 commit comments

Comments
 (0)