Search in sources :

Example 1 with LoadBalancer

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

the class ElbAlarmSetupTest method testGetLoadBalancerFromEnvironmentNameOneLoadBalancer.

@Test
public void testGetLoadBalancerFromEnvironmentNameOneLoadBalancer() throws Exception {
    // Return 1 load balancers
    List<LoadBalancer> loadBalancers = new ArrayList<>();
    LoadBalancer lb = new LoadBalancer().withName("loadBalancer");
    loadBalancers.add(lb);
    EnvironmentResourceDescription erd = new EnvironmentResourceDescription().withLoadBalancers(loadBalancers);
    DescribeEnvironmentResourcesResult expectedRes = new DescribeEnvironmentResourcesResult().withEnvironmentResources(erd);
    when(beanstalkClient.describeEnvironmentResources(any(DescribeEnvironmentResourcesRequest.class))).thenReturn(expectedRes);
    doNothing().when(mockSleeper).sleep(anyLong());
    LoadBalancer b = setup.getLoadBalancerFromEnvironmentName("repoEnvName");
    // Should have same name
    assertEquals(lb.getName(), b.getName());
}
Also used : DescribeEnvironmentResourcesResult(com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentResourcesResult) DescribeEnvironmentResourcesRequest(com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentResourcesRequest) ArrayList(java.util.ArrayList) LoadBalancer(com.amazonaws.services.elasticbeanstalk.model.LoadBalancer) EnvironmentResourceDescription(com.amazonaws.services.elasticbeanstalk.model.EnvironmentResourceDescription) Test(org.junit.Test)

Example 2 with LoadBalancer

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

the class ElbAlarmSetupTest method testCreateAlarms.

@Test
public void testCreateAlarms() throws Exception {
    EnvironmentResourceDescription erd = new EnvironmentResourceDescription().withLoadBalancers(new LoadBalancer().withName("loadBalancer"));
    DescribeEnvironmentResourcesResult expectedErr = new DescribeEnvironmentResourcesResult().withEnvironmentResources(erd);
    when(beanstalkClient.describeEnvironmentResources(any(DescribeEnvironmentResourcesRequest.class))).thenReturn(expectedErr);
    setup.createAlarms(resources.getEnvironment(StackEnvironmentType.REPO));
    verify(mockCwClient).putMetricAlarm(any(PutMetricAlarmRequest.class));
}
Also used : DescribeEnvironmentResourcesResult(com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentResourcesResult) PutMetricAlarmRequest(com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest) DescribeEnvironmentResourcesRequest(com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentResourcesRequest) LoadBalancer(com.amazonaws.services.elasticbeanstalk.model.LoadBalancer) EnvironmentResourceDescription(com.amazonaws.services.elasticbeanstalk.model.EnvironmentResourceDescription) Test(org.junit.Test)

Example 3 with LoadBalancer

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

the class ElbAlarmSetup method createAlarms.

public void createAlarms(EnvironmentDescription ed) throws InterruptedException {
    String topicArn = resources.getStackInstanceNotificationTopicArn();
    LoadBalancer loadBalancer = getLoadBalancerFromEnvironmentName(ed.getEnvironmentName());
    List<PutMetricAlarmRequest> reqs = createAllPutMetricAlarmRequests(ed.getEnvironmentName(), loadBalancer.getName(), topicArn);
    for (PutMetricAlarmRequest req : reqs) {
        this.cloudWatchClient.putMetricAlarm(req);
    }
}
Also used : PutMetricAlarmRequest(com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest) LoadBalancer(com.amazonaws.services.elasticbeanstalk.model.LoadBalancer)

Example 4 with LoadBalancer

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

the class ElbAlarmSetup method describeAlarms.

public DescribeAlarmsResult describeAlarms(EnvironmentDescription ed) throws InterruptedException {
    String topicArn = resources.getStackInstanceNotificationTopicArn();
    LoadBalancer loadBalancer = getLoadBalancerFromEnvironmentName(ed.getEnvironmentName());
    DescribeAlarmsRequest req = createDescribeAlarmsRequest(ed.getEnvironmentName(), loadBalancer.getName(), topicArn);
    DescribeAlarmsResult res = this.cloudWatchClient.describeAlarms(req);
    return res;
}
Also used : DescribeAlarmsResult(com.amazonaws.services.cloudwatch.model.DescribeAlarmsResult) LoadBalancer(com.amazonaws.services.elasticbeanstalk.model.LoadBalancer) DescribeAlarmsRequest(com.amazonaws.services.cloudwatch.model.DescribeAlarmsRequest)

Example 5 with LoadBalancer

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

the class ElbAlarmSetupTest method testGetLoadBalancerFromEnvironmentNameTwoLoadBalancers.

@Test(expected = IllegalStateException.class)
public void testGetLoadBalancerFromEnvironmentNameTwoLoadBalancers() throws Exception {
    // Return 2 load balancers
    List<LoadBalancer> loadBalancers = new ArrayList<>();
    LoadBalancer lb = new LoadBalancer();
    loadBalancers.add(lb);
    loadBalancers.add(lb);
    EnvironmentResourceDescription erd = new EnvironmentResourceDescription().withLoadBalancers(loadBalancers);
    DescribeEnvironmentResourcesResult expectedRes = new DescribeEnvironmentResourcesResult().withEnvironmentResources(erd);
    when(beanstalkClient.describeEnvironmentResources(any(DescribeEnvironmentResourcesRequest.class))).thenReturn(expectedRes);
    doNothing().when(mockSleeper).sleep(anyLong());
    setup.getLoadBalancerFromEnvironmentName("repoEnvName");
}
Also used : DescribeEnvironmentResourcesResult(com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentResourcesResult) DescribeEnvironmentResourcesRequest(com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentResourcesRequest) ArrayList(java.util.ArrayList) LoadBalancer(com.amazonaws.services.elasticbeanstalk.model.LoadBalancer) EnvironmentResourceDescription(com.amazonaws.services.elasticbeanstalk.model.EnvironmentResourceDescription) Test(org.junit.Test)

Aggregations

LoadBalancer (com.amazonaws.services.elasticbeanstalk.model.LoadBalancer)7 DescribeEnvironmentResourcesRequest (com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentResourcesRequest)5 DescribeEnvironmentResourcesResult (com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentResourcesResult)5 EnvironmentResourceDescription (com.amazonaws.services.elasticbeanstalk.model.EnvironmentResourceDescription)5 Test (org.junit.Test)4 PutMetricAlarmRequest (com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest)2 ArrayList (java.util.ArrayList)2 DescribeAlarmsRequest (com.amazonaws.services.cloudwatch.model.DescribeAlarmsRequest)1 DescribeAlarmsResult (com.amazonaws.services.cloudwatch.model.DescribeAlarmsResult)1