diff --git a/.github/workflows/race_tests.yml b/.github/workflows/race_tests.yml new file mode 100644 index 00000000..af3c5e1f --- /dev/null +++ b/.github/workflows/race_tests.yml @@ -0,0 +1,77 @@ +name: Race Tests + +on: + workflow_dispatch: + pull_request: + branches: + - "test/race-tests" + push: + branches: + - "test/race-tests" + paths-ignore: + - "**/*.md" + - "docs/**" + +permissions: + id-token: write # This is required for requesting the JWT + contents: read # This is required for actions/checkout + +jobs: + run-integration-tests: + name: Run Race Tests + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + dbEngine: ["aurora-mysql", "aurora-pg"] + steps: + - name: 'Clone repository' + uses: actions/checkout@v4 + - name: "Set up JDK 8" + uses: actions/setup-java@v3 + with: + distribution: "corretto" + java-version: 8 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.24' + cache-dependency-path: .test/go.sum + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_DEPLOY_ROLE }} + role-session-name: go_int_test + role-duration-seconds: 21600 + aws-region: ${{ secrets.AWS_DEFAULT_REGION }} + - name: Run Integration Tests + run: | + cd .test/test_framework/host && ./gradlew --no-parallel --no-daemon test-${{ matrix.dbEngine }}-race --info + env: + RDS_DB_REGION: ${{ secrets.AWS_DEFAULT_REGION }} + AURORA_MYSQL_DB_ENGINE_VERSION: "default" + AURORA_PG_DB_ENGINE_VERSION: "default" + RDS_MYSQL_DB_ENGINE_VERSION: "default" + RDS_PG_DB_ENGINE_VERSION: "default" + AWS_RDS_MONITORING_ROLE_ARN: ${{ secrets.AWS_RDS_MONITORING_ROLE_ARN }} + - name: "Get Github Action IP" + if: always() + id: ip + uses: haythem/public-ip@v1.3 + + - name: "Remove Github Action IP" + if: always() + run: | + aws ec2 revoke-security-group-ingress \ + --group-name default \ + --protocol -1 \ + --port -1 \ + --cidr ${{ steps.ip.outputs.ipv4 }}/32 \ + 2>&1 > /dev/null; + - name: Archive results + if: always() + uses: actions/upload-artifact@v4 + with: + name: integration-report-default-${{ matrix.dbEngine }} + path: ./.test/test_framework/container/reports + retention-days: 5 diff --git a/.test/test_framework/container/test_utils/fixed_value_types.go b/.test/test_framework/container/test_utils/fixed_value_types.go index 070d481d..e13d688b 100644 --- a/.test/test_framework/container/test_utils/fixed_value_types.go +++ b/.test/test_framework/container/test_utils/fixed_value_types.go @@ -56,6 +56,7 @@ const ( NETWORK_OUTAGES_ENABLED TestEnvironmentFeatures = "NETWORK_OUTAGES_ENABLED" AWS_CREDENTIALS_ENABLED TestEnvironmentFeatures = "AWS_CREDENTIALS_ENABLED" PERFORMANCE TestEnvironmentFeatures = "PERFORMANCE" + RACE TestEnvironmentFeatures = "RACE" RUN_AUTOSCALING_TESTS_ONLY TestEnvironmentFeatures = "RUN_AUTOSCALING_TESTS_ONLY" SKIP_MYSQL_DRIVER_TESTS TestEnvironmentFeatures = "SKIP_MYSQL_DRIVER_TESTS" SKIP_PG_DRIVER_TESTS TestEnvironmentFeatures = "SKIP_PG_DRIVER_TESTS" diff --git a/.test/test_framework/host/build.gradle.kts b/.test/test_framework/host/build.gradle.kts index 622afc66..d95afeff 100644 --- a/.test/test_framework/host/build.gradle.kts +++ b/.test/test_framework/host/build.gradle.kts @@ -96,6 +96,7 @@ tasks.register("test-docker") { systemProperty("exclude-multi-az", "true") systemProperty("exclude-limitless", "true") systemProperty("exclude-bg", "true") + systemProperty("exclude-race", "true") } } @@ -109,6 +110,7 @@ tasks.register("test-aurora") { systemProperty("exclude-multi-az-instance", "true") systemProperty("exclude-limitless", "true") systemProperty("exclude-bg", "true") + systemProperty("exclude-race", "true") } } @@ -124,6 +126,7 @@ tasks.register("test-aurora-postgres") { systemProperty("exclude-multi-az-instance", "true") systemProperty("exclude-limitless", "true") systemProperty("exclude-bg", "true") + systemProperty("exclude-race", "true") } } @@ -140,6 +143,7 @@ tasks.register("test-aurora-mysql") { systemProperty("exclude-multi-az-instance", "true") systemProperty("exclude-limitless", "true") systemProperty("exclude-bg", "true") + systemProperty("exclude-race", "true") } } @@ -162,6 +166,7 @@ tasks.register("test-aurora-pg-performance") { systemProperty("exclude-multi-az-instance", "true") systemProperty("exclude-limitless", "true") systemProperty("exclude-bg", "true") + systemProperty("exclude-race", "true") } } @@ -176,6 +181,7 @@ tasks.register("test-aurora-mysql-performance") { systemProperty("exclude-multi-az-instance", "true") systemProperty("exclude-limitless", "true") systemProperty("exclude-bg", "true") + systemProperty("exclude-race", "true") } } @@ -192,6 +198,7 @@ tasks.register("test-multi-az-postgres") { systemProperty("exclude-multi-az-instance", "true") systemProperty("exclude-limitless", "true") systemProperty("exclude-bg", "true") + systemProperty("exclude-race", "true") } } @@ -207,6 +214,7 @@ tasks.register("test-multi-az-mysql") { systemProperty("exclude-multi-az-instance", "true") systemProperty("exclude-limitless", "true") systemProperty("exclude-bg", "true") + systemProperty("exclude-race", "true") } } @@ -221,6 +229,7 @@ tasks.register("test-autoscaling") { systemProperty("test-autoscaling", "true") systemProperty("exclude-limitless", "true") systemProperty("exclude-bg", "true") + systemProperty("exclude-race", "true") } } @@ -237,6 +246,7 @@ tasks.register("test-autoscaling-mysql") { systemProperty("test-autoscaling", "true") systemProperty("exclude-limitless", "true") systemProperty("exclude-bg", "true") + systemProperty("exclude-race", "true") } } @@ -253,6 +263,7 @@ tasks.register("test-autoscaling-postgres") { systemProperty("test-autoscaling", "true") systemProperty("exclude-limitless", "true") systemProperty("exclude-bg", "true") + systemProperty("exclude-race", "true") } } @@ -267,6 +278,7 @@ tasks.register("test-bgd-mysql-aurora") { systemProperty("exclude-multi-az-cluster", "true") systemProperty("exclude-multi-az-instance", "true") systemProperty("exclude-limitless", "true") + systemProperty("exclude-race", "true") } } @@ -282,6 +294,7 @@ tasks.register("test-bgd-mysql-multiaz") { systemProperty("exclude-multi-az-cluster", "true") systemProperty("exclude-multi-az-instance", "false") systemProperty("exclude-limitless", "true") + systemProperty("exclude-race", "true") } } @@ -296,6 +309,7 @@ tasks.register("test-bgd-pg-aurora") { systemProperty("exclude-multi-az-cluster", "true") systemProperty("exclude-multi-az-instance", "true") systemProperty("exclude-limitless", "true") + systemProperty("exclude-race", "true") } } @@ -311,6 +325,7 @@ tasks.register("test-bgd-pg-multiaz") { systemProperty("exclude-multi-az-cluster", "true") systemProperty("exclude-multi-az-instance", "false") systemProperty("exclude-limitless", "true") + systemProperty("exclude-race", "true") } } @@ -327,6 +342,40 @@ tasks.register("test-aurora-limitless-postgres") { systemProperty("exclude-bg", "true") systemProperty("exclude-limitless", "false") systemProperty("limitless-only", "true") + systemProperty("exclude-race", "true") + } +} + +// TODO: change these filters +tasks.register("test-aurora-pg-race") { + group = "verification" + filter.includeTestsMatching("integration.host.TestRunner.runTests") + doFirst { + systemProperty("exclude-docker", "true") + systemProperty("exclude-performance", "true") + systemProperty("exclude-failover", "true") + systemProperty("exclude-multi-az", "true") + systemProperty("exclude-mysql-driver", "true") + systemProperty("exclude-mysql-engine", "true") + systemProperty("exclude-bg", "true") + systemProperty("exclude-limitless", "true") + systemProperty("exclude-race", "false") + } +} + +tasks.register("test-aurora-mysql-race") { + group = "verification" + filter.includeTestsMatching("integration.host.TestRunner.runTests") + doFirst { + systemProperty("exclude-docker", "true") + systemProperty("exclude-performance", "true") + systemProperty("exclude-failover", "true") + systemProperty("exclude-multi-az", "true") + systemProperty("exclude-mysql-driver", "true") + systemProperty("exclude-mysql-engine", "true") + systemProperty("exclude-bg", "true") + systemProperty("exclude-limitless", "true") + systemProperty("exclude-race", "false") } } @@ -337,6 +386,7 @@ tasks.register("debug-all-environments") { filter.includeTestsMatching("integration.host.TestRunner.debugTests") doFirst { systemProperty("exclude-performance", "true") + systemProperty("exclude-race", "true") } } @@ -350,6 +400,7 @@ tasks.register("debug-docker") { systemProperty("exclude-multi-az-instance", "true") systemProperty("exclude-bg", "true") systemProperty("exclude-limitless", "true") + systemProperty("exclude-race", "true") } } @@ -363,6 +414,7 @@ tasks.register("debug-aurora") { systemProperty("exclude-multi-az-instance", "true") systemProperty("exclude-bg", "true") systemProperty("exclude-limitless", "true") + systemProperty("exclude-race", "true") } } @@ -378,6 +430,7 @@ tasks.register("debug-aurora-postgres") { systemProperty("exclude-multi-az-instance", "true") systemProperty("exclude-bg", "true") systemProperty("exclude-limitless", "true") + systemProperty("exclude-race", "true") } } @@ -393,6 +446,7 @@ tasks.register("debug-aurora-mysql") { systemProperty("exclude-multi-az-instance", "true") systemProperty("exclude-bg", "true") systemProperty("exclude-limitless", "true") + systemProperty("exclude-race", "true") } } @@ -407,6 +461,7 @@ tasks.register("debug-aurora-pg-performance") { systemProperty("exclude-multi-az-instance", "true") systemProperty("exclude-bg", "true") systemProperty("exclude-limitless", "true") + systemProperty("exclude-race", "true") } } @@ -421,6 +476,7 @@ tasks.register("debug-aurora-mysql-performance") { systemProperty("exclude-multi-az-instance", "true") systemProperty("exclude-bg", "true") systemProperty("exclude-limitless", "true") + systemProperty("exclude-race", "true") } } @@ -435,6 +491,7 @@ tasks.register("debug-multi-az-mysql") { systemProperty("exclude-aurora", "true") systemProperty("exclude-bg", "true") systemProperty("exclude-limitless", "true") + systemProperty("exclude-race", "true") } } @@ -449,6 +506,7 @@ tasks.register("debug-multi-az-postgres") { systemProperty("exclude-aurora", "true") systemProperty("exclude-bg", "true") systemProperty("exclude-limitless", "true") + systemProperty("exclude-race", "true") } } @@ -463,6 +521,7 @@ tasks.register("debug-autoscaling") { systemProperty("exclude-bg", "true") systemProperty("exclude-limitless", "true") systemProperty("test-autoscaling", "true") + systemProperty("exclude-race", "true") } } @@ -479,6 +538,7 @@ tasks.register("debug-aurora-limitless-postgres") { systemProperty("exclude-bg", "true") systemProperty("exclude-limitless", "false") systemProperty("limitless-only", "true") + systemProperty("exclude-race", "true") } } @@ -493,5 +553,6 @@ tasks.register("debug-bgd-mysql-aurora") { systemProperty("exclude-multi-az-cluster", "true") systemProperty("exclude-multi-az-instance", "true") systemProperty("exclude-limitless", "true") + systemProperty("exclude-race", "true") } } diff --git a/.test/test_framework/host/src/test/java/integration/host/TestEnvironmentConfig.java b/.test/test_framework/host/src/test/java/integration/host/TestEnvironmentConfig.java index 3ef71a5b..91a8103b 100644 --- a/.test/test_framework/host/src/test/java/integration/host/TestEnvironmentConfig.java +++ b/.test/test_framework/host/src/test/java/integration/host/TestEnvironmentConfig.java @@ -1254,7 +1254,8 @@ private static String getEnvironmentInfoAsString(TestEnvironmentConfig env) { public void runTests() throws IOException, InterruptedException { final ContainerHelper containerHelper = new ContainerHelper(); boolean isPerformanceTest = info.getRequest().getFeatures().contains(TestEnvironmentFeatures.PERFORMANCE); - containerHelper.runTest(this.testContainer, isPerformanceTest); + boolean isRaceTest = info.getRequest().getFeatures().contains(TestEnvironmentFeatures.RACE); + containerHelper.runTest(this.testContainer, isPerformanceTest, isRaceTest); } public void debugTests() throws IOException, InterruptedException { diff --git a/.test/test_framework/host/src/test/java/integration/host/TestEnvironmentFeatures.java b/.test/test_framework/host/src/test/java/integration/host/TestEnvironmentFeatures.java index 298e5c8f..140bad6e 100644 --- a/.test/test_framework/host/src/test/java/integration/host/TestEnvironmentFeatures.java +++ b/.test/test_framework/host/src/test/java/integration/host/TestEnvironmentFeatures.java @@ -24,6 +24,7 @@ public enum TestEnvironmentFeatures { NETWORK_OUTAGES_ENABLED, AWS_CREDENTIALS_ENABLED, PERFORMANCE, + RACE, RUN_AUTOSCALING_TESTS_ONLY, SKIP_MYSQL_DRIVER_TESTS, SKIP_PG_DRIVER_TESTS, diff --git a/.test/test_framework/host/src/test/java/integration/host/TestEnvironmentProvider.java b/.test/test_framework/host/src/test/java/integration/host/TestEnvironmentProvider.java index 3148ca08..5d44df93 100644 --- a/.test/test_framework/host/src/test/java/integration/host/TestEnvironmentProvider.java +++ b/.test/test_framework/host/src/test/java/integration/host/TestEnvironmentProvider.java @@ -51,6 +51,8 @@ public Stream provideTestTemplateInvocationContex final boolean excludeLimitless = Boolean.parseBoolean(System.getProperty("exclude-limitless", "true")); final boolean excludePerformance = Boolean.parseBoolean(System.getProperty("exclude-performance", "false")); + final boolean excludeRace = + Boolean.parseBoolean(System.getProperty("exclude-race", "false")); final boolean excludeMysqlEngine = Boolean.parseBoolean(System.getProperty("exclude-mysql-engine", "false")); final boolean excludeMysqlDriver = @@ -149,6 +151,7 @@ public Stream provideTestTemplateInvocationContex : TestEnvironmentFeatures.IAM, excludeSecretsManager ? null : TestEnvironmentFeatures.SECRETS_MANAGER, excludePerformance ? null : TestEnvironmentFeatures.PERFORMANCE, + excludeRace ? null : TestEnvironmentFeatures.RACE, excludeMysqlDriver ? TestEnvironmentFeatures.SKIP_MYSQL_DRIVER_TESTS : null, excludePgDriver ? TestEnvironmentFeatures.SKIP_PG_DRIVER_TESTS : null, testAutoscalingOnly ? TestEnvironmentFeatures.RUN_AUTOSCALING_TESTS_ONLY : null, diff --git a/.test/test_framework/host/src/test/java/integration/host/util/ContainerHelper.java b/.test/test_framework/host/src/test/java/integration/host/util/ContainerHelper.java index f0c63c47..a8aa9b61 100644 --- a/.test/test_framework/host/src/test/java/integration/host/util/ContainerHelper.java +++ b/.test/test_framework/host/src/test/java/integration/host/util/ContainerHelper.java @@ -79,7 +79,7 @@ public Long runCmdInDirectory(GenericContainer container, String workingDirec return exitCode; } - public void runTest(GenericContainer container, boolean isPerformanceTest) + public void runTest(GenericContainer container, boolean isPerformanceTest, boolean isRaceTest) throws IOException, InterruptedException { System.out.println("==== Container console feed ==== >>>>"); Consumer consumer = new ConsoleConsumer(true); @@ -98,6 +98,13 @@ public void runTest(GenericContainer container, boolean isPerformanceTest) Long exitCode; if (isPerformanceTest) { exitCode = execInContainer(container, "/app/.test/", consumer, "go", "test", "-timeout", timeout, PERFORMANCE_TEST_TAG, "-run", PERFORMANCE_TEST_FILTER, "-v", "./test_framework/container/tests..."); + } else if (isRaceTest) { + if (filter != null) { + exitCode = execInContainer(container, "/app/.test/", consumer, "go", "test", "-race", "-timeout", timeout, "-v", "./test_framework/container/tests/stress_test.go", "-run", filter); + } else { + // Run all tests located in aws-advanced-go-wrapper/.test/test_framework/container. + exitCode = execInContainer(container, "/app/.test/", consumer, "go", "test", "-race", "-timeout", timeout, "-v", "./test_framework/container/tests/stress_test.go"); + } } else if (filter != null) { exitCode = execInContainer(container, "/app/.test/", consumer, "go", "test", "-timeout", timeout, "-v", "./test_framework/container/tests...", "-run", filter); } else {