Skip to content

Commit 77371ea

Browse files
committed
driver topology
failover metrics
1 parent 3b32ac2 commit 77371ea

37 files changed

+2067
-61
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Run Metrics Latest
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: "8 0 * * *" # Runs daily at 8am UTC (1am PST)
7+
8+
permissions:
9+
id-token: write # This is required for requesting the JWT
10+
contents: read # This is required for actions/checkout
11+
12+
jobs:
13+
all-integration-tests-latest:
14+
name: Run Metrics with latest engine version
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
dbEngine: [ "mysql-aurora", "mysql-multi-az", "pg-aurora", "pg-multi-az" ]
20+
steps:
21+
- name: 'Clone repository'
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 50
25+
- name: 'Set up JDK 8'
26+
uses: actions/setup-java@v4
27+
with:
28+
distribution: 'corretto'
29+
java-version: 8
30+
- name: 'Configure AWS credentials'
31+
uses: aws-actions/configure-aws-credentials@v4
32+
id: creds
33+
with:
34+
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_DEPLOY_ROLE }}
35+
role-session-name: run_integration_test_latest
36+
role-duration-seconds: 21600
37+
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
38+
output-credentials: true
39+
- name: Run integration tests
40+
run: |
41+
./gradlew --no-parallel --no-daemon test-metrics-${{ matrix.dbEngine }}
42+
env:
43+
AURORA_CLUSTER_DOMAIN: ${{ secrets.DB_CONN_SUFFIX }}
44+
RDS_DB_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
45+
AWS_ACCESS_KEY_ID: ${{ steps.creds.outputs.aws-access-key-id }}
46+
AWS_SECRET_ACCESS_KEY: ${{ steps.creds.outputs.aws-secret-access-key }}
47+
AWS_SESSION_TOKEN: ${{ steps.creds.outputs.aws-session-token }}
48+
MYSQL_VERSION: "latest"
49+
PG_VERSION: "latest"
50+
- name: Mask data
51+
run: |
52+
./gradlew --no-parallel --no-daemon maskJunitHtmlReport
53+
- name: Archive junit results for ${{ matrix.dbEngine }}
54+
if: always()
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: junit-report-latest-${{ matrix.dbEngine }}
58+
path: ./wrapper/build/test-results
59+
retention-days: 5
60+
- name: Archive html summary report for ${{ matrix.dbEngine }}
61+
if: always()
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: html-summary-report-latest-${{ matrix.dbEngine }}
65+
path: ./wrapper/build/report
66+
retention-days: 5
67+
- name: Archive metrics for ${{ matrix.dbEngine }}
68+
if: always()
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: metrics-latest-${{ matrix.dbEngine }}
72+
path: ./wrapper/build/reports/tests
73+
retention-days: 5

wrapper/build.gradle.kts

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ dependencies {
9696
testImplementation("de.vandermeer:asciitable:0.3.2")
9797
testImplementation("org.hibernate:hibernate-core:5.6.15.Final") // the latest version compatible with Java 8
9898
testImplementation("jakarta.persistence:jakarta.persistence-api:2.2.3")
99+
testImplementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.19.2")
99100
}
100101

101102
repositories {
@@ -880,3 +881,132 @@ tasks.register<Test>("debug-autoscaling-only") {
880881
systemProperty("test-no-openjdk22", "true")
881882
}
882883
}
884+
885+
// Metrics
886+
887+
tasks.register<Test>("test-all-metrics") {
888+
group = "verification"
889+
filter.includeTestsMatching("integration.host.TestRunner.runTests")
890+
doFirst {
891+
systemProperty("test-no-docker", "true")
892+
systemProperty("test-no-performance", "true")
893+
systemProperty("test-no-mariadb-engine", "true")
894+
systemProperty("test-no-mariadb-driver", "true")
895+
systemProperty("test-no-graalvm", "true")
896+
systemProperty("test-no-openjdk11", "true")
897+
systemProperty("test-no-openjdk17", "true")
898+
systemProperty("test-no-openjdk22", "true")
899+
systemProperty("test-no-failover", "true")
900+
systemProperty("test-no-secrets-manager", "true")
901+
systemProperty("test-no-hikari", "true")
902+
systemProperty("test-no-instances-1", "true")
903+
systemProperty("test-no-instances-2", "true")
904+
systemProperty("test-no-instances-5", "true")
905+
systemProperty("test-no-bg", "true")
906+
systemProperty("test-metrics-only", "true")
907+
}
908+
}
909+
910+
tasks.register<Test>("test-metrics-mysql-aurora") {
911+
group = "verification"
912+
filter.includeTestsMatching("integration.host.TestRunner.runTests")
913+
doFirst {
914+
systemProperty("test-no-docker", "true")
915+
systemProperty("test-no-performance", "true")
916+
systemProperty("test-no-mariadb-engine", "true")
917+
systemProperty("test-no-mariadb-driver", "true")
918+
systemProperty("test-no-graalvm", "true")
919+
systemProperty("test-no-openjdk11", "true")
920+
systemProperty("test-no-openjdk17", "true")
921+
systemProperty("test-no-openjdk22", "true")
922+
systemProperty("test-no-failover", "true")
923+
systemProperty("test-no-secrets-manager", "true")
924+
systemProperty("test-no-hikari", "true")
925+
systemProperty("test-no-instances-1", "true")
926+
systemProperty("test-no-instances-2", "true")
927+
systemProperty("test-no-instances-3", "true")
928+
systemProperty("test-no-bg", "true")
929+
systemProperty("test-metrics-only", "true")
930+
931+
systemProperty("test-no-multi-az-cluster", "true")
932+
systemProperty("test-no-pg-engine", "true")
933+
}
934+
}
935+
936+
tasks.register<Test>("test-metrics-mysql-multi-az") {
937+
group = "verification"
938+
filter.includeTestsMatching("integration.host.TestRunner.runTests")
939+
doFirst {
940+
systemProperty("test-no-docker", "true")
941+
systemProperty("test-no-performance", "true")
942+
systemProperty("test-no-mariadb-engine", "true")
943+
systemProperty("test-no-mariadb-driver", "true")
944+
systemProperty("test-no-graalvm", "true")
945+
systemProperty("test-no-openjdk11", "true")
946+
systemProperty("test-no-openjdk17", "true")
947+
systemProperty("test-no-openjdk22", "true")
948+
systemProperty("test-no-failover", "true")
949+
systemProperty("test-no-secrets-manager", "true")
950+
systemProperty("test-no-hikari", "true")
951+
systemProperty("test-no-instances-1", "true")
952+
systemProperty("test-no-instances-2", "true")
953+
systemProperty("test-no-instances-5", "true")
954+
systemProperty("test-no-bg", "true")
955+
systemProperty("test-metrics-only", "true")
956+
957+
systemProperty("test-no-aurora", "true")
958+
systemProperty("test-no-pg-engine", "true")
959+
}
960+
}
961+
962+
tasks.register<Test>("test-metrics-pg-aurora") {
963+
group = "verification"
964+
filter.includeTestsMatching("integration.host.TestRunner.runTests")
965+
doFirst {
966+
systemProperty("test-no-docker", "true")
967+
systemProperty("test-no-performance", "true")
968+
systemProperty("test-no-mariadb-engine", "true")
969+
systemProperty("test-no-mariadb-driver", "true")
970+
systemProperty("test-no-graalvm", "true")
971+
systemProperty("test-no-openjdk11", "true")
972+
systemProperty("test-no-openjdk17", "true")
973+
systemProperty("test-no-openjdk22", "true")
974+
systemProperty("test-no-failover", "true")
975+
systemProperty("test-no-secrets-manager", "true")
976+
systemProperty("test-no-hikari", "true")
977+
systemProperty("test-no-instances-1", "true")
978+
systemProperty("test-no-instances-2", "true")
979+
systemProperty("test-no-instances-3", "true")
980+
systemProperty("test-no-bg", "true")
981+
systemProperty("test-metrics-only", "true")
982+
983+
systemProperty("test-no-multi-az-cluster", "true")
984+
systemProperty("test-no-mysql-engine", "true")
985+
}
986+
}
987+
988+
tasks.register<Test>("test-metrics-pg-multi-az") {
989+
group = "verification"
990+
filter.includeTestsMatching("integration.host.TestRunner.runTests")
991+
doFirst {
992+
systemProperty("test-no-docker", "true")
993+
systemProperty("test-no-performance", "true")
994+
systemProperty("test-no-mariadb-engine", "true")
995+
systemProperty("test-no-mariadb-driver", "true")
996+
systemProperty("test-no-graalvm", "true")
997+
systemProperty("test-no-openjdk11", "true")
998+
systemProperty("test-no-openjdk17", "true")
999+
systemProperty("test-no-openjdk22", "true")
1000+
systemProperty("test-no-failover", "true")
1001+
systemProperty("test-no-secrets-manager", "true")
1002+
systemProperty("test-no-hikari", "true")
1003+
systemProperty("test-no-instances-1", "true")
1004+
systemProperty("test-no-instances-2", "true")
1005+
systemProperty("test-no-instances-5", "true")
1006+
systemProperty("test-no-bg", "true")
1007+
systemProperty("test-metrics-only", "true")
1008+
1009+
systemProperty("test-no-aurora", "true")
1010+
systemProperty("test-no-mysql-engine", "true")
1011+
}
1012+
}

wrapper/src/main/java/software/amazon/jdbc/HostSpec.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ public Set<String> asAliases() {
205205
}
206206

207207
public String toString() {
208-
return String.format("HostSpec[host=%s, port=%d, %s, %s, weight=%d, %s]",
208+
return String.format("HostSpec@%s [host=%s, port=%d, %s, %s, weight=%d, %s]",
209+
Integer.toHexString(System.identityHashCode(this)),
209210
this.host, this.port, this.role, this.availability, this.weight, this.lastUpdateTime);
210211
}
211212

wrapper/src/main/java/software/amazon/jdbc/hostlistprovider/monitoring/ClusterTopologyMonitorImpl.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ public void monitor() {
276276
try {
277277
LOGGER.finest(() -> Messages.get(
278278
"ClusterTopologyMonitorImpl.startMonitoringThread",
279-
new Object[]{this.initialHostSpec.getHost()}));
279+
new Object[]{this.clusterId, this.initialHostSpec.getHost()}));
280280

281281
while (!this.stop.get() && !Thread.currentThread().isInterrupted()) {
282282
this.lastActivityTimestampNanos.set(System.nanoTime());
@@ -306,8 +306,11 @@ public void monitor() {
306306
for (HostSpec hostSpec : hosts) {
307307
this.submittedNodes.computeIfAbsent(hostSpec.getHost(),
308308
(key) -> {
309-
this.nodeExecutorService.submit(
310-
this.getNodeMonitoringWorker(hostSpec, this.writerHostSpec.get()));
309+
final ExecutorService nodeExecutorServiceCopy = this.nodeExecutorService;
310+
if (nodeExecutorServiceCopy != null) {
311+
this.nodeExecutorService.submit(
312+
this.getNodeMonitoringWorker(hostSpec, this.writerHostSpec.get()));
313+
}
311314
return true;
312315
});
313316
}

wrapper/src/main/resources/aws_advanced_jdbc_wrapper_messages.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ NodeResponseTimeMonitor.exceptionDuringMonitoringStop=Stopping thread after unha
364364
NodeResponseTimeMonitor.openingConnection=Opening a Response time connection to ''{0}''.
365365
NodeResponseTimeMonitor.openedConnection=Opened Response time connection: {0}.
366366

367-
ClusterTopologyMonitorImpl.startMonitoringThread=Start cluster topology monitoring thread for ''{0}''.
367+
ClusterTopologyMonitorImpl.startMonitoringThread=[clusterId: ''{0}''] Start cluster topology monitoring thread for ''{1}''.
368368
ClusterTopologyMonitorImpl.stopMonitoringThread=Stop cluster topology monitoring thread for ''{0}''.
369369
ClusterTopologyMonitorImpl.exceptionDuringMonitoringStop=Stopping cluster topology monitoring after unhandled exception was thrown in monitoring thread for node ''{0}''.
370370
ClusterTopologyMonitorImpl.invalidQuery=An error occurred while attempting to obtain the topology because the topology query was invalid. Please ensure you are connecting to an Aurora or RDS Db cluster.

wrapper/src/test/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ dependencies {
6161
testImplementation("de.vandermeer:asciitable:0.3.2")
6262
testImplementation("org.hibernate:hibernate-core:5.6.15.Final") // the latest version compatible with Java 8
6363
testImplementation("jakarta.persistence:jakarta.persistence-api:2.2.3")
64+
testImplementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.19.2")
6465
}
6566

6667
tasks.withType<Test> {

wrapper/src/test/java/integration/TestEnvironmentFeatures.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ public enum TestEnvironmentFeatures {
3131
RUN_AUTOSCALING_TESTS_ONLY,
3232
TELEMETRY_TRACES_ENABLED,
3333
TELEMETRY_METRICS_ENABLED,
34-
BLUE_GREEN_DEPLOYMENT
34+
BLUE_GREEN_DEPLOYMENT,
35+
RUN_DB_METRICS_ONLY
3536
}

wrapper/src/test/java/integration/container/TestDriverProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ private static void clearCaches() {
218218
Driver.resetConnectionInitFunc();
219219
}
220220

221-
private static void checkClusterHealth(final boolean makeSureFirstInstanceWriter)
221+
public static void checkClusterHealth(final boolean makeSureFirstInstanceWriter)
222222
throws InterruptedException, SQLException {
223223

224224
final TestEnvironmentInfo testInfo = TestEnvironment.getCurrent().getInfo();

wrapper/src/test/java/integration/container/tests/AdvancedPerformanceTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import integration.container.TestEnvironment;
3232
import integration.container.aurora.TestAuroraHostListProvider;
3333
import integration.container.aurora.TestPluginServiceImpl;
34+
import integration.container.condition.DisableOnTestFeature;
3435
import integration.container.condition.EnableOnTestFeature;
3536
import integration.util.AuroraTestUtility;
3637
import java.io.File;
@@ -76,6 +77,7 @@
7677
TestEnvironmentFeatures.PERFORMANCE,
7778
TestEnvironmentFeatures.FAILOVER_SUPPORTED
7879
})
80+
@DisableOnTestFeature(TestEnvironmentFeatures.RUN_DB_METRICS_ONLY)
7981
@Tag("advanced")
8082
@Order(1)
8183
public class AdvancedPerformanceTest {

wrapper/src/test/java/integration/container/tests/AutoscalingTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import integration.container.ConnectionStringHelper;
3131
import integration.container.TestDriverProvider;
3232
import integration.container.TestEnvironment;
33+
import integration.container.condition.DisableOnTestFeature;
3334
import integration.container.condition.EnableOnDatabaseEngineDeployment;
3435
import integration.container.condition.EnableOnNumOfInstances;
3536
import integration.container.condition.EnableOnTestFeature;

0 commit comments

Comments
 (0)