Search in sources :

Example 31 with NativeTask

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

the class TestTaskAttributes method testEmptyAttributes.

@Test
public void testEmptyAttributes() throws Exception {
    JavaTask javaTask = createDefaultTask("task1");
    InternalTask taskData = saveSingleTask(javaTask).getTask("task1");
    Assert.assertNotNull(taskData.getId());
    NativeTask nativeTask = new NativeTask();
    nativeTask.setName("task1");
    nativeTask.setCommandLine("commandline");
    taskData = saveSingleTask(nativeTask).getTask("task1");
    Assert.assertNotNull(taskData.getId());
}
Also used : InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) Test(org.junit.Test)

Example 32 with NativeTask

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

the class TestTaskRuntimeData method testTaskTypes.

@Test
public void testTaskTypes() throws Exception {
    TaskFlowJob jobDef = new TaskFlowJob();
    JavaTask taskDef1 = createDefaultTask("task1");
    jobDef.addTask(taskDef1);
    JavaTask taskDef2 = createDefaultTask("task2");
    taskDef2.setForkEnvironment(new ForkEnvironment());
    jobDef.addTask(taskDef2);
    NativeTask taskDef3 = new NativeTask();
    taskDef3.setName("task3");
    taskDef3.setCommandLine("commandline");
    jobDef.addTask(taskDef3);
    InternalJob job = defaultSubmitJobAndLoadInternal(false, jobDef);
    // by default all tasks are executed in a forked JVM
    for (int i = 1; i <= 3; i++) {
        Assert.assertEquals(InternalForkedScriptTask.class, job.getTask("task" + i).getClass());
    }
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) NativeTask(org.ow2.proactive.scheduler.common.task.NativeTask) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment) Test(org.junit.Test)

Example 33 with NativeTask

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

the class TestErrorAndFailure method testErrorAndFailure.

@Test
public void testErrorAndFailure() throws Throwable {
    String javaCmd = System.getProperty("java.home") + "/bin/java";
    log("Test 1 : Creating job...");
    // creating job
    TaskFlowJob submittedJob = new TaskFlowJob();
    submittedJob.setName(this.getClass().getSimpleName() + "_12_tasks");
    submittedJob.setDescription("12 tasks job testing the behavior of error code and normal task ending.");
    submittedJob.setMaxNumberOfExecution(10);
    NativeTask finalTask = new NativeTask();
    finalTask.setName("TestMerge");
    finalTask.setCommandLine(new String[] { javaCmd, "-cp", TestScheduler.testClasspath(), NativeTestWithRandomDefault.class.getName(), "final" });
    for (int i = 1; i < 6; i++) {
        NativeTask task = new NativeTask();
        task.setName("Test" + i);
        task.setCommandLine(new String[] { javaCmd, "-cp", TestScheduler.testClasspath(), NativeTestWithRandomDefault.class.getName(), "0" });
        finalTask.addDependence(task);
        submittedJob.addTask(task);
    }
    submittedJob.addTask(finalTask);
    // test submission and event reception
    JobId id = schedulerHelper.submitJob(submittedJob);
    log("Job submitted, id " + id.toString());
    log("Waiting for jobSubmitted Event");
    Job receivedJob = schedulerHelper.waitForEventJobSubmitted(id);
    assertEquals(receivedJob.getId(), id);
    log("Waiting for job running");
    JobInfo jInfo = schedulerHelper.waitForEventJobRunning(id);
    assertEquals(jInfo.getJobId(), id);
    // TODO how to check that ?
    for (Task t : submittedJob.getTasks()) {
        log("Waiting for task running : " + t.getName());
        schedulerHelper.waitForEventTaskRunning(id, t.getName());
    }
    for (Task t : submittedJob.getTasks()) {
        log("Waiting for task finished : " + t.getName());
        schedulerHelper.waitForEventTaskFinished(id, t.getName());
    }
    log("Waiting for job finished");
    jInfo = schedulerHelper.waitForEventJobFinished(id);
    assertEquals(JobStatus.FINISHED, jInfo.getStatus());
    // check job results
    JobResult res = schedulerHelper.getJobResult(id);
    // Check the results
    Map<String, TaskResult> results = res.getAllResults();
    // check that number of results correspond to number of tasks
    assertEquals(submittedJob.getTasks().size(), results.size());
    // remove jobs and check its event
    schedulerHelper.removeJob(id);
    log("Waiting for job removed");
    jInfo = schedulerHelper.waitForEventJobRemoved(id);
    assertEquals(JobStatus.FINISHED, jInfo.getStatus());
    assertEquals(jInfo.getJobId(), id);
}
Also used : Task(org.ow2.proactive.scheduler.common.task.Task) NativeTask(org.ow2.proactive.scheduler.common.task.NativeTask) NativeTestWithRandomDefault(org.ow2.proactive.scheduler.examples.NativeTestWithRandomDefault) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) NativeTask(org.ow2.proactive.scheduler.common.task.NativeTask) Test(org.junit.Test)

Aggregations

NativeTask (org.ow2.proactive.scheduler.common.task.NativeTask)23 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)21 JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)12 Test (org.junit.Test)11 File (java.io.File)10 JobId (org.ow2.proactive.scheduler.common.job.JobId)9 ForkEnvironment (org.ow2.proactive.scheduler.common.task.ForkEnvironment)8 ArrayList (java.util.ArrayList)6 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)6 JobResult (org.ow2.proactive.scheduler.common.job.JobResult)6 Task (org.ow2.proactive.scheduler.common.task.Task)6 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)6 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)5 ScriptTask (org.ow2.proactive.scheduler.common.task.ScriptTask)4 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)4 FileNotFoundException (java.io.FileNotFoundException)3 XMLStreamException (javax.xml.stream.XMLStreamException)3 VerifierConfigurationException (org.iso_relax.verifier.VerifierConfigurationException)3 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)3 JobValidationException (org.ow2.proactive.scheduler.common.exception.JobValidationException)3