use of org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState in project scheduling by ow2-proactive.
the class SchedulerStateRecoverHelperTest method testRecoverWithFinishedJobsOnly.
@Test
public void testRecoverWithFinishedJobsOnly() throws Exception {
List<InternalJob> jobs = new ArrayList<>(DEFAULT_NUMBER_OF_JOBS);
for (int i = 0; i < DEFAULT_NUMBER_OF_JOBS; i++) {
InternalJob job = createJob(JobStatus.FINISHED);
changeTasksState(job, TaskStatus.FINISHED);
jobs.add(job);
}
RecoveredSchedulerState recoveredState = new Scenario(jobs).execute();
assertTasksStatus(recoveredState.getFinishedJobs(), TaskStatus.FINISHED);
}
use of org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState in project scheduling by ow2-proactive.
the class SchedulerStateRecoverHelperTest method testRecoverWithFailedJobOnly.
@Test
public void testRecoverWithFailedJobOnly() throws Exception {
InternalJob job = createJob(JobStatus.FAILED);
changeTasksState(job, TaskStatus.FAILED);
RecoveredSchedulerState recoveredState = new Scenario(job).execute();
assertThat(recoveredState.getFinishedJobs().get(0).getStatus()).isEqualTo(JobStatus.FAILED);
assertTasksStatus(job, TaskStatus.FAILED);
}
use of org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState in project scheduling by ow2-proactive.
the class SchedulerStateRecoverHelperTest method testRecoverWithPausedJobOnly.
@Test
public void testRecoverWithPausedJobOnly() throws Exception {
InternalJob job = createJob(JobStatus.PAUSED);
changeTasksState(job, TaskStatus.PAUSED);
ImmutableMap<String, TaskStatus> tasksStatus = ImmutableMap.of("Ta", TaskStatus.FINISHED, "Tb", TaskStatus.PAUSED, "Tc", TaskStatus.PENDING);
changeTasksState(job, tasksStatus);
RecoveredSchedulerState recoveredState = new Scenario(job).execute();
job = recoveredState.getRunningJobs().get(0);
assertThat(job.getStatus()).isEqualTo(JobStatus.PAUSED);
assertTasksStatus(job, ImmutableMap.of("Ta", TaskStatus.FINISHED, "Tb", TaskStatus.PAUSED, "Tc", TaskStatus.PAUSED));
}
use of org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState in project scheduling by ow2-proactive.
the class SchedulerStateRecoverHelperTest method testRecoverWithFinishedJobsOnlyFilteredByPeriod.
@Test
public void testRecoverWithFinishedJobsOnlyFilteredByPeriod() throws Exception {
List<InternalJob> jobs = new ArrayList<>(DEFAULT_NUMBER_OF_JOBS);
for (int i = 0; i < DEFAULT_NUMBER_OF_JOBS; i++) {
InternalJob job = createJob(JobStatus.FINISHED);
changeTasksState(job, TaskStatus.FINISHED);
job.setSubmittedTime(i);
jobs.add(job);
}
RecoveredSchedulerState recoveredState = new Scenario(jobs, 3).execute();
assertThat(recoveredState.getFinishedJobs()).hasSize(DEFAULT_NUMBER_OF_JOBS - 3);
assertTasksStatus(recoveredState.getFinishedJobs(), TaskStatus.FINISHED);
}
use of org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState in project scheduling by ow2-proactive.
the class TestLoadSchedulerClientState method testStateAfterTaskFinished.
@Test
public void testStateAfterTaskFinished() throws Exception {
TaskFlowJob jobDef = new TaskFlowJob();
JavaTask taskDef1 = createDefaultTask("task1");
JavaTask taskDef2 = createDefaultTask("task2");
taskDef2.addDependence(taskDef1);
jobDef.addTask(taskDef1);
jobDef.addTask(taskDef2);
InternalJob job = defaultSubmitJobAndLoadInternal(true, jobDef);
InternalTask task1 = job.getTask("task1");
job.start();
startTask(job, task1);
dbManager.jobTaskStarted(job, task1, true);
TaskResultImpl result = new TaskResultImpl(null, new TestResult(1, "res1"), null, 1000);
terminateTask(job, task1, result);
dbManager.updateAfterTaskFinished(job, task1, result);
SchedulerStateRecoverHelper stateRecoverHelper = new SchedulerStateRecoverHelper(dbManager);
RecoveredSchedulerState recovered;
recovered = stateRecoverHelper.recover(-1);
JobStateMatcher expectedJob;
expectedJob = job(job.getId(), JobStatus.STALLED).withFinished(task("task1", TaskStatus.FINISHED).checkFinished()).withPending(task("task2", TaskStatus.PENDING), true).withEligible("task2");
checkRecoveredState(recovered, state().withRunning(expectedJob));
job = recovered.getRunningJobs().get(0);
InternalTask task2 = job.getTask("task2");
startTask(job, task2);
dbManager.jobTaskStarted(job, task2, false);
expectedJob = job(job.getId(), JobStatus.STALLED).withFinished(task("task1", TaskStatus.FINISHED).checkFinished()).withPending(task("task2", TaskStatus.PENDING), true).withEligible("task2");
recovered = stateRecoverHelper.recover(-1);
checkRecoveredState(recovered, state().withRunning(expectedJob));
job = recovered.getRunningJobs().get(0);
task2 = job.getTask("task2");
startTask(job, task2);
dbManager.jobTaskStarted(job, task2, false);
terminateTask(job, task2, result);
dbManager.updateAfterTaskFinished(job, task2, result);
expectedJob = job(job.getId(), JobStatus.FINISHED).withFinished(task("task1", TaskStatus.FINISHED).checkFinished()).withFinished(task("task2", TaskStatus.FINISHED).checkFinished());
recovered = stateRecoverHelper.recover(-1);
checkRecoveredState(recovered, state().withFinished(expectedJob));
}
Aggregations