private void assertTwoFlowSame(final ExecutableFlow flow1, final ExecutableFlow flow2) { assertTwoFlowSame(flow1, flow2, true); }
@Test public void fetchFlowHistory() throws Exception { final ExecutableFlow flow = createTestFlow(); this.executionFlowDao.uploadExecutableFlow(flow); final List<ExecutableFlow> flowList1 = this.executionFlowDao.fetchFlowHistory(0, 2); assertThat(flowList1.size()).isEqualTo(1); final List<ExecutableFlow> flowList2 = this.executionFlowDao .fetchFlowHistory(flow.getProjectId(), flow.getId(), 0, 2); assertThat(flowList2.size()).isEqualTo(1); final ExecutableFlow fetchFlow = this.executionFlowDao.fetchExecutableFlow(flow.getExecutionId()); assertTwoFlowSame(flowList1.get(0), flowList2.get(0)); assertTwoFlowSame(flowList1.get(0), fetchFlow); }
@Test public void testFetchUnfinishedFlowsMetadata() throws Exception { final List<ExecutableFlow> flows = createExecutions(); final Map<Integer, Pair<ExecutionReference, ExecutableFlow>> unfinishedFlows = this.fetchActiveFlowDao.fetchUnfinishedFlowsMetadata(); assertFound(unfinishedFlows, flows.get(0), true); assertFound(unfinishedFlows, flows.get(1), false); assertFound(unfinishedFlows, flows.get(2), true); assertNotFound(unfinishedFlows, flows.get(3), "Returned an execution with a finished status"); assertFound(unfinishedFlows, flows.get(4), false); assertTwoFlowSame(unfinishedFlows.get(flows.get(0).getExecutionId()).getSecond(), flows.get(0), false); assertTwoFlowSame(unfinishedFlows.get(flows.get(1).getExecutionId()).getSecond(), flows.get(1), false); assertTwoFlowSame(unfinishedFlows.get(flows.get(2).getExecutionId()).getSecond(), flows.get(2), false); }
@Test public void testFetchActiveFlowsExecutorAssigned() throws Exception { final List<ExecutableFlow> flows = createExecutions(); final Map<Integer, Pair<ExecutionReference, ExecutableFlow>> activeFlows = this.fetchActiveFlowDao .fetchActiveFlows(); assertFound(activeFlows, flows.get(0), true); assertNotFound(activeFlows, flows.get(1), "Returned a queued execution"); assertFound(activeFlows, flows.get(2), true); assertNotFound(activeFlows, flows.get(3), "Returned an execution with a finished status"); assertFound(activeFlows, flows.get(4), false); assertTwoFlowSame(activeFlows.get(flows.get(0).getExecutionId()).getSecond(), flows.get(0)); }
@Test public void testFetchUnfinishedFlows() throws Exception { final List<ExecutableFlow> flows = createExecutions(); final Map<Integer, Pair<ExecutionReference, ExecutableFlow>> unfinishedFlows = this.fetchActiveFlowDao.fetchUnfinishedFlows(); assertFound(unfinishedFlows, flows.get(0), true); assertFound(unfinishedFlows, flows.get(1), false); assertFound(unfinishedFlows, flows.get(2), true); assertNotFound(unfinishedFlows, flows.get(3), "Returned an execution with a finished status"); assertFound(unfinishedFlows, flows.get(4), false); assertTwoFlowSame(unfinishedFlows.get(flows.get(0).getExecutionId()).getSecond(), flows.get(0)); }
@Test public void testFetchRecentlyFinishedFlows() throws Exception { final ExecutableFlow flow1 = createTestFlow(); this.executionFlowDao.uploadExecutableFlow(flow1); flow1.setStatus(Status.SUCCEEDED); flow1.setEndTime(System.currentTimeMillis()); this.executionFlowDao.updateExecutableFlow(flow1); //Flow just finished. Fetch recently finished flows immediately. Should get it. final List<ExecutableFlow> flows = this.executionFlowDao.fetchRecentlyFinishedFlows( RECENTLY_FINISHED_LIFETIME); assertThat(flows.size()).isEqualTo(1); assertTwoFlowSame(flow1, flows.get(0)); }
@Test public void testAdvancedFilter() throws Exception { createTestProject(); final ExecutableFlow flow = createTestFlow(); this.executionFlowDao.uploadExecutableFlow(flow); final List<ExecutableFlow> flowList1 = this.executionFlowDao .fetchFlowHistory("exectest1", "", "", 0, -1, -1, 0, 16); assertThat(flowList1.size()).isEqualTo(1); final ExecutableFlow fetchFlow = this.executionFlowDao.fetchExecutableFlow(flow.getExecutionId()); assertTwoFlowSame(flowList1.get(0), fetchFlow); }
@Test public void testFetchActiveFlowByExecId() throws Exception { final List<ExecutableFlow> flows = createExecutions(); assertTwoFlowSame( this.fetchActiveFlowDao.fetchActiveFlowByExecId(flows.get(0).getExecutionId()).getSecond(), flows.get(0)); assertThat(this.fetchActiveFlowDao.fetchActiveFlowByExecId(flows.get(1).getExecutionId())) .isNull(); assertTwoFlowSame( this.fetchActiveFlowDao.fetchActiveFlowByExecId(flows.get(2).getExecutionId()).getSecond(), flows.get(2)); assertThat(this.fetchActiveFlowDao.fetchActiveFlowByExecId(flows.get(3).getExecutionId())) .isNull(); assertTwoFlowSame( this.fetchActiveFlowDao.fetchActiveFlowByExecId(flows.get(4).getExecutionId()).getSecond(), flows.get(4)); }
@Test public void testFetchQueuedFlows() throws Exception { final ExecutableFlow flow = createTestFlow(); flow.setStatus(Status.PREPARING); this.executionFlowDao.uploadExecutableFlow(flow); final ExecutableFlow flow2 = TestUtils.createTestExecutableFlow("exectest1", "exec2"); flow2.setStatus(Status.PREPARING); this.executionFlowDao.uploadExecutableFlow(flow2); final List<Pair<ExecutionReference, ExecutableFlow>> fetchedQueuedFlows = this.executionFlowDao .fetchQueuedFlows(); assertThat(fetchedQueuedFlows.size()).isEqualTo(2); final Pair<ExecutionReference, ExecutableFlow> fetchedFlow1 = fetchedQueuedFlows.get(0); final Pair<ExecutionReference, ExecutableFlow> fetchedFlow2 = fetchedQueuedFlows.get(1); assertTwoFlowSame(flow, fetchedFlow1.getSecond()); assertTwoFlowSame(flow2, fetchedFlow2.getSecond()); }
@Test public void testUploadAndFetchExecutionFlows() throws Exception { final ExecutableFlow flow = createTestFlow(); this.executionFlowDao.uploadExecutableFlow(flow); final ExecutableFlow fetchFlow = this.executionFlowDao.fetchExecutableFlow(flow.getExecutionId()); assertThat(flow).isNotSameAs(fetchFlow); assertTwoFlowSame(flow, fetchFlow); }
assertTwoFlowSame(flowList.get(i), expected.get(i));
@Test public void testUpdateExecutableFlow() throws Exception { final ExecutableFlow flow = createTestFlow(); this.executionFlowDao.uploadExecutableFlow(flow); final ExecutableFlow fetchFlow = this.executionFlowDao.fetchExecutableFlow(flow.getExecutionId()); fetchFlow.setEndTime(System.currentTimeMillis()); fetchFlow.setStatus(Status.SUCCEEDED); this.executionFlowDao.updateExecutableFlow(fetchFlow); final ExecutableFlow fetchFlow2 = this.executionFlowDao.fetchExecutableFlow(flow.getExecutionId()); assertTwoFlowSame(fetchFlow, fetchFlow2); }