use of com.amazonaws.services.rds.model.DBInstance in project Synapse-Stack-Builder by Sage-Bionetworks.
the class MySqlDatabaseSetupTest method testWaitForDatabaseNotAvailable.
@Test
public void testWaitForDatabaseNotAvailable() throws Exception {
when(mockDbInstance.getDBInstanceStatus()).thenReturn("busy");
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);
List<DescribeDBInstancesRequest> actualRequests = captor.getAllValues();
assertEquals(10, actualRequests.size());
assertNull(instance);
}
use of com.amazonaws.services.rds.model.DBInstance in project Synapse-Stack-Builder by Sage-Bionetworks.
the class MySqlDatabaseSetupTest method testCreateOrGetDatabaseInstanceDoesExist.
@Test
public void testCreateOrGetDatabaseInstanceDoesExist() {
// For this case the database already exists so it should not be created again.
String dbIdentifier = "id-123";
CreateDBInstanceRequest request = MySqlDatabaseSetup.getDefaultCreateDBInstanceRequest();
request.setDBInstanceIdentifier(dbIdentifier);
DescribeDBInstancesRequest describeRequest = new DescribeDBInstancesRequest().withDBInstanceIdentifier(dbIdentifier);
DBInstance instance = new DBInstance();
instance.setDBInstanceIdentifier(dbIdentifier);
DescribeDBInstancesResult describeResult = new DescribeDBInstancesResult();
describeResult.withDBInstances(instance);
when(mockClient.describeDBInstances(describeRequest)).thenReturn(describeResult);
DBInstance instanceResult = databaseSetup.createOrGetDatabaseInstance(request);
assertEquals(instance, instanceResult);
// Describe once
verify(mockClient, times(1)).describeDBInstances(describeRequest);
// Create should not be called this time.
verify(mockClient, times(0)).createDBInstance(request);
}
use of com.amazonaws.services.rds.model.DBInstance in project Synapse-Stack-Builder by Sage-Bionetworks.
the class MySqlDatabaseSetupTest method testDeleteDatabaseInstanceDoesNotExist.
@Test
public void testDeleteDatabaseInstanceDoesNotExist() {
// Should just be a no-op
DeleteDBInstanceRequest req = new DeleteDBInstanceRequest();
when(mockClient.deleteDBInstance(req)).thenThrow(new DBInstanceNotFoundException("Database instance does not exist"));
DBInstance inst = databaseSetup.deleteDatabaseInstance(req);
assertNull(inst);
}
use of com.amazonaws.services.rds.model.DBInstance in project Synapse-Stack-Builder by Sage-Bionetworks.
the class MySqlDatabaseSetupTest method testWaitForDatabaseBecomesAvailable.
@Test
public void testWaitForDatabaseBecomesAvailable() throws Exception {
when(mockDbInstance.getDBInstanceStatus()).thenReturn("busy", "busy", "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);
List<DescribeDBInstancesRequest> actualRequests = captor.getAllValues();
assertEquals(3, actualRequests.size());
assertNotNull(instance);
}
use of com.amazonaws.services.rds.model.DBInstance in project Synapse-Stack-Builder by Sage-Bionetworks.
the class TestHelper method createTestResources.
/**
* Create GeneratedResources that can be used for a test.
*
* @param config
* @return
*/
public static GeneratedResources createTestResources(InputConfiguration config) {
GeneratedResources resources = new GeneratedResources();
resources.setIdGeneratorDatabase(new DBInstance().withDBInstanceIdentifier(config.getIdGeneratorDatabaseIdentifier()).withEndpoint(new Endpoint().withAddress("id-gen-db.someplace.com")));
resources.setStackInstancesDatabase(new DBInstance().withDBInstanceIdentifier(config.getStackInstanceDatabaseIdentifier()).withEndpoint(new Endpoint().withAddress("stack-instance-db.someplace.com")));
resources.setSearchDomain(new DomainStatus().withSearchService(new ServiceEndpoint().withEndpoint("search-service.someplace.com")));
resources.getSearchDomain().setDocService(new ServiceEndpoint().withEndpoint("doc-service.someplace.com"));
resources.setSslCertificate(StackEnvironmentType.REPO, new ServerCertificateMetadata().withArn("ssl:arn:123"));
resources.setSslCertificate(StackEnvironmentType.WORKERS, new ServerCertificateMetadata().withArn("ssl:arn:123"));
resources.setSslCertificate(StackEnvironmentType.PORTAL, new ServerCertificateMetadata().withArn("ssl:arn:456"));
resources.setACMCertificateArn(StackEnvironmentType.PORTAL, "arn:aws:acm:us-east1:123456789012:certificate/12345678-1234-1234-1234-123456789012");
resources.setACMCertificateArn(StackEnvironmentType.REPO, "arn:aws:acm:us-east1:123456789012:certificate/12345678-1234-1234-1234-223456789012");
resources.setACMCertificateArn(StackEnvironmentType.WORKERS, "arn:aws:acm:us-east1:123456789012:certificate/12345678-1234-1234-1234-323456789012");
resources.setPortalApplicationVersion(new ApplicationVersionDescription().withVersionLabel(config.getVersionLabel(PREFIX_PORTAL)));
resources.setRepoApplicationVersion(new ApplicationVersionDescription().withVersionLabel(config.getVersionLabel(PREFIX_REPO)));
resources.setWorkersApplicationVersion(new ApplicationVersionDescription().withVersionLabel(config.getVersionLabel(PREFIX_WORKERS)));
resources.setStackKeyPair(new KeyPairInfo().withKeyName(config.getStackKeyPairName()));
// Add tables database instances
List<DBInstance> tablesInstances = new LinkedList<DBInstance>();
tablesInstances.add(new DBInstance().withEndpoint(new Endpoint().withAddress("tables.endpoint.one")));
tablesInstances.add(new DBInstance().withEndpoint(new Endpoint().withAddress("tables.endpoint.two")));
resources.setStackInstanceTablesDatabases(tablesInstances);
return resources;
}
Aggregations