use of com.sequenceiq.sdx.api.model.SdxUpgradeResponse in project cloudbreak by hortonworks.
the class SdxUpgradeControllerTest method testUpgradeClusterByNameWhenImageIsSetAndRuntimeIsEnabled.
@Test
void testUpgradeClusterByNameWhenImageIsSetAndRuntimeIsEnabled() {
SdxUpgradeRequest request = new SdxUpgradeRequest();
request.setImageId("imageId");
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.SdxUpgradeResponse in project cloudbreak by hortonworks.
the class SdxUpgradeControllerTest method testUpgradeClusterByNameWhenRequestIsDryRunAndLockComponents.
@Test
void testUpgradeClusterByNameWhenRequestIsDryRunAndLockComponents() {
SdxUpgradeResponse sdxUpgradeResponse = new SdxUpgradeResponse();
sdxUpgradeResponse.setReason("No image available to upgrade");
SdxUpgradeRequest request = new SdxUpgradeRequest();
request.setDryRun(true);
request.setLockComponents(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());
}
use of com.sequenceiq.sdx.api.model.SdxUpgradeResponse 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.SdxUpgradeResponse 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.SdxUpgradeResponse 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());
}
Aggregations