Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/code_quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ jobs:
uses: JetBrains/[email protected]
with:
use-caches: false
upload-result: true
3 changes: 2 additions & 1 deletion .github/workflows/run-integration-tests-default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
push:
branches:
- main
- fix/multiaz-cluster-creation

permissions:
id-token: write # This is required for requesting the JWT
Expand All @@ -17,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
dbEngine: [ "mysql-aurora", "mysql-multi-az", "pg-aurora", "pg-multi-az" ]
dbEngine: [ "mysql-multi-az", "pg-multi-az" ]
steps:
- name: 'Clone repository'
uses: actions/checkout@v4
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/run-integration-tests-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
push:
branches:
- main
- fix/multiaz-cluster-creation

permissions:
id-token: write # This is required for requesting the JWT
Expand All @@ -17,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
dbEngine: [ "mysql-aurora", "mysql-multi-az", "pg-aurora", "pg-multi-az" ]
dbEngine: [ "mysql-multi-az","pg-multi-az" ]
steps:
- name: 'Clone repository'
uses: actions/checkout@v4
Expand Down
47 changes: 35 additions & 12 deletions wrapper/src/test/java/integration/util/AuroraTestUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,11 @@
import software.amazon.awssdk.services.rds.model.DescribeDbEngineVersionsRequest;
import software.amazon.awssdk.services.rds.model.DescribeDbEngineVersionsResponse;
import software.amazon.awssdk.services.rds.model.DescribeDbInstancesResponse;
import software.amazon.awssdk.services.rds.model.DescribeOrderableDbInstanceOptionsResponse;
import software.amazon.awssdk.services.rds.model.FailoverDbClusterResponse;
import software.amazon.awssdk.services.rds.model.Filter;
import software.amazon.awssdk.services.rds.model.OrderableDBInstanceOption;
import software.amazon.awssdk.services.rds.model.RdsException;
import software.amazon.awssdk.services.rds.model.RebootDbClusterResponse;
import software.amazon.awssdk.services.rds.model.RebootDbInstanceResponse;
import software.amazon.awssdk.services.rds.model.Tag;
Expand All @@ -114,8 +117,6 @@ public class AuroraTestUtility {
private static final Logger LOGGER = Logger.getLogger(AuroraTestUtility.class.getName());
private static final String DUPLICATE_IP_ERROR_CODE = "InvalidPermission.Duplicate";
private static final String DEFAULT_SECURITY_GROUP = "default";
private static final String DEFAULT_STORAGE_TYPE = "gp3";
private static final int DEFAULT_IOPS = 64000;
private static final int MULTI_AZ_SIZE = 3;
private static final Random rand = new Random();

Expand Down Expand Up @@ -234,7 +235,7 @@ public void createCluster(
}

createMultiAzCluster(
username, password, dbName, identifier, region, engine, instanceClass, version);
username, password, dbName, identifier, region, engine, version);
break;
default:
throw new UnsupportedOperationException(deployment.toString());
Expand Down Expand Up @@ -330,8 +331,6 @@ public void createAuroraCluster(
* @param region the region that the cluster should be created in
* @param engine the engine to use, refer to
* <a href="https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/rds/model/CreateDbClusterRequest.Builder.html#engine(java.lang.String)">CreateDbClusterRequest.engine</a>
* @param instanceClass the instance class, refer to
* <a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.DBInstanceClass.Support.html">Supported instance classes</a>
* @param version the database engine's version
* @throws InterruptedException when clusters have not started after 30 minutes
*/
Expand All @@ -341,9 +340,10 @@ public void createMultiAzCluster(String username,
String identifier,
String region,
String engine,
String instanceClass,
String version)
throws InterruptedException {

final List<OrderableDBInstanceOption> options = getAvailableDBInstances(engine, version);
final Tag testRunnerTag = Tag.builder().key("env").value("test-runner").build();
CreateDbClusterRequest.Builder clusterBuilder =
CreateDbClusterRequest.builder()
Expand All @@ -360,13 +360,27 @@ public void createMultiAzCluster(String username,
.storageEncrypted(true)
.tags(testRunnerTag);

clusterBuilder =
clusterBuilder.allocatedStorage(400)
.dbClusterInstanceClass(instanceClass)
.storageType(DEFAULT_STORAGE_TYPE)
.iops(DEFAULT_IOPS);
boolean buildSuccess = false;
for (OrderableDBInstanceOption option : options) {
try {
clusterBuilder =
clusterBuilder.allocatedStorage(option.maxStorageSize())
.dbClusterInstanceClass(option.dbInstanceClass())
.storageType(option.storageType());

rdsClient.createDBCluster(clusterBuilder.build());
rdsClient.createDBCluster(clusterBuilder.build());
buildSuccess = true;
break;
} catch (RdsException e) {
LOGGER.finest("Multi-AZ DB Cluster creation process failed: " + e.getMessage());
// RDS exception will get thrown if the instance class doesn't Multi-AZ DB clusters.
}
}

if (!buildSuccess) {
throw new InterruptedException(
"Unable to find compatible instance classes for the specified MultiAZ cluster engine that has at least 3 availabile zones.");
}

// For multi-AZ deployments, the cluster instances are created automatically. Wait for all instances to be up.
final RdsWaiter waiter = rdsClient.waiter();
Expand All @@ -384,6 +398,15 @@ public void createMultiAzCluster(String username,
}
}

private List<OrderableDBInstanceOption> getAvailableDBInstances(String engine, String version) {
return rdsClient
.describeOrderableDBInstanceOptions((builder) -> builder.engineVersion(version).engine(engine))
.orderableDBInstanceOptions()
.stream()
.filter(o -> !o.supportsIops() && o.availabilityZones().size() >= 3)
.collect(Collectors.toList());
}

/**
* Creates an RDS instance under the current cluster and waits until it is up.
*
Expand Down
Loading