use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer in project cloudbreak by hortonworks.
the class LoadBalancerConfigServiceTest method testCreateLoadBalancersEndpointGatewayNullNetwork.
@Test
public void testCreateLoadBalancersEndpointGatewayNullNetwork() {
Stack stack = createAwsStack(StackType.DATALAKE, PUBLIC_ID_1);
DetailedEnvironmentResponse environment = createEnvironment(getPrivateCloudSubnet(PUBLIC_ID_1, AZ_1), true, "AWS");
environment.setNetwork(null);
StackV4Request request = new StackV4Request();
request.setEnableLoadBalancer(false);
when(blueprint.getBlueprintText()).thenReturn(getBlueprintText("input/clouderamanager-knox.bp"));
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> {
Set<LoadBalancer> loadBalancers = underTest.createLoadBalancers(stack, environment, request);
assert loadBalancers.isEmpty();
});
}
use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer in project cloudbreak by hortonworks.
the class LoadBalancerConfigServiceTest method testCreateAzureLoadBalancerWithSkuSetToStandard.
@Test
public void testCreateAzureLoadBalancerWithSkuSetToStandard() {
Stack stack = createAzureStack(StackType.DATALAKE, PRIVATE_ID_1, true);
CloudSubnet subnet = getPrivateCloudSubnet(PRIVATE_ID_1, AZ_1);
DetailedEnvironmentResponse environment = createEnvironment(subnet, false, "AZURE");
AzureStackV4Parameters azureParameters = new AzureStackV4Parameters();
azureParameters.setLoadBalancerSku(LoadBalancerSku.STANDARD);
StackV4Request request = new StackV4Request();
request.setEnableLoadBalancer(false);
request.setAzure(azureParameters);
when(entitlementService.azureDatalakeLoadBalancerEnabled(anyString())).thenReturn(true);
when(blueprint.getBlueprintText()).thenReturn(getBlueprintText("input/clouderamanager-knox.bp"));
when(subnetSelector.findSubnetById(any(), anyString())).thenReturn(Optional.of(subnet));
when(availabilitySetNameService.generateName(any(), any())).thenReturn("");
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> {
Set<LoadBalancer> loadBalancers = underTest.createLoadBalancers(stack, environment, request);
assertEquals(2, loadBalancers.size());
assert loadBalancers.stream().anyMatch(l -> LoadBalancerType.PRIVATE.equals(l.getType()));
assert loadBalancers.stream().anyMatch(l -> LoadBalancerType.OUTBOUND.equals(l.getType()));
InstanceGroup masterInstanceGroup = stack.getInstanceGroups().stream().filter(ig -> "master".equals(ig.getGroupName())).findFirst().get();
assertEquals(1, masterInstanceGroup.getTargetGroups().size());
assertTrue(loadBalancers.stream().allMatch(l -> LoadBalancerSku.STANDARD.equals(l.getSku())));
checkAvailabilitySetAttributes(loadBalancers);
});
}
use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer in project cloudbreak by hortonworks.
the class LoadBalancerConfigServiceTest method testGetLoadBalancerUserFacingFQDNNoPublicPrivateMissingFQDNNoDNS.
@Test
public void testGetLoadBalancerUserFacingFQDNNoPublicPrivateMissingFQDNNoDNS() {
Set<LoadBalancer> loadBalancers = createPrivateOnlyLoadBalancer();
LoadBalancer privateLoadBalancer = loadBalancers.stream().filter(lb -> LoadBalancerType.PRIVATE.equals(lb.getType())).findFirst().get();
privateLoadBalancer.setFqdn(null);
privateLoadBalancer.setDns(null);
when(loadBalancerPersistenceService.findByStackId(0L)).thenReturn(loadBalancers);
String fqdn = underTest.getLoadBalancerUserFacingFQDN(0L);
assertEquals(PRIVATE_IP, fqdn);
}
use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer in project cloudbreak by hortonworks.
the class LoadBalancerConfigServiceTest method testCreateLoadBalancerUnsupportedPlatform.
@Test
public void testCreateLoadBalancerUnsupportedPlatform() {
Stack stack = createAwsStack(StackType.DATALAKE, PRIVATE_ID_1);
stack.setCloudPlatform(GCP);
CloudSubnet subnet = getPrivateCloudSubnet(PRIVATE_ID_1, AZ_1);
DetailedEnvironmentResponse environment = createEnvironment(subnet, false, "GCP");
StackV4Request request = new StackV4Request();
request.setEnableLoadBalancer(false);
when(entitlementService.datalakeLoadBalancerEnabled(anyString())).thenReturn(true);
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 testCreateLoadBalancersUnsupportedStackType.
@Test
public void testCreateLoadBalancersUnsupportedStackType() {
Stack stack1 = createAwsStack(StackType.TEMPLATE, PRIVATE_ID_1);
DetailedEnvironmentResponse environment = createEnvironment(getPrivateCloudSubnet(PRIVATE_ID_1, AZ_1), true, "AWS");
StackV4Request request = new StackV4Request();
request.setEnableLoadBalancer(false);
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> {
Set<LoadBalancer> loadBalancers = underTest.createLoadBalancers(stack1, environment, request);
assert loadBalancers.isEmpty();
});
Stack stack2 = createAwsStack(StackType.LEGACY, PRIVATE_ID_1);
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> {
Set<LoadBalancer> loadBalancers = underTest.createLoadBalancers(stack2, environment, request);
assert loadBalancers.isEmpty();
});
}
Aggregations