use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer in project cloudbreak by hortonworks.
the class LoadBalancerConfigServiceTest method testCreateLoadBalancerForDatahubWithDatalakeEntitlement.
@Test
public void testCreateLoadBalancerForDatahubWithDatalakeEntitlement() {
Stack stack = createAwsStack(StackType.WORKLOAD, PRIVATE_ID_1);
DetailedEnvironmentResponse environment = createEnvironment(getPrivateCloudSubnet(PRIVATE_ID_1, AZ_1), false, "AWS");
StackV4Request request = new StackV4Request();
request.setEnableLoadBalancer(false);
when(entitlementService.datalakeLoadBalancerEnabled(anyString())).thenReturn(true);
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 testCreateLoadBalancerForDataLakePublicSubnets.
@Test
public void testCreateLoadBalancerForDataLakePublicSubnets() {
Stack stack = createAwsStack(StackType.DATALAKE, PUBLIC_ID_1);
CloudSubnet subnet = getPublicCloudSubnet(PUBLIC_ID_1, AZ_1);
DetailedEnvironmentResponse environment = createEnvironment(subnet, false, "AWS");
StackV4Request request = new StackV4Request();
request.setEnableLoadBalancer(false);
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(1, loadBalancers.size());
assertEquals(LoadBalancerType.PUBLIC, loadBalancers.iterator().next().getType());
});
}
use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer in project cloudbreak by hortonworks.
the class LoadBalancerConfigServiceTest method testCreateAzureLoadBalancerSelectsDefaultWhenSkuIsNotSet.
@Test
public void testCreateAzureLoadBalancerSelectsDefaultWhenSkuIsNotSet() {
Stack stack = createAzureStack(StackType.DATALAKE, PRIVATE_ID_1, true);
CloudSubnet subnet = getPrivateCloudSubnet(PRIVATE_ID_1, AZ_1);
DetailedEnvironmentResponse environment = createEnvironment(subnet, false, "AZURE");
StackV4Request request = new StackV4Request();
request.setEnableLoadBalancer(false);
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);
if (LoadBalancerSku.getDefault().equals(LoadBalancerSku.STANDARD)) {
assertEquals(2, loadBalancers.size());
assert loadBalancers.stream().anyMatch(l -> LoadBalancerType.PRIVATE.equals(l.getType()));
assert loadBalancers.stream().anyMatch(l -> LoadBalancerType.OUTBOUND.equals(l.getType()));
} else if (LoadBalancerSku.getDefault().equals(LoadBalancerSku.BASIC)) {
assertEquals(1, loadBalancers.size());
assert loadBalancers.stream().anyMatch(l -> LoadBalancerType.PRIVATE.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.getDefault().equals(l.getSku())));
checkAvailabilitySetAttributes(loadBalancers);
});
}
use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer in project cloudbreak by hortonworks.
the class LoadBalancerConfigServiceTest method testCreateAzurePublicLoadBalancer.
@Test
public void testCreateAzurePublicLoadBalancer() {
Stack stack = createAzureStack(StackType.DATALAKE, PUBLIC_ID_1, false);
CloudSubnet subnet = getPublicCloudSubnet(PUBLIC_ID_1, AZ_1);
DetailedEnvironmentResponse environment = createEnvironment(subnet, false, "AZURE");
StackV4Request request = new StackV4Request();
request.setEnableLoadBalancer(false);
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(1, loadBalancers.size());
assertEquals(LoadBalancerType.PUBLIC, loadBalancers.iterator().next().getType());
InstanceGroup masterInstanceGroup = stack.getInstanceGroups().stream().filter(ig -> "master".equals(ig.getGroupName())).findFirst().get();
assertEquals(1, masterInstanceGroup.getTargetGroups().size());
checkAvailabilitySetAttributes(loadBalancers);
});
}
use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer in project cloudbreak by hortonworks.
the class LoadBalancerConfigServiceTest method testGetLoadBalancerUserFacingFQDNPublicMissingAll.
@Test
public void testGetLoadBalancerUserFacingFQDNPublicMissingAll() {
Set<LoadBalancer> loadBalancers = createLoadBalancers();
LoadBalancer publicLoadBalancer = loadBalancers.stream().filter(lb -> LoadBalancerType.PUBLIC.equals(lb.getType())).findFirst().get();
publicLoadBalancer.setFqdn(null);
publicLoadBalancer.setIp(null);
publicLoadBalancer.setDns(null);
when(loadBalancerPersistenceService.findByStackId(0L)).thenReturn(loadBalancers);
String fqdn = underTest.getLoadBalancerUserFacingFQDN(0L);
assertEquals(PRIVATE_FQDN, fqdn);
}
Aggregations