use of com.sequenceiq.sdx.api.model.SdxUpgradeRequest 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.SdxUpgradeRequest in project cloudbreak by hortonworks.
the class UpgradeRequestValidatorTest method testValidRequests.
@ParameterizedTest
@MethodSource("validUpgradeRequests")
public void testValidRequests(String imageId, String runtime, Boolean lockComponents, Boolean dryRun, SdxUpgradeShowAvailableImages showAvailableImages, SdxUpgradeReplaceVms replaceVms) {
SdxUpgradeRequest sdxUpgradeRequest = new SdxUpgradeRequest();
sdxUpgradeRequest.setImageId(imageId);
sdxUpgradeRequest.setRuntime(runtime);
sdxUpgradeRequest.setLockComponents(lockComponents);
sdxUpgradeRequest.setDryRun(dryRun);
sdxUpgradeRequest.setShowAvailableImages(showAvailableImages);
sdxUpgradeRequest.setReplaceVms(replaceVms);
Assertions.assertTrue(underTest.isValid(sdxUpgradeRequest, validatorContext));
}
use of com.sequenceiq.sdx.api.model.SdxUpgradeRequest in project cloudbreak by hortonworks.
the class UpgradeRequestValidatorTest method testInvalidRequests.
@ParameterizedTest
@MethodSource("invalidUpgradeRequests")
public void testInvalidRequests(String imageId, String runtime, Boolean lockComponents, Boolean dryRun, SdxUpgradeShowAvailableImages showAvailableImages, SdxUpgradeReplaceVms replaceVms) {
SdxUpgradeRequest sdxUpgradeRequest = new SdxUpgradeRequest();
sdxUpgradeRequest.setImageId(imageId);
sdxUpgradeRequest.setRuntime(runtime);
sdxUpgradeRequest.setLockComponents(lockComponents);
sdxUpgradeRequest.setDryRun(dryRun);
sdxUpgradeRequest.setShowAvailableImages(showAvailableImages);
sdxUpgradeRequest.setReplaceVms(replaceVms);
Assertions.assertFalse(underTest.isValid(sdxUpgradeRequest, validatorContext));
}
use of com.sequenceiq.sdx.api.model.SdxUpgradeRequest in project cloudbreak by hortonworks.
the class UpgradeRequestValidatorTest method testInvalidRequestsWithContext.
@ParameterizedTest
@MethodSource("invalidUpgradeRequestsWithContext")
public void testInvalidRequestsWithContext(String imageId, String runtime, Boolean lockComponents, Boolean dryRun, SdxUpgradeShowAvailableImages showAvailableImages, SdxUpgradeReplaceVms replaceVms) {
when(validatorContext.buildConstraintViolationWithTemplate(any())).thenReturn(constraintViolationBuilder);
when(constraintViolationBuilder.addConstraintViolation()).thenReturn(validatorContext);
doNothing().when(validatorContext).disableDefaultConstraintViolation();
SdxUpgradeRequest sdxUpgradeRequest = new SdxUpgradeRequest();
sdxUpgradeRequest.setImageId(imageId);
sdxUpgradeRequest.setRuntime(runtime);
sdxUpgradeRequest.setLockComponents(lockComponents);
sdxUpgradeRequest.setDryRun(dryRun);
sdxUpgradeRequest.setShowAvailableImages(showAvailableImages);
sdxUpgradeRequest.setReplaceVms(replaceVms);
Assertions.assertFalse(underTest.isValid(sdxUpgradeRequest, validatorContext));
}
use of com.sequenceiq.sdx.api.model.SdxUpgradeRequest 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());
}
Aggregations