use of org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper in project scheduling by ow2-proactive.
the class TestRestoreWorkflowJobs method finishedJobWithScriptsCanBeRecoveredAndLoaded.
@Test
public void finishedJobWithScriptsCanBeRecoveredAndLoaded() throws Exception {
InternalJob job = defaultSubmitJobAndLoadInternal(true, createJobWithAllKindOfScripts());
job.start();
InternalTask mainTask = job.getTask("T");
startTask(job, mainTask);
dbManager.jobTaskStarted(job, mainTask, true);
TaskResultImpl result = new TaskResultImpl(mainTask.getId(), "ok", null, 0);
ChangedTasksInfo changesInfo = job.terminateTask(false, mainTask.getId(), null, null, result);
job.setStatus(JobStatus.FINISHED);
dbManager.updateAfterWorkflowTaskFinished(job, changesInfo, result);
SchedulerStateRecoverHelper recoverHelper = new SchedulerStateRecoverHelper(dbManager);
JobStateMatcher expectedJob = job(job.getId(), JobStatus.FINISHED).withFinished(task("T", TaskStatus.FINISHED).checkFinished(), true);
checkRecoveredState(recoverHelper.recover(-1), state().withFinished(expectedJob));
List<InternalJob> finishedJobs = dbManager.loadFinishedJobs(true, -1);
assertEquals(1, finishedJobs.size());
}
use of org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper in project scheduling by ow2-proactive.
the class TestSetJobToBeRemoved method test.
@Test
public void test() throws Exception {
InternalJob job = defaultSubmitJobAndLoadInternal(false, new TaskFlowJob());
Assert.assertFalse(job.isToBeRemoved());
job.setToBeRemoved();
System.out.println("Set job to be removed");
dbManager.jobSetToBeRemoved(job.getId());
SchedulerStateRecoverHelper recoverHelper = new SchedulerStateRecoverHelper(dbManager);
Collection<InternalJob> jobs = recoverHelper.recover(-1).getPendingJobs();
Assert.assertEquals(1, jobs.size());
job = jobs.iterator().next();
Assert.assertTrue(job.isToBeRemoved());
}
use of org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper in project scheduling by ow2-proactive.
the class TestTaskIdGeneration method test.
@Test
public void test() throws Exception {
TaskFlowJob jobDef = new TaskFlowJob();
jobDef.addTask(createDefaultTask("task1"));
jobDef.addTask(createDefaultTask("task2"));
jobDef.addTask(createDefaultTask("task3"));
InternalJob job = InternalJobFactory.createJob(jobDef, getDefaultCredentials());
job.setOwner(DEFAULT_USER_NAME);
dbManager.newJobSubmitted(job);
for (InternalTask task : job.getITasks()) {
Assert.assertSame(task, job.getIHMTasks().get(task.getId()));
}
for (TaskDescriptor task : job.getJobDescriptor().getEligibleTasks()) {
Assert.assertNotNull(job.getIHMTasks().get(task.getTaskId()));
}
checkIds(job);
SchedulerStateRecoverHelper recoverHelper = new SchedulerStateRecoverHelper(dbManager);
RecoveredSchedulerState state = recoverHelper.recover(-1);
Collection<InternalJob> jobs = state.getPendingJobs();
Assert.assertEquals(1, jobs.size());
job = jobs.iterator().next();
checkIds(job);
JobState jobState = state.getSchedulerState().getPendingJobs().iterator().next();
checkIds(jobState);
}
use of org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper in project scheduling by ow2-proactive.
the class SchedulerStateRecoverHelperTest method testRecoverWithIncorrectStatusForLoadedNotFinishedJobs.
public void testRecoverWithIncorrectStatusForLoadedNotFinishedJobs(JobStatus jobStatus) {
InternalJob job = new InternalTaskFlowJob();
job.setStatus(jobStatus);
SchedulerDBManager dbManager = Mockito.mock(SchedulerDBManager.class);
SchedulerStateRecoverHelper stateRecoverHelper = new SchedulerStateRecoverHelper(dbManager);
Mockito.when(dbManager.loadNotFinishedJobs(true)).thenReturn(ImmutableList.of(job));
stateRecoverHelper.recover(-1);
}
Aggregations