Search in sources :

Example 31 with ParametersDto

use of com.sequenceiq.environment.parameter.dto.ParametersDto in project cloudbreak by hortonworks.

the class AwsParameterValidatorTest method validateFreeIpaSpotPercentage.

@ParameterizedTest(name = "FreeIpa Spot percentage {0} is validated as {1}")
@MethodSource("freeIpaSpotPercentageParameters")
void validateFreeIpaSpotPercentage(int percentage, boolean hasError) {
    AwsParametersDto awsParameters = AwsParametersDto.builder().withFreeIpaSpotPercentage(percentage).build();
    ParametersDto parametersDto = ParametersDto.builder().withAwsParameters(awsParameters).build();
    ValidationResult validationResult = underTest.validate(environmentValidationDto, parametersDto, ValidationResult.builder());
    assertEquals(hasError, validationResult.hasError());
    if (hasError) {
        assertEquals("FreeIpa spot percentage must be between 0 and 100.", validationResult.getErrors().get(0));
    }
}
Also used : AwsParametersDto(com.sequenceiq.environment.parameter.dto.AwsParametersDto) AwsDiskEncryptionParametersDto(com.sequenceiq.environment.parameter.dto.AwsDiskEncryptionParametersDto) ParametersDto(com.sequenceiq.environment.parameter.dto.ParametersDto) AwsParametersDto(com.sequenceiq.environment.parameter.dto.AwsParametersDto) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 32 with ParametersDto

use of com.sequenceiq.environment.parameter.dto.ParametersDto in project cloudbreak by hortonworks.

the class AwsParameterValidatorTest method validateAndDetermineAwsParametersAttached.

@Test
void validateAndDetermineAwsParametersAttached() {
    AwsParametersDto awsParameters = AwsParametersDto.builder().withDynamoDbTableName("tablename").build();
    ParametersDto parametersDto = ParametersDto.builder().withAwsParameters(awsParameters).build();
    when(parametersService.isS3GuardTableUsed(any(), any(), any(), any())).thenReturn(true);
    ValidationResult validationResult = underTest.validate(environmentValidationDto, parametersDto, ValidationResult.builder());
    assertTrue(validationResult.hasError());
    assertEquals(1L, validationResult.getErrors().size());
    assertEquals("S3Guard Dynamo table 'tablename' is already attached to another active environment. " + "Please select another unattached table or specify a non-existing name to create it. Refer to " + "Cloudera documentation at https://docs.cloudera.com/cdp/latest/requirements-aws/topics/mc-aws-req-dynamodb.html " + "for the required setup.", validationResult.getErrors().get(0));
    verify(noSqlTableCreationModeDeterminerService, never()).determineCreationMode(any(), any());
}
Also used : AwsParametersDto(com.sequenceiq.environment.parameter.dto.AwsParametersDto) AwsDiskEncryptionParametersDto(com.sequenceiq.environment.parameter.dto.AwsDiskEncryptionParametersDto) ParametersDto(com.sequenceiq.environment.parameter.dto.ParametersDto) AwsParametersDto(com.sequenceiq.environment.parameter.dto.AwsParametersDto) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 33 with ParametersDto

use of com.sequenceiq.environment.parameter.dto.ParametersDto in project cloudbreak by hortonworks.

the class AwsEnvironmentParametersConverter method postConvert.

@Override
protected void postConvert(BaseParameters baseParameters, Environment environment, ParametersDto parametersDto) {
    super.postConvert(baseParameters, environment, parametersDto);
    AwsParameters awsParameters = (AwsParameters) baseParameters;
    Optional<AwsParametersDto> awsParametersDto = Optional.of(parametersDto).map(ParametersDto::getAwsParametersDto);
    awsParameters.setS3guardTableName(awsParametersDto.map(AwsParametersDto::getS3GuardTableName).orElse(null));
    awsParameters.setS3guardTableCreation(awsParametersDto.map(AwsParametersDto::getDynamoDbTableCreation).orElse(null));
    awsParameters.setFreeIpaSpotPercentage(awsParametersDto.map(AwsParametersDto::getFreeIpaSpotPercentage).orElse(0));
    awsParameters.setFreeIpaSpotMaxPrice(awsParametersDto.map(AwsParametersDto::getFreeIpaSpotMaxPrice).orElse(null));
    awsParameters.setEncryptionKeyArn(awsParametersDto.map(AwsParametersDto::getAwsDiskEncryptionParametersDto).map(AwsDiskEncryptionParametersDto::getEncryptionKeyArn).orElse(null));
}
Also used : AwsParametersDto(com.sequenceiq.environment.parameter.dto.AwsParametersDto) AwsDiskEncryptionParametersDto(com.sequenceiq.environment.parameter.dto.AwsDiskEncryptionParametersDto) AwsParameters(com.sequenceiq.environment.parameters.dao.domain.AwsParameters) AwsDiskEncryptionParametersDto(com.sequenceiq.environment.parameter.dto.AwsDiskEncryptionParametersDto) ParametersDto(com.sequenceiq.environment.parameter.dto.ParametersDto) AwsParametersDto(com.sequenceiq.environment.parameter.dto.AwsParametersDto)

Example 34 with ParametersDto

use of com.sequenceiq.environment.parameter.dto.ParametersDto in project cloudbreak by hortonworks.

the class AzureEnvironmentParametersConverter method postConvert.

@Override
protected void postConvert(BaseParameters baseParameters, Environment environment, ParametersDto parametersDto) {
    super.postConvert(baseParameters, environment, parametersDto);
    AzureParameters azureParameters = (AzureParameters) baseParameters;
    Optional<AzureParametersDto> azureParametersDto = Optional.of(parametersDto).map(ParametersDto::getAzureParametersDto);
    azureParameters.setResourceGroupName(azureParametersDto.map(AzureParametersDto::getAzureResourceGroupDto).map(AzureResourceGroupDto::getName).orElse(null));
    azureParameters.setResourceGroupCreation(azureParametersDto.map(AzureParametersDto::getAzureResourceGroupDto).map(AzureResourceGroupDto::getResourceGroupCreation).orElse(null));
    azureParameters.setResourceGroupUsagePattern(azureParametersDto.map(AzureParametersDto::getAzureResourceGroupDto).map(AzureResourceGroupDto::getResourceGroupUsagePattern).orElse(null));
    azureParameters.setEncryptionKeyUrl(azureParametersDto.map(AzureParametersDto::getAzureResourceEncryptionParametersDto).map(AzureResourceEncryptionParametersDto::getEncryptionKeyUrl).orElse(null));
    azureParameters.setEncryptionKeyResourceGroupName(azureParametersDto.map(AzureParametersDto::getAzureResourceEncryptionParametersDto).map(AzureResourceEncryptionParametersDto::getEncryptionKeyResourceGroupName).orElse(null));
}
Also used : AzureParameters(com.sequenceiq.environment.parameters.dao.domain.AzureParameters) AzureResourceEncryptionParametersDto(com.sequenceiq.environment.parameter.dto.AzureResourceEncryptionParametersDto) ParametersDto(com.sequenceiq.environment.parameter.dto.ParametersDto) AzureResourceEncryptionParametersDto(com.sequenceiq.environment.parameter.dto.AzureResourceEncryptionParametersDto) AzureParametersDto(com.sequenceiq.environment.parameter.dto.AzureParametersDto) AzureParametersDto(com.sequenceiq.environment.parameter.dto.AzureParametersDto) AzureResourceGroupDto(com.sequenceiq.environment.parameter.dto.AzureResourceGroupDto)

Example 35 with ParametersDto

use of com.sequenceiq.environment.parameter.dto.ParametersDto in project cloudbreak by hortonworks.

the class EnvironmentDetailsToCDPEnvironmentDetailsConverterTest method testConversionResourceEncryptionEnabledWhenAWSUsingResourceEncryptionEnabledShouldReturnResourceEncryptionEnabledTrue.

@Test
public void testConversionResourceEncryptionEnabledWhenAWSUsingResourceEncryptionEnabledShouldReturnResourceEncryptionEnabledTrue() {
    ParametersDto parametersDto = ParametersDto.builder().withAwsParameters(AwsParametersDto.builder().withAwsDiskEncryptionParameters(AwsDiskEncryptionParametersDto.builder().withEncryptionKeyArn("dummyEncryptionKeyArn").build()).build()).build();
    when(environmentDetails.getParameters()).thenReturn(parametersDto);
    UsageProto.CDPEnvironmentDetails cdpEnvironmentDetails = underTest.convert(environmentDetails);
    Assertions.assertTrue(cdpEnvironmentDetails.getAwsDetails().getResourceEncryptionEnabled());
}
Also used : GcpResourceEncryptionParametersDto(com.sequenceiq.environment.parameter.dto.GcpResourceEncryptionParametersDto) AwsDiskEncryptionParametersDto(com.sequenceiq.environment.parameter.dto.AwsDiskEncryptionParametersDto) ParametersDto(com.sequenceiq.environment.parameter.dto.ParametersDto) AzureParametersDto(com.sequenceiq.environment.parameter.dto.AzureParametersDto) AwsParametersDto(com.sequenceiq.environment.parameter.dto.AwsParametersDto) AzureResourceEncryptionParametersDto(com.sequenceiq.environment.parameter.dto.AzureResourceEncryptionParametersDto) GcpParametersDto(com.sequenceiq.environment.parameter.dto.GcpParametersDto) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto) Test(org.junit.jupiter.api.Test)

Aggregations

ParametersDto (com.sequenceiq.environment.parameter.dto.ParametersDto)38 Test (org.junit.jupiter.api.Test)30 AwsParametersDto (com.sequenceiq.environment.parameter.dto.AwsParametersDto)28 AzureResourceEncryptionParametersDto (com.sequenceiq.environment.parameter.dto.AzureResourceEncryptionParametersDto)24 AwsDiskEncryptionParametersDto (com.sequenceiq.environment.parameter.dto.AwsDiskEncryptionParametersDto)23 GcpParametersDto (com.sequenceiq.environment.parameter.dto.GcpParametersDto)19 GcpResourceEncryptionParametersDto (com.sequenceiq.environment.parameter.dto.GcpResourceEncryptionParametersDto)19 AzureParametersDto (com.sequenceiq.environment.parameter.dto.AzureParametersDto)18 Environment (com.sequenceiq.environment.environment.domain.Environment)16 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)12 UsageProto (com.cloudera.thunderhead.service.common.usage.UsageProto)9 BaseParameters (com.sequenceiq.environment.parameters.dao.domain.BaseParameters)9 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)8 Credential (com.sequenceiq.environment.credential.domain.Credential)8 EnvironmentEditDto (com.sequenceiq.environment.environment.dto.EnvironmentEditDto)7 EnvironmentCreationDto (com.sequenceiq.environment.environment.dto.EnvironmentCreationDto)6 AwsParameters (com.sequenceiq.environment.parameters.dao.domain.AwsParameters)6 EnvironmentAuthentication (com.sequenceiq.environment.environment.domain.EnvironmentAuthentication)5 GcpParameters (com.sequenceiq.environment.parameters.dao.domain.GcpParameters)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5