Search in sources :

Example 86 with NetworkDto

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

the class AwsEnvironmentNetworkValidatorTest method testValidateDuringFlowWhenNetworkTypeIsNewThenNoValidationHappensEvenIfTheActualNetworkDtoIsInvalid.

@Test
void testValidateDuringFlowWhenNetworkTypeIsNewThenNoValidationHappensEvenIfTheActualNetworkDtoIsInvalid() {
    NetworkDto networkDto = NetworkTestUtils.getNetworkDto(null, null, null, null, null, 999, RegistrationType.CREATE_NEW);
    ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
    underTest.validateDuringFlow(new EnvironmentValidationDto(), networkDto, validationResultBuilder);
    verify(cloudNetworkService, times(0)).retrieveSubnetMetadata(any(EnvironmentDto.class), any(NetworkDto.class));
    verify(cloudNetworkService, times(0)).retrieveSubnetMetadata(any(Environment.class), any(NetworkDto.class));
    ValidationResult validationResult = validationResultBuilder.build();
    assertFalse(validationResult.hasError());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) Environment(com.sequenceiq.environment.environment.domain.Environment) EnvironmentValidationDto(com.sequenceiq.environment.environment.dto.EnvironmentValidationDto) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.jupiter.api.Test)

Example 87 with NetworkDto

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

the class AwsEnvironmentNetworkValidatorTest method testValidateDuringFlowWhenTheNetworkDoesNotContainAwsNetworkParams.

@Test
void testValidateDuringFlowWhenTheNetworkDoesNotContainAwsNetworkParams() {
    ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
    NetworkDto networkDto = NetworkDto.builder().withId(1L).withName("networkName").withResourceCrn("aResourceCRN").withAws(null).build();
    underTest.validateDuringRequest(networkDto, validationResultBuilder);
    ValidationResult validationResult = validationResultBuilder.build();
    assertTrue(validationResult.hasError());
    String actual = validationResult.getErrors().get(0);
    assertEquals("The 'AWS' related network parameters should be specified!", actual);
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.jupiter.api.Test)

Example 88 with NetworkDto

use of com.sequenceiq.environment.network.dto.NetworkDto 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 89 with NetworkDto

use of com.sequenceiq.environment.network.dto.NetworkDto 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)

Example 90 with NetworkDto

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

the class AwsEnvironmentNetworkValidatorTest method testValidateDuringRequestWhenNetworkHasNoNetworkIdAndNoCidr.

@Test
void testValidateDuringRequestWhenNetworkHasNoNetworkIdAndNoCidr() {
    NetworkDto networkDto = NetworkTestUtils.getNetworkDto(null, getAwsParams(), null, null, null, 1, RegistrationType.EXISTING);
    ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
    EnvironmentDto environmentDto = new EnvironmentDto();
    environmentDto.setNetwork(networkDto);
    EnvironmentValidationDto environmentValidationDto = EnvironmentValidationDto.builder().withEnvironmentDto(environmentDto).build();
    underTest.validateDuringFlow(environmentValidationDto, networkDto, validationResultBuilder);
    NetworkTestUtils.checkErrorsPresent(validationResultBuilder, List.of("Either the AWS network id or cidr needs to be defined!"));
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) EnvironmentValidationDto(com.sequenceiq.environment.environment.dto.EnvironmentValidationDto) Test(org.junit.jupiter.api.Test)

Aggregations

NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)144 Test (org.junit.jupiter.api.Test)124 ValidationResultBuilder (com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder)59 AzureParams (com.sequenceiq.environment.network.dto.AzureParams)40 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)31 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)27 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)21 EnvironmentValidationDto (com.sequenceiq.environment.environment.dto.EnvironmentValidationDto)21 UsageProto (com.cloudera.thunderhead.service.common.usage.UsageProto)15 Environment (com.sequenceiq.environment.environment.domain.Environment)15 ProvidedSubnetIds (com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds)14 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)13 AwsNetwork (com.sequenceiq.environment.network.dao.domain.AwsNetwork)12 EnvironmentTelemetry (com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry)10 AwsParams (com.sequenceiq.environment.network.dto.AwsParams)9 Features (com.sequenceiq.common.api.telemetry.model.Features)8 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)7 EnvironmentRequest (com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentRequest)7 ExperimentalFeatures (com.sequenceiq.environment.environment.domain.ExperimentalFeatures)7 BaseNetwork (com.sequenceiq.environment.network.dao.domain.BaseNetwork)7