Search in sources :

Example 6 with SdxUpgradeResponse

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

the class SdxUpgradeAction method action.

@Override
public SdxTestDto action(TestContext testContext, SdxTestDto testDto, SdxClient client) throws Exception {
    SdxUpgradeRequest upgradeRequest = testDto.getSdxUpgradeRequest();
    Log.when(LOGGER, " SDX endpoint: %s" + client.getDefaultClient().sdxEndpoint() + ", SDX's environment: " + testDto.getRequest().getEnvironment());
    Log.whenJson(LOGGER, " SDX upgrade request: ", upgradeRequest);
    SdxUpgradeResponse upgradeResponse = client.getDefaultClient().sdxUpgradeEndpoint().upgradeClusterByName(testDto.getName(), upgradeRequest);
    testDto.setFlow("SDX upgrade", upgradeResponse.getFlowIdentifier());
    SdxClusterDetailResponse detailedResponse = client.getDefaultClient().sdxEndpoint().getDetail(testDto.getName(), Collections.emptySet());
    testDto.setResponse(detailedResponse);
    Log.whenJson(LOGGER, " SDX upgrade response: ", detailedResponse);
    return testDto;
}
Also used : SdxUpgradeResponse(com.sequenceiq.sdx.api.model.SdxUpgradeResponse) SdxUpgradeRequest(com.sequenceiq.sdx.api.model.SdxUpgradeRequest) SdxClusterDetailResponse(com.sequenceiq.sdx.api.model.SdxClusterDetailResponse)

Example 7 with SdxUpgradeResponse

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

the class SdxUpgradeControllerTest method testUpgradeClusterByNameWhenRequestIsShowLatestImagesAndRuntimeIsDisabledShouldSetLockComponent.

@Test
@DisplayName("when show latest images is requested and runtime upgrade is disabled it should set the lock components flag")
void testUpgradeClusterByNameWhenRequestIsShowLatestImagesAndRuntimeIsDisabledShouldSetLockComponent() {
    SdxUpgradeRequest request = new SdxUpgradeRequest();
    request.setShowAvailableImages(SdxUpgradeShowAvailableImages.LATEST_ONLY);
    SdxUpgradeResponse sdxUpgradeResponse = new SdxUpgradeResponse();
    sdxUpgradeResponse.setReason("No image available to upgrade");
    when(sdxRuntimeUpgradeService.checkForUpgradeByName(USER_CRN, CLUSTER_NAME, request, ACCOUNT_ID)).thenReturn(sdxUpgradeResponse);
    SdxUpgradeResponse response = doAs(USER_CRN, () -> underTest.upgradeClusterByName(CLUSTER_NAME, request));
    verify(sdxRuntimeUpgradeService, times(1)).checkForUpgradeByName(any(), any(), upgradeRequestArgumentCaptor.capture(), anyString());
    // SdxUpgradeRequest capturedRequest = upgradeRequestArgumentCaptor.getValue();
    // assertTrue(capturedRequest.getLockComponents());
    assertEquals("No image available to upgrade", response.getReason());
}
Also used : SdxUpgradeResponse(com.sequenceiq.sdx.api.model.SdxUpgradeResponse) SdxUpgradeRequest(com.sequenceiq.sdx.api.model.SdxUpgradeRequest) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 8 with SdxUpgradeResponse

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

the class SdxUpgradeControllerTest method testUpgradeClusterByNameWhenRequestIsDryRunAndRuntimeIsDisabled.

@Test
void testUpgradeClusterByNameWhenRequestIsDryRunAndRuntimeIsDisabled() {
    SdxUpgradeResponse sdxUpgradeResponse = new SdxUpgradeResponse();
    sdxUpgradeResponse.setReason("No image available to upgrade");
    SdxUpgradeRequest request = new SdxUpgradeRequest();
    request.setDryRun(true);
    when(sdxRuntimeUpgradeService.checkForUpgradeByName(eq(USER_CRN), eq(CLUSTER_NAME), eq(request), anyString())).thenReturn(sdxUpgradeResponse);
    SdxUpgradeResponse response = doAs(USER_CRN, () -> underTest.upgradeClusterByName(CLUSTER_NAME, request));
    verify(sdxRuntimeUpgradeService, times(1)).checkForUpgradeByName(eq(USER_CRN), eq(CLUSTER_NAME), eq(request), anyString());
    assertEquals("No image available to upgrade", response.getReason());
}
Also used : SdxUpgradeResponse(com.sequenceiq.sdx.api.model.SdxUpgradeResponse) SdxUpgradeRequest(com.sequenceiq.sdx.api.model.SdxUpgradeRequest) Test(org.junit.jupiter.api.Test)

Example 9 with SdxUpgradeResponse

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

the class SdxUpgradeControllerTest method testUpgradeClusterByNameWhenRequestIsShowImagesAndRuntimeIsDisabledShouldNotSetLockComponent.

@Test
@DisplayName("when show images is requested and runtime upgrade is enabled it should not set the lock components flag")
void testUpgradeClusterByNameWhenRequestIsShowImagesAndRuntimeIsDisabledShouldNotSetLockComponent() {
    SdxUpgradeRequest request = new SdxUpgradeRequest();
    request.setShowAvailableImages(SdxUpgradeShowAvailableImages.SHOW);
    SdxUpgradeResponse sdxUpgradeResponse = new SdxUpgradeResponse();
    sdxUpgradeResponse.setReason("No image available to upgrade");
    when(sdxRuntimeUpgradeService.checkForUpgradeByName(USER_CRN, CLUSTER_NAME, request, ACCOUNT_ID)).thenReturn(sdxUpgradeResponse);
    SdxUpgradeResponse response = doAs(USER_CRN, () -> underTest.upgradeClusterByName(CLUSTER_NAME, request));
    verify(sdxRuntimeUpgradeService, times(1)).checkForUpgradeByName(any(), any(), upgradeRequestArgumentCaptor.capture(), anyString());
    SdxUpgradeRequest capturedRequest = upgradeRequestArgumentCaptor.getValue();
    assertNull(capturedRequest.getLockComponents());
    assertEquals("No image available to upgrade", response.getReason());
}
Also used : SdxUpgradeResponse(com.sequenceiq.sdx.api.model.SdxUpgradeResponse) SdxUpgradeRequest(com.sequenceiq.sdx.api.model.SdxUpgradeRequest) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 10 with SdxUpgradeResponse

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

the class SdxRuntimeUpgradeService method triggerUpgradeByName.

public SdxUpgradeResponse triggerUpgradeByName(String userCrn, String clusterName, SdxUpgradeRequest upgradeRequest, String accountId) {
    SdxCluster cluster = sdxService.getByNameInAccount(userCrn, clusterName);
    SdxUpgradeResponse sdxUpgradeResponse = checkForUpgradeByName(userCrn, clusterName, upgradeRequest, accountId);
    List<ImageInfoV4Response> imageInfoV4Responses = validateUpgradeCandidates(clusterName, sdxUpgradeResponse);
    return initSdxUpgrade(userCrn, imageInfoV4Responses, upgradeRequest, cluster);
}
Also used : SdxUpgradeResponse(com.sequenceiq.sdx.api.model.SdxUpgradeResponse) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) ImageInfoV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.ImageInfoV4Response)

Aggregations

SdxUpgradeResponse (com.sequenceiq.sdx.api.model.SdxUpgradeResponse)22 SdxUpgradeRequest (com.sequenceiq.sdx.api.model.SdxUpgradeRequest)15 Test (org.junit.jupiter.api.Test)15 ImageInfoV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.ImageInfoV4Response)9 UpgradeV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response)8 DisplayName (org.junit.jupiter.api.DisplayName)8 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)2 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)2 SdxClusterDetailResponse (com.sequenceiq.sdx.api.model.SdxClusterDetailResponse)2 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1