use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer in project cloudbreak by hortonworks.
the class LoadBalancerConfigServiceTest method testCreateLoadBalancerNoEnvironmentNetwork.
@Test
public void testCreateLoadBalancerNoEnvironmentNetwork() {
Stack stack = createAwsStack(StackType.DATALAKE, null);
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, null, request);
assert loadBalancers.isEmpty();
});
}
use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer in project cloudbreak by hortonworks.
the class LoadBalancerConfigServiceTest method testCreateLoadBalancersNullEnvironment.
@Test
public void testCreateLoadBalancersNullEnvironment() {
Stack stack = createAwsStack(StackType.DATALAKE, PRIVATE_ID_1);
StackV4Request request = new StackV4Request();
request.setEnableLoadBalancer(false);
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> {
Set<LoadBalancer> loadBalancers = underTest.createLoadBalancers(stack, null, request);
assert loadBalancers.isEmpty();
});
}
use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer in project cloudbreak by hortonworks.
the class LoadBalancerConfigServiceTest method testGetLoadBalancerUserFacingFQDNNoFqdnSet.
@Test
public void testGetLoadBalancerUserFacingFQDNNoFqdnSet() {
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);
LoadBalancer privateLoadBalancer = loadBalancers.stream().filter(lb -> LoadBalancerType.PRIVATE.equals(lb.getType())).findFirst().get();
privateLoadBalancer.setFqdn(null);
privateLoadBalancer.setDns(null);
privateLoadBalancer.setIp(null);
when(loadBalancerPersistenceService.findByStackId(0L)).thenReturn(loadBalancers);
String fqdn = underTest.getLoadBalancerUserFacingFQDN(0L);
assertNull(fqdn);
}
use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer in project cloudbreak by hortonworks.
the class LoadBalancerConfigServiceTest method testCreateAzureEndpointGateway.
@Test
public void testCreateAzureEndpointGateway() {
Stack stack = createAzureStack(StackType.DATALAKE, PRIVATE_ID_1, true);
CloudSubnet subnet = getPrivateCloudSubnet(PRIVATE_ID_1, AZ_1);
DetailedEnvironmentResponse environment = createEnvironment(subnet, true, "AZURE");
StackV4Request request = new StackV4Request();
request.setEnableLoadBalancer(false);
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.PUBLIC.equals(l.getType()));
checkAvailabilitySetAttributes(loadBalancers);
});
}
use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer in project cloudbreak by hortonworks.
the class StackToCloudStackConverterTest method testConvertWithMultipleKnoxLoadBalancers.
@Test
public void testConvertWithMultipleKnoxLoadBalancers() {
Set<InstanceGroup> instanceGroups = new LinkedHashSet<>();
InstanceGroup instanceGroup1 = mock(InstanceGroup.class);
InstanceGroup instanceGroup2 = mock(InstanceGroup.class);
when(instanceGroup1.getGroupName()).thenReturn("group1");
when(instanceGroup2.getGroupName()).thenReturn("group2");
instanceGroups.add(instanceGroup1);
instanceGroups.add(instanceGroup2);
when(stack.getInstanceGroupsAsList()).thenReturn(new ArrayList<>(instanceGroups));
Template template = new Template();
template.setVolumeTemplates(Set.of());
when(instanceGroup1.getTemplate()).thenReturn(template);
when(instanceGroup1.getNotDeletedInstanceMetaDataSet()).thenReturn(Set.of());
when(instanceGroup1.getStack()).thenReturn(stack);
when(instanceGroup2.getTemplate()).thenReturn(template);
when(instanceGroup2.getNotDeletedInstanceMetaDataSet()).thenReturn(Set.of());
when(instanceGroup2.getStack()).thenReturn(stack);
TargetGroup targetGroup = mock(TargetGroup.class);
when(targetGroup.getType()).thenReturn(TargetGroupType.KNOX);
LoadBalancer internalLoadBalancer = mock(LoadBalancer.class);
when(internalLoadBalancer.getType()).thenReturn(LoadBalancerType.PRIVATE);
when(internalLoadBalancer.getId()).thenReturn(1L);
LoadBalancer externalLoadBalancer = mock(LoadBalancer.class);
when(externalLoadBalancer.getType()).thenReturn(LoadBalancerType.PUBLIC);
when(externalLoadBalancer.getId()).thenReturn(2L);
when(loadBalancerPersistenceService.findByStackId(anyLong())).thenReturn(Set.of(internalLoadBalancer, externalLoadBalancer));
when(targetGroupPersistenceService.findByLoadBalancerId(anyLong())).thenReturn(Set.of(targetGroup));
when(instanceGroupService.findByTargetGroupId(anyLong())).thenReturn(Set.of(instanceGroup1, instanceGroup2));
when(loadBalancerConfigService.getTargetGroupPortPairs(any(TargetGroup.class))).thenReturn(Set.of(new TargetGroupPortPair(443, 8443)));
CloudStack result = underTest.convert(stack);
assertEquals(2, result.getLoadBalancers().size());
Optional<CloudLoadBalancer> internalCloudLoadBalancer = result.getLoadBalancers().stream().filter(lb -> lb.getType() == LoadBalancerType.PRIVATE).findFirst();
assertTrue(internalCloudLoadBalancer.isPresent());
Optional<CloudLoadBalancer> externalCloudLoadBalancer = result.getLoadBalancers().stream().filter(lb -> lb.getType() == LoadBalancerType.PUBLIC).findFirst();
assertTrue(externalCloudLoadBalancer.isPresent());
}
Aggregations