Search in sources :

Example 51 with UpgradeV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response in project cloudbreak by hortonworks.

the class StackUpgradeOperationsTest method createUpgradeResponse.

private UpgradeV4Response createUpgradeResponse() {
    UpgradeV4Response upgradeResponse = new UpgradeV4Response();
    upgradeResponse.setUpgradeCandidates(List.of(new ImageInfoV4Response()));
    return upgradeResponse;
}
Also used : UpgradeV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response) ImageInfoV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.ImageInfoV4Response)

Example 52 with UpgradeV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response in project cloudbreak by hortonworks.

the class StackUpgradeOperationsTest method testCheckForClusterUpgradeShouldReturnCompositeErrorWhenBothAttachedDataHubValidationsFail.

@Test
void testCheckForClusterUpgradeShouldReturnCompositeErrorWhenBothAttachedDataHubValidationsFail() {
    Stack stack = createStack(StackType.DATALAKE);
    StackViewV4Responses stackViewV4Responses = new StackViewV4Responses();
    UpgradeV4Request request = createUpgradeRequest(null);
    UpgradeV4Response upgradeResponseToReturn = createUpgradeResponse();
    UpgradeV4Response expectedResponse = createUpgradeResponse();
    expectedResponse.setReason("There are attached Data Hub clusters that are non-upgradeable There are attached Data Hub clusters in incorrect state");
    when(instanceGroupService.getByStackAndFetchTemplates(STACK_ID)).thenReturn(Collections.emptySet());
    when(upgradeService.isOsUpgrade(request)).thenReturn(false);
    StackInstanceCount instanceCount = mock(StackInstanceCount.class);
    when(instanceCount.getInstanceCount()).thenReturn(INSTANCE_COUNT);
    when(instanceMetaDataService.countByStackId(STACK_ID)).thenReturn(instanceCount);
    when(limitConfiguration.getUpgradeNodeCountLimit()).thenReturn(NODE_LIMIT);
    when(clusterUpgradeAvailabilityService.checkForUpgradesByName(stack, false, true, request.getInternalUpgradeSettings())).thenReturn(upgradeResponseToReturn);
    when(entitlementService.runtimeUpgradeEnabled(ACCOUNT_ID)).thenReturn(true);
    when(stackOperations.listByEnvironmentCrn(eq(WORKSPACE_ID), eq(ENVIRONMENT_CRN), any())).thenReturn(stackViewV4Responses);
    when(upgradePreconditionService.checkForRunningAttachedClusters(stackViewV4Responses, stack)).thenReturn("There are attached Data Hub clusters in incorrect state");
    when(upgradePreconditionService.checkForNonUpgradeableAttachedClusters(stackViewV4Responses)).thenReturn("There are attached Data Hub clusters that are non-upgradeable");
    UpgradeV4Response actual = underTest.checkForClusterUpgrade(ACCOUNT_ID, stack, WORKSPACE_ID, request);
    assertEquals(expectedResponse, actual);
    verify(instanceGroupService).getByStackAndFetchTemplates(STACK_ID);
    verify(upgradeService).isOsUpgrade(request);
    verify(instanceGroupService).getByStackAndFetchTemplates(STACK_ID);
    verify(limitConfiguration).getUpgradeNodeCountLimit();
    verify(clusterUpgradeAvailabilityService).checkForUpgradesByName(stack, false, true, request.getInternalUpgradeSettings());
    verify(clusterUpgradeAvailabilityService).filterUpgradeOptions(ACCOUNT_ID, upgradeResponseToReturn, request, true);
    verify(entitlementService).runtimeUpgradeEnabled(ACCOUNT_ID);
    verify(stackOperations).listByEnvironmentCrn(eq(WORKSPACE_ID), eq(ENVIRONMENT_CRN), any());
    verify(upgradePreconditionService).checkForRunningAttachedClusters(stackViewV4Responses, stack);
    verify(upgradePreconditionService).checkForNonUpgradeableAttachedClusters(stackViewV4Responses);
    verifyNoInteractions(clusterDBValidationService);
}
Also used : UpgradeV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response) StackInstanceCount(com.sequenceiq.cloudbreak.domain.projection.StackInstanceCount) UpgradeV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request) StackViewV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 53 with UpgradeV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response 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 54 with UpgradeV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response 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 55 with UpgradeV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response 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)

Aggregations

UpgradeV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response)69 ImageInfoV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.ImageInfoV4Response)43 Test (org.junit.jupiter.api.Test)41 UpgradeV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request)40 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)21 Test (org.junit.Test)16 DisplayName (org.junit.jupiter.api.DisplayName)16 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)13 ImageComponentVersions (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.ImageComponentVersions)10 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)10 ImageFilterResult (com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterResult)10 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)10 EntitlementService (com.sequenceiq.cloudbreak.auth.altus.EntitlementService)9 CloudbreakImageCatalogV3 (com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3)9 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)9 ImageFilterParams (com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterParams)9 List (java.util.List)9 BeforeEach (org.junit.jupiter.api.BeforeEach)8 InjectMocks (org.mockito.InjectMocks)8 Mock (org.mockito.Mock)8