Search in sources :

Example 1 with SdxCustomClusterRequest

use of com.sequenceiq.sdx.api.model.SdxCustomClusterRequest in project cloudbreak by hortonworks.

the class SdxServiceTest method createSdxCustomClusterRequest.

private SdxCustomClusterRequest createSdxCustomClusterRequest(SdxClusterShape shape, String catalog, String imageId) {
    ImageSettingsV4Request imageSettingsV4Request = new ImageSettingsV4Request();
    imageSettingsV4Request.setCatalog(catalog);
    imageSettingsV4Request.setId(imageId);
    SdxCustomClusterRequest sdxClusterRequest = new SdxCustomClusterRequest();
    sdxClusterRequest.setClusterShape(shape);
    sdxClusterRequest.addTags(TAGS);
    sdxClusterRequest.setEnvironment("envir");
    sdxClusterRequest.setImageSettingsV4Request(imageSettingsV4Request);
    return sdxClusterRequest;
}
Also used : ImageSettingsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.image.ImageSettingsV4Request) SdxCustomClusterRequest(com.sequenceiq.sdx.api.model.SdxCustomClusterRequest)

Example 2 with SdxCustomClusterRequest

use of com.sequenceiq.sdx.api.model.SdxCustomClusterRequest in project cloudbreak by hortonworks.

the class SdxServiceTest method testCreateSdxClusterWithCustomRequestContainsImageInfo.

@Test
void testCreateSdxClusterWithCustomRequestContainsImageInfo() throws Exception {
    ImageV4Response imageResponse = getImageResponse();
    when(transactionService.required(isA(Supplier.class))).thenAnswer(invocation -> invocation.getArgument(0, Supplier.class).get());
    String lightDutyJson = FileReaderUtils.readFileFromClasspath("/duties/7.2.7/aws/light_duty.json");
    when(cdpConfigService.getConfigForKey(any())).thenReturn(JsonUtil.readValue(lightDutyJson, StackV4Request.class));
    SdxCustomClusterRequest sdxClusterRequest = createSdxCustomClusterRequest(LIGHT_DUTY, "cdp-default", "imageId_1");
    setSpot(sdxClusterRequest);
    withCloudStorage(sdxClusterRequest);
    when(imageCatalogService.getImageResponseFromImageRequest(eq(sdxClusterRequest.getImageSettingsV4Request()), any())).thenReturn(imageResponse);
    long id = 10L;
    when(sdxClusterRepository.save(any(SdxCluster.class))).thenAnswer(invocation -> {
        SdxCluster sdxWithId = invocation.getArgument(0, SdxCluster.class);
        sdxWithId.setId(id);
        return sdxWithId;
    });
    mockEnvironmentCall(sdxClusterRequest, CloudPlatform.AWS, null);
    Pair<SdxCluster, FlowIdentifier> result = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.createSdx(USER_CRN, CLUSTER_NAME, sdxClusterRequest));
    SdxCluster createdSdxCluster = result.getLeft();
    StackV4Request stackV4Request = JsonUtil.readValue(createdSdxCluster.getStackRequest(), StackV4Request.class);
    assertNotNull(stackV4Request.getImage());
    assertEquals("cdp-default", stackV4Request.getImage().getCatalog());
    assertEquals("imageId_1", stackV4Request.getImage().getId());
}
Also used : SdxCustomClusterRequest(com.sequenceiq.sdx.api.model.SdxCustomClusterRequest) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) ImageV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageV4Response) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) Supplier(java.util.function.Supplier) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Aggregations

SdxCustomClusterRequest (com.sequenceiq.sdx.api.model.SdxCustomClusterRequest)2 ImageV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageV4Response)1 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)1 ImageSettingsV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.image.ImageSettingsV4Request)1 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)1 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)1 Supplier (java.util.function.Supplier)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1