use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer in project cloudbreak by hortonworks.
the class GatewayPublicEndpointManagementServiceTest method testDeleteDnsEntryForLoadBalancerWithIpAddress.
@Test
void testDeleteDnsEntryForLoadBalancerWithIpAddress() {
Cluster cluster = TestUtil.cluster();
LoadBalancer loadBalancer = new LoadBalancer();
loadBalancer.setEndpoint("gateway");
loadBalancer.setIp("1.2.3.4");
loadBalancer.setType(LoadBalancerType.PUBLIC);
Stack stack = cluster.getStack();
stack.setCluster(cluster);
stack.setLoadBalancers(Set.of(loadBalancer));
String lbEndpointName = loadBalancer.getEndpoint();
String envName = "anEnvName";
String ip = loadBalancer.getIp();
when(dnsManagementService.deleteDnsEntryWithIp(eq("123"), eq(lbEndpointName), eq(envName), eq(Boolean.FALSE), eq(List.of(ip)))).thenReturn(Boolean.TRUE);
when(loadBalancerPersistenceService.findByStackId(anyLong())).thenReturn(Set.of(loadBalancer));
when(loadBalancerConfigService.selectLoadBalancerForFrontend(any(), any())).thenReturn(Optional.of(loadBalancer));
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.deleteLoadBalancerDnsEntry(stack, envName));
verify(dnsManagementService, times(1)).deleteDnsEntryWithIp(eq("123"), eq(lbEndpointName), eq(envName), eq(Boolean.FALSE), eq(List.of(ip)));
}
use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer in project cloudbreak by hortonworks.
the class LoadBalancerConfigServiceTest method testCreateLoadBalancersForEndpointGatewayDatalakePublicSubnetsOnly.
@Test
public void testCreateLoadBalancersForEndpointGatewayDatalakePublicSubnetsOnly() {
Stack stack = createAwsStack(StackType.DATALAKE, PUBLIC_ID_1);
CloudSubnet subnet = getPublicCloudSubnet(PUBLIC_ID_1, AZ_1);
DetailedEnvironmentResponse environment = createEnvironment(subnet, true, "AWS");
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));
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 testCreateLoadBalancerForYarn.
@Test
public void testCreateLoadBalancerForYarn() {
Stack stack = createYarnStack();
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"));
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 testCreateAzurePrivateLoadBalancer.
@Test
public void testCreateAzurePrivateLoadBalancer() {
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);
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());
checkAvailabilitySetAttributes(loadBalancers);
});
}
use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer in project cloudbreak by hortonworks.
the class LoadBalancerConfigServiceTest method testCreateLoadBalancerForDataLakePrivateSubnets.
@Test
public void testCreateLoadBalancerForDataLakePrivateSubnets() {
Stack stack = createAwsStack(StackType.DATALAKE, PRIVATE_ID_1);
CloudSubnet subnet = getPrivateCloudSubnet(PRIVATE_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.PRIVATE, loadBalancers.iterator().next().getType());
InstanceGroup masterInstanceGroup = stack.getInstanceGroups().stream().filter(ig -> "master".equals(ig.getGroupName())).findFirst().get();
assertEquals(1, masterInstanceGroup.getTargetGroups().size());
});
}
Aggregations