use of com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription in project photon-model by vmware.
the class AWSLoadBalancerServiceTest method testCreateUpdateDeleteLoadBalancer.
@Test
public void testCreateUpdateDeleteLoadBalancer() throws Throwable {
// set name with invalid characters and more than 32 characters
this.lbName = generateLbName() + "-1234567890-1234567890-1234567890_;.,/";
LoadBalancerState lb = createLoadBalancerState(this.lbName);
// Provision load balancer
kickOffLoadBalancerProvision(InstanceRequestType.CREATE, lb.documentSelfLink, TaskStage.FINISHED);
lb = getServiceSynchronously(lb.documentSelfLink, LoadBalancerState.class);
this.lbName = lb.name;
if (!this.isMock) {
assertNotNull(lb.securityGroupLinks);
String securityGroupDocumentSelfLink = lb.securityGroupLinks.iterator().next();
assertNotNull(securityGroupDocumentSelfLink);
SecurityGroupState sgs = getServiceSynchronously(securityGroupDocumentSelfLink, SecurityGroupState.class);
this.sgId = sgs.id;
LoadBalancerDescription awsLoadBalancer = getAwsLoadBalancer(this.lbName);
assertNotNull(awsLoadBalancer);
assertEquals(awsLoadBalancer.getDNSName(), lb.address);
assertEquals("internet-facing", awsLoadBalancer.getScheme());
assertEquals(1, awsLoadBalancer.getInstances().size());
List<ListenerDescription> listeners = awsLoadBalancer.getListenerDescriptions();
assertEquals(2, listeners.size());
verifyListeners(lb.routes, listeners);
verifyHealthCheckConfiguration(lb.routes.get(0), awsLoadBalancer.getHealthCheck());
SecurityGroup securityGroup = getAwsSecurityGroup(sgs.id);
assertNotNull(securityGroup);
String lbSecGroupId = awsLoadBalancer.getSecurityGroups().stream().findFirst().orElse(null);
assertEquals(securityGroup.getGroupId(), lbSecGroupId);
}
// Update load balancer from 1 machines to 2 to simulate scale-out
if (!this.isMock) {
lb.computeLinks = new HashSet<>(Arrays.asList(this.cs1.documentSelfLink, this.cs2.documentSelfLink));
putServiceSynchronously(lb.documentSelfLink, lb);
}
kickOffLoadBalancerProvision(InstanceRequestType.UPDATE, lb.documentSelfLink, TaskStage.FINISHED);
if (!this.isMock) {
LoadBalancerDescription awsLoadBalancer = getAwsLoadBalancer(this.lbName);
assertNotNull(awsLoadBalancer);
assertEquals(2, awsLoadBalancer.getInstances().size());
// Update load balancer from 2 machines to 1 to simulate scale-in
lb.computeLinks = Collections.singleton(this.cs1.documentSelfLink);
putServiceSynchronously(lb.documentSelfLink, lb);
kickOffLoadBalancerProvision(InstanceRequestType.UPDATE, lb.documentSelfLink, TaskStage.FINISHED);
awsLoadBalancer = getAwsLoadBalancer(this.lbName);
assertNotNull(awsLoadBalancer);
assertEquals(1, awsLoadBalancer.getInstances().size());
}
kickOffLoadBalancerProvision(InstanceRequestType.DELETE, lb.documentSelfLink, TaskStage.FINISHED);
if (!this.isMock) {
assertNull(getAwsLoadBalancer(this.lbName));
assertNull(getAwsSecurityGroup(this.sgId));
}
this.lbName = null;
this.sgId = null;
}
use of com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription in project photon-model by vmware.
the class AWSLoadBalancerServiceTest method getAwsLoadBalancer.
private LoadBalancerDescription getAwsLoadBalancer(String name) {
DescribeLoadBalancersRequest describeRequest = new DescribeLoadBalancersRequest().withLoadBalancerNames(name);
DescribeLoadBalancersResult describeResult = null;
try {
describeResult = this.client.describeLoadBalancers(describeRequest);
} catch (Exception e) {
this.host.log("Exception describing load balancers with name '%s': %s", name, e.toString());
}
Collection<LoadBalancerDescription> lbs = describeResult != null ? describeResult.getLoadBalancerDescriptions() : null;
if (lbs == null || lbs.isEmpty()) {
return null;
}
if (lbs.size() > 1) {
throw new IllegalStateException("More than one load balancers found with name '" + name + "'.");
}
return lbs.iterator().next();
}
use of com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription in project chassis by Kixeye.
the class ZookeeperElbFilterTest method foundInternalExhibitor.
@Test
public void foundInternalExhibitor() {
LoadBalancerDescription loadBalancer = new LoadBalancerDescription();
List<ListenerDescription> listenerDescriptions = new ArrayList<>();
listenerDescriptions.add(new ListenerDescription());
loadBalancer.setListenerDescriptions(listenerDescriptions);
loadBalancer.setLoadBalancerName("exhibitor-" + ENVIRONMENT + "-internal");
Assert.assertTrue(filter.accept(loadBalancer));
}
use of com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription in project chassis by Kixeye.
the class ZookeeperElbFilterTest method randomUnmatchedELB.
@Test
public void randomUnmatchedELB() {
LoadBalancerDescription loadBalancer = new LoadBalancerDescription();
List<ListenerDescription> listenerDescriptions = new ArrayList<>();
listenerDescriptions.add(new ListenerDescription());
loadBalancer.setListenerDescriptions(listenerDescriptions);
loadBalancer.setLoadBalancerName(RandomStringUtils.random(5, "abcd"));
Assert.assertFalse(filter.accept(loadBalancer));
}
use of com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription in project chassis by Kixeye.
the class ZookeeperElbFilterTest method noMatchingEnvironment.
@Test
public void noMatchingEnvironment() {
LoadBalancerDescription loadBalancer = new LoadBalancerDescription();
loadBalancer.setLoadBalancerName("foo-Zookeeper-whatever");
Assert.assertFalse(filter.accept(loadBalancer));
}
Aggregations