use of org.sagebionetworks.stack.config.InputConfiguration in project Synapse-Stack-Builder by Sage-Bionetworks.
the class DatabaseParameterGroupTest method before.
@Before
public void before() throws IOException {
mockClient = factory.createRDSClient();
inputProperties = TestHelper.createInputProperties("dev");
config = new InputConfiguration(inputProperties);
resources = new GeneratedResources();
// Inject the dependencies.
databaseParamGroup = new DatabaseParameterGroup(factory, config, resources);
}
use of org.sagebionetworks.stack.config.InputConfiguration in project Synapse-Stack-Builder by Sage-Bionetworks.
the class BuildStackMainTest method before.
@Before
public void before() throws IOException {
inputProps = TestHelper.createInputProperties("dev");
InputConfiguration config = TestHelper.createTestConfig("dev");
defaultProps = TestHelper.createDefaultProperties();
clientFactory = new MockAmazonClientFactory();
AmazonS3Client mockS3Client = clientFactory.createS3Client();
AmazonEC2Client mockEC2Client = clientFactory.createEC2Client();
AmazonSNSClient mockSNSnsClient = clientFactory.createSNSClient();
AmazonRDSClient mockRdsClient = clientFactory.createRDSClient();
// Write the default properties.
when(mockS3Client.getObject(any(GetObjectRequest.class), any(File.class))).thenAnswer(new Answer<ObjectMetadata>() {
public ObjectMetadata answer(InvocationOnMock invocation) throws Throwable {
// Write the property file
File file = (File) invocation.getArguments()[1];
FileWriter writer = new FileWriter(file);
try {
defaultProps.store(writer, "test generated");
} finally {
writer.close();
}
return new ObjectMetadata();
}
});
// Return a valid EC2 security group.
DescribeSecurityGroupsRequest dsgr = new DescribeSecurityGroupsRequest().withGroupNames(config.getElasticSecurityGroupName());
when(mockEC2Client.describeSecurityGroups(dsgr)).thenReturn(new DescribeSecurityGroupsResult().withSecurityGroups(new SecurityGroup().withGroupName(config.getElasticSecurityGroupName())));
// Return a valid topic
String topicArn = "some:arn";
when(mockSNSnsClient.createTopic(new CreateTopicRequest(config.getRDSAlertTopicName()))).thenReturn(new CreateTopicResult().withTopicArn(topicArn));
when(mockSNSnsClient.listSubscriptionsByTopic(new ListSubscriptionsByTopicRequest(topicArn))).thenReturn(new ListSubscriptionsByTopicResult().withSubscriptions(new Subscription()));
// return a valid group
when(mockRdsClient.describeDBParameterGroups(new DescribeDBParameterGroupsRequest().withDBParameterGroupName(config.getDatabaseParameterGroupName()))).thenReturn(new DescribeDBParameterGroupsResult().withDBParameterGroups(new DBParameterGroup().withDBParameterGroupName(config.getDatabaseParameterGroupName())));
when(mockRdsClient.describeDBParameters(new DescribeDBParametersRequest().withDBParameterGroupName(config.getDatabaseParameterGroupName()))).thenReturn(new DescribeDBParametersResult().withParameters(new Parameter().withParameterName(Constants.DB_PARAM_KEY_SLOW_QUERY_LOG)).withParameters(new Parameter().withParameterName(Constants.DB_PARAM_KEY_LONG_QUERY_TIME)));
}
use of org.sagebionetworks.stack.config.InputConfiguration in project Synapse-Stack-Builder by Sage-Bionetworks.
the class TestHelper method createTestConfig.
/**
* Create a test Config.
* @return
* @throws IOException
*/
public static InputConfiguration createTestConfig(String stack) throws IOException {
Properties inputProperties = createInputProperties(stack);
InputConfiguration config = new InputConfiguration(inputProperties);
Properties defaults = createDefaultProperties();
config.addPropertiesWithPlaintext(defaults);
// config.setSSLCertificateARN("portal", "ssl:arn:123:456");
return config;
}
use of org.sagebionetworks.stack.config.InputConfiguration in project Synapse-Stack-Builder by Sage-Bionetworks.
the class TestHelper method createRoute53TestConfig.
public static InputConfiguration createRoute53TestConfig(String stack) throws IOException {
Properties inputProperties = createInputProperties(stack);
InputConfiguration config = new InputConfiguration(inputProperties);
Properties defaultProperties = createDefaultProperties();
Map<String, String> cnameProps = getSvcCNAMEsProps(stack, Arrays.asList(Constants.PREFIX_PORTAL, Constants.PREFIX_REPO, Constants.PREFIX_WORKERS));
defaultProperties.putAll(cnameProps);
defaultProperties.put("stack.subdomain", stack + ".sagebase.org");
config.addPropertiesWithPlaintext(defaultProperties);
return config;
}
use of org.sagebionetworks.stack.config.InputConfiguration in project Synapse-Stack-Builder by Sage-Bionetworks.
the class BuildStackMain method buildStack.
/**
* @param pathConfig
* @throws FileNotFoundException
* @throws IOException
*/
public static GeneratedResources buildStack(Properties inputProps, AmazonClientFactory factory, Sleeper sleeper) throws FileNotFoundException, IOException, InterruptedException {
// First load the configuration properties.
InputConfiguration config = new InputConfiguration(inputProps);
// Set the credentials
factory.setCredentials(config.getAWSCredentials());
// Load the default properties used for this stack
Properties defaultStackProperties = new StackDefaults(factory.createS3Client(), config).loadStackDefaultsFromS3();
// Add the default properties to the config
// Note: This is where all encrypted properties are also added.
config.addPropertiesWithPlaintext(defaultStackProperties);
// Collect all of the resources generated by this build
GeneratedResources resources = new GeneratedResources();
// Since the search index can take time to setup, we buid it first.
new SearchIndexSetup(factory, config, resources, sleeper).setupResources();
// Setup the Route53 CNAMEs
new Route53Setup(factory, config, resources).setupResources();
// The first step is to setup the stack security
new EC2SecuritySetup(factory, config, resources).setupResources();
// Setup the notification topic.
new StackInstanceNotificationSetup(factory, config, resources).setupResources();
new EnvironmentInstancesNotificationSetup(factory, config, resources).setupResources();
// Setup the Database Parameter group
new DatabaseParameterGroup(factory, config, resources).setupResources();
// Setup all of the database security groups
new DatabaseSecuritySetup(factory, config, resources).setupResources();
// We are ready to create the database instances
new MySqlDatabaseSetup(factory, config, resources, sleeper).setupResources();
// Add all of the the alarms
new RdsAlarmSetup(factory, config, resources).setupResources();
// Create the configuration file and upload it S3
new StackConfigurationSetup(factory, config, resources).setupResources();
// Process the artifacts
new ArtifactProcessing(new DefaultHttpClient(), factory, config, resources).processArtifacts();
// Setup the SSL certificates
// new SSLSetup(factory, config, resources).setupResources();
// Gather ACM ARNs
new ACMSetup(factory, config, resources).setupResources();
// Setup all environments
new ElasticBeanstalkSetup(factory, config, resources).setupResources();
// Setup the alarm for unhealthy instances on load balancer
new ElbAlarmSetup(factory, config, resources, sleeper).setupResources();
// Return all of the generated objects
return resources;
}
Aggregations