Skip to content

Commit 6178402

Browse files
authored
chore: add manual workflow testing with codebuild (#973)
1 parent 5164f98 commit 6178402

12 files changed

+153
-58
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Run Aurora Integration Tests CodeBuild
2+
3+
on:
4+
workflow_dispatch:
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}
8+
cancel-in-progress: true
9+
10+
jobs:
11+
aurora-integration-tests:
12+
strategy:
13+
matrix:
14+
engine_version: ["latest"]
15+
environment: ["mysql", "pg"]
16+
runs-on: codebuild-jdbcWrapper-${{ github.run_id }}-${{ github.run_attempt }}
17+
environment: ${{ matrix.environment }}_integ
18+
steps:
19+
- name: 'Clone repository'
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 1
23+
- name: 'Set up JDK 8'
24+
uses: actions/setup-java@v4
25+
with:
26+
distribution: 'corretto'
27+
java-version: 8
28+
- name: 'Configure AWS credentials'
29+
uses: aws-actions/configure-aws-credentials@v4
30+
with:
31+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
32+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
33+
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
34+
- name: 'Set up temp AWS credentials'
35+
run: |
36+
creds=($(aws sts get-session-token \
37+
--duration-seconds 21600 \
38+
--query 'Credentials.[AccessKeyId, SecretAccessKey, SessionToken]' \
39+
--output text \
40+
| xargs));
41+
echo "::add-mask::${creds[0]}"
42+
echo "::add-mask::${creds[1]}"
43+
echo "::add-mask::${creds[2]}"
44+
echo "TEMP_AWS_ACCESS_KEY_ID=${creds[0]}" >> $GITHUB_ENV
45+
echo "TEMP_AWS_SECRET_ACCESS_KEY=${creds[1]}" >> $GITHUB_ENV
46+
echo "TEMP_AWS_SESSION_TOKEN=${creds[2]}" >> $GITHUB_ENV
47+
- name: Run integration tests
48+
run: |
49+
./gradlew --no-parallel --no-daemon test-all-${{ matrix.environment }}-aurora
50+
env:
51+
AURORA_CLUSTER_DOMAIN: ${{ secrets.DB_CONN_SUFFIX }}
52+
AURORA_DB_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
53+
AWS_ACCESS_KEY_ID: ${{ env.TEMP_AWS_ACCESS_KEY_ID }}
54+
AWS_SECRET_ACCESS_KEY: ${{ env.TEMP_AWS_SECRET_ACCESS_KEY }}
55+
AWS_SESSION_TOKEN: ${{ env.TEMP_AWS_SESSION_TOKEN }}
56+
RDS_ENDPOINT: ${{ secrets.RDS_ENDPOINT }}
57+
AURORA_MYSQL_DB_ENGINE_VERSION: "latest"
58+
AURORA_PG_ENGINE_VERSION: "latest"
59+
- name: 'Archive junit results ${{ matrix.engine_version }}'
60+
if: always()
61+
uses: actions/upload-artifact@v4
62+
with:
63+
name: junit-report-${{ matrix.engine_version }}
64+
path: ./wrapper/build/test-results
65+
retention-days: 5
66+
- name: 'Archive html summary report ${{ matrix.engine_version }}'
67+
if: always()
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: html-summary-report-${{ matrix.engine_version }}
71+
path: ./wrapper/build/report
72+
retention-days: 5

wrapper/src/test/java/integration/TestEnvironmentInfo.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class TestEnvironmentInfo {
2525
private String awsSessionToken;
2626

2727
private String auroraRegion;
28+
private String rdsEndpoint;
2829
private String auroraClusterName;
2930
private String iamUsername;
3031

@@ -79,6 +80,10 @@ public String getAuroraRegion() {
7980
return this.auroraRegion;
8081
}
8182

83+
public String getRdsEndpoint() {
84+
return this.rdsEndpoint;
85+
}
86+
8287
public String getAuroraClusterName() {
8388
return this.auroraClusterName;
8489
}
@@ -95,6 +100,10 @@ public void setAuroraRegion(String auroraRegion) {
95100
this.auroraRegion = auroraRegion;
96101
}
97102

103+
public void setRdsEndpoint(String rdsEndpoint) {
104+
this.rdsEndpoint = rdsEndpoint;
105+
}
106+
98107
public void setAuroraClusterName(String auroraClusterName) {
99108
this.auroraClusterName = auroraClusterName;
100109
}

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@ public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContex
7777
for (TestDriver testDriver : TestEnvironment.getCurrent().getAllowedTestDrivers()) {
7878
TestTemplateInvocationContext testTemplateInvocationContext =
7979
getEnvironment(context, testDriver);
80-
if (testTemplateInvocationContext != null) {
81-
resultContextList.add(testTemplateInvocationContext);
82-
}
80+
resultContextList.add(testTemplateInvocationContext);
8381
}
8482
return Arrays.stream(resultContextList.toArray(new TestTemplateInvocationContext[0]));
8583
}
@@ -146,7 +144,7 @@ public void beforeEach(ExtensionContext context) throws Exception {
146144
}
147145

148146
if (testRequest.getDatabaseEngineDeployment() == DatabaseEngineDeployment.AURORA) {
149-
AuroraTestUtility auroraUtil = new AuroraTestUtility(testInfo.getAuroraRegion());
147+
AuroraTestUtility auroraUtil = AuroraTestUtility.getUtility(testInfo);
150148
auroraUtil.waitUntilClusterHasRightState(testInfo.getAuroraClusterName());
151149

152150
boolean makeSureFirstInstanceWriter =
@@ -161,7 +159,7 @@ public void beforeEach(ExtensionContext context) throws Exception {
161159
// Wait up to 5min
162160
long startTimeNano = System.nanoTime();
163161
while ((instanceIDs.size() != testRequest.getNumOfInstances()
164-
|| instanceIDs.size() == 0
162+
|| instanceIDs.isEmpty()
165163
|| !auroraUtil.isDBInstanceWriter(instanceIDs.get(0)))
166164
&& TimeUnit.NANOSECONDS.toMinutes(System.nanoTime() - startTimeNano) < 5) {
167165

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import java.util.Set;
4444
import java.util.concurrent.TimeUnit;
4545
import java.util.logging.Logger;
46-
import org.testcontainers.shaded.org.apache.commons.lang3.NotImplementedException;
4746
import software.amazon.jdbc.util.StringUtils;
4847

4948
public class TestEnvironment {
@@ -260,7 +259,7 @@ public boolean isTestDriverAllowed(TestDriver testDriver) {
260259
disabledByFeature = features.contains(TestEnvironmentFeatures.SKIP_MARIADB_DRIVER_TESTS);
261260
break;
262261
default:
263-
throw new NotImplementedException(testDriver.toString());
262+
throw new UnsupportedOperationException(testDriver.toString());
264263
}
265264

266265
if (disabledByFeature || !driverCompatibleToDatabaseEngine) {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import static software.amazon.jdbc.plugin.failover.FailoverConnectionPlugin.FAILOVER_TIMEOUT_MS;
2727

2828
import integration.TestEnvironmentFeatures;
29+
import integration.TestEnvironmentInfo;
2930
import integration.container.ConnectionStringHelper;
3031
import integration.container.TestDriverProvider;
3132
import integration.container.TestEnvironment;
@@ -37,6 +38,7 @@
3738
import java.io.FileOutputStream;
3839
import java.io.IOException;
3940
import java.net.InetAddress;
41+
import java.net.URISyntaxException;
4042
import java.net.UnknownHostException;
4143
import java.sql.Connection;
4244
import java.sql.DriverManager;
@@ -97,8 +99,7 @@ public class AdvancedPerformanceTest {
9799

98100
private static final ConcurrentLinkedQueue<PerfStat> perfDataList = new ConcurrentLinkedQueue<>();
99101

100-
protected static final AuroraTestUtility auroraUtil =
101-
new AuroraTestUtility(TestEnvironment.getCurrent().getInfo().getAuroraRegion());
102+
protected static final AuroraTestUtility auroraUtil = AuroraTestUtility.getUtility();
102103

103104
private static void doWritePerfDataToFile(
104105
String fileName, ConcurrentLinkedQueue<PerfStat> dataList) throws IOException {

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import integration.DatabaseEngine;
2727
import integration.DriverHelper;
2828
import integration.TestEnvironmentFeatures;
29+
import integration.TestEnvironmentInfo;
2930
import integration.TestInstanceInfo;
3031
import integration.container.ConnectionStringHelper;
3132
import integration.container.ProxyHelper;
@@ -38,6 +39,7 @@
3839
import integration.container.condition.EnableOnTestFeature;
3940
import integration.container.condition.MakeSureFirstInstanceWriter;
4041
import integration.util.AuroraTestUtility;
42+
import java.net.URISyntaxException;
4143
import java.sql.Connection;
4244
import java.sql.DriverManager;
4345
import java.sql.ResultSet;
@@ -73,8 +75,8 @@ public class AuroraFailoverTest {
7375

7476
private static final Logger LOGGER = Logger.getLogger(AuroraFailoverTest.class.getName());
7577

76-
protected static final AuroraTestUtility auroraUtil =
77-
new AuroraTestUtility(TestEnvironment.getCurrent().getInfo().getAuroraRegion());
78+
protected static final AuroraTestUtility auroraUtil = AuroraTestUtility.getUtility();
79+
7880
protected static final int IS_VALID_TIMEOUT = 5;
7981

8082
protected String currentWriter;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import integration.container.condition.EnableOnTestFeature;
3737
import integration.container.condition.MakeSureFirstInstanceWriter;
3838
import integration.util.AuroraTestUtility;
39+
import java.net.URISyntaxException;
3940
import java.sql.Connection;
4041
import java.sql.DriverManager;
4142
import java.sql.SQLException;
@@ -62,8 +63,7 @@
6263
@EnableOnNumOfInstances(min = 5)
6364
@MakeSureFirstInstanceWriter
6465
public class AutoscalingTests {
65-
protected static final AuroraTestUtility auroraUtil =
66-
new AuroraTestUtility(TestEnvironment.getCurrent().getInfo().getAuroraRegion());
66+
protected static final AuroraTestUtility auroraUtil = AuroraTestUtility.getUtility();
6767

6868
protected static Properties getDefaultPropsNoPlugins() {
6969
final Properties props = ConnectionStringHelper.getDefaultProperties();

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ void test_TokenGenerators() {
280280
protected Properties initAwsIamProps(String user, String password) {
281281
final Properties props = ConnectionStringHelper.getDefaultProperties();
282282
props.setProperty(PropertyDefinition.PLUGINS.name, "iam");
283+
props.setProperty(
284+
IamAuthConnectionPlugin.IAM_REGION.name,
285+
TestEnvironment.getCurrent().getInfo().getAuroraRegion());
283286
props.setProperty(PropertyDefinition.USER.name, user);
284287
props.setProperty(PropertyDefinition.PASSWORD.name, password);
285288
DriverHelper.setTcpKeepAlive(TestEnvironment.getCurrent().getCurrentDriver(), props, false);

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import integration.container.condition.EnableOnTestFeature;
4848
import integration.container.condition.MakeSureFirstInstanceWriter;
4949
import integration.util.AuroraTestUtility;
50+
import java.net.URISyntaxException;
5051
import java.sql.Connection;
5152
import java.sql.DriverManager;
5253
import java.sql.ResultSet;
@@ -85,9 +86,7 @@
8586
TestEnvironmentFeatures.RUN_AUTOSCALING_TESTS_ONLY})
8687
@MakeSureFirstInstanceWriter
8788
public class ReadWriteSplittingTests {
88-
89-
protected static final AuroraTestUtility auroraUtil =
90-
new AuroraTestUtility(TestEnvironment.getCurrent().getInfo().getAuroraRegion());
89+
protected static final AuroraTestUtility auroraUtil = AuroraTestUtility.getUtility();
9190
private static final Logger LOGGER = Logger.getLogger(ReadWriteSplittingTests.class.getName());
9291

9392
protected static Properties getProxiedPropsWithFailover() {

wrapper/src/test/java/integration/host/TestEnvironment.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import integration.util.AuroraTestUtility;
3636
import integration.util.ContainerHelper;
3737
import java.io.IOException;
38+
import java.net.URISyntaxException;
3839
import java.net.UnknownHostException;
3940
import java.sql.SQLException;
4041
import java.util.ArrayList;
@@ -82,6 +83,7 @@ public class TestEnvironment implements AutoCloseable {
8283
private boolean reuseAuroraDbCluster;
8384
private String auroraClusterName; // "cluster-mysql"
8485
private String auroraClusterDomain; // "XYZ.us-west-2.rds.amazonaws.com"
86+
private String rdsEndpoint; // "https://rds-int.amazon.com"
8587

8688
private String awsAccessKeyId;
8789
private String awsSecretAccessKey;
@@ -103,7 +105,7 @@ private TestEnvironment(TestEnvironmentRequest request) {
103105
this.info.setRequest(request);
104106
}
105107

106-
public static TestEnvironment build(TestEnvironmentRequest request) throws IOException {
108+
public static TestEnvironment build(TestEnvironmentRequest request) throws IOException, URISyntaxException {
107109
LOGGER.finest("Building test env: " + request.getEnvPreCreateIndex());
108110
preCreateEnvironment(request.getEnvPreCreateIndex());
109111

@@ -155,7 +157,7 @@ public static TestEnvironment build(TestEnvironmentRequest request) throws IOExc
155157
return env;
156158
}
157159

158-
private static TestEnvironment createAuroraEnvironment(TestEnvironmentRequest request) {
160+
private static TestEnvironment createAuroraEnvironment(TestEnvironmentRequest request) throws URISyntaxException {
159161

160162
EnvPreCreateInfo preCreateInfo =
161163
TestEnvironmentProvider.preCreateInfos.get(request.getEnvPreCreateIndex());
@@ -302,7 +304,7 @@ private static void createDatabaseContainers(TestEnvironment env) {
302304
}
303305
}
304306

305-
private static void createAuroraDbCluster(TestEnvironment env) {
307+
private static void createAuroraDbCluster(TestEnvironment env) throws URISyntaxException {
306308

307309
switch (env.info.getRequest().getDatabaseInstances()) {
308310
case SINGLE_INSTANCE:
@@ -328,7 +330,7 @@ private static void createAuroraDbCluster(TestEnvironment env) {
328330
}
329331
}
330332

331-
private static void createAuroraDbCluster(TestEnvironment env, int numOfInstances) {
333+
private static void createAuroraDbCluster(TestEnvironment env, int numOfInstances) throws URISyntaxException {
332334

333335
env.info.setAuroraRegion(
334336
!StringUtils.isNullOrEmpty(config.auroraDbRegion)
@@ -340,6 +342,8 @@ private static void createAuroraDbCluster(TestEnvironment env, int numOfInstance
340342
&& Boolean.parseBoolean(config.reuseAuroraCluster);
341343
env.auroraClusterName = config.auroraClusterName; // "cluster-mysql"
342344
env.auroraClusterDomain = config.auroraClusterDomain; // "XYZ.us-west-2.rds.amazonaws.com"
345+
env.rdsEndpoint = config.rdsEndpoint; // "XYZ.us-west-2.rds.amazonaws.com"
346+
env.info.setRdsEndpoint(env.rdsEndpoint);
343347

344348
if (StringUtils.isNullOrEmpty(env.auroraClusterDomain)) {
345349
throw new RuntimeException("Environment variable AURORA_CLUSTER_DOMAIN is required.");
@@ -348,6 +352,7 @@ private static void createAuroraDbCluster(TestEnvironment env, int numOfInstance
348352
env.auroraUtil =
349353
new AuroraTestUtility(
350354
env.info.getAuroraRegion(),
355+
env.rdsEndpoint,
351356
env.awsAccessKeyId,
352357
env.awsSecretAccessKey,
353358
env.awsSessionToken);

0 commit comments

Comments
 (0)