Search in sources :

Example 21 with SubnetSelectionResult

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

the class GcpNetworkConnectorTest method testFilterSubnets.

@Test
public void testFilterSubnets() {
    when(gcpSubnetSelectorService.select(anyCollection(), any(SubnetSelectionParameters.class))).thenReturn(new SubnetSelectionResult(new ArrayList<>()));
    underTest.filterSubnets(new ArrayList<>(), SubnetSelectionParameters.builder().build());
    verify(gcpSubnetSelectorService, times(1)).select(anyCollection(), any(SubnetSelectionParameters.class));
}
Also used : SubnetSelectionParameters(com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionParameters) ArrayList(java.util.ArrayList) SubnetSelectionResult(com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionResult) Test(org.junit.jupiter.api.Test)

Example 22 with SubnetSelectionResult

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

the class GcpSubnetSelectorServiceTest method testSelectWhenNoSubnetSelectionParametersShouldReturnError.

@Test
public void testSelectWhenNoSubnetSelectionParametersShouldReturnError() {
    SubnetSelectionResult select = underTest.select(generateSubnetMetas(1), null);
    Assert.assertEquals(select.getErrorMessage(), "GCP subnet selection: parameters were not specified.");
}
Also used : SubnetSelectionResult(com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionResult) Test(org.junit.jupiter.api.Test)

Example 23 with SubnetSelectionResult

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

the class SubnetFilterStrategyMultiplePreferPrivateTest method testFilterPrivateSubnetWhenOnlyPrivateAndPublicSubnetPresentedShouldReturnPrivateSubnets.

@Test
public void testFilterPrivateSubnetWhenOnlyPrivateAndPublicSubnetPresentedShouldReturnPrivateSubnets() {
    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, 3);
    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 24 with SubnetSelectionResult

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

the class SubnetFilterStrategyMultiplePreferPrivateTest method testFilterHAPrivateSubnetWhenMixedSubnetWithDifferentAzPresentedShouldReturnPrivateAnPublicSubnets.

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

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

the class SubnetFilterStrategyMultiplePreferPublicTest method testSelectHAPublicSubnetWhenMixedSubnetPresentedShouldReturnMixedSubnets.

@Test
public void testSelectHAPublicSubnetWhenMixedSubnetPresentedShouldReturnMixedSubnets() {
    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, 3);
    verify(subnetSelectorService, times(1)).collectPublicSubnets(anyCollection());
    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)

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