Search in sources :

Example 66 with Job

use of org.ow2.proactive.scheduler.common.job.Job 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 67 with Job

use of org.ow2.proactive.scheduler.common.job.Job 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 68 with Job

use of org.ow2.proactive.scheduler.common.job.Job 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 69 with Job

use of org.ow2.proactive.scheduler.common.job.Job 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 70 with Job

use of org.ow2.proactive.scheduler.common.job.Job in project scheduling by ow2-proactive.

the class ScriptUpdateUtil method resolveScripts.

/**
 * Filters the scripts in the specified job.
 */
public static TaskFlowJob resolveScripts(TaskFlowJob job) {
    ArrayList<Task> tasks = job.getTasks();
    for (Task task : tasks) {
        Map<String, String> variables = task.getVariablesOverriden(job);
        List<SelectionScript> selectionScripts = task.getSelectionScripts();
        if (selectionScripts != null) {
            for (SelectionScript sscript : selectionScripts) {
                resolveScript(sscript, variables);
            }
        }
        resolveScript(task.getFlowScript(), variables);
        resolveScript(task.getPreScript(), variables);
        resolveScript(task.getPostScript(), variables);
        resolveScript(task.getCleaningScript(), variables);
    }
    return job;
}
Also used : Task(org.ow2.proactive.scheduler.common.task.Task) SelectionScript(org.ow2.proactive.scripting.SelectionScript)

Aggregations

Test (org.junit.Test)260 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)198 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)145 JobId (org.ow2.proactive.scheduler.common.job.JobId)122 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)91 JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)87 File (java.io.File)76 SimpleScript (org.ow2.proactive.scripting.SimpleScript)70 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)68 TaskScript (org.ow2.proactive.scripting.TaskScript)65 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)64 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)58 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)52 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)48 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)48 ArrayList (java.util.ArrayList)46 JobState (org.ow2.proactive.scheduler.common.job.JobState)45 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)45 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)41 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)39