Search in sources :

Example 26 with EnvironmentNetworkResponse

use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.

the class NetworkV1ToNetworkV4ConverterTest method testConvertToStackRequestWhenAzurePresentedWithoutSubnet.

@Test
public void testConvertToStackRequestWhenAzurePresentedWithoutSubnet() {
    NetworkV1Request networkV1Request = azureEmptyNetworkV1Request();
    DetailedEnvironmentResponse environmentNetworkResponse = azureEnvironmentNetwork();
    NetworkV4Request networkV4Request = underTest.convertToNetworkV4Request(new ImmutablePair<>(networkV1Request, environmentNetworkResponse));
    assertEquals(networkV4Request.createAzure().getNetworkId(), VPC_ID);
    assertEquals(networkV4Request.createAzure().getResourceGroupName(), GROUP_NAME);
    assertTrue(SUBNET_IDS.contains(networkV4Request.createAzure().getSubnetId()));
}
Also used : DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) NetworkV1Request(com.sequenceiq.distrox.api.v1.distrox.model.network.NetworkV1Request) NetworkV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request) Test(org.junit.jupiter.api.Test)

Example 27 with EnvironmentNetworkResponse

use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.

the class NetworkV1ToNetworkV4ConverterTest method createEnvironmentNetworkResponseForMock.

private EnvironmentNetworkResponse createEnvironmentNetworkResponseForMock() {
    EnvironmentNetworkResponse environmentNetworkResponse = new EnvironmentNetworkResponse();
    environmentNetworkResponse.setSubnetIds(SUBNET_IDS);
    environmentNetworkResponse.setPreferedSubnetId(SUBNET_ID);
    environmentNetworkResponse.setMock(createEnvironmentNetworkMockParams());
    return environmentNetworkResponse;
}
Also used : EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse)

Example 28 with EnvironmentNetworkResponse

use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.

the class NetworkV1ToNetworkV4ConverterTest method testConvertToStackRequestWhenAwsPresentedWithoutSubnet.

@Test
public void testConvertToStackRequestWhenAwsPresentedWithoutSubnet() {
    NetworkV1Request networkV1Request = awsEmptyNetworkV1Request();
    DetailedEnvironmentResponse environmentNetworkResponse = awsEnvironmentNetwork();
    NetworkV4Request[] networkV4Request = new NetworkV4Request[1];
    ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> {
        networkV4Request[0] = underTest.convertToNetworkV4Request(new ImmutablePair<>(networkV1Request, environmentNetworkResponse));
    });
    assertEquals(networkV4Request[0].createAws().getVpcId(), VPC_ID);
    assertTrue(SUBNET_IDS.contains(networkV4Request[0].createAws().getSubnetId()));
}
Also used : ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) NetworkV1Request(com.sequenceiq.distrox.api.v1.distrox.model.network.NetworkV1Request) NetworkV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request) Test(org.junit.jupiter.api.Test)

Example 29 with EnvironmentNetworkResponse

use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.

the class EnvironmentValidatorTest method createNetwork.

private EnvironmentNetworkResponse createNetwork(Map<String, CloudSubnet> subnetMetas) {
    EnvironmentNetworkResponse network = new EnvironmentNetworkResponse();
    network.setSubnetMetas(subnetMetas);
    return network;
}
Also used : EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse)

Example 30 with EnvironmentNetworkResponse

use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.

the class MultiAzDecoratorTest method decorateStackRequestWithMultiAzShouldUseTheSingleEnvironmentPreferredSubnetIdWhenClusterShapeIsNotHA.

@Test
void decorateStackRequestWithMultiAzShouldUseTheSingleEnvironmentPreferredSubnetIdWhenClusterShapeIsNotHA() {
    StackV4Request stackV4Request = new StackV4Request();
    stackV4Request.setInstanceGroups(List.of(getInstanceGroupV4Request(InstanceGroupType.GATEWAY), getInstanceGroupV4Request(InstanceGroupType.CORE)));
    EnvironmentNetworkResponse network = new EnvironmentNetworkResponse();
    network.setPreferedSubnetId(PREFERRED_SUBNET_ID);
    DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
    environment.setNetwork(network);
    underTest.decorateStackRequestWithMultiAz(stackV4Request, environment, SdxClusterShape.LIGHT_DUTY);
    Assertions.assertTrue(stackV4Request.getInstanceGroups().stream().allMatch(ig -> ig.getNetwork().getAws().getSubnetIds().stream().allMatch(PREFERRED_SUBNET_ID::equals)));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) SdxClusterShape(com.sequenceiq.sdx.api.model.SdxClusterShape) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) Set(java.util.Set) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) Test(org.junit.jupiter.api.Test) List(java.util.List) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) SubnetType(com.sequenceiq.cloudbreak.cloud.model.network.SubnetType) Map(java.util.Map) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) Assertions(org.junit.jupiter.api.Assertions) InstanceGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request) Tunnel(com.sequenceiq.common.api.type.Tunnel) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) Test(org.junit.jupiter.api.Test)

Aggregations

EnvironmentNetworkResponse (com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse)70 Test (org.junit.jupiter.api.Test)40 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)27 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)24 SubnetTest (com.sequenceiq.cloudbreak.core.network.SubnetTest)22 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)8 NetworkV1Request (com.sequenceiq.distrox.api.v1.distrox.model.network.NetworkV1Request)8 NetworkV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request)7 Test (org.junit.Test)7 EnvironmentNetworkGcpParams (com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkGcpParams)6 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)5 Network (com.sequenceiq.cloudbreak.domain.Network)5 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)5 ProvidedSubnetIds (com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 InstanceGroupV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request)3 SubnetType (com.sequenceiq.cloudbreak.cloud.model.network.SubnetType)3 InstanceGroupType (com.sequenceiq.common.api.type.InstanceGroupType)3 Tunnel (com.sequenceiq.common.api.type.Tunnel)3 EnvironmentNetworkAwsParams (com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkAwsParams)3