use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup in project cloudbreak by hortonworks.
the class GatewaySecurityGroupDecoratorTest method testConvertExtendsGatewaySecurityGroupsWithDefaultGatewayCidrsWithoutCCM.
@Test
public void testConvertExtendsGatewaySecurityGroupsWithDefaultGatewayCidrsWithoutCCM() {
ReflectionTestUtils.setField(underTest, "defaultGatewayCidr", Set.of("0.0.0.0/0", "1.1.1.1/1"));
ReflectionTestUtils.setField(underTest, "nginxPort", 9443);
// WHEN
underTest.extendGatewaySecurityGroupWithDefaultGatewayCidrs(stack, Tunnel.DIRECT);
// THEN
Set<InstanceGroup> gateways = stack.getInstanceGroups().stream().filter(ig -> InstanceGroupType.isGateway(ig.getInstanceGroupType())).collect(Collectors.toSet());
for (InstanceGroup ig : gateways) {
assertEquals(2, ig.getSecurityGroup().getSecurityRules().stream().filter(rule -> rule.getCidr().equals("0.0.0.0/0") || rule.getCidr().equals("1.1.1.1/1") && Arrays.stream(rule.getPorts()).anyMatch(port -> port.equals("9443"))).count());
}
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup 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.instance.InstanceGroup 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());
});
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup 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.instance.InstanceGroup in project cloudbreak by hortonworks.
the class LoadBalancerConfigServiceTest method testGetKnoxGatewayWhenKnoxImplicitlyDefinedByGatewayGroup.
@Test
public void testGetKnoxGatewayWhenKnoxImplicitlyDefinedByGatewayGroup() {
Set<String> groups = Set.of("gateway");
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setGroupName("gateway");
instanceGroup.setInstanceGroupType(InstanceGroupType.GATEWAY);
Cluster cluster = new Cluster();
cluster.setBlueprint(blueprint);
Stack stack = new Stack();
stack.setCluster(cluster);
stack.setInstanceGroups(Set.of(instanceGroup));
when(blueprint.getBlueprintText()).thenReturn("{}");
Set<String> selectedGroups = underTest.getKnoxGatewayGroups(stack);
assertEquals(groups, selectedGroups);
}
Aggregations