use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.
the class TestJobAttributes method testGenericInformation.
@Test
public void testGenericInformation() throws Exception {
TaskFlowJob job = new TaskFlowJob();
Map<String, String> genericInfo;
InternalJob jobData;
genericInfo = new HashMap<>();
job.setGenericInformation(genericInfo);
jobData = defaultSubmitJobAndLoadInternal(false, job);
Assert.assertNotNull(jobData.getGenericInformation());
Assert.assertTrue(jobData.getGenericInformation().isEmpty());
genericInfo = new HashMap<>();
genericInfo.put("p1", "v1");
genericInfo.put("p2", "v2");
job.setGenericInformation(genericInfo);
jobData = defaultSubmitJobAndLoadInternal(false, job);
Assert.assertEquals(2, jobData.getGenericInformation().size());
Assert.assertEquals("v1", jobData.getGenericInformation().get("p1"));
Assert.assertEquals("v2", jobData.getGenericInformation().get("p2"));
StringBuilder longString = new StringBuilder();
for (int i = 0; i < 100; i++) {
longString.append("0123456789abcdefghijklmnopqrstuvwxyz");
}
genericInfo = new HashMap<>();
genericInfo.put("longProperty", longString.toString());
job.setGenericInformation(genericInfo);
jobData = defaultSubmitJobAndLoadInternal(false, job);
Assert.assertEquals(1, jobData.getGenericInformation().size());
Assert.assertEquals(longString.toString(), jobData.getGenericInformation().get("longProperty"));
}
use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.
the class TestJobAttributes method testJobAttribute.
@Test
public void testJobAttribute() throws Exception {
TaskFlowJob job = new TaskFlowJob();
job.setMaxNumberOfExecution(10);
job.setOnTaskError(OnTaskError.CANCEL_JOB);
job.setDescription("desc");
job.setProjectName("project");
job.setName("name");
job.setInputSpace("input");
job.setOutputSpace("output");
job.setGenericInformation(null);
job.setPriority(JobPriority.HIGHEST);
InternalJob jobData = defaultSubmitJob(job, DEFAULT_USER_NAME);
Assert.assertNotNull(jobData.getId());
Assert.assertEquals("name", jobData.getId().getReadableName());
jobData = loadInternalJob(true, jobData.getId());
Assert.assertNotNull(jobData.getId());
Assert.assertEquals("name", jobData.getId().getReadableName());
Assert.assertEquals(10, jobData.getMaxNumberOfExecution());
Assert.assertEquals(OnTaskError.CANCEL_JOB, jobData.getOnTaskErrorProperty().getValue());
Assert.assertEquals("name", jobData.getName());
Assert.assertEquals("desc", jobData.getDescription());
Assert.assertEquals("project", jobData.getProjectName());
Assert.assertEquals("input", jobData.getInputSpace());
Assert.assertEquals("output", jobData.getOutputSpace());
Assert.assertEquals(JobPriority.HIGHEST, jobData.getPriority());
Assert.assertNotNull(jobData.getGenericInformation());
Assert.assertTrue(jobData.getGenericInformation().isEmpty());
Map<String, JobVariable> jobDataVariables = jobData.getVariables();
Assert.assertNotNull(jobDataVariables);
Assert.assertTrue(jobDataVariables.isEmpty());
}
use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.
the class TestJobAttributes method testJobIdGeneration.
@Test
public void testJobIdGeneration() throws Exception {
// test job ids are sequential
for (int i = 0; i < 5; i++) {
TaskFlowJob jobDef = new TaskFlowJob();
for (int j = 0; j < 10; j++) {
jobDef.addTask(createDefaultTask("task" + j));
}
InternalJob job = defaultSubmitJob(jobDef);
Assert.assertEquals(String.valueOf(i + 1), job.getId().value());
}
}
use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.
the class TestJobOperations method testSetToBeRemoved.
@Test
public void testSetToBeRemoved() 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());
job = recoverJob();
Assert.assertTrue(job.isToBeRemoved());
}
use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.
the class TestJobOperations method recoverJob.
private InternalJob recoverJob() {
SchedulerStateRecoverHelper recoverHelper = new SchedulerStateRecoverHelper(dbManager);
Collection<InternalJob> jobs = recoverHelper.recover(-1).getPendingJobs();
Assert.assertEquals(1, jobs.size());
return jobs.iterator().next();
}
Aggregations