use of org.ow2.proactive.scheduler.job.InternalTaskFlowJob in project scheduling by ow2-proactive.
the class LiveJobsTest method testTaskTerminatedWithResultPauseJobOnError.
@Test(timeout = 60000)
public void testTaskTerminatedWithResultPauseJobOnError() throws UnknownTaskException {
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);
TaskId taskId = TaskIdImpl.createTaskId(id, "task-name", 0L);
internalTask.setId(taskId);
internalTask.setName("task-name");
internalTask.setExecuterInformation(Mockito.mock(ExecuterInformation.class));
TaskInfoImpl taskInfoImpl = (TaskInfoImpl) internalTask.getTaskInfo();
taskInfoImpl.setNumberOfExecutionLeft(10);
internalTask.setOnTaskError(OnTaskError.PAUSE_JOB);
InternalTask internalTask2 = new InternalScriptTask(job);
TaskId taskId2 = TaskIdImpl.createTaskId(id, "task-name2", 1L);
internalTask2.setId(taskId2);
internalTask2.setName("task-name2");
internalTask2.setExecuterInformation(Mockito.mock(ExecuterInformation.class));
TaskInfoImpl taskInfoImpl2 = (TaskInfoImpl) internalTask2.getTaskInfo();
taskInfoImpl2.setNumberOfExecutionLeft(10);
internalTask2.setOnTaskError(OnTaskError.NONE);
tasksList.add(internalTask);
tasksList.add(internalTask2);
job.setTasks(tasksList);
liveJobs.jobSubmitted(job);
liveJobs.lockJobsToSchedule(false);
liveJobs.taskStarted(job, job.getTask("task-name"), null);
TaskResultImpl result = new TaskResultImpl(taskId, new Exception());
liveJobs.taskTerminatedWithResult(taskId, result);
assertThat(taskInfoImpl.getNumberOfExecutionLeft(), is(9));
assertThat(taskInfoImpl.getStatus(), is(TaskStatus.WAITING_ON_ERROR));
assertThat(taskInfoImpl2.getNumberOfExecutionLeft(), is(10));
assertThat(taskInfoImpl2.getStatus(), is(TaskStatus.SUBMITTED));
assertThat(job.getStatus(), is(JobStatus.STALLED));
}
use of org.ow2.proactive.scheduler.job.InternalTaskFlowJob in project scheduling by ow2-proactive.
the class LiveJobsTest method testTaskTerminatedWithResultSuspendTaskOnErrorLastExecution.
@Test(timeout = 60000)
public void testTaskTerminatedWithResultSuspendTaskOnErrorLastExecution() throws UnknownTaskException {
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);
TaskId taskId = TaskIdImpl.createTaskId(id, "task-name", 0L);
internalTask.setId(taskId);
internalTask.setName("task-name");
internalTask.setStatus(TaskStatus.RUNNING);
internalTask.setExecuterInformation(Mockito.mock(ExecuterInformation.class));
TaskInfoImpl taskInfoImpl = (TaskInfoImpl) internalTask.getTaskInfo();
taskInfoImpl.setNumberOfExecutionLeft(0);
internalTask.setOnTaskError(OnTaskError.PAUSE_TASK);
tasksList.add(internalTask);
job.setTasks(tasksList);
liveJobs.jobSubmitted(job);
liveJobs.lockJobsToSchedule(false);
liveJobs.taskStarted(job, job.getTask("task-name"), null);
TaskResultImpl result = new TaskResultImpl(taskId, new Exception(), null, 330);
liveJobs.taskTerminatedWithResult(taskId, result);
assertThat(taskInfoImpl.getNumberOfExecutionLeft(), is(-1));
assertThat(taskInfoImpl.getStatus(), is(TaskStatus.IN_ERROR));
assertThat(job.getStatus(), is(JobStatus.IN_ERROR));
}
use of org.ow2.proactive.scheduler.job.InternalTaskFlowJob in project scheduling by ow2-proactive.
the class LiveJobsTest method testFinishInErrorTask.
@Test(timeout = 60000)
public void testFinishInErrorTask() 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.IN_ERROR);
Node node = Mockito.mock(Node.class);
Mockito.when(node.getVMInformation()).thenAnswer(new Answer<VMInformation>() {
@Override
public VMInformation answer(InvocationOnMock invocation) throws Throwable {
return Mockito.mock(VMInformation.class);
}
});
Mockito.when(node.getNodeInformation()).thenAnswer(new Answer<NodeInformation>() {
@Override
public NodeInformation answer(InvocationOnMock invocation) throws Throwable {
return Mockito.mock(NodeInformation.class);
}
});
TaskLauncher taskLauncher = Mockito.mock(TaskLauncher.class);
internalTask.setExecuterInformation(new ExecuterInformation(taskLauncher, node));
tasksList.add(internalTask);
job.setTasks(tasksList);
liveJobs.jobSubmitted(job);
liveJobs.finishInErrorTask(job.getId(), "task-name");
assertThat(internalTask.getStatus(), is(TaskStatus.FINISHED));
}
use of org.ow2.proactive.scheduler.job.InternalTaskFlowJob in project scheduling by ow2-proactive.
the class LiveJobsTest method testJobSubmitted.
@Test(timeout = 60000)
public void testJobSubmitted() {
InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
JobId id = new JobIdImpl(666L, "test-name");
job.setId(id);
liveJobs.jobSubmitted(job);
Mockito.verify(listener, Mockito.times(1)).jobSubmitted(Matchers.any(ClientJobState.class));
}
use of org.ow2.proactive.scheduler.job.InternalTaskFlowJob 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));
}
Aggregations