Search in sources :

Example 36 with JavaTask

use of org.ow2.proactive.scheduler.common.task.JavaTask in project scheduling by ow2-proactive.

the class TestTaskAttributes method testAttributes.

@Test
public void testAttributes() throws Exception {
    JavaTask task = createDefaultTask("task");
    task.setOnTaskError(OnTaskError.CANCEL_JOB);
    task.setDescription("desc");
    // TODO: create test using valid flow
    // task.setFlowBlock(FlowBlock.START);
    task.setMaxNumberOfExecution(7);
    task.setPreciousLogs(true);
    task.setPreciousResult(true);
    task.setRunAsMe(true);
    task.setWallTime(123);
    InternalTask taskData = saveSingleTask(task).getTask(task.getName());
    Assert.assertEquals(OnTaskError.CANCEL_JOB, taskData.getOnTaskErrorProperty().getValue());
    Assert.assertEquals("desc", taskData.getDescription());
    // Assert.assertEquals(FlowBlock.START, taskData.getFlowBlock());
    Assert.assertEquals(7, taskData.getMaxNumberOfExecution());
    Assert.assertEquals("task", taskData.getName());
    Assert.assertEquals(true, taskData.isPreciousLogs());
    Assert.assertEquals(true, taskData.isPreciousResult());
    Assert.assertEquals(true, taskData.isRunAsMe());
    Assert.assertEquals(123, taskData.getWallTime());
}
Also used : InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) Test(org.junit.Test)

Example 37 with JavaTask

use of org.ow2.proactive.scheduler.common.task.JavaTask in project scheduling by ow2-proactive.

the class TestUsageData method createJob.

private TaskFlowJob createJob(String name, String... taskNames) throws Exception {
    TaskFlowJob job = new TaskFlowJob();
    job.setName(name);
    job.setPriority(JobPriority.IDLE);
    for (String taskName : taskNames) {
        JavaTask task = new JavaTask();
        task.setName(taskName);
        task.setExecutableClassName("className");
        job.addTask(task);
    }
    return job;
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask)

Example 38 with JavaTask

use of org.ow2.proactive.scheduler.common.task.JavaTask in project scheduling by ow2-proactive.

the class TestSmartProxy method createTestJob.

protected TaskFlowJob createTestJob(boolean isolateOutputs) throws Exception {
    TaskFlowJob job = new TaskFlowJob();
    job.setName(this.getClass().getSimpleName());
    ForkEnvironment forkEnvironment = new ForkEnvironment();
    forkEnvironment.addAdditionalClasspath(getClasspath(job));
    for (int i = 0; i < NB_TASKS; i++) {
        JavaTask testTask = new JavaTask();
        testTask.setName(TASK_NAME + i);
        testTask.setExecutableClassName(SimpleJavaExecutable.class.getName());
        testTask.setForkEnvironment(forkEnvironment);
        // testTask.
        // ------------- create an input File ------------
        File inputFile = new File(inputLocalFolder, inputFileBaseName + "_" + i + inputFileExt);
        String outputFileName = outputFileBaseName + "_" + i + outputFileExt;
        // delete files after the test is finished
        File outputFile = new File(outputLocalFolder, outputFileName);
        outputFile.deleteOnExit();
        inputFile.deleteOnExit();
        FileWriter fw = new FileWriter(inputFile);
        for (int j = 0; j <= Math.round(Math.random() * 100) + 1; j++) fw.write("Some random input");
        fw.close();
        // Add dummy input files, make sure no error happen
        testTask.addInputFiles("DUMMY", InputAccessMode.TransferFromInputSpace);
        testTask.addInputFiles(inputFile.getName(), InputAccessMode.TransferFromInputSpace);
        if (isolateOutputs) {
            testTask.addOutputFiles("*" + outputFileExt, OutputAccessMode.TransferToOutputSpace);
        } else {
            testTask.addOutputFiles(outputFileName, OutputAccessMode.TransferToOutputSpace);
        }
        job.addTask(testTask);
    }
    job.setInputSpace(dataServerURI);
    job.setOutputSpace(dataServerURI);
    return job;
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) FileWriter(java.io.FileWriter) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment) File(java.io.File)

Example 39 with JavaTask

use of org.ow2.proactive.scheduler.common.task.JavaTask in project scheduling by ow2-proactive.

the class TestKillTaskWhileExecutingScripts method javaTaskKillEndlessPreScript.

public void javaTaskKillEndlessPreScript() throws Throwable {
    log("Test Java Task : killing an Endless PreScript ...");
    String tname = "javaTaskKillEndlessPreScript";
    // pre script interruption
    TaskFlowJob job = new TaskFlowJob();
    job.setName(this.getClass().getSimpleName() + "_" + tname);
    JavaTask task1 = new JavaTask();
    task1.setName(tname);
    task1.setExecutableClassName(EmptyExecutable.class.getName());
    task1.setPreScript(endlessScript);
    job.addTask(task1);
    submitAndCheckJob(job, tname);
}
Also used : EmptyExecutable(functionaltests.executables.EmptyExecutable) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask)

Example 40 with JavaTask

use of org.ow2.proactive.scheduler.common.task.JavaTask in project scheduling by ow2-proactive.

the class TestKillWhenInStoppedState method createPendingJob.

private TaskFlowJob createPendingJob() throws Exception {
    TaskFlowJob job = new TaskFlowJob();
    job.setName("Test pending job");
    job.setOnTaskError(OnTaskError.CONTINUE_JOB_EXECUTION);
    JavaTask javaTask = new JavaTask();
    javaTask.setExecutableClassName(TestJavaTask.class.getName());
    javaTask.setName(TASK_NAME2);
    javaTask.setSelectionScript(new SelectionScript("selected = false;", "JavaScript", false));
    job.addTask(javaTask);
    return job;
}
Also used : SelectionScript(org.ow2.proactive.scripting.SelectionScript) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask)

Aggregations

JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)96 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)92 Test (org.junit.Test)40 ForkEnvironment (org.ow2.proactive.scheduler.common.task.ForkEnvironment)22 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)18 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)17 JobId (org.ow2.proactive.scheduler.common.job.JobId)14 NativeTask (org.ow2.proactive.scheduler.common.task.NativeTask)12 EmptyTask (org.ow2.proactive.scheduler.examples.EmptyTask)11 SelectionScript (org.ow2.proactive.scripting.SelectionScript)10 SimpleScript (org.ow2.proactive.scripting.SimpleScript)10 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)9 File (java.io.File)8 HashMap (java.util.HashMap)7 Task (org.ow2.proactive.scheduler.common.task.Task)7 JobResult (org.ow2.proactive.scheduler.common.job.JobResult)6 EmptyExecutable (functionaltests.executables.EmptyExecutable)5 JobDescriptor (org.ow2.proactive.scheduler.common.JobDescriptor)5 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)5 TaskDescriptor (org.ow2.proactive.scheduler.common.TaskDescriptor)4