use of com.amazonaws.services.elasticbeanstalk.model.LoadBalancer in project Synapse-Stack-Builder by Sage-Bionetworks.
the class ElbAlarmSetupTest method testGetLoadBalancerFromEnvironmentNameNoLoadBalancer.
@Test(expected = IllegalStateException.class)
public void testGetLoadBalancerFromEnvironmentNameNoLoadBalancer() throws Exception {
// Return empty list
EnvironmentResourceDescription erd = new EnvironmentResourceDescription().withLoadBalancers(new ArrayList<LoadBalancer>());
DescribeEnvironmentResourcesResult expectedRes = new DescribeEnvironmentResourcesResult().withEnvironmentResources(erd);
when(beanstalkClient.describeEnvironmentResources(any(DescribeEnvironmentResourcesRequest.class))).thenReturn(expectedRes);
doNothing().when(mockSleeper).sleep(anyLong());
setup.getLoadBalancerFromEnvironmentName("repoEnvName");
}
use of com.amazonaws.services.elasticbeanstalk.model.LoadBalancer in project Synapse-Stack-Builder by Sage-Bionetworks.
the class ElbAlarmSetup method getLoadBalancerFromEnvironmentName.
public LoadBalancer getLoadBalancerFromEnvironmentName(String envName) throws InterruptedException {
if (envName == null)
throw new IllegalArgumentException("Environment name cannot be null.");
DescribeEnvironmentResourcesRequest req = new DescribeEnvironmentResourcesRequest();
req.setEnvironmentName(envName);
DescribeEnvironmentResourcesResult res = beanstalkClient.describeEnvironmentResources(req);
EnvironmentResourceDescription erd = res.getEnvironmentResources();
List<LoadBalancer> loadBalancers = erd.getLoadBalancers();
int count = 0;
while ((loadBalancers != null) && (loadBalancers.size() == 0)) {
count += 1;
if (count == 10) {
throw new IllegalStateException("Load balancer for environment " + envName + " did not come up within 5 minutes");
}
sleeper.sleep(30000L);
loadBalancers = erd.getLoadBalancers();
}
// In case loadBalancers was null to start with, should not happen
if ((loadBalancers != null) && (loadBalancers.size() != 1)) {
throw new IllegalStateException("Should only be one load balancer for environment " + envName);
}
return loadBalancers.get(0);
}
Aggregations