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 BaseSchedulerDBTest method initTest.
@Before
public void initTest() throws Exception {
if (System.getProperty("pa.scheduler.home") == null) {
PASchedulerProperties.SCHEDULER_HOME.updateProperty(ClasspathUtils.findSchedulerHome());
}
System.out.println("Scheduler home : " + PASchedulerProperties.SCHEDULER_HOME.getValueAsString());
PASchedulerProperties.TASK_FORK.updateProperty("true");
CentralPAPropertyRepository.PA_CLASSLOADING_USEHTTP.setValue(false);
if (inMemory) {
dbManager = SchedulerDBManager.createInMemorySchedulerDBManager();
} else {
Configuration config = new Configuration().configure(new File(this.getClass().getResource("/functionaltests/config/hibernate-unit.cfg.xml").toURI()));
dbManager = new SchedulerDBManager(config, true);
}
}
use of org.ow2.proactive.scheduler.core.db.SchedulerDBManager 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.SchedulerDBManager in project scheduling by ow2-proactive.
the class TestInMemorySchedulerDB method sanityLastUpdatedTimeTest.
@Test
public void sanityLastUpdatedTimeTest() throws Exception {
SchedulerDBManager dbManager = SchedulerDBManager.createInMemorySchedulerDBManager();
TaskFlowJob jobDef = new TaskFlowJob();
jobDef.addTask(BaseSchedulerDBTest.createDefaultTask("task1"));
InternalJob job = InternalJobFactory.createJob(jobDef, BaseSchedulerDBTest.getDefaultCredentials());
job.setOwner("test");
dbManager.newJobSubmitted(job);
List<InternalJob> jobs = dbManager.loadJobs(false, job.getId());
// when job is submitted, the last updated time is initialized as submitted time
Assert.assertThat(jobs.size(), is(1));
Assert.assertThat(jobs.get(0).getJobInfo().getLastUpdatedTime(), is(jobs.get(0).getJobInfo().getSubmittedTime()));
dbManager.changeJobPriority(job.getId(), JobPriority.HIGH);
jobs = dbManager.loadJobs(false, job.getId());
// job's priority was changed, the last update time must be greater than submitted time
long priorityChangedTime = jobs.get(0).getJobInfo().getLastUpdatedTime();
Assert.assertThat(priorityChangedTime - jobs.get(0).getJobInfo().getSubmittedTime() > 0, is(true));
dbManager.jobSetToBeRemoved(job.getId());
jobs = dbManager.loadJobs(false, job.getId());
// job's state was changed, the last update time must be greater than submitted time
Assert.assertThat(jobs.get(0).getJobInfo().getLastUpdatedTime() - priorityChangedTime > 0, is(true));
}
use of org.ow2.proactive.scheduler.core.db.SchedulerDBManager in project scheduling by ow2-proactive.
the class TestInMemorySchedulerDB method sanityTest.
@Test
public void sanityTest() 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);
dbManager.readAccount("test");
dbManager.changeJobPriority(job.getId(), JobPriority.HIGH);
Assert.assertEquals(1, dbManager.loadNotFinishedJobs(true).size());
}
Aggregations