Search in sources :

Example 1 with RootVolumeV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.volume.RootVolumeV1Request in project cloudbreak by hortonworks.

the class RootVolumeSizeValidatorTest method tesIsValidWhenSizeIsNull.

@Test
public void tesIsValidWhenSizeIsNull() {
    InstanceTemplateV1Request templateV1Request = new InstanceTemplateV1Request();
    templateV1Request.setRootVolume(new RootVolumeV1Request());
    InstanceGroupV1Request value = new InstanceGroupV1Request();
    value.setTemplate(templateV1Request);
    boolean actual = underTest.isValid(value, null);
    Assertions.assertTrue(actual);
    verify(rootVolumeSizeProvider, never()).getForPlatform(any());
}
Also used : InstanceGroupV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request) InstanceTemplateV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.InstanceTemplateV1Request) RootVolumeV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.volume.RootVolumeV1Request) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with RootVolumeV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.volume.RootVolumeV1Request in project cloudbreak by hortonworks.

the class RootVolumeSizeValidatorTest method testIsValid.

@ParameterizedTest
@MethodSource("isValidSource")
public void testIsValid(boolean valid, int size) {
    InstanceTemplateV1Request templateV1Request = new InstanceTemplateV1Request();
    templateV1Request.setAws(new AwsInstanceTemplateV1Parameters());
    RootVolumeV1Request rootVolume = new RootVolumeV1Request();
    rootVolume.setSize(size);
    templateV1Request.setRootVolume(rootVolume);
    ConstraintValidatorContext context = mock(ConstraintValidatorContext.class);
    ConstraintValidatorContext.ConstraintViolationBuilder builder = mock(ConstraintValidatorContext.ConstraintViolationBuilder.class);
    when(rootVolumeSizeProvider.getForPlatform("AWS")).thenReturn(10);
    if (!valid) {
        when(context.buildConstraintViolationWithTemplate("Group root volume (" + size + "GB) couldn't be less than 10GB")).thenReturn(builder);
    }
    InstanceGroupV1Request value = new InstanceGroupV1Request();
    value.setName("group");
    value.setTemplate(templateV1Request);
    boolean actual = underTest.isValid(value, context);
    Assertions.assertEquals(actual, valid);
    int times = valid ? 0 : 1;
    verify(context, times(times)).buildConstraintViolationWithTemplate("Group root volume (" + size + "GB) couldn't be less than 10GB");
}
Also used : InstanceGroupV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request) InstanceTemplateV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.InstanceTemplateV1Request) ConstraintValidatorContext(javax.validation.ConstraintValidatorContext) AwsInstanceTemplateV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.AwsInstanceTemplateV1Parameters) RootVolumeV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.volume.RootVolumeV1Request) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 3 with RootVolumeV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.volume.RootVolumeV1Request in project cloudbreak by hortonworks.

the class InstanceTemplateV1ToInstanceTemplateV4ConverterTest method convertTestInstanceTemplateV1RequestToInstanceTemplateV4RequestWhenAzure.

@Test
void convertTestInstanceTemplateV1RequestToInstanceTemplateV4RequestWhenAzure() {
    InstanceTemplateV1Request source = new InstanceTemplateV1Request();
    RootVolumeV1Request rootVolumeV1Request = new RootVolumeV1Request();
    source.setRootVolume(rootVolumeV1Request);
    AzureInstanceTemplateV1Parameters azureInstanceTemplateV1Parameters = new AzureInstanceTemplateV1Parameters();
    source.setAzure(azureInstanceTemplateV1Parameters);
    source.setInstanceType(INSTANCE_TYPE);
    RootVolumeV4Request rootVolumeV4Request = new RootVolumeV4Request();
    when(volumeConverter.convert(rootVolumeV1Request)).thenReturn(rootVolumeV4Request);
    AzureInstanceTemplateV4Parameters azureInstanceTemplateV4Parameters = new AzureInstanceTemplateV4Parameters();
    when(instanceTemplateParameterConverter.convert(azureInstanceTemplateV1Parameters, environment)).thenReturn(azureInstanceTemplateV4Parameters);
    InstanceTemplateV4Request instanceTemplateV4Request = underTest.convert(source, environment);
    assertThat(instanceTemplateV4Request).isNotNull();
    assertThat(instanceTemplateV4Request.getRootVolume()).isSameAs(rootVolumeV4Request);
    assertThat(instanceTemplateV4Request.getAzure()).isSameAs(azureInstanceTemplateV4Parameters);
    assertThat(instanceTemplateV4Request.getCloudPlatform()).isEqualTo(CloudPlatform.AZURE);
    assertThat(instanceTemplateV4Request.getInstanceType()).isEqualTo(INSTANCE_TYPE);
}
Also used : AzureInstanceTemplateV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureInstanceTemplateV4Parameters) InstanceTemplateV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request) RootVolumeV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.volume.RootVolumeV4Request) InstanceTemplateV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.InstanceTemplateV1Request) AzureInstanceTemplateV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.AzureInstanceTemplateV1Parameters) RootVolumeV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.volume.RootVolumeV1Request) Test(org.junit.jupiter.api.Test)

Example 4 with RootVolumeV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.volume.RootVolumeV1Request in project cloudbreak by hortonworks.

the class InstanceTemplateV1ToInstanceTemplateV4ConverterTest method convertTestInstanceTemplateV4RequestToInstanceTemplateV1RequestWhenAzure.

@Test
void convertTestInstanceTemplateV4RequestToInstanceTemplateV1RequestWhenAzure() {
    InstanceTemplateV4Request source = new InstanceTemplateV4Request();
    RootVolumeV4Request rootVolumeV4Request = new RootVolumeV4Request();
    source.setRootVolume(rootVolumeV4Request);
    AzureInstanceTemplateV4Parameters azureInstanceTemplateV4Parameters = new AzureInstanceTemplateV4Parameters();
    source.setAzure(azureInstanceTemplateV4Parameters);
    source.setInstanceType(INSTANCE_TYPE);
    RootVolumeV1Request rootVolumeV1Request = new RootVolumeV1Request();
    when(volumeConverter.convert(rootVolumeV4Request)).thenReturn(rootVolumeV1Request);
    AzureInstanceTemplateV1Parameters azureInstanceTemplateV1Parameters = new AzureInstanceTemplateV1Parameters();
    when(instanceTemplateParameterConverter.convert(azureInstanceTemplateV4Parameters)).thenReturn(azureInstanceTemplateV1Parameters);
    InstanceTemplateV1Request instanceTemplateV1Request = underTest.convert(source, environment);
    assertThat(instanceTemplateV1Request).isNotNull();
    assertThat(instanceTemplateV1Request.getRootVolume()).isSameAs(rootVolumeV1Request);
    assertThat(instanceTemplateV1Request.getAzure()).isSameAs(azureInstanceTemplateV1Parameters);
    assertThat(instanceTemplateV1Request.getCloudPlatform()).isEqualTo(CloudPlatform.AZURE);
    assertThat(instanceTemplateV1Request.getInstanceType()).isEqualTo(INSTANCE_TYPE);
}
Also used : InstanceTemplateV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request) AzureInstanceTemplateV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureInstanceTemplateV4Parameters) RootVolumeV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.volume.RootVolumeV4Request) InstanceTemplateV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.InstanceTemplateV1Request) AzureInstanceTemplateV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.AzureInstanceTemplateV1Parameters) RootVolumeV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.volume.RootVolumeV1Request) Test(org.junit.jupiter.api.Test)

Example 5 with RootVolumeV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.volume.RootVolumeV1Request in project cloudbreak by hortonworks.

the class DistroXTemplateTestDto method withInstanceGroups.

private DistroXTemplateTestDto withInstanceGroups(InstanceGroupV4Request instanceGroupTestDto) {
    InstanceGroupV1Request instanceGroup = new InstanceGroupV1Request();
    InstanceTemplateV1Request template = new InstanceTemplateV1Request();
    RootVolumeV1Request rootVolume = new RootVolumeV1Request();
    rootVolume.setSize(instanceGroupTestDto.getTemplate().getRootVolume().getSize());
    template.setRootVolume(rootVolume);
    instanceGroup.setTemplate(template);
    instanceGroup.setName(instanceGroupTestDto.getName());
    instanceGroup.setNodeCount(instanceGroupTestDto.getNodeCount());
    getRequest().setInstanceGroups(Set.of(instanceGroup));
    return this;
}
Also used : InstanceGroupV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request) InstanceTemplateV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.InstanceTemplateV1Request) RootVolumeV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.volume.RootVolumeV1Request)

Aggregations

RootVolumeV1Request (com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.volume.RootVolumeV1Request)6 InstanceTemplateV1Request (com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.InstanceTemplateV1Request)5 InstanceGroupV1Request (com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request)3 Test (org.junit.jupiter.api.Test)3 AzureInstanceTemplateV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureInstanceTemplateV4Parameters)2 InstanceTemplateV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request)2 RootVolumeV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.volume.RootVolumeV4Request)2 AzureInstanceTemplateV1Parameters (com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.AzureInstanceTemplateV1Parameters)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 AwsInstanceTemplateV1Parameters (com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.AwsInstanceTemplateV1Parameters)1 ConstraintValidatorContext (javax.validation.ConstraintValidatorContext)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1