Search in sources :

Example 11 with AwsParams

use of com.sequenceiq.environment.network.dto.AwsParams in project cloudbreak by hortonworks.

the class AwsEnvironmentNetworkValidatorTest method testValidateDuringRequestWhenNetworkHasTwoSubnetSubnetMetasHasThreeSubnets.

@Test
void testValidateDuringRequestWhenNetworkHasTwoSubnetSubnetMetasHasThreeSubnets() {
    AwsParams awsParams = getAwsParams();
    NetworkDto networkDto = NetworkTestUtils.getNetworkDto(null, getAwsParams(), null, awsParams.getVpcId(), null, 2, RegistrationType.EXISTING);
    ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
    EnvironmentDto environmentDto = new EnvironmentDto();
    environmentDto.setName(ENV_NAME);
    environmentDto.setNetwork(networkDto);
    EnvironmentValidationDto environmentValidationDto = EnvironmentValidationDto.builder().withEnvironmentDto(environmentDto).build();
    when(cloudNetworkService.retrieveSubnetMetadata(environmentDto, networkDto)).thenReturn(new LinkedHashMap<>());
    underTest.validateDuringFlow(environmentValidationDto, networkDto, validationResultBuilder);
    NetworkTestUtils.checkErrorsPresent(validationResultBuilder, List.of("Subnets of the environment (someenv) are not found in the VPC (key1, key0). All subnets are expected to belong to the same VPC"));
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) AwsParams(com.sequenceiq.environment.network.dto.AwsParams) EnvironmentValidationDto(com.sequenceiq.environment.environment.dto.EnvironmentValidationDto) Test(org.junit.jupiter.api.Test)

Example 12 with AwsParams

use of com.sequenceiq.environment.network.dto.AwsParams in project cloudbreak by hortonworks.

the class AwsEnvironmentNetworkValidatorTest method testValidateDuringRequestWhenNetworkHasTwoSubnetsWithSameAvailabilityZone.

@Test
void testValidateDuringRequestWhenNetworkHasTwoSubnetsWithSameAvailabilityZone() {
    AwsParams awsParams = getAwsParams();
    NetworkDto networkDto = NetworkTestUtils.getNetworkDto(null, awsParams, null, awsParams.getVpcId(), null, 2, RegistrationType.EXISTING);
    Map<String, CloudSubnet> subnetMetas = new HashMap<>();
    for (int i = 0; i < 2; i++) {
        subnetMetas.put("key" + i, NetworkTestUtils.getCloudSubnet("eu-west-1-a"));
    }
    ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
    EnvironmentDto environmentDto = new EnvironmentDto();
    environmentDto.setNetwork(networkDto);
    EnvironmentValidationDto environmentValidationDto = EnvironmentValidationDto.builder().withEnvironmentDto(environmentDto).build();
    when(cloudNetworkService.retrieveSubnetMetadata(environmentDto, networkDto)).thenReturn(subnetMetas);
    underTest.validateDuringFlow(environmentValidationDto, networkDto, validationResultBuilder);
    NetworkTestUtils.checkErrorsPresent(validationResultBuilder, List.of("The Subnets in the VPC (eu-west-1-a) should be present at least in two different availability zones, " + "but they are present only in availability zone name, name. Please add subnets to the environment " + "from the required number of different availability zones."));
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) AwsParams(com.sequenceiq.environment.network.dto.AwsParams) EnvironmentValidationDto(com.sequenceiq.environment.environment.dto.EnvironmentValidationDto) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Test(org.junit.jupiter.api.Test)

Aggregations

AwsParams (com.sequenceiq.environment.network.dto.AwsParams)12 Test (org.junit.jupiter.api.Test)10 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)8 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)7 ValidationResultBuilder (com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder)6 LinkedHashMap (java.util.LinkedHashMap)6 CloudNetwork (com.sequenceiq.cloudbreak.cloud.model.CloudNetwork)4 Set (java.util.Set)4 DisplayName (org.junit.jupiter.api.DisplayName)4 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)3 EnvironmentValidationDto (com.sequenceiq.environment.environment.dto.EnvironmentValidationDto)3 HashMap (java.util.HashMap)2 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)1 AzureParams (com.sequenceiq.environment.network.dto.AzureParams)1 GcpParams (com.sequenceiq.environment.network.dto.GcpParams)1 MockParams (com.sequenceiq.environment.network.dto.MockParams)1 YarnParams (com.sequenceiq.environment.network.dto.YarnParams)1 ProvidedSubnetIds (com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds)1 InstanceGroupNetworkRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupNetworkRequest)1 InstanceGroupAwsNetworkParameters (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.aws.InstanceGroupAwsNetworkParameters)1