Search in sources :

Example 86 with InternalJob

use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.

the class SchedulingServiceTest method testScheduleJobRemoveShouldUseHousekeepingButAlreadyRemoved.

@Test
public void testScheduleJobRemoveShouldUseHousekeepingButAlreadyRemoved() {
    Mockito.when(schedulerDBManager.loadJobWithTasksIfNotRemoved(any(JobId.class))).thenReturn(Collections.<InternalJob>emptyList());
    JobId jobId = JobIdImpl.makeJobId("42");
    schedulingService.scheduleJobRemove(jobId, 42);
    Mockito.verify(schedulerDBManager).loadJobWithTasksIfNotRemoved(jobId);
}
Also used : JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 87 with InternalJob

use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.

the class SchedulingServiceTest method testRestartTaskOnNodeFailure.

@Test
public void testRestartTaskOnNodeFailure() {
    InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
    InternalTask task = new InternalScriptTask(job);
    ExecutorService executorService = Mockito.mock(ExecutorService.class);
    Mockito.when(infrastructure.getInternalOperationsThreadPool()).thenReturn(executorService);
    schedulingService.restartTaskOnNodeFailure(task);
    Mockito.verify(executorService, Mockito.times(1)).submit(any(Runnable.class));
}
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) ExecutorService(java.util.concurrent.ExecutorService) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) Test(org.junit.Test)

Example 88 with InternalJob

use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.

the class SchedulingServiceTest method testScheduleJobRemoveShouldUseHousekeeping.

@Test
public void testScheduleJobRemoveShouldUseHousekeeping() {
    JobId jobId = JobIdImpl.makeJobId("42");
    InternalJob mockedInternalJob = createMockedInternalJob(jobId);
    Mockito.when(schedulerDBManager.loadJobWithTasksIfNotRemoved(any(JobId.class))).thenReturn(Collections.singletonList(mockedInternalJob));
    schedulingService.scheduleJobRemove(jobId, 42);
    // second case: the job is not null
    Mockito.verify(schedulerDBManager).loadJobWithTasksIfNotRemoved(jobId);
    Mockito.verify(schedulerDBManager).scheduleJobForRemoval(eq(jobId), eq(42L), anyBoolean());
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 89 with InternalJob

use of org.ow2.proactive.scheduler.job.InternalJob 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 90 with InternalJob

use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.

the class TaskResultCreatorTest method getMockedInternalJobTaskFlowType.

private InternalJob getMockedInternalJobTaskFlowType(JobDescriptorImpl mockedJobDescriptor) {
    InternalJob mockedInternalJob = mock(InternalJob.class);
    when(mockedInternalJob.getJobDescriptor()).thenReturn(mockedJobDescriptor);
    when(mockedInternalJob.getType()).thenReturn(JobType.TASKSFLOW);
    when(mockedInternalJob.getVariables()).thenReturn(new HashMap<String, JobVariable>());
    return mockedInternalJob;
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable)

Aggregations

InternalJob (org.ow2.proactive.scheduler.job.InternalJob)166 Test (org.junit.Test)115 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)90 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)53 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)36 InternalTaskFlowJob (org.ow2.proactive.scheduler.job.InternalTaskFlowJob)34 InternalScriptTask (org.ow2.proactive.scheduler.task.internal.InternalScriptTask)33 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)32 JobId (org.ow2.proactive.scheduler.common.job.JobId)28 ArrayList (java.util.ArrayList)27 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)26 JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)19 RecoveredSchedulerState (org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState)19 Matchers.containsString (org.hamcrest.Matchers.containsString)16 Matchers.anyString (org.mockito.Matchers.anyString)16 ExecuterInformation (org.ow2.proactive.scheduler.task.internal.ExecuterInformation)15 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)13 SchedulerStateRecoverHelper (org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper)12 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)12 HashMap (java.util.HashMap)10