Search in sources :

Example 86 with InternalTask

use of org.ow2.proactive.scheduler.task.internal.InternalTask in project scheduling by ow2-proactive.

the class SchedulingServiceTest method testCannotRestartTaskOnNodeFailure.

@Test
public void testCannotRestartTaskOnNodeFailure() {
    InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
    schedulingService.status = schedulingService.status.KILLED;
    InternalTask task = new InternalScriptTask(job);
    schedulingService.restartTaskOnNodeFailure(task);
    Mockito.verify(infrastructure, Mockito.times(0)).getInternalOperationsThreadPool();
}
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) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) Test(org.junit.Test)

Example 87 with InternalTask

use of org.ow2.proactive.scheduler.task.internal.InternalTask in project scheduling by ow2-proactive.

the class TerminationDataTest method testAddTaskData.

@Test
public void testAddTaskData() {
    assertThat(terminationData.isEmpty(), is(true));
    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, null);
    terminationData.addTaskData(null, taskData, TerminationData.TerminationStatus.NORMAL, null);
    assertThat(terminationData.isEmpty(), is(false));
    assertThat(terminationData.taskTerminated(jobId, "task-name"), 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) 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 88 with InternalTask

use of org.ow2.proactive.scheduler.task.internal.InternalTask in project scheduling by ow2-proactive.

the class TerminationDataTest method testHandleTerminationForTaskNormalTermination.

@Test
public void testHandleTerminationForTaskNormalTermination() throws RMProxyCreationException, 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.NORMAL, null);
    terminationData.handleTermination(service);
    Mockito.verify(proxiesManager, Mockito.times(1)).getUserRMProxy("user", null);
    Mockito.verify(rmProxy, Mockito.times(1)).releaseNodes(org.mockito.Matchers.any(NodeSet.class), org.mockito.Matchers.any(org.ow2.proactive.scripting.Script.class), Mockito.any(VariablesMap.class), Mockito.any(HashMap.class), Mockito.any(TaskId.class), Mockito.any(Credentials.class));
}
Also used : ExecuterInformation(org.ow2.proactive.scheduler.task.internal.ExecuterInformation) NodeSet(org.ow2.proactive.utils.NodeSet) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) HashMap(java.util.HashMap) InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) VariablesMap(org.ow2.proactive.scheduler.task.utils.VariablesMap) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) JobId(org.ow2.proactive.scheduler.common.job.JobId) Credentials(org.ow2.proactive.authentication.crypto.Credentials) Test(org.junit.Test)

Example 89 with InternalTask

use of org.ow2.proactive.scheduler.task.internal.InternalTask in project scheduling by ow2-proactive.

the class TerminationDataTest method testHandleTerminationForTaskAbortedTermination.

@Test
public void testHandleTerminationForTaskAbortedTermination() 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.ABORTED, null);
    terminationData.handleTermination(service);
    Mockito.verify(launcher, Mockito.times(1)).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 90 with InternalTask

use of org.ow2.proactive.scheduler.task.internal.InternalTask in project scheduling by ow2-proactive.

the class TaskResultCreatorTest method testThatGetEmptyTaskResultWithTaskIdAndExecutionTimeSetsCorrectTime.

@Test
public void testThatGetEmptyTaskResultWithTaskIdAndExecutionTimeSetsCorrectTime() {
    TaskResultCreator taskResultCreator = new TaskResultCreator();
    InternalTask mockedInternalTask = mock(InternalTask.class);
    when(mockedInternalTask.getStartTime()).thenReturn(System.currentTimeMillis() - 1);
    TaskResultImpl taskResult = taskResultCreator.getEmptyTaskResult(mockedInternalTask, null, null);
    // Between 1 millisecond and 1 second.
    assertThat(taskResult.getTaskDuration(), Matchers.greaterThan(0L));
    assertThat(taskResult.getTaskDuration(), Matchers.lessThan(1000L));
}
Also used : TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) Test(org.junit.Test)

Aggregations

InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)142 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)74 Test (org.junit.Test)72 InternalScriptTask (org.ow2.proactive.scheduler.task.internal.InternalScriptTask)39 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)37 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)32 InternalTaskFlowJob (org.ow2.proactive.scheduler.job.InternalTaskFlowJob)31 ArrayList (java.util.ArrayList)30 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)25 JobId (org.ow2.proactive.scheduler.common.job.JobId)22 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)18 ExecuterInformation (org.ow2.proactive.scheduler.task.internal.ExecuterInformation)16 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)13 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)12 HashMap (java.util.HashMap)10 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)10 ProActiveTest (org.ow2.tests.ProActiveTest)10 TaskInfo (org.ow2.proactive.scheduler.common.task.TaskInfo)9 HashSet (java.util.HashSet)8 SchedulerStateRecoverHelper (org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper)8