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