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