Search in sources :

Example 6 with ConfigurationOptionSetting

use of com.amazonaws.services.elasticbeanstalk.model.ConfigurationOptionSetting in project Synapse-Stack-Builder by Sage-Bionetworks.

the class ElasticBeanstalkSetupTest method testAreSettingsEquals.

@Test
public void testAreSettingsEquals() {
    List<ConfigurationOptionSetting> one = setup.getAllElasticBeanstalkOptions(StackEnvironmentType.REPO);
    List<ConfigurationOptionSetting> two = setup.getAllElasticBeanstalkOptions(StackEnvironmentType.REPO);
    // Add some setting to the second that are not in the first.
    two.add(new ConfigurationOptionSetting("ns", "os", "123"));
    Collections.shuffle(one);
    Collections.shuffle(two);
    assertTrue(ElasticBeanstalkSetup.areExpectedSettingsEquals(one, two));
    // Now make a change
    one = setup.getAllElasticBeanstalkOptions(StackEnvironmentType.REPO);
    two = setup.getAllElasticBeanstalkOptions(StackEnvironmentType.REPO);
    two.get(0).setValue("some crazy value");
    Collections.shuffle(one);
    Collections.shuffle(two);
    assertFalse(ElasticBeanstalkSetup.areExpectedSettingsEquals(one, two));
}
Also used : ConfigurationOptionSetting(com.amazonaws.services.elasticbeanstalk.model.ConfigurationOptionSetting) Test(org.junit.Test)

Example 7 with ConfigurationOptionSetting

use of com.amazonaws.services.elasticbeanstalk.model.ConfigurationOptionSetting in project Synapse-Stack-Builder by Sage-Bionetworks.

the class ElasticBeanstalkSetupTest method testGetAllElasticBeanstalkOptions.

// @Test
// public void testCreateEnvironment() {
// //TODO: All services
// String svcPrefix = Constants.PREFIX_AUTH;
// ApplicationVersionDescription appVersionDesc = resources.getAuthApplicationVersion();
// String genericElbTemplateName = config.getElasticBeanstalkTemplateName() + "-generic";
// List<ConfigurationOptionSetting> cfgOptSettings = setup.getAllElasticBeanstalkOptions("generic");
// resources.setElasticBeanstalkConfigurationTemplate("generic", setup.createOrUpdateConfigurationTemplate(genericElbTemplateName, cfgOptSettings));
// setup.createOrUpdateEnvironment(svcPrefix, genericElbTemplateName, appVersionDesc);
// }
// 
@Test
public void testGetAllElasticBeanstalkOptions() {
    List<ConfigurationOptionSetting> expected = new LinkedList<ConfigurationOptionSetting>();
    // From the server tab
    expected.add(new ConfigurationOptionSetting().withNamespace("aws:autoscaling:launchconfiguration").withOptionName("InstanceType").withValue("m1.small"));
    expected.add(new ConfigurationOptionSetting().withNamespace("aws:autoscaling:launchconfiguration").withOptionName("SecurityGroups").withValue(config.getElasticSecurityGroupName()));
    expected.add(new ConfigurationOptionSetting().withNamespace("aws:autoscaling:launchconfiguration").withOptionName("EC2KeyName").withValue(config.getStackKeyPairName()));
    // From the load balancer tab
    expected.add(new ConfigurationOptionSetting().withNamespace("aws:elb:loadbalancer").withOptionName("LoadBalancerHTTPPort").withValue("80"));
    expected.add(new ConfigurationOptionSetting().withNamespace("aws:elb:loadbalancer").withOptionName("LoadBalancerHTTPSPort").withValue("443"));
    // From the container tab.
    expected.add(new ConfigurationOptionSetting().withNamespace("aws:elasticbeanstalk:container:tomcat:jvmoptions").withOptionName("Xmx").withValue("1024m"));
    expected.add(new ConfigurationOptionSetting().withNamespace("aws:elasticbeanstalk:application:environment").withOptionName("AWS_ACCESS_KEY_ID").withValue(config.getAWSAccessKey()));
    expected.add(new ConfigurationOptionSetting().withNamespace("aws:elasticbeanstalk:application:environment").withOptionName("AWS_SECRET_KEY").withValue(config.getAWSSecretKey()));
    expected.add(new ConfigurationOptionSetting().withNamespace("aws:elasticbeanstalk:application:environment").withOptionName("PARAM1").withValue(config.getStackConfigurationFileURL()));
    expected.add(new ConfigurationOptionSetting().withNamespace("aws:elasticbeanstalk:application:environment").withOptionName("PARAM2").withValue(config.getEncryptionKey()));
    expected.add(new ConfigurationOptionSetting().withNamespace("aws:elasticbeanstalk:application:environment").withOptionName("PARAM3").withValue(config.getStack()));
    expected.add(new ConfigurationOptionSetting().withNamespace("aws:elasticbeanstalk:application:environment").withOptionName("PARAM4").withValue(config.getStackInstance()));
    expected.add(new ConfigurationOptionSetting().withNamespace("aws:elasticbeanstalk:hostmanager").withOptionName("LogPublicationControl").withValue("false"));
    // Check if the SSLCertificateID is correctly added for "plfm' and "portal" cases
    expected.add(new ConfigurationOptionSetting().withNamespace("aws:elb:loadbalancer").withOptionName("SSLCertificateId").withValue(resources.getACMCertificateArn(StackEnvironmentType.REPO)));
    // Also check if healthcheck url has been overriden
    expected.add(new ConfigurationOptionSetting().withNamespace("aws:elasticbeanstalk:application").withOptionName("Application Healthcheck URL").withValue("/repo/v1/version"));
    // Check if SNS topic set properly
    expected.add(new ConfigurationOptionSetting().withNamespace("aws:elasticbeanstalk:sns:topics").withOptionName("Notification Topic Name").withValue(config.getEnvironmentInstanceNotificationTopicName(StackEnvironmentType.REPO)));
    List<ConfigurationOptionSetting> result = setup.getAllElasticBeanstalkOptions(StackEnvironmentType.REPO);
    // Make sure we can find all of the expected values
    for (ConfigurationOptionSetting expectedCon : expected) {
        ConfigurationOptionSetting found = find(expectedCon.getNamespace(), expectedCon.getOptionName(), result);
        assertNotNull("Failed to find expected configuration: " + expectedCon, found);
        assertEquals("Values did not match for namespace: " + expectedCon.getNamespace() + " and option name: " + expectedCon.getOptionName(), expectedCon.getValue(), found.getValue());
    }
    // Change the expected values for portal
    expected.remove(expected.size() - 1);
    expected.remove(expected.size() - 1);
    expected.remove(expected.size() - 1);
    expected.add(new ConfigurationOptionSetting().withNamespace("aws:elb:loadbalancer").withOptionName("SSLCertificateId").withValue(resources.getACMCertificateArn(StackEnvironmentType.PORTAL)));
    expected.add(new ConfigurationOptionSetting().withNamespace("aws:elasticbeanstalk:application").withOptionName("Application Healthcheck URL").withValue("/"));
    expected.add(new ConfigurationOptionSetting().withNamespace("aws:elasticbeanstalk:sns:topics").withOptionName("Notification Topic Name").withValue(config.getEnvironmentInstanceNotificationTopicName(StackEnvironmentType.PORTAL)));
    result = setup.getAllElasticBeanstalkOptions(StackEnvironmentType.PORTAL);
    // Make sure we can find all of the expected values
    for (ConfigurationOptionSetting expectedCon : expected) {
        ConfigurationOptionSetting found = find(expectedCon.getNamespace(), expectedCon.getOptionName(), result);
        assertNotNull("Failed to find expected configuration: " + expectedCon, found);
        assertEquals("Values did not match for namespace: " + expectedCon.getNamespace() + " and option name: " + expectedCon.getOptionName(), expectedCon.getValue(), found.getValue());
    }
}
Also used : ConfigurationOptionSetting(com.amazonaws.services.elasticbeanstalk.model.ConfigurationOptionSetting) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 8 with ConfigurationOptionSetting

use of com.amazonaws.services.elasticbeanstalk.model.ConfigurationOptionSetting in project Synapse-Stack-Builder by Sage-Bionetworks.

the class ElasticBeanstalkSetupTest method testMinAutoScaleSizeDev.

@Test
public void testMinAutoScaleSizeDev() throws IOException {
    List<ConfigurationOptionSetting> expected = new LinkedList<ConfigurationOptionSetting>();
    // For dev the min should be 1
    config = TestHelper.createTestConfig("dev");
    resources = TestHelper.createTestResources(config);
    setup = new ElasticBeanstalkSetup(factory, config, resources);
    // From the server tab
    expected.add(new ConfigurationOptionSetting().withNamespace("aws:autoscaling:asg").withOptionName("MinSize").withValue("1"));
    List<ConfigurationOptionSetting> result = setup.getAllElasticBeanstalkOptions(StackEnvironmentType.REPO);
    // Make sure we can find all of the expected values
    for (ConfigurationOptionSetting expectedCon : expected) {
        ConfigurationOptionSetting found = find(expectedCon.getNamespace(), expectedCon.getOptionName(), result);
        assertNotNull("Failed to find expected configuration: " + expectedCon, found);
        assertEquals("Values did not match for namespace: " + expectedCon.getNamespace() + " and option name: " + expectedCon.getOptionName(), expectedCon.getValue(), found.getValue());
    }
}
Also used : ConfigurationOptionSetting(com.amazonaws.services.elasticbeanstalk.model.ConfigurationOptionSetting) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 9 with ConfigurationOptionSetting

use of com.amazonaws.services.elasticbeanstalk.model.ConfigurationOptionSetting in project Synapse-Stack-Builder by Sage-Bionetworks.

the class ElasticBeanstalkSetupTest method testMinAutoScaleSizeProductionWorkers.

@Test
public void testMinAutoScaleSizeProductionWorkers() throws IOException {
    List<ConfigurationOptionSetting> expected = new LinkedList<ConfigurationOptionSetting>();
    // For prod the min should be 2
    config = TestHelper.createTestConfig("prod");
    resources = TestHelper.createTestResources(config);
    setup = new ElasticBeanstalkSetup(factory, config, resources);
    // From the server tab
    expected.add(new ConfigurationOptionSetting().withNamespace("aws:autoscaling:asg").withOptionName("MinSize").withValue("8"));
    List<ConfigurationOptionSetting> result = setup.getAllElasticBeanstalkOptions(StackEnvironmentType.WORKERS);
    // Make sure we can find all of the expected values
    for (ConfigurationOptionSetting expectedCon : expected) {
        ConfigurationOptionSetting found = find(expectedCon.getNamespace(), expectedCon.getOptionName(), result);
        assertNotNull("Failed to find expected configuration: " + expectedCon, found);
        assertEquals("Values did not match for namespace: " + expectedCon.getNamespace() + " and option name: " + expectedCon.getOptionName(), expectedCon.getValue(), found.getValue());
    }
}
Also used : ConfigurationOptionSetting(com.amazonaws.services.elasticbeanstalk.model.ConfigurationOptionSetting) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 10 with ConfigurationOptionSetting

use of com.amazonaws.services.elasticbeanstalk.model.ConfigurationOptionSetting in project Synapse-Stack-Builder by Sage-Bionetworks.

the class ElasticBeanstalkSetupTest method testUpdateConfigurationTemplate.

@Test
public void testUpdateConfigurationTemplate() {
    List<ConfigurationOptionSetting> cfgOptSettings = new ArrayList<ConfigurationOptionSetting>();
    String templateName = "existingTemplate";
    DescribeConfigurationOptionsRequest dcoReq = new DescribeConfigurationOptionsRequest().withApplicationName(config.getElasticBeanstalkApplicationName()).withTemplateName(templateName);
    DescribeConfigurationOptionsResult expectedDcoRes = new DescribeConfigurationOptionsResult();
    when(mockClient.describeConfigurationOptions(dcoReq)).thenReturn(expectedDcoRes);
    UpdateConfigurationTemplateRequest expectedUctReq = new UpdateConfigurationTemplateRequest();
    expectedUctReq.setApplicationName(config.getElasticBeanstalkApplicationName());
    expectedUctReq.setOptionSettings(cfgOptSettings);
    expectedUctReq.setTemplateName(templateName);
    setup.createOrUpdateConfigurationTemplate(templateName, cfgOptSettings);
    verify(mockClient).updateConfigurationTemplate(expectedUctReq);
}
Also used : UpdateConfigurationTemplateRequest(com.amazonaws.services.elasticbeanstalk.model.UpdateConfigurationTemplateRequest) ArrayList(java.util.ArrayList) DescribeConfigurationOptionsResult(com.amazonaws.services.elasticbeanstalk.model.DescribeConfigurationOptionsResult) ConfigurationOptionSetting(com.amazonaws.services.elasticbeanstalk.model.ConfigurationOptionSetting) DescribeConfigurationOptionsRequest(com.amazonaws.services.elasticbeanstalk.model.DescribeConfigurationOptionsRequest) Test(org.junit.Test)

Aggregations

ConfigurationOptionSetting (com.amazonaws.services.elasticbeanstalk.model.ConfigurationOptionSetting)12 Test (org.junit.Test)10 LinkedList (java.util.LinkedList)8 DescribeConfigurationOptionsRequest (com.amazonaws.services.elasticbeanstalk.model.DescribeConfigurationOptionsRequest)2 ArrayList (java.util.ArrayList)2 AmazonServiceException (com.amazonaws.AmazonServiceException)1 CreateConfigurationTemplateRequest (com.amazonaws.services.elasticbeanstalk.model.CreateConfigurationTemplateRequest)1 DescribeConfigurationOptionsResult (com.amazonaws.services.elasticbeanstalk.model.DescribeConfigurationOptionsResult)1 EnvironmentDescription (com.amazonaws.services.elasticbeanstalk.model.EnvironmentDescription)1 UpdateConfigurationTemplateRequest (com.amazonaws.services.elasticbeanstalk.model.UpdateConfigurationTemplateRequest)1 Properties (java.util.Properties)1 ExecutionException (java.util.concurrent.ExecutionException)1