use of org.ow2.proactive.scheduler.task.internal.InternalScriptTask 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.InternalScriptTask 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));
}
use of org.ow2.proactive.scheduler.task.internal.InternalScriptTask in project scheduling by ow2-proactive.
the class LiveJobsTest method submitJobAndStartTask.
private void submitJobAndStartTask(JobId id, TaskId tid) throws UnknownTaskException {
InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
job.setId(id);
List<InternalTask> tasksList = new ArrayList<>();
InternalScriptTask internalTask = new InternalScriptTask(job);
internalTask.setName(tid.getReadableName());
internalTask.setStatus(TaskStatus.RUNNING);
internalTask.setMaxNumberOfExecution(5);
internalTask.setExecuterInformation(Mockito.mock(ExecuterInformation.class));
tasksList.add(internalTask);
job.setTasks(tasksList);
liveJobs.jobSubmitted(job);
liveJobs.lockJobsToSchedule();
liveJobs.taskStarted(job, job.getTask(tid.getReadableName()), null);
}
use of org.ow2.proactive.scheduler.task.internal.InternalScriptTask 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.task.internal.InternalScriptTask 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.setStatus(TaskStatus.RUNNING);
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.setStatus(TaskStatus.RUNNING);
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();
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.PENDING));
assertThat(job.getStatus(), is(JobStatus.STALLED));
}
Aggregations