use of com.amazonaws.services.rds.model.CreateDBInstanceRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class MySqlDatabaseSetupTest method testGetDefaultCreateDBInstanceRequest.
@Test
public void testGetDefaultCreateDBInstanceRequest() {
// There are the current expected defaults.
CreateDBInstanceRequest expected = new CreateDBInstanceRequest();
expected.setAllocatedStorage(new Integer(10));
expected.setDBInstanceClass(DATABASE_INSTANCE_CLASS_M1_SMALL);
expected.setEngine(DATABASE_ENGINE_MYSQL);
// expected.setAvailabilityZone(EC2_AVAILABILITY_ZONE_US_EAST_1D);
expected.setPreferredMaintenanceWindow(PREFERRED_DATABASE_MAINTENANCE_WINDOW_SUNDAY_NIGHT_PDT);
expected.setBackupRetentionPeriod(new Integer(7));
expected.setPreferredBackupWindow(PREFERRED_DATABASE_BACKUP_WINDOW_MIDNIGHT);
expected.setMultiAZ(false);
expected.setEngineVersion(DATABASE_ENGINE_MYSQL_VERSION);
expected.setAutoMinorVersionUpgrade(true);
expected.setLicenseModel(LICENSE_MODEL_GENERAL_PUBLIC);
CreateDBInstanceRequest request = MySqlDatabaseSetup.getDefaultCreateDBInstanceRequest();
assertEquals(expected, request);
}
use of com.amazonaws.services.rds.model.CreateDBInstanceRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class MySqlDatabaseSetupTest method testBuildStackInstancesCreateDBInstanceRequestNonProduction.
/**
* Test that we setup a non-production database correctly.
* @throws IOException
*/
@Test
public void testBuildStackInstancesCreateDBInstanceRequestNonProduction() throws IOException {
// Setup for development
setupDevelopmentConfig();
// Start with the defaults.
CreateDBInstanceRequest expected = MySqlDatabaseSetup.getDefaultCreateDBInstanceRequest();
// A development database must have Multi-AZ backup replication truned off!!!!
expected.setMultiAZ(false);
// The development database must be on a small.
expected.setDBInstanceClass(DATABASE_INSTANCE_CLASS_M1_SMALL);
expected.setDBName(config.getStackInstanceDatabaseSchema());
expected.setDBInstanceIdentifier(config.getStackInstanceDatabaseIdentifier());
expected.setAllocatedStorage(new Integer(10));
expected.setMasterUsername(config.getStackInstanceDatabaseMasterUser());
expected.setMasterUserPassword(config.getStackInstanceDatabaseMasterPasswordPlaintext());
expected.withDBSecurityGroups(config.getStackDatabaseSecurityGroupName());
expected.setDBParameterGroupName(config.getDatabaseParameterGroupName());
// Test against expected
CreateDBInstanceRequest request = databaseSetup.buildStackInstancesCreateDBInstanceRequest();
assertEquals(expected, request);
}
use of com.amazonaws.services.rds.model.CreateDBInstanceRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class MySqlDatabaseSetupTest method testBuildIdGeneratorCreateDBInstanceRequestProduction.
/**
* Test that we setup a production database as expected.
* @throws IOException
*/
@Test
public void testBuildIdGeneratorCreateDBInstanceRequestProduction() throws IOException {
setupProductionConfig();
// Start with the defaults
CreateDBInstanceRequest expected = MySqlDatabaseSetup.getDefaultCreateDBInstanceRequest();
expected.setDBName(config.getIdGeneratorDatabaseSchemaName());
expected.setDBInstanceIdentifier(config.getIdGeneratorDatabaseIdentifier());
expected.setAllocatedStorage(new Integer(5));
expected.setMasterUsername(config.getIdGeneratorDatabaseMasterUsername());
expected.setMasterUserPassword(config.getIdGeneratorDatabaseMasterPasswordPlaintext());
expected.withDBSecurityGroups(config.getIdGeneratorDatabaseSecurityGroupName());
expected.setDBParameterGroupName(config.getDatabaseParameterGroupName());
// In production the Multi-AZ must be turned on
expected.setMultiAZ(true);
// This needs to be a production configuration
CreateDBInstanceRequest request = databaseSetup.buildIdGeneratorCreateDBInstanceRequest();
assertEquals(expected, request);
}
use of com.amazonaws.services.rds.model.CreateDBInstanceRequest 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.CreateDBInstanceRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class MySqlDatabaseSetupTest method testCreateOrGetDatabaseInstanceDoesNotExist.
@Test
public void testCreateOrGetDatabaseInstanceDoesNotExist() {
// Amazon notifies us that a database instances does not exist by throwing DBInstanceNotFoundException
// with a describe methods. This should trigger a create.
String dbIdentifier = "id-123";
CreateDBInstanceRequest request = MySqlDatabaseSetup.getDefaultCreateDBInstanceRequest();
request.setDBInstanceIdentifier(dbIdentifier);
DescribeDBInstancesRequest describeRequest = new DescribeDBInstancesRequest().withDBInstanceIdentifier(dbIdentifier);
when(mockClient.describeDBInstances(describeRequest)).thenThrow(new DBInstanceNotFoundException("Does not exist"));
databaseSetup.createOrGetDatabaseInstance(request);
verify(mockClient, times(1)).createDBInstance(request);
}
Aggregations