Search in sources :

Example 61 with TaskId

use of org.ow2.proactive.scheduler.common.task.TaskId in project scheduling by ow2-proactive.

the class TerminationDataTest method testHandleTerminationForTaskNodeFailureTermination.

@Test
public void testHandleTerminationForTaskNodeFailureTermination() throws IOException, ClassNotFoundException {
    InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
    JobId jobId = new JobIdImpl(666, "readableName");
    InternalTask internalTask = new InternalScriptTask(job);
    TaskId taskId = TaskIdImpl.createTaskId(jobId, "task-name", 777L);
    internalTask.setId(taskId);
    internalTask.setName("task-name");
    internalTask.setStatus(TaskStatus.RUNNING);
    internalTask.setExecuterInformation(Mockito.mock(ExecuterInformation.class));
    RunningTaskData taskData = new RunningTaskData(internalTask, "user", null, launcher);
    terminationData.addTaskData(null, taskData, TerminationData.TerminationStatus.NODEFAILED, null);
    terminationData.handleTermination(service);
    Mockito.verify(launcher, Mockito.times(0)).kill();
}
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) 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 62 with TaskId

use of org.ow2.proactive.scheduler.common.task.TaskId in project scheduling by ow2-proactive.

the class TaskResultCreatorTest method testPausedTasksAreCheckedForATaskId.

@Test
public void testPausedTasksAreCheckedForATaskId() throws UnknownTaskException {
    TaskResultCreator taskResultCreator = new TaskResultCreator();
    TaskResultImpl mockedTaskResultImpl = mock(TaskResultImpl.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))).thenReturn(loadTaskResultsValue);
    JobDescriptorImpl mockedJobDescriptorHasPausedTask = this.getMockedJobDescriptorWithPausedTask();
    taskResultCreator.getTaskResult(mockedschedulerDbManager, this.getMockedInternalJob(mockedJobDescriptorHasPausedTask), this.getMockedInternalTask());
    verify(mockedJobDescriptorHasPausedTask, atLeastOnce()).getPausedTasks();
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) HashMap(java.util.HashMap) SchedulerDBManager(org.ow2.proactive.scheduler.core.db.SchedulerDBManager) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) List(java.util.List) JobDescriptorImpl(org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 63 with TaskId

use of org.ow2.proactive.scheduler.common.task.TaskId in project scheduling by ow2-proactive.

the class TaskResultCreatorTest method mockedPausedOrRunningTaskMapWithoutParentTasks.

private Map<TaskId, EligibleTaskDescriptor> mockedPausedOrRunningTaskMapWithoutParentTasks() {
    EligibleTaskDescriptor eligibleTaskDescriptor = this.createEligibleTaskDescriptor(new Vector<TaskDescriptor>());
    Map<TaskId, EligibleTaskDescriptor> mockedMap = mock(HashMap.class);
    when(mockedMap.get(any())).thenReturn(eligibleTaskDescriptor);
    return mockedMap;
}
Also used : TaskDescriptor(org.ow2.proactive.scheduler.common.TaskDescriptor) EligibleTaskDescriptor(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) EligibleTaskDescriptor(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor)

Example 64 with TaskId

use of org.ow2.proactive.scheduler.common.task.TaskId in project scheduling by ow2-proactive.

the class TaskResultCreatorTest method testThatNotFoundTaskResultIsHandled.

@Test
public void testThatNotFoundTaskResultIsHandled() throws UnknownTaskException {
    TaskResultCreator taskResultCreator = new TaskResultCreator();
    TaskResultImpl mockedTaskResultImpl = mock(TaskResultImpl.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());
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) HashMap(java.util.HashMap) SchedulerDBManager(org.ow2.proactive.scheduler.core.db.SchedulerDBManager) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) List(java.util.List) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 65 with TaskId

use of org.ow2.proactive.scheduler.common.task.TaskId in project scheduling by ow2-proactive.

the class TaskResultCreatorTest method createParentTaskDescriptor.

private EligibleTaskDescriptorImpl createParentTaskDescriptor() {
    EligibleTaskDescriptorImpl mockedEligibleTaskDescriptorImpl = mock(EligibleTaskDescriptorImpl.class);
    TaskId parentId = this.createParentTaskID();
    doReturn(parentId).when(mockedEligibleTaskDescriptorImpl).getTaskId();
    return mockedEligibleTaskDescriptorImpl;
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) EligibleTaskDescriptorImpl(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptorImpl)

Aggregations

TaskId (org.ow2.proactive.scheduler.common.task.TaskId)100 Test (org.junit.Test)43 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)43 JobId (org.ow2.proactive.scheduler.common.job.JobId)33 ArrayList (java.util.ArrayList)27 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)25 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)25 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)22 HashMap (java.util.HashMap)18 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)18 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)15 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)13 InternalScriptTask (org.ow2.proactive.scheduler.task.internal.InternalScriptTask)13 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)12 ExecuterInformation (org.ow2.proactive.scheduler.task.internal.ExecuterInformation)12 TaskInfo (org.ow2.proactive.scheduler.common.task.TaskInfo)11 InternalTaskFlowJob (org.ow2.proactive.scheduler.job.InternalTaskFlowJob)11 List (java.util.List)10 TaskDescriptor (org.ow2.proactive.scheduler.common.TaskDescriptor)9 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)9