use of org.ow2.proactive.scheduler.job.InternalTaskFlowJob in project scheduling by ow2-proactive.
the class LiveJobsTest method testRestartTaskOnNodeRunningDecreasingExecution.
@Test(timeout = 60000)
public void testRestartTaskOnNodeRunningDecreasingExecution() throws UnknownJobException, UnknownTaskException {
PASchedulerProperties.NUMBER_OF_EXECUTION_ON_FAILURE.updateProperty("5");
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<>();
InternalScriptTask internalTask = new InternalScriptTask(job);
internalTask.setName("task-name");
internalTask.setStatus(TaskStatus.RUNNING);
internalTask.setMaxNumberOfExecution(5);
internalTask.setExecuterInformation(Mockito.mock(ExecuterInformation.class));
tasksList.add(internalTask);
job.setTasks(tasksList);
liveJobs.jobSubmitted(job);
liveJobs.lockJobsToSchedule(false);
liveJobs.taskStarted(job, job.getTask("task-name"), null);
assertThat(internalTask.getMaxNumberOfExecutionOnFailure(), is(5));
assertThat(internalTask.getTaskInfo().getNumberOfExecutionOnFailureLeft(), is(5));
liveJobs.restartTaskOnNodeFailure(internalTask);
internalTask.setStatus(TaskStatus.RUNNING);
assertThat(internalTask.getMaxNumberOfExecutionOnFailure(), is(5));
assertThat(internalTask.getTaskInfo().getNumberOfExecutionOnFailureLeft(), is(4));
Mockito.verify(dbManager, Mockito.times(1)).taskRestarted(job, internalTask, null);
}
use of org.ow2.proactive.scheduler.job.InternalTaskFlowJob in project scheduling by ow2-proactive.
the class LiveJobsTest method testRestartTaskOnNodeFailureRunningExceptionExpectedBecauseNotLockedTask.
@Test(expected = IllegalStateException.class, timeout = 60000)
public void testRestartTaskOnNodeFailureRunningExceptionExpectedBecauseNotLockedTask() throws UnknownJobException, 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);
internalTask.setName("task-name");
internalTask.setStatus(TaskStatus.RUNNING);
tasksList.add(internalTask);
job.setTasks(tasksList);
liveJobs.jobSubmitted(job);
liveJobs.restartTaskOnNodeFailure(internalTask);
}
use of org.ow2.proactive.scheduler.job.InternalTaskFlowJob in project scheduling by ow2-proactive.
the class LiveJobsTest method testTaskTerminatedWithResultCancelJobOnError.
@Test(timeout = 60000)
public void testTaskTerminatedWithResultCancelJobOnError() 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(1);
internalTask.setOnTaskError(OnTaskError.CANCEL_JOB);
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());
liveJobs.taskTerminatedWithResult(taskId, result);
assertThat(taskInfoImpl.getNumberOfExecutionLeft(), is(0));
assertThat(taskInfoImpl.getStatus(), is(TaskStatus.FAULTY));
assertThat(job.getStatus(), is(JobStatus.CANCELED));
}
use of org.ow2.proactive.scheduler.job.InternalTaskFlowJob in project scheduling by ow2-proactive.
the class LiveJobsTest method testTaskTerminatedWithResultContinueJobOnError.
@Test(timeout = 60000)
public void testTaskTerminatedWithResultContinueJobOnError() 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(2);
internalTask.setOnTaskError(OnTaskError.CONTINUE_JOB_EXECUTION);
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());
liveJobs.taskTerminatedWithResult(taskId, result);
assertThat(taskInfoImpl.getNumberOfExecutionLeft(), is(1));
assertThat(taskInfoImpl.getStatus(), is(TaskStatus.WAITING_ON_ERROR));
assertThat(job.getStatus(), is(JobStatus.STALLED));
}
use of org.ow2.proactive.scheduler.job.InternalTaskFlowJob 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(false);
liveJobs.taskStarted(job, job.getTask(tid.getReadableName()), null);
}
Aggregations