use of org.ow2.proactive.scheduler.job.InternalJob 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.job.InternalJob 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());
}
use of org.ow2.proactive.scheduler.job.InternalJob 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.job.InternalJob in project scheduling by ow2-proactive.
the class TestJobAttributes method testJobVariables.
@Test
public void testJobVariables() throws Exception {
TaskFlowJob job = new TaskFlowJob();
InternalJob jobData;
HashMap<String, JobVariable> jobVariables = new HashMap<>();
job.setVariables(jobVariables);
jobData = defaultSubmitJobAndLoadInternal(false, job);
Assert.assertNotNull(jobData.getVariables());
Assert.assertTrue(jobData.getVariables().isEmpty());
jobVariables.put("var1", new JobVariable("var1", "value1", null));
jobVariables.put("var2", new JobVariable("var2", "value2", null));
job.setVariables(jobVariables);
jobVariables = new HashMap<>();
jobVariables.put("var1", new JobVariable("var1", "value1", null));
jobVariables.put("var2", new JobVariable("var2", "value2", null));
job.setVariables(jobVariables);
jobData = defaultSubmitJobAndLoadInternal(false, job);
Assert.assertEquals(2, jobData.getVariables().size());
Assert.assertEquals("value1", jobData.getVariables().get("var1").getValue());
Assert.assertEquals("value2", jobData.getVariables().get("var2").getValue());
StringBuilder longString = new StringBuilder();
for (int i = 0; i < 100; i++) {
longString.append("0123456789abcdefghijklmnopqrstuvwxyz");
}
jobVariables = new HashMap<>();
jobVariables.put("longProperty", new JobVariable("longProperty", longString.toString()));
job.setVariables(jobVariables);
jobData = defaultSubmitJobAndLoadInternal(false, job);
Assert.assertEquals(1, jobData.getVariables().size());
Assert.assertEquals(longString.toString(), jobData.getVariables().get("longProperty").getValue());
}
use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.
the class TestJobAttributes method testLargeStringValues.
@Test
public void testLargeStringValues() throws Exception {
String description = createString(500);
TaskFlowJob jobDef = new TaskFlowJob();
jobDef.setDescription(description);
InternalJob job = defaultSubmitJobAndLoadInternal(false, jobDef);
Assert.assertEquals(description, job.getDescription());
}
Aggregations