use of com.sequenceiq.flow.domain.FlowLog in project cloudbreak by hortonworks.
the class TerminationTriggerServiceTest method whenStackNotDeletedAndNotTerminationFlowLogAndNotKerbAndForcedShouldTerminate.
@Test
public void whenStackNotDeletedAndNotTerminationFlowLogAndNotKerbAndForcedShouldTerminate() {
FlowLog flowLog = new FlowLog();
flowLog.setFlowType(ClassValue.of(StackCreationFlowConfig.class));
when(flowLogService.findAllByResourceIdAndFinalizedIsFalseOrderByCreatedDesc(anyLong())).thenReturn(List.of(flowLog));
setupNotKerberized();
underTest.triggerTermination(getAvailableStack(), true);
verifyTerminationEventFired(false, true, false);
}
use of com.sequenceiq.flow.domain.FlowLog in project cloudbreak by hortonworks.
the class UpgradeCcmFlowIntegrationTest method testCcmUpgradeWhenTunnelUpdateFail.
@Test
public void testCcmUpgradeWhenTunnelUpdateFail() throws CloudbreakOrchestratorException {
doThrow(new BadRequestException()).when(upgradeCcmService).updateTunnel(STACK_ID);
FlowIdentifier flowIdentifier = triggerFlow();
letItFlow(flowIdentifier);
ArgumentCaptor<FlowLog> flowLog = ArgumentCaptor.forClass(FlowLog.class);
verify(flowLogRepository, times(2)).save(flowLog.capture());
Assertions.assertTrue(flowLog.getAllValues().stream().anyMatch(FlowLog::getFinalized), "flow has not finalized");
InOrder inOrder = Mockito.inOrder(upgradeCcmService);
inOrder.verify(upgradeCcmService, times(1)).updateTunnel(STACK_ID);
inOrder.verify(upgradeCcmService, times(1)).ccmUpgradeFailed(STACK_ID, CLUSTER_ID, Tunnel.CCM);
verify(upgradeCcmService, never()).pushSaltState(STACK_ID, CLUSTER_ID);
verify(upgradeCcmService, never()).reconfigureNginx(STACK_ID);
verify(upgradeCcmService, never()).registerClusterProxy(STACK_ID);
verify(upgradeCcmService, never()).healthCheck(STACK_ID);
verify(upgradeCcmService, never()).deregisterAgent(STACK_ID, Tunnel.CCM);
verify(upgradeCcmService, never()).removeAgent(STACK_ID, Tunnel.CCM);
}
use of com.sequenceiq.flow.domain.FlowLog in project cloudbreak by hortonworks.
the class DatalakeRestoreActionsTest method testGetNewSdxIdForResizeCreateFlowContext.
@Test
public void testGetNewSdxIdForResizeCreateFlowContext() throws Exception {
SdxCluster sdxCluster = genCluster();
FlowParameters flowParameters = new FlowParameters(FLOW_ID, null, null);
when(sdxService.getByNameInAccount(eq(USER_CRN), eq(DATALAKE_NAME))).thenReturn(sdxCluster);
when(flowLogService.getLastFlowLog(anyString())).thenReturn(Optional.of(new FlowLog()));
FlowChainLog flowChainLog = new FlowChainLog();
flowChainLog.setFlowChainType(DatalakeResizeFlowEventChainFactory.class.getSimpleName());
when(flowChainLogService.findFirstByFlowChainIdOrderByCreatedDesc(any())).thenReturn(Optional.of(flowChainLog));
DatalakeTriggerRestoreEvent event = new DatalakeTriggerRestoreEvent(DATALAKE_TRIGGER_RESTORE_EVENT.event(), OLD_SDX_ID, DATALAKE_NAME, USER_CRN, null, BACKUP_LOCATION, null, DatalakeRestoreFailureReason.RESTORE_ON_RESIZE);
AbstractAction action = (AbstractAction) underTest.triggerDatalakeRestore();
initActionPrivateFields(action);
AbstractActionTestSupport testSupport = new AbstractActionTestSupport(action);
SdxContext context = (SdxContext) testSupport.createFlowContext(flowParameters, null, event);
Assert.assertEquals(NEW_SDX_ID, context.getSdxId());
Assert.assertEquals(USER_CRN, context.getUserId());
Assert.assertEquals(FLOW_ID, context.getFlowId());
Assert.assertEquals(NEW_SDX_ID, event.getDrStatus().getSdxClusterId());
flowChainLog.setFlowChainType(DatalakeUpgradeFlowEventChainFactory.class.getSimpleName());
context = (SdxContext) testSupport.createFlowContext(flowParameters, null, event);
Assert.assertEquals(OLD_SDX_ID, context.getSdxId());
}
use of com.sequenceiq.flow.domain.FlowLog in project cloudbreak by hortonworks.
the class FlowLogUtil method isFlowFailHandled.
public static boolean isFlowFailHandled(List<FlowLog> flowLogs, Set<String> failHandledEvents) {
if (flowLogs.size() > 2) {
FlowLog lastFlowLog = flowLogs.get(0);
FlowLog secondLastFlowLog = flowLogs.get(1);
LOGGER.debug("Last two log items: {}, {}", lastFlowLog, secondLastFlowLog);
return lastFlowLog.getFinalized() && failHandledEvents.contains(secondLastFlowLog.getNextEvent());
}
return false;
}
use of com.sequenceiq.flow.domain.FlowLog in project cloudbreak by hortonworks.
the class FlowLogUtil method isFlowInFailedState.
public static boolean isFlowInFailedState(List<FlowLog> flowLogs, Set<String> failHandledEvents) {
if (flowLogs.size() > 2) {
FlowLog lastFlowLog = flowLogs.get(0);
FlowLog secondLastFlowLog = flowLogs.get(1);
LOGGER.debug("Last two log items: {}, {}", lastFlowLog, secondLastFlowLog);
return lastFlowLog.getFinalized() && (failHandledEvents.contains(secondLastFlowLog.getNextEvent()) || StateStatus.FAILED.equals(secondLastFlowLog.getStateStatus()));
}
return false;
}
Aggregations