Search in sources :

Example 6 with SdxUpgradeRequest

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;
}
Also used : SdxUpgradeResponse(com.sequenceiq.sdx.api.model.SdxUpgradeResponse) SdxUpgradeRequest(com.sequenceiq.sdx.api.model.SdxUpgradeRequest) SdxClusterDetailResponse(com.sequenceiq.sdx.api.model.SdxClusterDetailResponse)

Example 7 with SdxUpgradeRequest

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));
}
Also used : SdxUpgradeRequest(com.sequenceiq.sdx.api.model.SdxUpgradeRequest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 8 with SdxUpgradeRequest

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));
}
Also used : SdxUpgradeRequest(com.sequenceiq.sdx.api.model.SdxUpgradeRequest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 9 with SdxUpgradeRequest

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));
}
Also used : SdxUpgradeRequest(com.sequenceiq.sdx.api.model.SdxUpgradeRequest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 10 with SdxUpgradeRequest

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

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