use of org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState in project scheduling by ow2-proactive.
the class SchedulerStateRecoverHelperTest method testRecoverWithCanceledJobOnly.
@Test
public void testRecoverWithCanceledJobOnly() throws Exception {
InternalJob job = createJob(JobStatus.CANCELED);
changeTasksState(job, TaskStatus.PENDING);
ImmutableMap<String, TaskStatus> tasksStatus = ImmutableMap.of("Ta", TaskStatus.FINISHED, "Tb", TaskStatus.FAILED, "Tc", TaskStatus.NOT_STARTED);
changeTasksState(job, tasksStatus);
RecoveredSchedulerState recoveredState = new Scenario(job).execute();
job = recoveredState.getFinishedJobs().get(0);
assertThat(job.getStatus()).isEqualTo(JobStatus.CANCELED);
assertTasksStatus(job, tasksStatus);
}
use of org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState in project scheduling by ow2-proactive.
the class SchedulerStateRecoverHelperTest method testRecoverWithPausedJobOnlyAllTasksSameStatus.
@Test
public void testRecoverWithPausedJobOnlyAllTasksSameStatus() throws Exception {
InternalJob job = createJob(JobStatus.PAUSED);
changeTasksState(job, TaskStatus.PAUSED);
RecoveredSchedulerState recoveredState = new Scenario(job).execute(false);
job = recoveredState.getPendingJobs().get(0);
assertThat(job.getStatus()).isEqualTo(JobStatus.PAUSED);
assertTasksStatus(job, TaskStatus.PAUSED);
}
use of org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState in project scheduling by ow2-proactive.
the class SchedulerStateRecoverHelperTest method testRecoverWithPendingJobOnly.
@Test
public void testRecoverWithPendingJobOnly() throws Exception {
InternalJob job = createJob(JobStatus.PENDING);
changeTasksState(job, TaskStatus.PENDING);
RecoveredSchedulerState recoveredState = new Scenario(job).execute();
assertTasksStatus(recoveredState.getPendingJobs(), TaskStatus.PENDING);
}
use of org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState in project scheduling by ow2-proactive.
the class SchedulerStateRecoverHelperTest method testRecoverWithCopyAndSortThrowingRuntimeException.
@Test
public void testRecoverWithCopyAndSortThrowingRuntimeException() throws KeyException, JobCreationException {
RecoveredSchedulerState recoveredState = new Scenario(createJob(JobStatus.RUNNING)).execute(new SchedulerStateRecoverHelperSupplier() {
@Override
public SchedulerStateRecoverHelper get(SchedulerDBManager dbManager) {
return new SchedulerStateRecoverHelper(dbManager) {
@Override
protected List<InternalTask> copyAndSort(List<InternalTask> tasks) {
throw new RuntimeException("bouh!");
}
};
}
}, false);
assertThat(recoveredState.getFinishedJobs()).hasSize(1);
assertThat(recoveredState.getPendingJobs()).hasSize(0);
assertThat(recoveredState.getRunningJobs()).hasSize(0);
assertThat(recoveredState.getFinishedJobs().get(0).getStatus()).isEqualTo(JobStatus.CANCELED);
}
use of org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState in project scheduling by ow2-proactive.
the class SchedulerTasksStateRecoverIntegrationTest method testRecover.
@Test
public void testRecover() throws Exception {
SchedulerStateRecoverHelper recoverHelper = new SchedulerStateRecoverHelper(dbManager);
RecoveredSchedulerState state = recoverHelper.recover(-1);
Assert.assertEquals(0, state.getFinishedJobs().size());
Assert.assertEquals(0, state.getRunningJobs().size());
Assert.assertEquals(0, state.getPendingJobs().size());
TaskFlowJob job1 = new TaskFlowJob();
JavaTask task1 = createDefaultTask("task1");
JavaTask task2 = createDefaultTask("task2");
JavaTask task3 = createDefaultTask("task3");
task1.addDependence(task2);
task1.addDependence(task3);
task2.addDependence(task3);
job1.addTask(task1);
job1.addTask(task2);
job1.addTask(task3);
InternalJob job = defaultSubmitJob(job1);
JobStateMatcher expectedJob;
expectedJob = job(job.getId(), JobStatus.PENDING).withPending(task("task1", TaskStatus.SUBMITTED), false).withPending(task("task2", TaskStatus.SUBMITTED), false).withPending(task("task3", TaskStatus.SUBMITTED), false).withEligible("task3");
state = checkRecoveredState(recoverHelper.recover(-1), state().withPending(expectedJob));
job = state.getPendingJobs().get(0);
TaskDescriptor task = job.getJobDescriptor().getEligibleTasks().iterator().next();
Assert.assertEquals(2, task.getChildren().size());
Assert.assertEquals(0, task.getParents().size());
job.terminate();
dbManager.updateAfterTaskFinished(job, null, null);
expectedJob = job(job.getId(), JobStatus.FINISHED).withPending(task("task1", TaskStatus.SUBMITTED), false).withPending(task("task2", TaskStatus.SUBMITTED), false).withPending(task("task3", TaskStatus.SUBMITTED), false).withEligible("task3");
state = checkRecoveredState(recoverHelper.recover(-1), state().withFinished(expectedJob));
job = state.getFinishedJobs().get(0);
task = job.getJobDescriptor().getEligibleTasks().iterator().next();
Assert.assertEquals(2, task.getChildren().size());
Assert.assertEquals(0, task.getParents().size());
}
Aggregations