Search in sources :

Example 41 with UnknownTaskException

use of org.ow2.proactive.scheduler.common.exception.UnknownTaskException in project scheduling by ow2-proactive.

the class TaskResultCreatorTest method testThatEmptyTaskResultIsUsedWhenResultIsNotInDatabase.

@Test
public void testThatEmptyTaskResultIsUsedWhenResultIsNotInDatabase() throws UnknownTaskException {
    TaskResultCreator taskResultCreator = spy(TaskResultCreator.class);
    TaskResultImpl mockedTaskResultImpl = mock(TaskResultImpl.class);
    doReturn(mockedTaskResultImpl).when(taskResultCreator).getEmptyTaskResult(any(InternalTask.class), any(Throwable.class), any(TaskLogs.class));
    Map<TaskId, TaskResult> loadTaskResultsValue = new HashMap<>();
    loadTaskResultsValue.put(this.createTaskID(), mockedTaskResultImpl);
    SchedulerDBManager mockedschedulerDbManager = mock(SchedulerDBManager.class);
    when(mockedschedulerDbManager.loadTasksResults(any(JobId.class), any(List.class))).thenThrow(DatabaseManagerException.class);
    taskResultCreator.getTaskResult(mockedschedulerDbManager, this.getMockedInternalJob(this.getMockedJobDescriptorWithPausedTask()), this.getMockedInternalTask());
    verify(mockedTaskResultImpl).setPropagatedVariables(any(Map.class));
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) HashMap(java.util.HashMap) SchedulerDBManager(org.ow2.proactive.scheduler.core.db.SchedulerDBManager) TaskLogs(org.ow2.proactive.scheduler.common.task.TaskLogs) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 42 with UnknownTaskException

use of org.ow2.proactive.scheduler.common.exception.UnknownTaskException in project scheduling by ow2-proactive.

the class LiveJobsTest method testRestartTaskOnNodeRunning0ExecutionsLeft.

@Test(timeout = 60000)
public void testRestartTaskOnNodeRunning0ExecutionsLeft() throws UnknownJobException, UnknownTaskException {
    PASchedulerProperties.NUMBER_OF_EXECUTION_ON_FAILURE.updateProperty("0");
    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(0));
    assertThat(internalTask.getTaskInfo().getNumberOfExecutionOnFailureLeft(), is(0));
    liveJobs.restartTaskOnNodeFailure(internalTask);
    internalTask.setStatus(TaskStatus.RUNNING);
    Mockito.verify(dbManager, Mockito.times(0)).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 43 with UnknownTaskException

use of org.ow2.proactive.scheduler.common.exception.UnknownTaskException in project scheduling by ow2-proactive.

the class LiveJobsTest method testGetRunningTaskByTaskId.

@Test(timeout = 600000)
public void testGetRunningTaskByTaskId() throws UnknownTaskException {
    PASchedulerProperties.NUMBER_OF_EXECUTION_ON_FAILURE.updateProperty("5");
    JobId id = new JobIdImpl(666L, "test-name");
    TaskId tid = TaskIdImpl.createTaskId(id, "task-name", 0L);
    submitJobAndStartTask(id, tid);
    JobId id2 = new JobIdImpl(667L, "test-name");
    TaskId tid2 = TaskIdImpl.createTaskId(id2, "task-name2", 0L);
    submitJobAndStartTask(id2, tid2);
    JobId id3 = new JobIdImpl(668L, "test-name");
    TaskId tid3 = TaskIdImpl.createTaskId(id3, "task-name3", 0L);
    submitJobAndStartTask(id3, tid3);
    JobId id4 = new JobIdImpl(669L, "test-name");
    TaskId tid4 = TaskIdImpl.createTaskId(id4, "task-name4", 0L);
    submitJobAndStartTask(id4, tid4);
    JobId id5 = new JobIdImpl(670L, "test-name");
    TaskId tid5 = TaskIdImpl.createTaskId(id5, "task-name5", 0L);
    submitJobAndStartTask(id5, tid5);
    assertThat(liveJobs.getRunningTasks().size(), is(5));
    assertThat(liveJobs.getRunningTask(tid).getTask().getName(), is("task-name"));
    assertThat(liveJobs.getRunningTask(tid).getTask().getJobId(), is(id));
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 44 with UnknownTaskException

use of org.ow2.proactive.scheduler.common.exception.UnknownTaskException in project scheduling by ow2-proactive.

the class LiveJobsTest method testLockJobsToSchedule.

@Test(timeout = 60000)
public void testLockJobsToSchedule() 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");
    tasksList.add(internalTask);
    job.setTasks(tasksList);
    liveJobs.jobSubmitted(job);
    liveJobs.pauseJob(id);
    assertThat(liveJobs.lockJobsToSchedule().size(), is(1));
}
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)

Example 45 with UnknownTaskException

use of org.ow2.proactive.scheduler.common.exception.UnknownTaskException in project scheduling by ow2-proactive.

the class LiveJobsTest method testCanPingTask.

@Test(timeout = 60000)
public void testCanPingTask() 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);
    TaskId taskId = TaskIdImpl.createTaskId(id, "task-name", 777L);
    internalTask.setId(taskId);
    internalTask.setName("task-name");
    internalTask.setStatus(TaskStatus.RUNNING);
    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(liveJobs.canPingTask(liveJobs.getRunningTasks().iterator().next()), is(true));
}
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) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) 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

UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)28 Test (org.junit.Test)27 JobId (org.ow2.proactive.scheduler.common.job.JobId)25 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)25 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)21 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)21 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)21 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)18 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)18 ArrayList (java.util.ArrayList)16 InternalScriptTask (org.ow2.proactive.scheduler.task.internal.InternalScriptTask)16 InternalTaskFlowJob (org.ow2.proactive.scheduler.job.InternalTaskFlowJob)14 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)14 ExecuterInformation (org.ow2.proactive.scheduler.task.internal.ExecuterInformation)10 HashMap (java.util.HashMap)8 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)8 SchedulerDBManager (org.ow2.proactive.scheduler.core.db.SchedulerDBManager)8 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)8 List (java.util.List)7 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)7