@Test public void testDeleteTask() throws Exception { PipelineExecutorTrace trace = mock(PipelineExecutorTrace.class); PipelineExecutorTask task = mock(PipelineExecutorTask.class); PipelineExecutorTask.Status status = PipelineExecutorTask.Status.STOPPED; when(task.getPipelineStatus()).thenReturn(status); when(trace.getTask()).thenReturn(task); when(pipelineExecutorRegistry.getExecutorTrace(TASK_ID)).thenReturn(trace); taskManager.delete(TASK_ID); verify(pipelineExecutorRegistry, times(1)).deregister(TASK_ID); }
@Test public void testDeleteTask() throws Exception { PipelineExecutorTrace trace = mock(PipelineExecutorTrace.class); PipelineExecutorTask task = mock(PipelineExecutorTask.class); PipelineExecutorTask.Status status = PipelineExecutorTask.Status.STOPPED; when(task.getPipelineStatus()).thenReturn(status); when(trace.getTask()).thenReturn(task); when(pipelineExecutorRegistry.getExecutorTrace(TASK_ID)).thenReturn(trace); taskManager.delete(TASK_ID); verify(pipelineExecutorRegistry, times(1)).deregister(TASK_ID); }
private void testDeleteTaskInNonStopeableState(PipelineExecutorTask.Status nonStopeableStatus) throws Exception { PipelineExecutorTask task = mock(PipelineExecutorTask.class); when(task.getPipelineStatus()).thenReturn(nonStopeableStatus); PipelineExecutorTrace trace = mock(PipelineExecutorTrace.class); when(trace.getTask()).thenReturn(task); when(pipelineExecutorRegistry.getExecutorTrace(TASK_ID)).thenReturn(trace); expectedException.expectMessage(new StartsWith("A PipelineExecutorTask in status: " + nonStopeableStatus + " can not" + " be deleted. Delete operation is available for the following status set:")); taskManager.delete(TASK_ID); }
private void testDeleteTaskInNonStopeableState(PipelineExecutorTask.Status nonStopeableStatus) throws Exception { PipelineExecutorTask task = mock(PipelineExecutorTask.class); when(task.getPipelineStatus()).thenReturn(nonStopeableStatus); PipelineExecutorTrace trace = mock(PipelineExecutorTrace.class); when(trace.getTask()).thenReturn(task); when(pipelineExecutorRegistry.getExecutorTrace(TASK_ID)).thenReturn(trace); expectedException.expectMessage(new StartsWith("A PipelineExecutorTask in status: " + nonStopeableStatus + " can not" + " be deleted. Delete operation is available for the following status set:")); taskManager.delete(TASK_ID); }
@Override public void delete(final String taskId) throws PipelineExecutorException { final TaskEntry entry = getTaskEntry(taskId); if (entry != null) { throw new PipelineExecutorException("An active PipelineExecutorTask was found for taskId: " + taskId + " delete operation is only available for the following status set: " + deleteEnabledStatus); } final PipelineExecutorTrace trace = pipelineExecutorRegistry.getExecutorTrace(taskId); if (trace == null) { throw new PipelineExecutorException("No PipelineExecutorTask was found for taskId: " + taskId); } else { if (!deleteEnabledStatus.contains(trace.getTask().getPipelineStatus())) { throw new PipelineExecutorException("A PipelineExecutorTask in status: " + trace.getTask().getPipelineStatus().name() + " can not" + " be deleted. Delete operation is available for the following status set: " + deleteEnabledStatus); } else { pipelineExecutorRegistry.deregister(taskId); } } }
@Override public void delete(final String taskId) throws PipelineExecutorException { final TaskEntry entry = getTaskEntry(taskId); if (entry != null) { throw new PipelineExecutorException("An active PipelineExecutorTask was found for taskId: " + taskId + " delete operation is only available for the following status set: " + deleteEnabledStatus); } final PipelineExecutorTrace trace = pipelineExecutorRegistry.getExecutorTrace(taskId); if (trace == null) { throw new PipelineExecutorException("No PipelineExecutorTask was found for taskId: " + taskId); } else { if (!deleteEnabledStatus.contains(trace.getTask().getPipelineStatus())) { throw new PipelineExecutorException("A PipelineExecutorTask in status: " + trace.getTask().getPipelineStatus().name() + " can not" + " be deleted. Delete operation is available for the following status set: " + deleteEnabledStatus); } else { pipelineExecutorRegistry.deregister(taskId); } } }
protected void assertHasSameInfo(PipelineExecutorTask expectedTask, PipelineExecutorTask task) { assertEquals(expectedTask.getId(), task.getId()); assertEquals(expectedTask.getPipelineStatus(), task.getPipelineStatus()); assertEquals(expectedTask.getPipelineError(), task.getPipelineError()); assertEquals(expectedTask.getOutput(), task.getOutput()); assertHasSameInfo(expectedTask.getTaskDef(), task.getTaskDef()); expectedTask.getTaskDef().getStages().forEach(stage -> { assertEquals(expectedTask.getStageStatus(stage), task.getStageStatus(stage)); assertEquals(expectedTask.getStageError(stage), task.getStageError(stage)); }); }
protected void assertHasSameInfo(PipelineExecutorTask expectedTask, PipelineExecutorTask task) { assertEquals(expectedTask.getId(), task.getId()); assertEquals(expectedTask.getPipelineStatus(), task.getPipelineStatus()); assertEquals(expectedTask.getPipelineError(), task.getPipelineError()); assertEquals(expectedTask.getOutput(), task.getOutput()); assertHasSameInfo(expectedTask.getTaskDef(), task.getTaskDef()); expectedTask.getTaskDef().getStages().forEach(stage -> { assertEquals(expectedTask.getStageStatus(stage), task.getStageStatus(stage)); assertEquals(expectedTask.getStageError(stage), task.getStageError(stage)); }); }
private void assertEqualsPipelineExecutorTrace(PipelineExecutorTraceImpl expectedValue, PipelineExecutorTraceImpl value) { assertEquals(expectedValue.getTaskId(), value.getTaskId()); assertEquals(expectedValue.getPipelineId(), value.getPipelineId()); assertEquals(expectedValue.getTask().getTaskDef(), value.getTask().getTaskDef()); assertEquals(expectedValue.getTask().getPipelineStatus(), value.getTask().getPipelineStatus()); assertEqualsPipelineExecutorException(expectedValue.getTask().getPipelineError(), value.getTask().getPipelineError()); for (String stage : expectedValue.getTask().getTaskDef().getStages()) { assertEquals(expectedValue.getTask().getStageStatus(stage), value.getTask().getStageStatus(stage)); assertEqualsPipelineExecutorException(expectedValue.getTask().getStageError(stage), value.getTask().getStageError(stage)); } assertEquals(expectedValue.getTask().getOutput(), value.getTask().getOutput()); }
private void assertEqualsPipelineExecutorTrace(PipelineExecutorTraceImpl expectedValue, PipelineExecutorTraceImpl value) { assertEquals(expectedValue.getTaskId(), value.getTaskId()); assertEquals(expectedValue.getPipelineId(), value.getPipelineId()); assertEquals(expectedValue.getTask().getTaskDef(), value.getTask().getTaskDef()); assertEquals(expectedValue.getTask().getPipelineStatus(), value.getTask().getPipelineStatus()); assertEquals(expectedValue.getTask().getPipelineError(), value.getTask().getPipelineError()); for (String stage : expectedValue.getTask().getTaskDef().getStages()) { assertEquals(expectedValue.getTask().getStageStatus(stage), value.getTask().getStageStatus(stage)); assertEquals(expectedValue.getTask().getStageError(stage), value.getTask().getStageError(stage)); } assertEquals(expectedValue.getTask().getOutput(), value.getTask().getOutput()); }
item.setPipelineStatus(pipelineExecutorTrace.getTask().getPipelineStatus().name()); if (pipelineExecutorTrace.getTask().getPipelineError() != null) { item.setPipelineError(pipelineExecutorTrace.getTask().getPipelineError().toString());