Search in sources :

Example 11 with SubnetSelectionParameters

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

the class SubnetChooserServiceTest method testChooseSubnetsThenNetworkSelectorCalled.

@Test
public void testChooseSubnetsThenNetworkSelectorCalled() {
    List<CloudSubnet> subnets = List.of(new CloudSubnet(SUBNET_1, "", AVAILABILITY_ZONE_A, ""), new CloudSubnet(SUBNET_2, "", AVAILABILITY_ZONE_B, ""), new CloudSubnet(SUBNET_3, "", AVAILABILITY_ZONE_B, ""));
    NetworkConnector networkConnector = setupConnector();
    underTest.chooseSubnets(subnets, CloudPlatform.AWS, new DBStack());
    ArgumentCaptor<SubnetSelectionParameters> subnetSelectionParametersCaptor = ArgumentCaptor.forClass(SubnetSelectionParameters.class);
    verify(networkConnector).chooseSubnets(eq(subnets), subnetSelectionParametersCaptor.capture());
    assertTrue(subnetSelectionParametersCaptor.getValue().isPreferPrivateIfExist());
    assertTrue(subnetSelectionParametersCaptor.getValue().isHa());
}
Also used : DBStack(com.sequenceiq.redbeams.domain.stack.DBStack) SubnetSelectionParameters(com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionParameters) NetworkConnector(com.sequenceiq.cloudbreak.cloud.NetworkConnector) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Test(org.junit.Test)

Example 12 with SubnetSelectionParameters

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

the class SubnetChooserServiceTest method testChooseSubnetsWhenAwsNoHaThenHaIsFalse.

@Test
public void testChooseSubnetsWhenAwsNoHaThenHaIsFalse() {
    List<CloudSubnet> subnets = List.of();
    NetworkConnector networkConnector = setupConnector();
    DBStack dbStack = mock(DBStack.class);
    when(dbStack.isHa()).thenReturn(false);
    underTest.chooseSubnets(subnets, CloudPlatform.AWS, dbStack);
    ArgumentCaptor<SubnetSelectionParameters> subnetSelectionParametersCaptor = ArgumentCaptor.forClass(SubnetSelectionParameters.class);
    verify(networkConnector).chooseSubnets(eq(subnets), subnetSelectionParametersCaptor.capture());
    assertTrue(subnetSelectionParametersCaptor.getValue().isPreferPrivateIfExist());
    assertFalse(subnetSelectionParametersCaptor.getValue().isHa());
}
Also used : DBStack(com.sequenceiq.redbeams.domain.stack.DBStack) SubnetSelectionParameters(com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionParameters) NetworkConnector(com.sequenceiq.cloudbreak.cloud.NetworkConnector) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Test(org.junit.Test)

Aggregations

SubnetSelectionParameters (com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionParameters)12 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)11 Test (org.junit.Test)9 SubnetSelectionResult (com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionResult)8 NetworkConnector (com.sequenceiq.cloudbreak.cloud.NetworkConnector)6 DBStack (com.sequenceiq.redbeams.domain.stack.DBStack)3 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)2 ProvidedSubnetIds (com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds)2 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 Tunnel (com.sequenceiq.common.api.type.Tunnel)1 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)1 Test (org.junit.jupiter.api.Test)1