use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer in project cloudbreak by hortonworks.
the class LoadBalancerConfigServiceTest method createLoadBalancers.
private Set<LoadBalancer> createLoadBalancers(boolean createPrivate, boolean createPublic, boolean createOutbound) {
Set<LoadBalancer> loadBalancers = new HashSet<>();
if (createPrivate) {
LoadBalancer privateLoadBalancer = new LoadBalancer();
privateLoadBalancer.setType(LoadBalancerType.PRIVATE);
privateLoadBalancer.setFqdn(PRIVATE_FQDN);
privateLoadBalancer.setDns(PRIVATE_DNS);
privateLoadBalancer.setIp(PRIVATE_IP);
loadBalancers.add(privateLoadBalancer);
}
if (createPublic) {
LoadBalancer publicLoadBalancer = new LoadBalancer();
publicLoadBalancer.setType(LoadBalancerType.PUBLIC);
publicLoadBalancer.setFqdn(PUBLIC_FQDN);
publicLoadBalancer.setDns(PUBLIC_DNS);
publicLoadBalancer.setIp(PUBLIC_IP);
loadBalancers.add(publicLoadBalancer);
}
if (createOutbound) {
LoadBalancer outboundLoadBalancer = new LoadBalancer();
outboundLoadBalancer.setType(LoadBalancerType.OUTBOUND);
loadBalancers.add(outboundLoadBalancer);
}
return loadBalancers;
}
use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer in project cloudbreak by hortonworks.
the class LoadBalancerConfigServiceTest method testGetLoadBalancerUserFacingFQDNPrivateOnly.
@Test
public void testGetLoadBalancerUserFacingFQDNPrivateOnly() {
Set<LoadBalancer> loadBalancers = createPrivateOnlyLoadBalancer();
when(loadBalancerPersistenceService.findByStackId(0L)).thenReturn(loadBalancers);
String fqdn = underTest.getLoadBalancerUserFacingFQDN(0L);
assertEquals(PRIVATE_FQDN, fqdn);
}
use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer in project cloudbreak by hortonworks.
the class LoadBalancerConfigServiceTest method testDisableLoadBalancer.
@Test
public void testDisableLoadBalancer() {
Stack stack = createAwsStack(StackType.DATALAKE, PUBLIC_ID_1);
CloudSubnet subnet = getPublicCloudSubnet(PUBLIC_ID_1, AZ_1);
DetailedEnvironmentResponse environment = createEnvironment(subnet, false, "AWS");
environment.getNetwork().setLoadBalancerCreation(LoadBalancerCreation.DISABLED);
StackV4Request request = new StackV4Request();
when(entitlementService.datalakeLoadBalancerEnabled(anyString())).thenReturn(true);
when(blueprint.getBlueprintText()).thenReturn(getBlueprintText("input/clouderamanager-knox.bp"));
when(subnetSelector.findSubnetById(any(), anyString())).thenReturn(Optional.of(subnet));
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> {
Set<LoadBalancer> loadBalancers = underTest.createLoadBalancers(stack, environment, request);
assertEquals(0, loadBalancers.size());
});
}
use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer in project cloudbreak by hortonworks.
the class LoadBalancerConfigServiceTest method testCreateAWSLoadBalancerForDataLakeEntitlementDisabledPrivateSubnets.
@Test
public void testCreateAWSLoadBalancerForDataLakeEntitlementDisabledPrivateSubnets() {
Stack stack = createAwsStack(StackType.DATALAKE, PRIVATE_ID_1);
CloudSubnet subnet = getPrivateCloudSubnet(PRIVATE_ID_1, AZ_1);
DetailedEnvironmentResponse environment = createEnvironment(subnet, false, "AWS");
environment.setCloudPlatform(CloudPlatform.AWS.name());
StackV4Request request = new StackV4Request();
request.setEnableLoadBalancer(false);
when(entitlementService.datalakeLoadBalancerEnabled(anyString())).thenReturn(false);
when(blueprint.getBlueprintText()).thenReturn(getBlueprintText("input/clouderamanager-knox.bp"));
when(subnetSelector.findSubnetById(any(), anyString())).thenReturn(Optional.of(subnet));
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> {
Set<LoadBalancer> loadBalancers = underTest.createLoadBalancers(stack, environment, request);
assertEquals(1, loadBalancers.size());
assertEquals(LoadBalancerType.PRIVATE, loadBalancers.iterator().next().getType());
InstanceGroup masterInstanceGroup = stack.getInstanceGroups().stream().filter(ig -> "master".equals(ig.getGroupName())).findFirst().get();
assertEquals(1, masterInstanceGroup.getTargetGroups().size());
});
}
use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer in project cloudbreak by hortonworks.
the class LoadBalancerConfigServiceTest method testGetLoadBalancerUserFacingFQDNIPOnlyMissingFQDN.
@Test
public void testGetLoadBalancerUserFacingFQDNIPOnlyMissingFQDN() {
Set<LoadBalancer> loadBalancers = createLoadBalancers();
LoadBalancer publicLoadBalancer = loadBalancers.stream().filter(lb -> LoadBalancerType.PUBLIC.equals(lb.getType())).findFirst().get();
publicLoadBalancer.setFqdn(null);
publicLoadBalancer.setDns(null);
when(loadBalancerPersistenceService.findByStackId(0L)).thenReturn(loadBalancers);
String fqdn = underTest.getLoadBalancerUserFacingFQDN(0L);
assertEquals(PUBLIC_IP, fqdn);
}
Aggregations