Search in sources :

Example 1 with Job2XMLTransformer

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"));
}
Also used : HashMap(java.util.HashMap) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) TaskVariable(org.ow2.proactive.scheduler.common.task.TaskVariable) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) File(java.io.File) Test(org.junit.Test)

Example 2 with Job2XMLTransformer

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());
    }
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) File(java.io.File) Test(org.junit.Test)

Example 3 with Job2XMLTransformer

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());
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment) File(java.io.File) Test(org.junit.Test)

Example 4 with Job2XMLTransformer

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));
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob)

Example 5 with Job2XMLTransformer

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));
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask)

Aggregations

TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)7 File (java.io.File)5 Test (org.junit.Test)4 JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)4 Job2XMLTransformer (org.ow2.proactive.scheduler.common.job.factories.Job2XMLTransformer)3 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URISyntaxException (java.net.URISyntaxException)1 KeyException (java.security.KeyException)1 HashMap (java.util.HashMap)1 TimeoutException (java.util.concurrent.TimeoutException)1 JobAlreadyFinishedException (org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException)1 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)1 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)1 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)1 SubmissionClosedException (org.ow2.proactive.scheduler.common.exception.SubmissionClosedException)1 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)1 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)1 JobComparator (org.ow2.proactive.scheduler.common.job.factories.JobComparator)1