Search in sources :

Example 6 with StackInstanceCount

use of com.sequenceiq.cloudbreak.domain.projection.StackInstanceCount 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)

Aggregations

StackInstanceCount (com.sequenceiq.cloudbreak.domain.projection.StackInstanceCount)6 UpgradeV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request)5 UpgradeV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response)5 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)5 Test (org.junit.jupiter.api.Test)5 StackViewV4Responses (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses)3 BadRequestException (javax.ws.rs.BadRequestException)2