Skip to content

Commit cb317f2

Browse files
test: add race tests
1 parent 45481a8 commit cb317f2

File tree

7 files changed

+153
-2
lines changed

7 files changed

+153
-2
lines changed

.github/workflows/race_tests.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Race Tests
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches:
7+
- "test/race-tests"
8+
push:
9+
branches:
10+
- "test/race-tests"
11+
paths-ignore:
12+
- "**/*.md"
13+
- "docs/**"
14+
15+
permissions:
16+
id-token: write # This is required for requesting the JWT
17+
contents: read # This is required for actions/checkout
18+
19+
jobs:
20+
run-integration-tests:
21+
name: Run Race Tests
22+
runs-on: ubuntu-latest
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
dbEngine: ["aurora-mysql", "aurora-pg"]
27+
steps:
28+
- name: 'Clone repository'
29+
uses: actions/checkout@v4
30+
- name: "Set up JDK 8"
31+
uses: actions/setup-java@v3
32+
with:
33+
distribution: "corretto"
34+
java-version: 8
35+
- name: Set up Go
36+
uses: actions/setup-go@v4
37+
with:
38+
go-version: '1.24'
39+
cache-dependency-path: .test/go.sum
40+
- name: Configure AWS Credentials
41+
uses: aws-actions/configure-aws-credentials@v4
42+
with:
43+
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_DEPLOY_ROLE }}
44+
role-session-name: go_int_test
45+
role-duration-seconds: 21600
46+
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
47+
- name: Run Integration Tests
48+
run: |
49+
cd .test/test_framework/host && ./gradlew --no-parallel --no-daemon test-${{ matrix.dbEngine }}-race --info
50+
env:
51+
RDS_DB_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
52+
AURORA_MYSQL_DB_ENGINE_VERSION: "default"
53+
AURORA_PG_DB_ENGINE_VERSION: "default"
54+
RDS_MYSQL_DB_ENGINE_VERSION: "default"
55+
RDS_PG_DB_ENGINE_VERSION: "default"
56+
AWS_RDS_MONITORING_ROLE_ARN: ${{ secrets.AWS_RDS_MONITORING_ROLE_ARN }}
57+
- name: "Get Github Action IP"
58+
if: always()
59+
id: ip
60+
uses: haythem/public-ip@v1.3
61+
62+
- name: "Remove Github Action IP"
63+
if: always()
64+
run: |
65+
aws ec2 revoke-security-group-ingress \
66+
--group-name default \
67+
--protocol -1 \
68+
--port -1 \
69+
--cidr ${{ steps.ip.outputs.ipv4 }}/32 \
70+
2>&1 > /dev/null;
71+
- name: Archive results
72+
if: always()
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name: integration-report-default-${{ matrix.dbEngine }}
76+
path: ./.test/test_framework/container/reports
77+
retention-days: 5

.test/test_framework/container/test_utils/fixed_value_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const (
5656
NETWORK_OUTAGES_ENABLED TestEnvironmentFeatures = "NETWORK_OUTAGES_ENABLED"
5757
AWS_CREDENTIALS_ENABLED TestEnvironmentFeatures = "AWS_CREDENTIALS_ENABLED"
5858
PERFORMANCE TestEnvironmentFeatures = "PERFORMANCE"
59+
RACE TestEnvironmentFeatures = "RACE"
5960
RUN_AUTOSCALING_TESTS_ONLY TestEnvironmentFeatures = "RUN_AUTOSCALING_TESTS_ONLY"
6061
SKIP_MYSQL_DRIVER_TESTS TestEnvironmentFeatures = "SKIP_MYSQL_DRIVER_TESTS"
6162
SKIP_PG_DRIVER_TESTS TestEnvironmentFeatures = "SKIP_PG_DRIVER_TESTS"

.test/test_framework/host/build.gradle.kts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ tasks.register<Test>("test-docker") {
9696
systemProperty("exclude-multi-az", "true")
9797
systemProperty("exclude-limitless", "true")
9898
systemProperty("exclude-bg", "true")
99+
systemProperty("exclude-race", "true")
99100
}
100101
}
101102

@@ -109,6 +110,7 @@ tasks.register<Test>("test-aurora") {
109110
systemProperty("exclude-multi-az-instance", "true")
110111
systemProperty("exclude-limitless", "true")
111112
systemProperty("exclude-bg", "true")
113+
systemProperty("exclude-race", "true")
112114
}
113115
}
114116

@@ -124,6 +126,7 @@ tasks.register<Test>("test-aurora-postgres") {
124126
systemProperty("exclude-multi-az-instance", "true")
125127
systemProperty("exclude-limitless", "true")
126128
systemProperty("exclude-bg", "true")
129+
systemProperty("exclude-race", "true")
127130
}
128131
}
129132

@@ -140,6 +143,7 @@ tasks.register<Test>("test-aurora-mysql") {
140143
systemProperty("exclude-multi-az-instance", "true")
141144
systemProperty("exclude-limitless", "true")
142145
systemProperty("exclude-bg", "true")
146+
systemProperty("exclude-race", "true")
143147
}
144148
}
145149

@@ -162,6 +166,7 @@ tasks.register<Test>("test-aurora-pg-performance") {
162166
systemProperty("exclude-multi-az-instance", "true")
163167
systemProperty("exclude-limitless", "true")
164168
systemProperty("exclude-bg", "true")
169+
systemProperty("exclude-race", "true")
165170
}
166171
}
167172

@@ -176,6 +181,7 @@ tasks.register<Test>("test-aurora-mysql-performance") {
176181
systemProperty("exclude-multi-az-instance", "true")
177182
systemProperty("exclude-limitless", "true")
178183
systemProperty("exclude-bg", "true")
184+
systemProperty("exclude-race", "true")
179185
}
180186
}
181187

@@ -192,6 +198,7 @@ tasks.register<Test>("test-multi-az-postgres") {
192198
systemProperty("exclude-multi-az-instance", "true")
193199
systemProperty("exclude-limitless", "true")
194200
systemProperty("exclude-bg", "true")
201+
systemProperty("exclude-race", "true")
195202
}
196203
}
197204

@@ -207,6 +214,7 @@ tasks.register<Test>("test-multi-az-mysql") {
207214
systemProperty("exclude-multi-az-instance", "true")
208215
systemProperty("exclude-limitless", "true")
209216
systemProperty("exclude-bg", "true")
217+
systemProperty("exclude-race", "true")
210218
}
211219
}
212220

@@ -221,6 +229,7 @@ tasks.register<Test>("test-autoscaling") {
221229
systemProperty("test-autoscaling", "true")
222230
systemProperty("exclude-limitless", "true")
223231
systemProperty("exclude-bg", "true")
232+
systemProperty("exclude-race", "true")
224233
}
225234
}
226235

@@ -237,6 +246,7 @@ tasks.register<Test>("test-autoscaling-mysql") {
237246
systemProperty("test-autoscaling", "true")
238247
systemProperty("exclude-limitless", "true")
239248
systemProperty("exclude-bg", "true")
249+
systemProperty("exclude-race", "true")
240250
}
241251
}
242252

@@ -253,6 +263,7 @@ tasks.register<Test>("test-autoscaling-postgres") {
253263
systemProperty("test-autoscaling", "true")
254264
systemProperty("exclude-limitless", "true")
255265
systemProperty("exclude-bg", "true")
266+
systemProperty("exclude-race", "true")
256267
}
257268
}
258269

@@ -267,6 +278,7 @@ tasks.register<Test>("test-bgd-mysql-aurora") {
267278
systemProperty("exclude-multi-az-cluster", "true")
268279
systemProperty("exclude-multi-az-instance", "true")
269280
systemProperty("exclude-limitless", "true")
281+
systemProperty("exclude-race", "true")
270282
}
271283
}
272284

@@ -282,6 +294,7 @@ tasks.register<Test>("test-bgd-mysql-multiaz") {
282294
systemProperty("exclude-multi-az-cluster", "true")
283295
systemProperty("exclude-multi-az-instance", "false")
284296
systemProperty("exclude-limitless", "true")
297+
systemProperty("exclude-race", "true")
285298
}
286299
}
287300

@@ -296,6 +309,7 @@ tasks.register<Test>("test-bgd-pg-aurora") {
296309
systemProperty("exclude-multi-az-cluster", "true")
297310
systemProperty("exclude-multi-az-instance", "true")
298311
systemProperty("exclude-limitless", "true")
312+
systemProperty("exclude-race", "true")
299313
}
300314
}
301315

@@ -311,6 +325,7 @@ tasks.register<Test>("test-bgd-pg-multiaz") {
311325
systemProperty("exclude-multi-az-cluster", "true")
312326
systemProperty("exclude-multi-az-instance", "false")
313327
systemProperty("exclude-limitless", "true")
328+
systemProperty("exclude-race", "true")
314329
}
315330
}
316331

@@ -327,6 +342,40 @@ tasks.register<Test>("test-aurora-limitless-postgres") {
327342
systemProperty("exclude-bg", "true")
328343
systemProperty("exclude-limitless", "false")
329344
systemProperty("limitless-only", "true")
345+
systemProperty("exclude-race", "true")
346+
}
347+
}
348+
349+
// TODO: change these filters
350+
tasks.register<Test>("test-aurora-pg-race") {
351+
group = "verification"
352+
filter.includeTestsMatching("integration.host.TestRunner.runTests")
353+
doFirst {
354+
systemProperty("exclude-docker", "true")
355+
systemProperty("exclude-performance", "true")
356+
systemProperty("exclude-failover", "true")
357+
systemProperty("exclude-multi-az", "true")
358+
systemProperty("exclude-mysql-driver", "true")
359+
systemProperty("exclude-mysql-engine", "true")
360+
systemProperty("exclude-bg", "true")
361+
systemProperty("exclude-limitless", "true")
362+
systemProperty("exclude-race", "false")
363+
}
364+
}
365+
366+
tasks.register<Test>("test-aurora-mysql-race") {
367+
group = "verification"
368+
filter.includeTestsMatching("integration.host.TestRunner.runTests")
369+
doFirst {
370+
systemProperty("exclude-docker", "true")
371+
systemProperty("exclude-performance", "true")
372+
systemProperty("exclude-failover", "true")
373+
systemProperty("exclude-multi-az", "true")
374+
systemProperty("exclude-mysql-driver", "true")
375+
systemProperty("exclude-mysql-engine", "true")
376+
systemProperty("exclude-bg", "true")
377+
systemProperty("exclude-limitless", "true")
378+
systemProperty("exclude-race", "false")
330379
}
331380
}
332381

@@ -337,6 +386,7 @@ tasks.register<Test>("debug-all-environments") {
337386
filter.includeTestsMatching("integration.host.TestRunner.debugTests")
338387
doFirst {
339388
systemProperty("exclude-performance", "true")
389+
systemProperty("exclude-race", "true")
340390
}
341391
}
342392

@@ -350,6 +400,7 @@ tasks.register<Test>("debug-docker") {
350400
systemProperty("exclude-multi-az-instance", "true")
351401
systemProperty("exclude-bg", "true")
352402
systemProperty("exclude-limitless", "true")
403+
systemProperty("exclude-race", "true")
353404
}
354405
}
355406

@@ -363,6 +414,7 @@ tasks.register<Test>("debug-aurora") {
363414
systemProperty("exclude-multi-az-instance", "true")
364415
systemProperty("exclude-bg", "true")
365416
systemProperty("exclude-limitless", "true")
417+
systemProperty("exclude-race", "true")
366418
}
367419
}
368420

@@ -378,6 +430,7 @@ tasks.register<Test>("debug-aurora-postgres") {
378430
systemProperty("exclude-multi-az-instance", "true")
379431
systemProperty("exclude-bg", "true")
380432
systemProperty("exclude-limitless", "true")
433+
systemProperty("exclude-race", "true")
381434
}
382435
}
383436

@@ -393,6 +446,7 @@ tasks.register<Test>("debug-aurora-mysql") {
393446
systemProperty("exclude-multi-az-instance", "true")
394447
systemProperty("exclude-bg", "true")
395448
systemProperty("exclude-limitless", "true")
449+
systemProperty("exclude-race", "true")
396450
}
397451
}
398452

@@ -407,6 +461,7 @@ tasks.register<Test>("debug-aurora-pg-performance") {
407461
systemProperty("exclude-multi-az-instance", "true")
408462
systemProperty("exclude-bg", "true")
409463
systemProperty("exclude-limitless", "true")
464+
systemProperty("exclude-race", "true")
410465
}
411466
}
412467

@@ -421,6 +476,7 @@ tasks.register<Test>("debug-aurora-mysql-performance") {
421476
systemProperty("exclude-multi-az-instance", "true")
422477
systemProperty("exclude-bg", "true")
423478
systemProperty("exclude-limitless", "true")
479+
systemProperty("exclude-race", "true")
424480
}
425481
}
426482

@@ -435,6 +491,7 @@ tasks.register<Test>("debug-multi-az-mysql") {
435491
systemProperty("exclude-aurora", "true")
436492
systemProperty("exclude-bg", "true")
437493
systemProperty("exclude-limitless", "true")
494+
systemProperty("exclude-race", "true")
438495
}
439496
}
440497

@@ -449,6 +506,7 @@ tasks.register<Test>("debug-multi-az-postgres") {
449506
systemProperty("exclude-aurora", "true")
450507
systemProperty("exclude-bg", "true")
451508
systemProperty("exclude-limitless", "true")
509+
systemProperty("exclude-race", "true")
452510
}
453511
}
454512

@@ -463,6 +521,7 @@ tasks.register<Test>("debug-autoscaling") {
463521
systemProperty("exclude-bg", "true")
464522
systemProperty("exclude-limitless", "true")
465523
systemProperty("test-autoscaling", "true")
524+
systemProperty("exclude-race", "true")
466525
}
467526
}
468527

@@ -479,6 +538,7 @@ tasks.register<Test>("debug-aurora-limitless-postgres") {
479538
systemProperty("exclude-bg", "true")
480539
systemProperty("exclude-limitless", "false")
481540
systemProperty("limitless-only", "true")
541+
systemProperty("exclude-race", "true")
482542
}
483543
}
484544

@@ -493,5 +553,6 @@ tasks.register<Test>("debug-bgd-mysql-aurora") {
493553
systemProperty("exclude-multi-az-cluster", "true")
494554
systemProperty("exclude-multi-az-instance", "true")
495555
systemProperty("exclude-limitless", "true")
556+
systemProperty("exclude-race", "true")
496557
}
497558
}

.test/test_framework/host/src/test/java/integration/host/TestEnvironmentConfig.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,8 @@ private static String getEnvironmentInfoAsString(TestEnvironmentConfig env) {
12541254
public void runTests() throws IOException, InterruptedException {
12551255
final ContainerHelper containerHelper = new ContainerHelper();
12561256
boolean isPerformanceTest = info.getRequest().getFeatures().contains(TestEnvironmentFeatures.PERFORMANCE);
1257-
containerHelper.runTest(this.testContainer, isPerformanceTest);
1257+
boolean isRaceTest = info.getRequest().getFeatures().contains(TestEnvironmentFeatures.RACE);
1258+
containerHelper.runTest(this.testContainer, isPerformanceTest, isRaceTest);
12581259
}
12591260

12601261
public void debugTests() throws IOException, InterruptedException {

.test/test_framework/host/src/test/java/integration/host/TestEnvironmentFeatures.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public enum TestEnvironmentFeatures {
2424
NETWORK_OUTAGES_ENABLED,
2525
AWS_CREDENTIALS_ENABLED,
2626
PERFORMANCE,
27+
RACE,
2728
RUN_AUTOSCALING_TESTS_ONLY,
2829
SKIP_MYSQL_DRIVER_TESTS,
2930
SKIP_PG_DRIVER_TESTS,

.test/test_framework/host/src/test/java/integration/host/TestEnvironmentProvider.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContex
5151
final boolean excludeLimitless = Boolean.parseBoolean(System.getProperty("exclude-limitless", "true"));
5252
final boolean excludePerformance =
5353
Boolean.parseBoolean(System.getProperty("exclude-performance", "false"));
54+
final boolean excludeRace =
55+
Boolean.parseBoolean(System.getProperty("exclude-race", "false"));
5456
final boolean excludeMysqlEngine =
5557
Boolean.parseBoolean(System.getProperty("exclude-mysql-engine", "false"));
5658
final boolean excludeMysqlDriver =
@@ -149,6 +151,7 @@ public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContex
149151
: TestEnvironmentFeatures.IAM,
150152
excludeSecretsManager ? null : TestEnvironmentFeatures.SECRETS_MANAGER,
151153
excludePerformance ? null : TestEnvironmentFeatures.PERFORMANCE,
154+
excludeRace ? null : TestEnvironmentFeatures.RACE,
152155
excludeMysqlDriver ? TestEnvironmentFeatures.SKIP_MYSQL_DRIVER_TESTS : null,
153156
excludePgDriver ? TestEnvironmentFeatures.SKIP_PG_DRIVER_TESTS : null,
154157
testAutoscalingOnly ? TestEnvironmentFeatures.RUN_AUTOSCALING_TESTS_ONLY : null,

.test/test_framework/host/src/test/java/integration/host/util/ContainerHelper.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public Long runCmdInDirectory(GenericContainer<?> container, String workingDirec
7979
return exitCode;
8080
}
8181

82-
public void runTest(GenericContainer<?> container, boolean isPerformanceTest)
82+
public void runTest(GenericContainer<?> container, boolean isPerformanceTest, boolean isRaceTest)
8383
throws IOException, InterruptedException {
8484
System.out.println("==== Container console feed ==== >>>>");
8585
Consumer<OutputFrame> consumer = new ConsoleConsumer(true);
@@ -98,6 +98,13 @@ public void runTest(GenericContainer<?> container, boolean isPerformanceTest)
9898
Long exitCode;
9999
if (isPerformanceTest) {
100100
exitCode = execInContainer(container, "/app/.test/", consumer, "go", "test", "-timeout", timeout, PERFORMANCE_TEST_TAG, "-run", PERFORMANCE_TEST_FILTER, "-v", "./test_framework/container/tests...");
101+
} else if (isRaceTest) {
102+
if (filter != null) {
103+
exitCode = execInContainer(container, "/app/.test/", consumer, "go", "test", "-race", "-timeout", timeout, "-v", "./test_framework/container/tests/stress_test.go", "-run", filter);
104+
} else {
105+
// Run all tests located in aws-advanced-go-wrapper/.test/test_framework/container.
106+
exitCode = execInContainer(container, "/app/.test/", consumer, "go", "test", "-race", "-timeout", timeout, "-v", "./test_framework/container/tests/stress_test.go");
107+
}
101108
} else if (filter != null) {
102109
exitCode = execInContainer(container, "/app/.test/", consumer, "go", "test", "-timeout", timeout, "-v", "./test_framework/container/tests...", "-run", filter);
103110
} else {

0 commit comments

Comments
 (0)