use of org.ow2.proactive.scheduler.task.internal.InternalTask in project scheduling by ow2-proactive.
the class JobDescriptorImplTest method testThatDoLoopPausesNewlyCreatedTasksIfJobIsPaused.
@Test
public void testThatDoLoopPausesNewlyCreatedTasksIfJobIsPaused() {
JobDescriptorImpl pausedJob = createEmptyJobDescriptor();
pausedJob.getInternal().setStatus(JobStatus.PAUSED);
// Create mocks for the loop root task
TaskId runningRootTaskId = TaskIdImpl.createTaskId(new JobIdImpl(1L, "Root"), "FirstLoopTask", 1L);
EligibleTaskDescriptorImpl mockLoopStartCurrentlyRunningTask = mock(EligibleTaskDescriptorImpl.class);
InternalTask mockInternalLoopRootTask = mock(InternalTask.class);
when(mockInternalLoopRootTask.getId()).thenReturn(runningRootTaskId);
when(mockLoopStartCurrentlyRunningTask.getTaskId()).thenReturn(runningRootTaskId);
when(mockLoopStartCurrentlyRunningTask.getInternal()).thenReturn(mockInternalLoopRootTask);
when(mockLoopStartCurrentlyRunningTask.getChildren()).thenReturn(new Vector<TaskDescriptor>());
// Create mocks for the new loop task
TaskId newLoopTaskId = TaskIdImpl.createTaskId(new JobIdImpl(1L, "Root"), "SecondLoopTask", 2L);
EligibleTaskDescriptorImpl mockLoopNewCreatedTaskForLoop = mock(EligibleTaskDescriptorImpl.class);
InternalTask mockInternalNewLoopTask = mock(InternalTask.class);
TaskInfo mockNewTaskTaskInfo = mock(TaskInfo.class);
when(mockNewTaskTaskInfo.getTaskId()).thenReturn(newLoopTaskId);
when(mockInternalNewLoopTask.getId()).thenReturn(newLoopTaskId);
when(mockInternalNewLoopTask.getStatus()).thenReturn(TaskStatus.SUBMITTED);
when(mockInternalNewLoopTask.getTaskInfo()).thenReturn(mockNewTaskTaskInfo);
when(mockLoopNewCreatedTaskForLoop.getTaskId()).thenReturn(newLoopTaskId);
when(mockLoopNewCreatedTaskForLoop.getInternal()).thenReturn(mockInternalNewLoopTask);
// Put the root loop task into running tasks, because it just terminated
pausedJob.getRunningTasks().put(mockLoopStartCurrentlyRunningTask.getTaskId(), mockLoopStartCurrentlyRunningTask);
// Put the new loop task into the Map, this is clue so that the test works
HashMap<TaskId, InternalTask> workflowTree = new HashMap<>();
workflowTree.put(newLoopTaskId, mockInternalNewLoopTask);
pausedJob.doLoop(mockLoopStartCurrentlyRunningTask.getTaskId(), workflowTree, mockLoopNewCreatedTaskForLoop.getInternal(), mockLoopNewCreatedTaskForLoop.getInternal());
verify(mockInternalNewLoopTask).setStatus(TaskStatus.PAUSED);
}
use of org.ow2.proactive.scheduler.task.internal.InternalTask in project scheduling by ow2-proactive.
the class TerminateReplicateTaskHandlerTest method generateInternalTask.
private InternalTask generateInternalTask(long id) {
InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
InternalTask internalTask = new InternalScriptTask(job);
internalTask.setId(TaskIdImpl.createTaskId(new JobIdImpl(666L, "JobName"), "readableName", id));
internalTask.setStatus(TaskStatus.PENDING);
return internalTask;
}
use of org.ow2.proactive.scheduler.task.internal.InternalTask in project scheduling by ow2-proactive.
the class ExtendedSchedulerPolicyTest method createJobDescWithTwoTasks.
private JobDescriptor createJobDescWithTwoTasks(String jobStartAt, String oneTaskStartAt, String otherTaskStartAt) {
InternalTaskFlowJob taskFlowJob = new InternalTaskFlowJob("test", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "");
taskFlowJob.setId(JobIdImpl.makeJobId(Integer.toString(jobId++)));
ArrayList<InternalTask> tasks = new ArrayList<>();
tasks.add(createTask(oneTaskStartAt));
tasks.add(createTask(otherTaskStartAt));
taskFlowJob.addTasks(tasks);
if (jobStartAt != null) {
taskFlowJob.addGenericInformation("START_AT", jobStartAt);
}
return new JobDescriptorImpl(taskFlowJob);
}
use of org.ow2.proactive.scheduler.task.internal.InternalTask in project scheduling by ow2-proactive.
the class LiveJobsTest method testResumeUnstartedJob.
@Test(timeout = 60000)
public void testResumeUnstartedJob() {
InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
JobId id = new JobIdImpl(666L, "test-name");
job.setId(id);
List<InternalTask> tasksList = new ArrayList<>();
InternalTask internalTask = new InternalScriptTask(job);
tasksList.add(internalTask);
job.setTasks(tasksList);
liveJobs.jobSubmitted(job);
assertThat(liveJobs.resumeJob(id), is(false));
}
use of org.ow2.proactive.scheduler.task.internal.InternalTask in project scheduling by ow2-proactive.
the class LiveJobsTest method testFinishInErrorTaskDoesNotFinishPendingTask.
@Test(timeout = 60000)
public void testFinishInErrorTaskDoesNotFinishPendingTask() throws UnknownTaskException, UnknownJobException {
InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CONTINUE_JOB_EXECUTION, "description");
JobId id = new JobIdImpl(666L, "test-name");
job.setId(id);
List<InternalTask> tasksList = new ArrayList<>();
InternalTask internalTask = new InternalScriptTask(job);
internalTask.setName("task-name");
internalTask.setStatus(TaskStatus.PENDING);
tasksList.add(internalTask);
job.setTasks(tasksList);
liveJobs.jobSubmitted(job);
liveJobs.finishInErrorTask(job.getId(), "task-name");
assertThat(internalTask.getStatus(), is(TaskStatus.PENDING));
}
Aggregations