Search in sources :

Example 6 with SubnetSelectionResult

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

the class SubnetFilterStrategyMultiplePreferPrivateTest method testFilterNonHAPrivateSubnetWhenOnlyPrivateSubnetPresentedShouldReturnPrivateSubnets.

@Test
public void testFilterNonHAPrivateSubnetWhenOnlyPrivateSubnetPresentedShouldReturnPrivateSubnets() {
    List<CloudSubnet> subnets = new SubnetBuilder().withPrivateSubnet(AZ_A).withPrivateSubnet(AZ_B).withPrivateSubnet(AZ_B).build();
    SubnetSelectionResult chosenSubnets = underTest.filter(subnets, 1);
    verify(subnetSelectorService, times(1)).collectPrivateSubnets(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 7 with SubnetSelectionResult

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

the class SubnetFilterStrategyMultiplePreferPrivateTest method testFilterHAMixedSubnetWhenOnlyPrivateSubnetHasUniqueAZPresentedShouldReturnOnlyPrivateSubnets.

@Test
public void testFilterHAMixedSubnetWhenOnlyPrivateSubnetHasUniqueAZPresentedShouldReturnOnlyPrivateSubnets() {
    List<CloudSubnet> subnets = new SubnetBuilder().withPrivateSubnet(AZ_A).withPrivateSubnet(AZ_B).withPublicSubnet(AZ_B).build();
    SubnetSelectionResult chosenSubnets = underTest.filter(subnets, 3);
    verify(subnetSelectorService, times(1)).collectPrivateSubnets(anyCollection());
    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 8 with SubnetSelectionResult

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

the class SubnetFilterStrategyMultiplePreferPrivateTest method testFilterNonHAPrivateSubnetWhenMixedSubnetWithDifferentAzPresentedShouldReturnPrivateAnPublicSubnets.

@Test
public void testFilterNonHAPrivateSubnetWhenMixedSubnetWithDifferentAzPresentedShouldReturnPrivateAnPublicSubnets() {
    List<CloudSubnet> subnets = new SubnetBuilder().withPrivateSubnet(AZ_A).withPrivateSubnet(AZ_B).withPublicSubnet(AZ_C).build();
    SubnetSelectionResult chosenSubnets = underTest.filter(subnets, 1);
    verify(subnetSelectorService, times(1)).collectPrivateSubnets(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 9 with SubnetSelectionResult

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

the class GcpSubnetSelectorServiceTest method testSelectWhenNoErrorShouldReturnFirstSubnet.

@Test
public void testSelectWhenNoErrorShouldReturnFirstSubnet() {
    SubnetSelectionResult select = underTest.select(generateSubnetMetas(1), SubnetSelectionParameters.builder().build());
    Assert.assertEquals(1, select.getResult().size());
}
Also used : SubnetSelectionResult(com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionResult) Test(org.junit.jupiter.api.Test)

Example 10 with SubnetSelectionResult

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

the class GcpSubnetSelectorServiceTest method testSelectWhenNoSubnetMetadataShouldReturnError.

@Test
public void testSelectWhenNoSubnetMetadataShouldReturnError() {
    SubnetSelectionResult select = underTest.select(generateSubnetMetas(0), SubnetSelectionParameters.builder().build());
    Assert.assertEquals(select.getErrorMessage(), "GCP subnet selection: there are no subnets to choose from.");
}
Also used : SubnetSelectionResult(com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionResult) Test(org.junit.jupiter.api.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