Search in sources :

Example 16 with InternalScriptTask

use of org.ow2.proactive.scheduler.task.internal.InternalScriptTask 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();
    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));
}
Also used : ExecuterInformation(org.ow2.proactive.scheduler.task.internal.ExecuterInformation) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) ArrayList(java.util.ArrayList) TaskInfoImpl(org.ow2.proactive.scheduler.task.TaskInfoImpl) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 17 with InternalScriptTask

use of org.ow2.proactive.scheduler.task.internal.InternalScriptTask 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();
    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));
}
Also used : ExecuterInformation(org.ow2.proactive.scheduler.task.internal.ExecuterInformation) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) ArrayList(java.util.ArrayList) TaskInfoImpl(org.ow2.proactive.scheduler.task.TaskInfoImpl) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 18 with InternalScriptTask

use of org.ow2.proactive.scheduler.task.internal.InternalScriptTask 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();
    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));
}
Also used : ExecuterInformation(org.ow2.proactive.scheduler.task.internal.ExecuterInformation) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) ArrayList(java.util.ArrayList) TaskInfoImpl(org.ow2.proactive.scheduler.task.TaskInfoImpl) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 19 with InternalScriptTask

use of org.ow2.proactive.scheduler.task.internal.InternalScriptTask 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();
    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);
}
Also used : ExecuterInformation(org.ow2.proactive.scheduler.task.internal.ExecuterInformation) InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) ArrayList(java.util.ArrayList) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 20 with InternalScriptTask

use of org.ow2.proactive.scheduler.task.internal.InternalScriptTask 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);
}
Also used : InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) ArrayList(java.util.ArrayList) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Aggregations

InternalScriptTask (org.ow2.proactive.scheduler.task.internal.InternalScriptTask)43 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)33 InternalTaskFlowJob (org.ow2.proactive.scheduler.job.InternalTaskFlowJob)32 Test (org.junit.Test)28 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)28 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)25 JobId (org.ow2.proactive.scheduler.common.job.JobId)20 ArrayList (java.util.ArrayList)18 ExecuterInformation (org.ow2.proactive.scheduler.task.internal.ExecuterInformation)14 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)11 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)5 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)5 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)5 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)5 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)4 InternalForkedScriptTask (org.ow2.proactive.scheduler.task.internal.InternalForkedScriptTask)4 ProActiveTest (org.ow2.tests.ProActiveTest)4 InternalException (org.ow2.proactive.scheduler.common.exception.InternalException)3 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)3 ForkEnvironment (org.ow2.proactive.scheduler.common.task.ForkEnvironment)3