Search in sources :

Example 6 with InputConfiguration

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);
}
Also used : GeneratedResources(org.sagebionetworks.stack.GeneratedResources) DatabaseParameterGroup(org.sagebionetworks.stack.DatabaseParameterGroup) InputConfiguration(org.sagebionetworks.stack.config.InputConfiguration) Before(org.junit.Before)

Example 7 with InputConfiguration

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)));
}
Also used : DescribeSecurityGroupsRequest(com.amazonaws.services.ec2.model.DescribeSecurityGroupsRequest) DescribeDBParameterGroupsResult(com.amazonaws.services.rds.model.DescribeDBParameterGroupsResult) FileWriter(java.io.FileWriter) AmazonSNSClient(com.amazonaws.services.sns.AmazonSNSClient) CreateTopicResult(com.amazonaws.services.sns.model.CreateTopicResult) DescribeDBParametersRequest(com.amazonaws.services.rds.model.DescribeDBParametersRequest) DescribeDBParameterGroupsRequest(com.amazonaws.services.rds.model.DescribeDBParameterGroupsRequest) DescribeSecurityGroupsResult(com.amazonaws.services.ec2.model.DescribeSecurityGroupsResult) Subscription(com.amazonaws.services.sns.model.Subscription) GetObjectRequest(com.amazonaws.services.s3.model.GetObjectRequest) AmazonEC2Client(com.amazonaws.services.ec2.AmazonEC2Client) DBParameterGroup(com.amazonaws.services.rds.model.DBParameterGroup) ListSubscriptionsByTopicRequest(com.amazonaws.services.sns.model.ListSubscriptionsByTopicRequest) DescribeDBParametersResult(com.amazonaws.services.rds.model.DescribeDBParametersResult) CreateTopicRequest(com.amazonaws.services.sns.model.CreateTopicRequest) MockAmazonClientFactory(org.sagebionetworks.factory.MockAmazonClientFactory) AmazonRDSClient(com.amazonaws.services.rds.AmazonRDSClient) SecurityGroup(com.amazonaws.services.ec2.model.SecurityGroup) InputConfiguration(org.sagebionetworks.stack.config.InputConfiguration) AmazonS3Client(com.amazonaws.services.s3.AmazonS3Client) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ListSubscriptionsByTopicResult(com.amazonaws.services.sns.model.ListSubscriptionsByTopicResult) Parameter(com.amazonaws.services.rds.model.Parameter) File(java.io.File) ObjectMetadata(com.amazonaws.services.s3.model.ObjectMetadata) Before(org.junit.Before)

Example 8 with InputConfiguration

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;
}
Also used : Properties(java.util.Properties) InputConfiguration(org.sagebionetworks.stack.config.InputConfiguration)

Example 9 with InputConfiguration

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;
}
Also used : Properties(java.util.Properties) InputConfiguration(org.sagebionetworks.stack.config.InputConfiguration)

Example 10 with InputConfiguration

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;
}
Also used : StackInstanceNotificationSetup(org.sagebionetworks.stack.notifications.StackInstanceNotificationSetup) ACMSetup(org.sagebionetworks.stack.ssl.ACMSetup) ElbAlarmSetup(org.sagebionetworks.stack.alarms.ElbAlarmSetup) Properties(java.util.Properties) InputConfiguration(org.sagebionetworks.stack.config.InputConfiguration) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) EnvironmentInstancesNotificationSetup(org.sagebionetworks.stack.notifications.EnvironmentInstancesNotificationSetup) RdsAlarmSetup(org.sagebionetworks.stack.alarms.RdsAlarmSetup)

Aggregations

InputConfiguration (org.sagebionetworks.stack.config.InputConfiguration)10 Properties (java.util.Properties)5 Test (org.junit.Test)5 Before (org.junit.Before)2 AWSCredentials (com.amazonaws.auth.AWSCredentials)1 AmazonEC2Client (com.amazonaws.services.ec2.AmazonEC2Client)1 DescribeSecurityGroupsRequest (com.amazonaws.services.ec2.model.DescribeSecurityGroupsRequest)1 DescribeSecurityGroupsResult (com.amazonaws.services.ec2.model.DescribeSecurityGroupsResult)1 SecurityGroup (com.amazonaws.services.ec2.model.SecurityGroup)1 AmazonRDSClient (com.amazonaws.services.rds.AmazonRDSClient)1 DBParameterGroup (com.amazonaws.services.rds.model.DBParameterGroup)1 DescribeDBParameterGroupsRequest (com.amazonaws.services.rds.model.DescribeDBParameterGroupsRequest)1 DescribeDBParameterGroupsResult (com.amazonaws.services.rds.model.DescribeDBParameterGroupsResult)1 DescribeDBParametersRequest (com.amazonaws.services.rds.model.DescribeDBParametersRequest)1 DescribeDBParametersResult (com.amazonaws.services.rds.model.DescribeDBParametersResult)1 Parameter (com.amazonaws.services.rds.model.Parameter)1 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)1 GetObjectRequest (com.amazonaws.services.s3.model.GetObjectRequest)1 ObjectMetadata (com.amazonaws.services.s3.model.ObjectMetadata)1 AmazonSNSClient (com.amazonaws.services.sns.AmazonSNSClient)1