use of org.ow2.proactive.scheduler.common.job.factories.Job2XMLTransformer in project scheduling by ow2-proactive.
the class Job2XMLTransformerTest method checkTaskVariables.
@Test
public void checkTaskVariables() throws Exception {
File xmlFile = tmpFolder.newFile();
Map<String, TaskVariable> variablesMap = new HashMap<>();
TaskVariable taskVariable1 = new TaskVariable();
taskVariable1.setName("name1");
taskVariable1.setValue("value1");
taskVariable1.setJobInherited(false);
taskVariable1.setModel("model1");
TaskVariable taskVariable2 = new TaskVariable();
taskVariable2.setName("name2");
taskVariable2.setValue("value2");
taskVariable2.setJobInherited(true);
taskVariable2.setModel("model2");
variablesMap.put(taskVariable1.getName(), taskVariable1);
variablesMap.put(taskVariable2.getName(), taskVariable2);
TaskFlowJob job = new TaskFlowJob();
JavaTask task = new JavaTask();
task.setName("task");
task.setExecutableClassName("oo.Bar");
task.setVariables(variablesMap);
job.addTask(task);
new Job2XMLTransformer().job2xmlFile(job, xmlFile);
TaskFlowJob recreatedJob = (TaskFlowJob) (JobFactory.getFactory().createJob(xmlFile.getAbsolutePath()));
Map<String, TaskVariable> resVariables = recreatedJob.getTask("task").getVariables();
assertEquals(2, resVariables.size());
assertEquals(taskVariable1, resVariables.get("name1"));
assertEquals(taskVariable2, resVariables.get("name2"));
}
use of org.ow2.proactive.scheduler.common.job.factories.Job2XMLTransformer in project scheduling by ow2-proactive.
the class Job2XMLTransformerTest method walltimeIsPreserved.
@Test
public void walltimeIsPreserved() throws Exception {
File xmlFile = tmpFolder.newFile();
String taskName = "walltimeTask";
// tests for various values including one second, one minute, one minute and one second, big value, etc. miliseconds are discarded
long[] walltimesToTest = { 0, 1000, 60000, 61000, 3600000, 3601000, 3660000, 3661000, 999999000 };
for (int i = 1; i < walltimesToTest.length; i++) {
TaskFlowJob job = new TaskFlowJob();
JavaTask task = new JavaTask();
task.setName(taskName);
task.setExecutableClassName("oo.Bar");
task.setWallTime(walltimesToTest[i]);
job.addTask(task);
new Job2XMLTransformer().job2xmlFile(job, xmlFile);
TaskFlowJob recreatedJob = (TaskFlowJob) (JobFactory.getFactory().createJob(xmlFile.getAbsolutePath()));
assertEquals("Walltimes between original and recreated job must be equal", walltimesToTest[i], recreatedJob.getTask(taskName).getWallTime());
}
}
use of org.ow2.proactive.scheduler.common.job.factories.Job2XMLTransformer in project scheduling by ow2-proactive.
the class Job2XMLTransformerTest method forkEnvironmentIsPreserved.
@Test
public void forkEnvironmentIsPreserved() throws Exception {
File xmlFile = tmpFolder.newFile();
TaskFlowJob job = new TaskFlowJob();
JavaTask task = new JavaTask();
task.setName("forkedTask");
task.setExecutableClassName("oo.Bar");
task.setForkEnvironment(new ForkEnvironment());
job.addTask(task);
new Job2XMLTransformer().job2xmlFile(job, xmlFile);
TaskFlowJob recreatedJob = (TaskFlowJob) (JobFactory.getFactory().createJob(xmlFile.getAbsolutePath()));
assertNotNull(recreatedJob.getTask("forkedTask").getForkEnvironment());
}
use of org.ow2.proactive.scheduler.common.job.factories.Job2XMLTransformer in project scheduling by ow2-proactive.
the class Job2XMLTransformerTest method checkIfOnTaskErrorIsInJobInXML.
private void checkIfOnTaskErrorIsInJobInXML(OnTaskError jobOnTaskErrorSetting) throws TransformerException, ParserConfigurationException, IOException {
TaskFlowJob jobWithCancelJobOnErrorTrue = new TaskFlowJob();
jobWithCancelJobOnErrorTrue.setOnTaskError(jobOnTaskErrorSetting);
// Check that onTaskError is inside the <job [here] > xml tag
assertThat("XML must contain onTaskError=\\\"" + jobOnTaskErrorSetting.toString() + "\\\"", new Job2XMLTransformer().jobToxmlString(jobWithCancelJobOnErrorTrue), org.hamcrest.Matchers.matchesPattern(matchEvery + matchJobTagOpening + notMatchSmallerSign + matchOnTaskErrorEquals(jobOnTaskErrorSetting) + matchEvery + matchSmallerSign + matchEvery));
}
use of org.ow2.proactive.scheduler.common.job.factories.Job2XMLTransformer in project scheduling by ow2-proactive.
the class Job2XMLTransformerTest method checkIfOnTaskErrorIsInJobAndTaskInXML.
private void checkIfOnTaskErrorIsInJobAndTaskInXML(OnTaskError jobOnTaskErrorSetting, OnTaskError taskOnTaskErrorSetting) throws UserException, TransformerException, ParserConfigurationException, IOException {
String taskName = "taskName";
TaskFlowJob jobWithCancelJobOnErrorTrue = new TaskFlowJob();
jobWithCancelJobOnErrorTrue.setOnTaskError(jobOnTaskErrorSetting);
JavaTask task = new JavaTask();
task.setName(taskName);
task.setExecutableClassName("oo.Bar");
task.setOnTaskError(taskOnTaskErrorSetting);
jobWithCancelJobOnErrorTrue.addTask(task);
// Check that onTaskError is inside the <job [here] > xml tag
assertThat("XML must contain onTaskError=\\\"" + jobOnTaskErrorSetting.toString() + "\\\"", new Job2XMLTransformer().jobToxmlString(jobWithCancelJobOnErrorTrue), org.hamcrest.Matchers.matchesPattern(matchEvery + matchJobTagOpening + notMatchSmallerSign + matchOnTaskErrorEquals(jobOnTaskErrorSetting) + matchEvery + matchSmallerSign + matchEvery));
// Check that onTaskError is inside the <task [here] > xml tag
assertThat("XML must contain onTaskError=\\\"" + taskOnTaskErrorSetting.toString() + "\\\"", new Job2XMLTransformer().jobToxmlString(jobWithCancelJobOnErrorTrue), org.hamcrest.Matchers.matchesPattern(matchEvery + matchTaskTagOpening + notMatchSmallerSign + matchOnTaskErrorEquals(taskOnTaskErrorSetting) + matchEvery + matchSmallerSign + matchEvery));
}
Aggregations