use of org.ow2.proactive.scheduler.core.db.SchedulerDBManager in project scheduling by ow2-proactive.
the class TestInMemorySchedulerDB method sanityTestJobContent.
@Test
public void sanityTestJobContent() throws Exception {
SchedulerDBManager dbManager = SchedulerDBManager.createInMemorySchedulerDBManager();
TaskFlowJob jobDef = new TaskFlowJob();
jobDef.addTask(BaseSchedulerDBTest.createDefaultTask("task1"));
jobDef.addTask(BaseSchedulerDBTest.createDefaultTask("task2"));
jobDef.addTask(BaseSchedulerDBTest.createDefaultTask("task3"));
InternalJob job = InternalJobFactory.createJob(jobDef, BaseSchedulerDBTest.getDefaultCredentials());
job.setOwner("test");
dbManager.newJobSubmitted(job);
Job content = dbManager.loadInitalJobContent(job.getId());
Assert.assertTrue(content instanceof TaskFlowJob);
Assert.assertThat(((TaskFlowJob) content).getTasks().size(), is(3));
}
use of org.ow2.proactive.scheduler.core.db.SchedulerDBManager 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);
}
use of org.ow2.proactive.scheduler.core.db.SchedulerDBManager 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());
}
use of org.ow2.proactive.scheduler.core.db.SchedulerDBManager 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();
}
use of org.ow2.proactive.scheduler.core.db.SchedulerDBManager 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());
}
Aggregations