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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations