Search in sources :

Example 11 with NetworkConnector

use of com.sequenceiq.cloudbreak.cloud.NetworkConnector 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 NetworkConnector

use of com.sequenceiq.cloudbreak.cloud.NetworkConnector in project cloudbreak by hortonworks.

the class SubnetChooserServiceTest method setupConnector.

private NetworkConnector setupConnector(String errorMessage) {
    CloudConnector cloudConnector = mock(CloudConnector.class);
    NetworkConnector networkConnector = mock(NetworkConnector.class);
    SubnetSelectionResult subnetSelectionResult = StringUtils.isEmpty(errorMessage) ? new SubnetSelectionResult(List.of()) : new SubnetSelectionResult(errorMessage);
    when(networkConnector.chooseSubnets(any(), any())).thenReturn(subnetSelectionResult);
    when(cloudConnector.networkConnector()).thenReturn(networkConnector);
    when(cloudPlatformConnectors.get(any())).thenReturn(cloudConnector);
    return networkConnector;
}
Also used : CloudConnector(com.sequenceiq.cloudbreak.cloud.CloudConnector) NetworkConnector(com.sequenceiq.cloudbreak.cloud.NetworkConnector) SubnetSelectionResult(com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionResult)

Example 13 with NetworkConnector

use of com.sequenceiq.cloudbreak.cloud.NetworkConnector 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

NetworkConnector (com.sequenceiq.cloudbreak.cloud.NetworkConnector)13 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)6 SubnetSelectionParameters (com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionParameters)6 SubnetSelectionResult (com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionResult)4 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)3 DBStack (com.sequenceiq.redbeams.domain.stack.DBStack)3 Test (org.junit.Test)3 CloudConnector (com.sequenceiq.cloudbreak.cloud.CloudConnector)2 ProvidedSubnetIds (com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds)2 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)1 CreatedCloudNetwork (com.sequenceiq.cloudbreak.cloud.model.network.CreatedCloudNetwork)1 NetworkCreationRequest (com.sequenceiq.cloudbreak.cloud.model.network.NetworkCreationRequest)1 NetworkResourcesCreationRequest (com.sequenceiq.cloudbreak.cloud.model.network.NetworkResourcesCreationRequest)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 Tunnel (com.sequenceiq.common.api.type.Tunnel)1 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)1 EnvironmentNetworkConverter (com.sequenceiq.environment.network.v1.converter.EnvironmentNetworkConverter)1 Test (org.junit.jupiter.api.Test)1