use of org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl in project scheduling by ow2-proactive.
the class TaskResultCreatorTest method getMockedJobDescriptorWithPausedTaskWithoutParent.
private JobDescriptorImpl getMockedJobDescriptorWithPausedTaskWithoutParent() {
JobDescriptorImpl mockedJobDescriptor = this.getMockedJobDescriptor();
Map fakeMap = this.mockedPausedOrRunningTaskMapWithoutParentTasks();
when(mockedJobDescriptor.getPausedTasks()).thenReturn(fakeMap);
return mockedJobDescriptor;
}
use of org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl 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;
}
use of org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl in project scheduling by ow2-proactive.
the class JobDescriptorImplTest method testThatDoLoopPausesNewlyCreatedTasksIfJobIsPaused.
@Test
public void testThatDoLoopPausesNewlyCreatedTasksIfJobIsPaused() {
JobDescriptorImpl pausedJob = createEmptyJobDescriptor();
pausedJob.getInternal().setStatus(JobStatus.PAUSED);
// Create mocks for the loop root task
TaskId runningRootTaskId = TaskIdImpl.createTaskId(new JobIdImpl(1L, "Root"), "FirstLoopTask", 1L);
EligibleTaskDescriptorImpl mockLoopStartCurrentlyRunningTask = mock(EligibleTaskDescriptorImpl.class);
InternalTask mockInternalLoopRootTask = mock(InternalTask.class);
when(mockInternalLoopRootTask.getId()).thenReturn(runningRootTaskId);
when(mockLoopStartCurrentlyRunningTask.getTaskId()).thenReturn(runningRootTaskId);
when(mockLoopStartCurrentlyRunningTask.getInternal()).thenReturn(mockInternalLoopRootTask);
when(mockLoopStartCurrentlyRunningTask.getChildren()).thenReturn(new Vector<TaskDescriptor>());
// Create mocks for the new loop task
TaskId newLoopTaskId = TaskIdImpl.createTaskId(new JobIdImpl(1L, "Root"), "SecondLoopTask", 2L);
EligibleTaskDescriptorImpl mockLoopNewCreatedTaskForLoop = mock(EligibleTaskDescriptorImpl.class);
InternalTask mockInternalNewLoopTask = mock(InternalTask.class);
TaskInfo mockNewTaskTaskInfo = mock(TaskInfo.class);
when(mockNewTaskTaskInfo.getTaskId()).thenReturn(newLoopTaskId);
when(mockInternalNewLoopTask.getId()).thenReturn(newLoopTaskId);
when(mockInternalNewLoopTask.getStatus()).thenReturn(TaskStatus.SUBMITTED);
when(mockInternalNewLoopTask.getTaskInfo()).thenReturn(mockNewTaskTaskInfo);
when(mockLoopNewCreatedTaskForLoop.getTaskId()).thenReturn(newLoopTaskId);
when(mockLoopNewCreatedTaskForLoop.getInternal()).thenReturn(mockInternalNewLoopTask);
// Put the root loop task into running tasks, because it just terminated
pausedJob.getRunningTasks().put(mockLoopStartCurrentlyRunningTask.getTaskId(), mockLoopStartCurrentlyRunningTask);
// Put the new loop task into the Map, this is clue so that the test works
HashMap<TaskId, InternalTask> workflowTree = new HashMap<>();
workflowTree.put(newLoopTaskId, mockInternalNewLoopTask);
pausedJob.doLoop(mockLoopStartCurrentlyRunningTask.getTaskId(), workflowTree, mockLoopNewCreatedTaskForLoop.getInternal(), mockLoopNewCreatedTaskForLoop.getInternal());
verify(mockInternalNewLoopTask).setStatus(TaskStatus.PAUSED);
}
use of org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl in project scheduling by ow2-proactive.
the class TerminateReplicateTaskHandlerTest method init.
@Before
public void init() {
action = new FlowAction(FlowActionType.REPLICATE);
action.setDupNumber(0);
MockitoAnnotations.initMocks(this);
when(internalJob.getJobInfo()).thenReturn(jobInfoImpl);
when(internalJob.getJobDescriptor()).thenReturn(jobDescriptorImpl);
terminateReplicateTaskHandler = new TerminateReplicateTaskHandler(internalJob);
}
use of org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl in project scheduling by ow2-proactive.
the class DefaultPolicyTest method job_with_different_priorities.
@Test
public void job_with_different_priorities() throws Exception {
JobDescriptorImpl jobHigh = createSingleTaskJob(JobPriority.HIGH);
JobDescriptorImpl jobLow = createSingleTaskJob(JobPriority.LOW);
JobDescriptorImpl jobNormal = createSingleTaskJob(JobPriority.NORMAL);
List<JobDescriptor> jobs = submitJobs(jobHigh, jobLow, jobNormal);
LinkedList<EligibleTaskDescriptor> orderedTasks = new DefaultPolicy().getOrderedTasks(jobs);
assertEquals(jobHigh.getJobId(), orderedTasks.get(0).getJobId());
assertEquals(jobNormal.getJobId(), orderedTasks.get(1).getJobId());
assertEquals(jobLow.getJobId(), orderedTasks.get(2).getJobId());
}
Aggregations