use of com.amazonaws.services.rds.model.DescribeDBInstancesRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class MySqlDatabaseSetup method waitForDatabase.
/**
* Wait for a database to be available
* @param stackInstance
*/
public DBInstance waitForDatabase(DBInstance stackInstance) throws InterruptedException {
String status = null;
DBInstance instance = null;
// Try to minimize risk of bouncing available status
boolean available = false;
for (int i = 0; i < 10; i++) {
sleeper.sleep(30000);
DescribeDBInstancesResult result = client.describeDBInstances(new DescribeDBInstancesRequest().withDBInstanceIdentifier(stackInstance.getDBInstanceIdentifier()));
if ((result != null) && (result.getDBInstances() != null) && (result.getDBInstances().size() >= 1)) {
instance = result.getDBInstances().get(0);
status = instance.getDBInstanceStatus();
log.info(String.format("Waiting for database: instance: %1$s status: %2$s ", stackInstance.getDBInstanceIdentifier(), status));
if (available = "available".equals(status.toLowerCase())) {
break;
}
}
}
if (available) {
return instance;
} else {
return null;
}
}
use of com.amazonaws.services.rds.model.DescribeDBInstancesRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class MySqlDatabaseSetupTest method testbuildStackTableDBInstanceDescribeDBInstanceRequest.
@Test
public void testbuildStackTableDBInstanceDescribeDBInstanceRequest() {
int numTableInstances = Integer.parseInt(config.getNumberTableInstances());
for (int i = 0; i < numTableInstances; i++) {
DescribeDBInstancesRequest expectedReq = new DescribeDBInstancesRequest().withDBInstanceIdentifier(config.getStackTableDBInstanceDatabaseIdentifier(i));
DescribeDBInstancesRequest req = databaseSetup.buildStackTableDBInstanceDescribeDBInstanceRequest(i);
assertEquals(expectedReq, req);
}
}
use of com.amazonaws.services.rds.model.DescribeDBInstancesRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class MySqlDatabaseSetupTest method testbuildIdGeneratorDescribeDBInstanceRequest.
@Test
public void testbuildIdGeneratorDescribeDBInstanceRequest() {
DescribeDBInstancesRequest expectedReq = new DescribeDBInstancesRequest().withDBInstanceIdentifier(config.getIdGeneratorDatabaseIdentifier());
DescribeDBInstancesRequest req = databaseSetup.buildIdGeneratorDescribeDBInstanceRequest();
assertEquals(expectedReq, req);
}
use of com.amazonaws.services.rds.model.DescribeDBInstancesRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class MySqlDatabaseSetupTest method testWaitForDatabaseAvailable.
@Test
public void testWaitForDatabaseAvailable() throws Exception {
when(mockDbInstance.getDBInstanceStatus()).thenReturn("available");
when(mockDbInstance.getDBInstanceIdentifier()).thenReturn("dbInstanceId");
List<DBInstance> expectedDBInstances = Arrays.asList(mockDbInstance);
when(mockDBInstancesResult.getDBInstances()).thenReturn(expectedDBInstances);
ArgumentCaptor<DescribeDBInstancesRequest> captor = new ArgumentCaptor<>();
when(mockClient.describeDBInstances(captor.capture())).thenReturn(mockDBInstancesResult);
DBInstance instance = databaseSetup.waitForDatabase(mockDbInstance);
DescribeDBInstancesRequest actualRequest = captor.getValue();
assertEquals(mockDbInstance.getDBInstanceIdentifier(), actualRequest.getDBInstanceIdentifier());
assertNotNull(instance);
}
Aggregations