Search in sources :

Example 1 with InstanceTemplateV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request in project cloudbreak by hortonworks.

the class InstanceTemplateV4RequestToTemplateConverterTest method convertWithNullTemporaryStorage.

@Test
public void convertWithNullTemporaryStorage() {
    InstanceTemplateV4Request source = getSampleGcpRequest();
    source.setTemporaryStorage(null);
    Template result = underTest.convert(source);
    assertThat(result.getTemporaryStorage()).isEqualTo(TemporaryStorage.ATTACHED_VOLUMES);
}
Also used : InstanceTemplateV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate) Template(com.sequenceiq.cloudbreak.domain.Template) Test(org.junit.jupiter.api.Test)

Example 2 with InstanceTemplateV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request in project cloudbreak by hortonworks.

the class InstanceTemplateV4RequestToTemplateConverterTest method convertWithAwsEncryption.

@Test
public void convertWithAwsEncryption() {
    InstanceTemplateV4Request source = getSampleAwsRequest();
    Template result = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.convert(source));
    assertAwsEncryptionConvertResult(source, result);
    assertThat(new Json(result.getSecretAttributes()).getMap().get(InstanceTemplate.VOLUME_ENCRYPTION_KEY_ID)).isEqualTo("myKey");
}
Also used : InstanceTemplateV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request) Json(com.sequenceiq.cloudbreak.common.json.Json) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate) Template(com.sequenceiq.cloudbreak.domain.Template) Test(org.junit.jupiter.api.Test)

Example 3 with InstanceTemplateV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request in project cloudbreak by hortonworks.

the class InstanceTemplateV4RequestToTemplateConverterTest method getSampleGcpRequest.

private InstanceTemplateV4Request getSampleGcpRequest() {
    InstanceTemplateV4Request source = new InstanceTemplateV4Request();
    source.setCloudPlatform(CloudPlatform.GCP);
    source.setRootVolume(getRootVolume(100));
    source.setInstanceType("n1-standard-4");
    GcpInstanceTemplateV4Parameters parameters = new GcpInstanceTemplateV4Parameters();
    GcpEncryptionV4Parameters encryption = new GcpEncryptionV4Parameters();
    encryption.setType(EncryptionType.CUSTOM);
    encryption.setKeyEncryptionMethod(KeyEncryptionMethod.RAW);
    encryption.setKey("myKey");
    parameters.setEncryption(encryption);
    source.setGcp(parameters);
    ProviderParameterCalculator providerParameterCalculator = new ProviderParameterCalculator();
    ReflectionTestUtils.setField(underTest, "providerParameterCalculator", providerParameterCalculator);
    when(missingResourceNameGenerator.generateName(APIResourceType.TEMPLATE)).thenReturn("name");
    return source;
}
Also used : InstanceTemplateV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request) GcpInstanceTemplateV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.GcpInstanceTemplateV4Parameters) GcpEncryptionV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.GcpEncryptionV4Parameters) ProviderParameterCalculator(com.sequenceiq.cloudbreak.common.mappable.ProviderParameterCalculator)

Example 4 with InstanceTemplateV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request in project cloudbreak by hortonworks.

the class InstanceTemplateV4RequestToTemplateConverterTest method convertWithGcpEncryptionWithNullKey.

@Test
public void convertWithGcpEncryptionWithNullKey() {
    InstanceTemplateV4Request source = getSampleGcpRequest();
    source.getGcp().getEncryption().setKey(null);
    Template result = underTest.convert(source);
    assertGcpEncryptionConvertResult(source, result);
    assertThat(new Json(result.getSecretAttributes()).getMap().get(InstanceTemplate.VOLUME_ENCRYPTION_KEY_ID)).isNull();
}
Also used : InstanceTemplateV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request) Json(com.sequenceiq.cloudbreak.common.json.Json) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate) Template(com.sequenceiq.cloudbreak.domain.Template) Test(org.junit.jupiter.api.Test)

Example 5 with InstanceTemplateV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request in project cloudbreak by hortonworks.

the class InstanceTemplateV4RequestToTemplateConverterTest method convert.

@Test
public void convert() {
    InstanceTemplateV4Request source = new InstanceTemplateV4Request();
    source.setCloudPlatform(CloudPlatform.GCP);
    source.setRootVolume(getRootVolume(100));
    source.setInstanceType("large");
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("cpus", 1);
    when(missingResourceNameGenerator.generateName(APIResourceType.TEMPLATE)).thenReturn("name");
    when(providerParameterCalculator.get(source)).thenReturn(mappable);
    when(mappable.asMap()).thenReturn(parameters);
    Template result = underTest.convert(source);
    assertThat(result.getStatus()).isEqualTo(ResourceStatus.USER_MANAGED);
    assertThat(result.cloudPlatform()).isEqualTo(source.getCloudPlatform().name());
    assertThat(result.getRootVolumeSize()).isEqualTo(source.getRootVolume().getSize());
    assertThat(result.getInstanceType()).isEqualTo(source.getInstanceType());
    assertThat(result.getAttributes()).isNotNull();
    assertThat(result.getAttributes().getMap().get("cpus")).isEqualTo(1);
    assertThat(result.getSecretAttributes()).isNotNull();
}
Also used : InstanceTemplateV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request) HashMap(java.util.HashMap) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate) Template(com.sequenceiq.cloudbreak.domain.Template) Test(org.junit.jupiter.api.Test)

Aggregations

InstanceTemplateV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request)35 Test (org.junit.jupiter.api.Test)25 InstanceGroupV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request)15 Template (com.sequenceiq.cloudbreak.domain.Template)10 InstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)9 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)9 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)9 AzureInstanceTemplateV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureInstanceTemplateV4Parameters)5 Json (com.sequenceiq.cloudbreak.common.json.Json)5 AzureInstanceTemplateV1Parameters (com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.AzureInstanceTemplateV1Parameters)4 InstanceTemplateV1Request (com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.InstanceTemplateV1Request)4 AwsEncryptionV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsEncryptionV4Parameters)2 AwsInstanceTemplateV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsInstanceTemplateV4Parameters)2 AzureEncryptionV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureEncryptionV4Parameters)2 GcpEncryptionV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.GcpEncryptionV4Parameters)2 GcpInstanceTemplateV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.GcpInstanceTemplateV4Parameters)2 RootVolumeV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.volume.RootVolumeV4Request)2 ProviderParameterCalculator (com.sequenceiq.cloudbreak.common.mappable.ProviderParameterCalculator)2 RootVolumeV1Request (com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.template.volume.RootVolumeV1Request)2 HashMap (java.util.HashMap)2