use of com.sequenceiq.freeipa.flow.stack.upgrade.ccm.event.UpgradeCcmFailureEvent in project cloudbreak by hortonworks.
the class UpgradeCcmFlowIntegrationTest method verifyFinishingStatCalls.
private void verifyFinishingStatCalls(boolean success) {
verify(upgradeCcmService, times(success ? 1 : 0)).finishedState(STACK_ID);
verify(operationService, times(success ? 1 : 0)).completeOperation(any(), any(), any(), any());
ArgumentCaptor<UpgradeCcmContext> contextCaptor = ArgumentCaptor.forClass(UpgradeCcmContext.class);
ArgumentCaptor<UpgradeCcmFailureEvent> payloadCaptor = ArgumentCaptor.forClass(UpgradeCcmFailureEvent.class);
verify(upgradeCcmService, times(success ? 0 : 1)).failedState(contextCaptor.capture(), payloadCaptor.capture());
if (!success) {
UpgradeCcmContext context = contextCaptor.getValue();
UpgradeCcmFailureEvent payload = payloadCaptor.getValue();
assertEquals(STACK_ID, context.getStack().getId());
assertEquals(STACK_ID, payload.getResourceId());
}
verify(operationService, times(success ? 0 : 1)).failOperation(any(), any(), any());
}
use of com.sequenceiq.freeipa.flow.stack.upgrade.ccm.event.UpgradeCcmFailureEvent in project cloudbreak by hortonworks.
the class UpgradeCcmFlowChainIntegrationTest method verifyFinishingStatCalls.
private void verifyFinishingStatCalls(boolean ccmUpgradeSuccess, boolean userDataUpdateSuccess) throws Exception {
verify(upgradeCcmService, times(ccmUpgradeSuccess ? 1 : 0)).finishedState(STACK_ID);
verify(resourcesApi, times(userDataUpdateSuccess ? 1 : 0)).updateUserData(any(), any(), any(), eq(USER_DATA));
ArgumentCaptor<UpgradeCcmContext> contextCaptor = ArgumentCaptor.forClass(UpgradeCcmContext.class);
ArgumentCaptor<UpgradeCcmFailureEvent> payloadCaptor = ArgumentCaptor.forClass(UpgradeCcmFailureEvent.class);
verify(upgradeCcmService, times(ccmUpgradeSuccess ? 0 : 1)).failedState(contextCaptor.capture(), payloadCaptor.capture());
if (!ccmUpgradeSuccess) {
UpgradeCcmContext context = contextCaptor.getValue();
UpgradeCcmFailureEvent payload = payloadCaptor.getValue();
assertEquals(STACK_ID, context.getStack().getId());
assertEquals(STACK_ID, payload.getResourceId());
}
verify(operationService, times(ccmUpgradeSuccess && userDataUpdateSuccess ? 1 : 0)).completeOperation(any(), any(), any(), any());
verify(operationService, times(ccmUpgradeSuccess && userDataUpdateSuccess ? 0 : 1)).failOperation(any(), any(), any());
}
use of com.sequenceiq.freeipa.flow.stack.upgrade.ccm.event.UpgradeCcmFailureEvent in project cloudbreak by hortonworks.
the class UpgradeCcmActions method failed.
@Bean(name = UPGRADE_CCM_FAILED_STATE_NAME)
public Action<?, ?> failed() {
return new AbstractUpgradeCcmAction<>(UpgradeCcmFailureEvent.class) {
@Override
protected UpgradeCcmContext createFlowContext(FlowParameters flowParameters, StateContext<UpgradeCcmState, UpgradeCcmStateSelector> stateContext, UpgradeCcmFailureEvent payload) {
Flow flow = getFlow(flowParameters.getFlowId());
flow.setFlowFailed(payload.getException());
return super.createFlowContext(flowParameters, stateContext, payload);
}
@Override
protected void doExecute(UpgradeCcmContext context, UpgradeCcmFailureEvent payload, Map<Object, Object> variables) {
LOGGER.info("FreeIPA CCM upgrade failed {}", payload);
upgradeCcmService.failedState(context, payload);
failOperation(context.getStack().getAccountId(), payload.getException().getMessage(), variables);
sendEvent(context, UPGRADE_CCM_FAILURE_HANDLED_EVENT.event(), new StackEvent(context.getStack().getId()));
}
};
}
use of com.sequenceiq.freeipa.flow.stack.upgrade.ccm.event.UpgradeCcmFailureEvent in project cloudbreak by hortonworks.
the class UpgradeCcmUpgradeHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<UpgradeCcmEvent> event) {
UpgradeCcmEvent request = event.getData();
if (request.getOldTunnel().useCcmV1()) {
try {
LOGGER.info("Running upgrade state for CCM...");
upgradeCcmService.upgrade(request.getResourceId());
} catch (CloudbreakOrchestratorException e) {
LOGGER.debug("Failed applying CCM upgrade state");
return new UpgradeCcmFailureEvent(UPGRADE_CCM_FAILED_EVENT.event(), request.getResourceId(), e);
}
} else {
LOGGER.info("Running upgrade step is skipped for previous tunnel type '{}'", request.getOldTunnel());
}
return UPGRADE_CCM_UPGRADE_FINISHED_EVENT.createBasedOn(request);
}
Aggregations