Skip to content

Commit

Permalink
clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonli-improving committed Mar 1, 2024
1 parent 90a4246 commit 0237dc7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@
TestEnvironmentFeatures.RUN_AUTOSCALING_TESTS_ONLY})
public class TopologyQueryTests {
private static final Logger LOGGER = Logger.getLogger(TopologyQueryTests.class.getName());
private AuroraTestUtility util = new AuroraTestUtility();

@TestTemplate
@EnableOnDatabaseEngineDeployment(DatabaseEngineDeployment.AURORA)
@ExtendWith(TestDriverProvider.class)
public void auroraTestTypes(TestDriver testDriver) throws SQLException {
public void testAuroraTypes(TestDriver testDriver) throws SQLException {
LOGGER.info(testDriver.toString());
List<String> expectedTypes;

Expand Down Expand Up @@ -134,7 +135,7 @@ public void auroraTestTypes(TestDriver testDriver) throws SQLException {
@ExtendWith(TestDriverProvider.class)
@EnableOnDatabaseEngineDeployment(DatabaseEngineDeployment.AURORA)
@EnableOnNumOfInstances(min = 2)
public void auroraTestTimestamp(TestDriver testDriver) throws SQLException, ParseException {
public void testAuroraTimestamp(TestDriver testDriver) throws SQLException, ParseException {
LOGGER.info(testDriver.toString());

final Properties props = ConnectionStringHelper.getDefaultPropertiesWithNoPlugins();
Expand All @@ -159,6 +160,7 @@ public void auroraTestTimestamp(TestDriver testDriver) throws SQLException, Pars
TestEnvironment.getCurrent().getInfo().getDatabaseInfo().getDefaultDbName());
LOGGER.finest("Connecting to " + url);

// Update cluster to get non-null timestamp
String dbInstanceIdentifier = TestEnvironment.getCurrent().getInfo()
.getDatabaseInfo()
.getInstances()
Expand All @@ -171,7 +173,8 @@ public void auroraTestTimestamp(TestDriver testDriver) throws SQLException, Pars
RdsClient client = RdsClient.builder()
.region(region)
.build();
AuroraTestUtility.updateInstance(client, dbInstanceIdentifier);
util.updateInstanceCertificateIdentifier(
dbInstanceIdentifier, "rds-ca-rsa4096-g1");
client.close();

String query = null;
Expand All @@ -192,7 +195,6 @@ public void auroraTestTimestamp(TestDriver testDriver) throws SQLException, Pars
ResultSet rs = stmt.getResultSet();

Date date = null;
// Skip the first row, empty timestamp
while (rs.next()) {
if (rs.getString(5) != null) {
date = format.parse(rs.getString(5));
Expand All @@ -209,7 +211,7 @@ public void auroraTestTimestamp(TestDriver testDriver) throws SQLException, Pars
@EnableOnDatabaseEngineDeployment(DatabaseEngineDeployment.RDS)
@Disabled
// TODO: Disabled due to RDS integration tests not being supported yet
public void rdsTestTypes(TestDriver testDriver) throws SQLException {
public void testRdsTypes(TestDriver testDriver) throws SQLException {
LOGGER.info(testDriver.toString());

final Properties props = ConnectionStringHelper.getDefaultPropertiesWithNoPlugins();
Expand Down Expand Up @@ -245,7 +247,7 @@ public void rdsTestTypes(TestDriver testDriver) throws SQLException {
} else {
query = RdsMultiAzDbClusterMysqlDialect.TOPOLOGY_QUERY;
expectedTypes = Arrays.asList(
"INT",
"VARCHAR",
"VARCHAR",
"INT"
);
Expand Down
7 changes: 3 additions & 4 deletions wrapper/src/test/java/integration/util/AuroraTestUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
import software.amazon.awssdk.services.rds.model.FailoverDbClusterResponse;
import software.amazon.awssdk.services.rds.model.Filter;
import software.amazon.awssdk.services.rds.model.ModifyDbInstanceRequest;
import software.amazon.awssdk.services.rds.model.ModifyDbInstanceResponse;
import software.amazon.awssdk.services.rds.model.RdsException;
import software.amazon.awssdk.services.rds.model.Tag;
import software.amazon.awssdk.services.rds.waiters.RdsWaiter;
Expand Down Expand Up @@ -927,15 +926,15 @@ public void addAuroraAwsIamUser(
}
}

public static void updateInstance(RdsClient client, String dbInstanceIdentifier) {
public void updateInstanceCertificateIdentifier(String dbInstanceIdentifier, String certificateIdentifier) {
try {
ModifyDbInstanceRequest modifyDbInstanceRequest = ModifyDbInstanceRequest.builder()
.dbInstanceIdentifier(dbInstanceIdentifier)
.publiclyAccessible(true)
.applyImmediately(true)
.caCertificateIdentifier("rds-ca-rsa4096-g1")
.caCertificateIdentifier(certificateIdentifier)
.build();
client.modifyDBInstance(modifyDbInstanceRequest);
rdsClient.modifyDBInstance(modifyDbInstanceRequest);
} catch (RdsException e) {
LOGGER.finer(e.getLocalizedMessage());
}
Expand Down

0 comments on commit 0237dc7

Please sign in to comment.