use of com.sequenceiq.flow.domain.FlowLog in project cloudbreak by hortonworks.
the class EventBusConfigTest method uncaughtErrorButFlowNotFound.
@Test
@DirtiesContext(methodMode = DirtiesContext.MethodMode.AFTER_METHOD)
public void uncaughtErrorButFlowNotFound() {
FlowLog flowLog = new FlowLog();
flowLog.setFlowId("123");
when(flowLogDBService.getLastFlowLog("123")).thenReturn(Optional.empty());
Event.Headers headers = new Event.Headers();
headers.set("FLOW_ID", "123");
eventBus.on(Selectors.regex("exampleselector"), (Consumer<Event<? extends Payload>>) event -> {
throw new RuntimeException("uncaught exception");
});
eventBus.notify("exampleselector", new Event<>(headers, null));
verify(flowLogDBService, timeout(2000).times(1)).getLastFlowLog("123");
verify(applicationFlowInformation, times(0)).handleFlowFail(any());
verify(flowLogDBService, times(0)).updateLastFlowLogStatus(any(), anyBoolean());
verify(flowLogDBService, times(0)).finalize(any());
}
use of com.sequenceiq.flow.domain.FlowLog in project cloudbreak by hortonworks.
the class EventBusConfigTest method uncaughtErrorButFlowFound.
@Test
@DirtiesContext(methodMode = DirtiesContext.MethodMode.AFTER_METHOD)
public void uncaughtErrorButFlowFound() {
FlowLog flowLog = new FlowLog();
flowLog.setFlowId("123");
when(flowLogDBService.getLastFlowLog("123")).thenReturn(Optional.of(flowLog));
Event.Headers headers = new Event.Headers();
headers.set("FLOW_ID", "123");
eventBus.on(Selectors.regex("exampleselector"), (Consumer<Event<? extends Payload>>) event -> {
throw new RuntimeException("uncaught exception");
});
eventBus.notify("exampleselector", new Event<>(headers, null));
verify(flowLogDBService, timeout(2000).times(1)).getLastFlowLog("123");
verify(applicationFlowInformation, timeout(1000).times(1)).handleFlowFail(flowLog);
verify(flowLogDBService, timeout(1000).times(1)).updateLastFlowLogStatus(flowLog, true);
verify(flowLogDBService, timeout(1000).times(1)).finalize(flowLog.getFlowId());
}
use of com.sequenceiq.flow.domain.FlowLog in project cloudbreak by hortonworks.
the class EventBusConfigTest method unknownMessageButFlowFound.
@Test
@DirtiesContext(methodMode = DirtiesContext.MethodMode.AFTER_METHOD)
public void unknownMessageButFlowFound() {
FlowLog flowLog = new FlowLog();
flowLog.setFlowId("123");
when(flowLogDBService.getLastFlowLog("123")).thenReturn(Optional.of(flowLog));
Event.Headers headers = new Event.Headers();
headers.set("FLOW_ID", "123");
eventBus.notify("notexist", new Event<>(headers, null));
verify(flowLogDBService, timeout(2000).times(1)).getLastFlowLog("123");
verify(applicationFlowInformation, timeout(1000).times(1)).handleFlowFail(flowLog);
verify(flowLogDBService, timeout(1000).times(1)).updateLastFlowLogStatus(flowLog, true);
verify(flowLogDBService, timeout(1000).times(1)).finalize(flowLog.getFlowId());
}
use of com.sequenceiq.flow.domain.FlowLog in project cloudbreak by hortonworks.
the class FlowCancelServiceTest method testCancelFlow.
@Test
public void testCancelFlow() throws TransactionExecutionException {
FlowLog flowLog = new FlowLog();
flowLog.setResourceId(1L);
flowLog.setFlowId("flowid");
underTest.cancelFlow(flowLog);
verify(flow2Handler, times(1)).cancelFlow(flowLog.getResourceId(), flowLog.getFlowId());
}
use of com.sequenceiq.flow.domain.FlowLog in project cloudbreak by hortonworks.
the class FlowRetryServiceTest method retry.
@Test
public void retry() {
FlowLog lastSuccessfulState = createFlowLog("INTERMEDIATE_STATE", StateStatus.SUCCESSFUL, 5, TestFlowEvent.TEST_FINISHED_EVENT.event());
List<FlowLog> pendingFlowLogs = Lists.newArrayList(createFlowLog("FINISHED", StateStatus.SUCCESSFUL, 7, null), createFlowLog("NEXT_STATE", StateStatus.FAILED, 6, TestFlowEvent.TEST_FAIL_HANDLED_EVENT.event()), lastSuccessfulState, createFlowLog("FINISHED", StateStatus.SUCCESSFUL, 4, null), createFlowLog("NEXT_STATE", StateStatus.FAILED, 3, TestFlowEvent.TEST_FAIL_HANDLED_EVENT.event()), createFlowLog("INTERMEDIATE_STATE", StateStatus.SUCCESSFUL, 2, TestFlowEvent.TEST_FINISHED_EVENT.event()), createFlowLog("INIT_STATE", StateStatus.SUCCESSFUL, 1, TestFlowEvent.TEST_FLOW_EVENT.event()));
when(flowLogRepository.findAllByResourceIdOrderByCreatedDesc(STACK_ID, PageRequest.of(0, 50))).thenReturn(pendingFlowLogs);
underTest.retry(STACK_ID);
verify(flow2Handler, times(1)).restartFlow(ArgumentMatchers.eq(lastSuccessfulState));
}
Aggregations