Search in sources :

Example 1 with UpgradeCcmFlowChainTriggerEvent

use of com.sequenceiq.freeipa.flow.stack.upgrade.ccm.event.UpgradeCcmFlowChainTriggerEvent in project cloudbreak by hortonworks.

the class FreeIpaUpgradeCcmServiceTest method upgradeCcmTestWhenAvailableAndOperationRunning.

@Test
void upgradeCcmTestWhenAvailableAndOperationRunning() {
    Stack stack = createStack(Status.AVAILABLE);
    when(stackService.getByEnvironmentCrnAndAccountIdWithListsAndMdcContext(ENVIRONMENT_CRN, ACCOUNT_ID)).thenReturn(stack);
    Operation operation = createOperation(OperationState.RUNNING);
    when(operationService.startOperation(ACCOUNT_ID, OperationType.UPGRADE_CCM, List.of(ENVIRONMENT_CRN), List.of())).thenReturn(operation);
    when(operationConverter.convert(operation)).thenReturn(operationStatus);
    OperationStatus result = underTest.upgradeCcm(ENVIRONMENT_CRN, ACCOUNT_ID);
    assertThat(result).isSameAs(operationStatus);
    ArgumentCaptor<UpgradeCcmFlowChainTriggerEvent> eventCaptor = ArgumentCaptor.forClass(UpgradeCcmFlowChainTriggerEvent.class);
    verify(flowManager).notify(eq(UPGRADE_CCM_CHAIN_TRIGGER_EVENT), eventCaptor.capture());
    UpgradeCcmFlowChainTriggerEvent event = eventCaptor.getValue();
    assertThat(event.getOldTunnel()).isEqualTo(Tunnel.CCM);
    assertThat(event.getOperationId()).isEqualTo(OPERATION_ID);
    assertThat(event.getResourceId()).isEqualTo(STACK_ID);
}
Also used : OperationStatus(com.sequenceiq.freeipa.api.v1.operation.model.OperationStatus) UpgradeCcmFlowChainTriggerEvent(com.sequenceiq.freeipa.flow.stack.upgrade.ccm.event.UpgradeCcmFlowChainTriggerEvent) Operation(com.sequenceiq.freeipa.entity.Operation) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with UpgradeCcmFlowChainTriggerEvent

use of com.sequenceiq.freeipa.flow.stack.upgrade.ccm.event.UpgradeCcmFlowChainTriggerEvent in project cloudbreak by hortonworks.

the class FreeIpaUpgradeCcmService method triggerCcmUpgradeFlowChain.

private Operation triggerCcmUpgradeFlowChain(String accountId, Operation operation, Stack stack) {
    try {
        LOGGER.info("Starting CCM upgrade flow chain, new status: {}", UPGRADE_CCM_REQUESTED);
        stackUpdater.updateStackStatus(stack, UPGRADE_CCM_REQUESTED, "Starting of CCM upgrade requested");
        UpgradeCcmFlowChainTriggerEvent event = new UpgradeCcmFlowChainTriggerEvent(UPGRADE_CCM_CHAIN_TRIGGER_EVENT, operation.getOperationId(), stack.getId(), stack.getTunnel());
        flowManager.notify(UPGRADE_CCM_CHAIN_TRIGGER_EVENT, event);
        LOGGER.info("Started CCM upgrade flow");
        return operation;
    } catch (Exception e) {
        LOGGER.error("Couldn't start CCM upgrade flow", e);
        return operationService.failOperation(accountId, operation.getOperationId(), "Couldn't start Cluster Connectivity Manager upgrade flow: " + e.getMessage());
    }
}
Also used : UpgradeCcmFlowChainTriggerEvent(com.sequenceiq.freeipa.flow.stack.upgrade.ccm.event.UpgradeCcmFlowChainTriggerEvent) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException)

Aggregations

UpgradeCcmFlowChainTriggerEvent (com.sequenceiq.freeipa.flow.stack.upgrade.ccm.event.UpgradeCcmFlowChainTriggerEvent)2 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 OperationStatus (com.sequenceiq.freeipa.api.v1.operation.model.OperationStatus)1 Operation (com.sequenceiq.freeipa.entity.Operation)1 Stack (com.sequenceiq.freeipa.entity.Stack)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1