Search in sources :

Example 21 with SdxUpgradeRequest

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

the class SdxUpgradeControllerTest method testUpgradeClusterByNameWhenRuntimeIsSetAndEnabled.

@Test
void testUpgradeClusterByNameWhenRuntimeIsSetAndEnabled() {
    SdxUpgradeRequest request = new SdxUpgradeRequest();
    request.setRuntime("7.1.0");
    SdxUpgradeResponse sdxUpgradeResponse = new SdxUpgradeResponse();
    sdxUpgradeResponse.setReason("No image available to upgrade");
    when(sdxRuntimeUpgradeService.triggerUpgradeByName(USER_CRN, CLUSTER_NAME, request, Crn.fromString(USER_CRN).getAccountId())).thenReturn(sdxUpgradeResponse);
    SdxUpgradeResponse response = doAs(USER_CRN, () -> underTest.upgradeClusterByName(CLUSTER_NAME, request));
    verify(sdxRuntimeUpgradeService, times(0)).checkForUpgradeByName(any(), any(), any(), anyString());
    verify(sdxRuntimeUpgradeService).triggerUpgradeByName(USER_CRN, CLUSTER_NAME, request, Crn.fromString(USER_CRN).getAccountId());
    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 22 with SdxUpgradeRequest

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

the class SdxUpgradeControllerTest method testUpgradeClusterByNameWhenRequestIsShowImagesAndRuntimeIsDisabledShouldSetLockComponent.

@Test
@DisplayName("when show images is requested and runtime upgrade is disabled it should set the lock components flag")
void testUpgradeClusterByNameWhenRequestIsShowImagesAndRuntimeIsDisabledShouldSetLockComponent() {
    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();
    // 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 23 with SdxUpgradeRequest

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

the class SdxUpgradeControllerTest method testUpgradeClusterByNameWhenLockComponentsIsSet.

@Test
void testUpgradeClusterByNameWhenLockComponentsIsSet() {
    SdxUpgradeRequest request = new SdxUpgradeRequest();
    request.setLockComponents(true);
    SdxUpgradeResponse sdxUpgradeResponse = new SdxUpgradeResponse();
    sdxUpgradeResponse.setReason("No image available to upgrade");
    when(sdxRuntimeUpgradeService.triggerUpgradeByName(USER_CRN, CLUSTER_NAME, request, Crn.fromString(USER_CRN).getAccountId())).thenReturn(sdxUpgradeResponse);
    SdxUpgradeResponse response = doAs(USER_CRN, () -> underTest.upgradeClusterByName(CLUSTER_NAME, request));
    verify(sdxRuntimeUpgradeService, times(0)).checkForUpgradeByName(any(), any(), any(), anyString());
    verify(sdxRuntimeUpgradeService, times(1)).triggerUpgradeByName(any(), any(), any(), 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 24 with SdxUpgradeRequest

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

the class SdxUpgradeControllerTest method testUpgradeClusterByNameWhenRequestIsDryRunAndRuntimeAndRuntimeIsDisabled.

@Test
void testUpgradeClusterByNameWhenRequestIsDryRunAndRuntimeAndRuntimeIsDisabled() {
    SdxUpgradeRequest request = new SdxUpgradeRequest();
    request.setDryRun(true);
    request.setRuntime("7.1.0");
    doThrow(new BadRequestException("Runtime upgrade feature is not enabled")).when(sdxRuntimeUpgradeService).checkForUpgradeByName(eq(USER_CRN), eq(CLUSTER_NAME), eq(request), anyString());
    BadRequestException exception = doAs(USER_CRN, () -> Assertions.assertThrows(BadRequestException.class, () -> underTest.upgradeClusterByName(CLUSTER_NAME, request)));
    assertEquals("Runtime upgrade feature is not enabled", exception.getMessage());
}
Also used : SdxUpgradeRequest(com.sequenceiq.sdx.api.model.SdxUpgradeRequest) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Test(org.junit.jupiter.api.Test)

Example 25 with SdxUpgradeRequest

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

the class SdxUpgradeControllerTest method testUpgradeClusterByNameWhenImageIsSetAndRuntimeIsDisabled.

@Test
void testUpgradeClusterByNameWhenImageIsSetAndRuntimeIsDisabled() {
    SdxUpgradeRequest request = new SdxUpgradeRequest();
    request.setImageId("imageId");
    doThrow(new BadRequestException("Runtime upgrade feature is not enabled")).when(sdxRuntimeUpgradeService).triggerUpgradeByName(USER_CRN, CLUSTER_NAME, request, Crn.fromString(USER_CRN).getAccountId());
    BadRequestException exception = doAs(USER_CRN, () -> Assertions.assertThrows(BadRequestException.class, () -> underTest.upgradeClusterByName(CLUSTER_NAME, request)));
    assertEquals("Runtime upgrade feature is not enabled", exception.getMessage());
}
Also used : SdxUpgradeRequest(com.sequenceiq.sdx.api.model.SdxUpgradeRequest) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Test(org.junit.jupiter.api.Test)

Aggregations

SdxUpgradeRequest (com.sequenceiq.sdx.api.model.SdxUpgradeRequest)27 Test (org.junit.jupiter.api.Test)19 SdxUpgradeResponse (com.sequenceiq.sdx.api.model.SdxUpgradeResponse)18 DisplayName (org.junit.jupiter.api.DisplayName)9 ImageInfoV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.ImageInfoV4Response)7 UpgradeV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response)7 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)6 StackV4Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.StackV4Endpoint)3 ImageComponentVersions (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.ImageComponentVersions)3 ClouderaManagerLicenseProvider (com.sequenceiq.cloudbreak.auth.ClouderaManagerLicenseProvider)3 JsonCMLicense (com.sequenceiq.cloudbreak.auth.JsonCMLicense)3 PaywallAccessChecker (com.sequenceiq.cloudbreak.auth.PaywallAccessChecker)3 ThreadBasedUserCrnProvider (com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider)3 EntitlementService (com.sequenceiq.cloudbreak.auth.altus.EntitlementService)3 RegionAwareInternalCrnGeneratorFactory (com.sequenceiq.cloudbreak.auth.crn.RegionAwareInternalCrnGeneratorFactory)3 CloudbreakMessagesService (com.sequenceiq.cloudbreak.message.CloudbreakMessagesService)3 SdxUpgradeClusterConverter (com.sequenceiq.datalake.controller.sdx.SdxUpgradeClusterConverter)3 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)3 SdxReactorFlowManager (com.sequenceiq.datalake.flow.SdxReactorFlowManager)3 SdxService (com.sequenceiq.datalake.service.sdx.SdxService)3