Search in sources :

Example 26 with SubnetSelectionResult

use of com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionResult in project cloudbreak by hortonworks.

the class SubnetFilterStrategyMultiplePreferPublicTest method testSelectHAPublicSubnetWhenMixedSubnetPresentedShouldReturnMixedSubnetsWithNotUniquePublicAzs.

@Test
public void testSelectHAPublicSubnetWhenMixedSubnetPresentedShouldReturnMixedSubnetsWithNotUniquePublicAzs() {
    List<CloudSubnet> subnets = new SubnetBuilder().withPrivateSubnet(AZ_A).withPrivateSubnet(AZ_B).withPrivateSubnet(AZ_B).withPublicSubnet(AZ_C).withPublicSubnet(AZ_D).withPublicSubnet(AZ_D).build();
    SubnetSelectionResult chosenSubnets = underTest.filter(subnets, 3);
    verify(subnetSelectorService, times(1)).collectPublicSubnets(anyCollection());
    verify(subnetSelectorService, times(1)).collectPrivateSubnets(anyCollection());
    assertThat(chosenSubnets.getResult(), hasSize(4));
}
Also used : SubnetSelectionResult(com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionResult) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Test(org.junit.Test)

Example 27 with SubnetSelectionResult

use of com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionResult in project cloudbreak by hortonworks.

the class SubnetFilterStrategyMultiplePreferPublicTest method testSelectNonHAMixedSubnetWhenOnlyPrivateSubnetPresentedShouldReturnMixedSubnets.

@Test
public void testSelectNonHAMixedSubnetWhenOnlyPrivateSubnetPresentedShouldReturnMixedSubnets() {
    List<CloudSubnet> subnets = new SubnetBuilder().withPublicSubnet(AZ_A).withPublicSubnet(AZ_B).withPublicSubnet(AZ_B).withPrivateSubnet(AZ_C).build();
    SubnetSelectionResult chosenSubnets = underTest.filter(subnets, 1);
    verify(subnetSelectorService, times(1)).collectPublicSubnets(anyCollection());
    assertThat(chosenSubnets.getResult(), hasSize(3));
}
Also used : SubnetSelectionResult(com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionResult) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Test(org.junit.Test)

Example 28 with SubnetSelectionResult

use of com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionResult in project cloudbreak by hortonworks.

the class SubnetFilterStrategyMultiplePreferPublicTest method testSelectNonHAPrivateSubnetWhenOnlyPrivateAndPublicSubnetPresentedShouldReturnPrivateSubnets.

@Test
public void testSelectNonHAPrivateSubnetWhenOnlyPrivateAndPublicSubnetPresentedShouldReturnPrivateSubnets() {
    List<CloudSubnet> subnets = new SubnetBuilder().withPrivateSubnet(AZ_A).withPrivateSubnet(AZ_B).withPrivateSubnet(AZ_B).withPublicSubnet(AZ_C).withPublicSubnet(AZ_D).build();
    SubnetSelectionResult chosenSubnets = underTest.filter(subnets, 1);
    verify(subnetSelectorService, times(1)).collectPublicSubnets(anyCollection());
    assertThat(chosenSubnets.getResult(), hasSize(2));
}
Also used : SubnetSelectionResult(com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionResult) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Test(org.junit.Test)

Example 29 with SubnetSelectionResult

use of com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionResult in project cloudbreak by hortonworks.

the class SubnetFilterStrategyMultiplePreferPublicTest method testSelectHAPublicSubnetWhenOnlyPublicSubnetPresentedShouldReturnPublicSubnets.

@Test
public void testSelectHAPublicSubnetWhenOnlyPublicSubnetPresentedShouldReturnPublicSubnets() {
    List<CloudSubnet> subnets = new SubnetBuilder().withPublicSubnet(AZ_A).withPublicSubnet(AZ_B).withPublicSubnet(AZ_B).build();
    SubnetSelectionResult chosenSubnets = underTest.filter(subnets, 3);
    verify(subnetSelectorService, times(1)).collectPublicSubnets(anyCollection());
    assertThat(chosenSubnets.getResult(), hasSize(3));
}
Also used : SubnetSelectionResult(com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionResult) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Test(org.junit.Test)

Example 30 with SubnetSelectionResult

use of com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionResult in project cloudbreak by hortonworks.

the class AzureSubnetSelectorServiceTest method testSelectWhenSubnetmetasNullThenReturnsError.

@Test
public void testSelectWhenSubnetmetasNullThenReturnsError() {
    SubnetSelectionResult subnetSelectionResult = underTest.select(null, SubnetSelectionParameters.builder().build());
    assertTrue(subnetSelectionResult.hasError());
    assertEquals("Azure subnet selection: there are no subnets to choose from.", subnetSelectionResult.getErrorMessage());
}
Also used : SubnetSelectionResult(com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionResult) Test(org.junit.Test)

Aggregations

SubnetSelectionResult (com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionResult)35 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)26 Test (org.junit.Test)22 SubnetSelectionParameters (com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionParameters)9 NetworkConnector (com.sequenceiq.cloudbreak.cloud.NetworkConnector)4 Test (org.junit.jupiter.api.Test)4 CloudConnector (com.sequenceiq.cloudbreak.cloud.CloudConnector)2 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)2 Collection (java.util.Collection)2 List (java.util.List)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Inject (javax.inject.Inject)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 Component (org.springframework.stereotype.Component)2 SubnetFilterStrategy (com.sequenceiq.cloudbreak.cloud.aws.common.subnetselector.SubnetFilterStrategy)1 SubnetFilterStrategyType (com.sequenceiq.cloudbreak.cloud.aws.common.subnetselector.SubnetFilterStrategyType)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 ProvidedSubnetIds (com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds)1