Search in sources :

Example 16 with InternalUpgradeSettings

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings in project cloudbreak by hortonworks.

the class StackUpgradeOperationsTest method createUpgradeRequest.

private UpgradeV4Request createUpgradeRequest(Boolean replaceVm) {
    UpgradeV4Request upgradeRequest = new UpgradeV4Request();
    upgradeRequest.setReplaceVms(replaceVm);
    upgradeRequest.setInternalUpgradeSettings(new InternalUpgradeSettings(true, true, true));
    return upgradeRequest;
}
Also used : InternalUpgradeSettings(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings) UpgradeV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request)

Example 17 with InternalUpgradeSettings

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings in project cloudbreak by hortonworks.

the class DistroXUpgradeV1ControllerTest method testUpgradeCalledWithCrn.

@Test
public void testUpgradeCalledWithCrn() {
    DistroXUpgradeV1Request distroxUpgradeRequest = new DistroXUpgradeV1Request();
    UpgradeV4Request upgradeV4Request = new UpgradeV4Request();
    upgradeV4Request.setDryRun(Boolean.FALSE);
    when(upgradeAvailabilityService.isRuntimeUpgradeEnabledByAccountId(ACCOUNT_ID)).thenReturn(true);
    when(upgradeAvailabilityService.isOsUpgradeEnabledByAccountId(ACCOUNT_ID)).thenReturn(true);
    when(upgradeConverter.convert(distroxUpgradeRequest, new InternalUpgradeSettings(false, true, true))).thenReturn(upgradeV4Request);
    UpgradeV4Response upgradeV4Response = new UpgradeV4Response();
    when(upgradeService.triggerUpgrade(NameOrCrn.ofCrn(CLUSTER_NAME), WORKSPACE_ID, USER_CRN, upgradeV4Request)).thenReturn(upgradeV4Response);
    when(upgradeConverter.convert(upgradeV4Response)).thenReturn(new DistroXUpgradeV1Response());
    ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.upgradeClusterByCrn(CLUSTER_NAME, distroxUpgradeRequest));
    verify(upgradeService).triggerUpgrade(NameOrCrn.ofCrn(CLUSTER_NAME), WORKSPACE_ID, USER_CRN, upgradeV4Request);
}
Also used : UpgradeV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response) InternalUpgradeSettings(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings) UpgradeV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request) DistroXUpgradeV1Response(com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Response) DistroXUpgradeV1Request(com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Request) Test(org.junit.jupiter.api.Test)

Example 18 with InternalUpgradeSettings

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings in project cloudbreak by hortonworks.

the class DistroXUpgradeV1ControllerTest method testShowAvailableImages.

@Test
public void testShowAvailableImages() {
    DistroXUpgradeV1Request distroxUpgradeRequest = new DistroXUpgradeV1Request();
    UpgradeV4Request upgradeV4Request = new UpgradeV4Request();
    upgradeV4Request.setShowAvailableImages(UpgradeShowAvailableImages.SHOW);
    when(upgradeAvailabilityService.isRuntimeUpgradeEnabledByAccountId(ACCOUNT_ID)).thenReturn(true);
    when(upgradeAvailabilityService.isOsUpgradeEnabledByAccountId(ACCOUNT_ID)).thenReturn(true);
    when(upgradeConverter.convert(distroxUpgradeRequest, new InternalUpgradeSettings(false, true, true))).thenReturn(upgradeV4Request);
    UpgradeV4Response upgradeV4Response = new UpgradeV4Response();
    when(upgradeAvailabilityService.checkForUpgrade(NameOrCrn.ofName(CLUSTER_NAME), WORKSPACE_ID, upgradeV4Request, USER_CRN)).thenReturn(upgradeV4Response);
    when(upgradeConverter.convert(upgradeV4Response)).thenReturn(new DistroXUpgradeV1Response());
    ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.upgradeClusterByName(CLUSTER_NAME, distroxUpgradeRequest));
    verify(upgradeAvailabilityService).checkForUpgrade(NameOrCrn.ofName(CLUSTER_NAME), WORKSPACE_ID, upgradeV4Request, USER_CRN);
    verifyNoInteractions(upgradeService);
}
Also used : UpgradeV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response) InternalUpgradeSettings(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings) UpgradeV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request) DistroXUpgradeV1Response(com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Response) DistroXUpgradeV1Request(com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Request) Test(org.junit.jupiter.api.Test)

Example 19 with InternalUpgradeSettings

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings in project cloudbreak by hortonworks.

the class DistroXUpgradeV1ControllerTest method testUpgradeCalled.

@Test
public void testUpgradeCalled() {
    DistroXUpgradeV1Request distroxUpgradeRequest = new DistroXUpgradeV1Request();
    UpgradeV4Request upgradeV4Request = new UpgradeV4Request();
    upgradeV4Request.setDryRun(Boolean.FALSE);
    when(upgradeAvailabilityService.isRuntimeUpgradeEnabledByAccountId(ACCOUNT_ID)).thenReturn(true);
    when(upgradeAvailabilityService.isOsUpgradeEnabledByAccountId(ACCOUNT_ID)).thenReturn(true);
    when(upgradeConverter.convert(distroxUpgradeRequest, new InternalUpgradeSettings(false, true, true))).thenReturn(upgradeV4Request);
    UpgradeV4Response upgradeV4Response = new UpgradeV4Response();
    when(upgradeService.triggerUpgrade(NameOrCrn.ofName(CLUSTER_NAME), WORKSPACE_ID, USER_CRN, upgradeV4Request)).thenReturn(upgradeV4Response);
    when(upgradeConverter.convert(upgradeV4Response)).thenReturn(new DistroXUpgradeV1Response());
    ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.upgradeClusterByName(CLUSTER_NAME, distroxUpgradeRequest));
    verify(upgradeService).triggerUpgrade(NameOrCrn.ofName(CLUSTER_NAME), WORKSPACE_ID, USER_CRN, upgradeV4Request);
}
Also used : UpgradeV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response) InternalUpgradeSettings(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings) UpgradeV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request) DistroXUpgradeV1Response(com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Response) DistroXUpgradeV1Request(com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Request) Test(org.junit.jupiter.api.Test)

Example 20 with InternalUpgradeSettings

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings in project cloudbreak by hortonworks.

the class UpgradeConverter method convert.

public UpgradeV4Request convert(DistroXUpgradeV1Request source, InternalUpgradeSettings internalUpgradeSettings) {
    UpgradeV4Request request = new UpgradeV4Request();
    request.setImageId(source.getImageId());
    request.setRuntime(source.getRuntime());
    request.setDryRun(source.getDryRun());
    request.setLockComponents(source.getLockComponents());
    request.setInternalUpgradeSettings(internalUpgradeSettings);
    Optional.ofNullable(source.getShowAvailableImages()).ifPresent(value -> request.setShowAvailableImages(UpgradeShowAvailableImages.valueOf(value.name())));
    request.setReplaceVms(convertReplaceVms(source));
    return request;
}
Also used : UpgradeV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request)

Aggregations

InternalUpgradeSettings (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings)25 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)13 ImageFilterParams (com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterParams)12 Test (org.junit.Test)12 UpgradeV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request)11 UpgradeV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response)7 DistroXUpgradeV1Request (com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Request)7 Test (org.junit.jupiter.api.Test)7 DistroXUpgradeV1Response (com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Response)4 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)3 ClusterComponent (com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 InternalOnly (com.sequenceiq.authorization.annotation.InternalOnly)2 NameOrCrn (com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)1 CloudbreakImageCatalogV3 (com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3)1 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)1 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)1 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)1