Search in sources :

Example 11 with JobResult

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

the class TestKilledJobResult method printResult.

private void printResult(JobResult jobResult) throws Throwable {
    for (TaskResult taskResult : jobResult.getAllResults().values()) {
        log("Task result for " + taskResult.getTaskId() + " " + taskResult.getTaskId().getReadableName());
        if (taskResult.getException() != null) {
            log("Task exception:");
            taskResult.getException().printStackTrace(System.out);
        } else {
            log("Task output:");
            log(taskResult.getOutput().getAllLogs(false));
            log("Task result value: " + taskResult.value());
        }
    }
}
Also used : TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult)

Example 12 with JobResult

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

the class TestOperationsWhenUnlinked method checkJobResult.

private void checkJobResult(Scheduler scheduler, JobId jobId, int expectedTasksNumber) throws Throwable {
    JobResult jobResult = scheduler.getJobResult(jobId);
    assertEquals("Unexpected number of task results", expectedTasksNumber, jobResult.getAllResults().size());
    for (TaskResult taskResult : jobResult.getAllResults().values()) {
        log("Task " + taskResult.getTaskId());
        if (taskResult.getException() != null) {
            fail("Unexpected task result exception:" + taskResult.getException());
        }
        assertEquals(taskResult.value(), "Nothing");
    }
}
Also used : JobResult(org.ow2.proactive.scheduler.common.job.JobResult) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult)

Example 13 with JobResult

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

the class TestScriptEngines method testScriptEnginesWithGivenWorkflow.

private void testScriptEnginesWithGivenWorkflow(URL workflow, int numberOfTasks) throws Throwable {
    log("Testing submission of job descriptor : " + workflow);
    JobId id = schedulerHelper.testJobSubmission(new File(workflow.toURI()).getAbsolutePath());
    // check result are not null
    JobResult res = schedulerHelper.getJobResult(id);
    assertFalse("Had Exception : " + workflow.toString(), schedulerHelper.getJobResult(id).hadException());
    Assert.assertEquals(numberOfTasks, res.getAllResults().size());
    for (Map.Entry<String, TaskResult> entry : res.getAllResults().entrySet()) {
        assertFalse("Had Exception : " + entry.getKey(), entry.getValue().hadException());
        assertNotNull("Result not null : " + entry.getKey(), entry.getValue().value());
        assertTrue("Hello World in Output : " + entry.getKey(), entry.getValue().getOutput().getAllLogs(false).contains("Hello World"));
    }
    schedulerHelper.removeJob(id);
    schedulerHelper.waitForEventJobRemoved(id);
}
Also used : JobResult(org.ow2.proactive.scheduler.common.job.JobResult) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) File(java.io.File) Map(java.util.Map) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 14 with JobResult

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

the class TestScriptTask method forkedTasks.

private void forkedTasks() throws Throwable {
    TaskFlowJob job = (TaskFlowJob) StaxJobFactory.getFactory().createJob(new File(jobDescriptor.toURI()).getAbsolutePath());
    JobId id = schedulerHelper.submitJob(job);
    schedulerHelper.waitForEventJobFinished(id);
    JobResult jobResult = schedulerHelper.getJobResult(id);
    // Hello Work script task
    TaskResult simpleTaskResult = jobResult.getResult("simple");
    assertEquals(true, simpleTaskResult.value());
    assertTrue(simpleTaskResult.getOutput().getAllLogs(false).contains("hello"));
    // return binding should be used as task result
    TaskResult returnTaskResult = jobResult.getResult("return");
    assertEquals("42", returnTaskResult.value().toString());
    // results binding should be avaible in dependent tasks
    TaskResult resultFromDependentTaskTaskResult = jobResult.getResult("results_from_dependent_task");
    assertEquals("42", resultFromDependentTaskTaskResult.value().toString());
    // pas properties are exposed in the script task
    TaskResult propertiesTaskResult = jobResult.getResult("properties");
    String logs = propertiesTaskResult.getOutput().getAllLogs(false);
    assertThat(logs, containsString("PA_JOB_ID=" + jobResult.getJobId().value()));
    assertThat(logs, containsString("PA_JOB_NAME=" + jobResult.getName()));
    assertThat(logs, containsString("PA_TASK_ID=" + propertiesTaskResult.getTaskId().value()));
    assertThat(logs, containsString("PA_TASK_NAME=" + propertiesTaskResult.getTaskId().getReadableName()));
    assertThat(logs, containsString("PA_TASK_ITERATION=0"));
    assertThat(logs, containsString("PA_TASK_REPLICATION=0"));
    // the script can be a file
    TaskResult fileTaskResult = jobResult.getResult("file");
    assertTrue(fileTaskResult.getOutput().getAllLogs(false).contains("Beginning of clean script"));
    TaskResult fileAndArgsTaskResult = jobResult.getResult("file_and_args");
    assertTrue(fileAndArgsTaskResult.getOutput().getAllLogs(false).contains("My_Magic_Arg"));
    // dataspaces binding should be available
    TaskResult dataspacesTaskResult = jobResult.getResult("dataspaces");
    String dataspacesLogs = dataspacesTaskResult.getOutput().getAllLogs(false);
    System.out.println(dataspacesLogs);
    String schedulerHome = System.getProperty("pa.scheduler.home");
    assertTrue(dataspacesLogs.contains("global=" + schedulerHome));
    assertTrue(dataspacesLogs.contains("user=" + schedulerHome));
    assertTrue(dataspacesLogs.contains("input=" + schedulerHome));
    assertTrue(dataspacesLogs.contains("output=" + schedulerHome));
    TaskResult multiNodeTaskResult = jobResult.getResult("multi-node");
    String mnLogs = multiNodeTaskResult.getOutput().getAllLogs(false);
    assertTrue("Invalid binding for nodesurl", mnLogs.contains("nodesurl=" + (SchedulerStartForFunctionalTest.RM_NODE_NUMBER - 1)));
    // script task should be forked by default, ie it will not kill the scheduler on system.exit
    JobState jobState = schedulerHelper.getSchedulerInterface().getJobState(id);
    TaskResult killJVMTaskResult = jobResult.getResult("killJVM");
    assertTrue(killJVMTaskResult.getException() instanceof ForkedJvmProcessException);
    TaskState killJVMTaskState = jobState.getHMTasks().get(killJVMTaskResult.getTaskId());
    assertEquals(TaskStatus.FAULTY, killJVMTaskState.getStatus());
}
Also used : ForkedJvmProcessException(org.ow2.proactive.scheduler.task.exceptions.ForkedJvmProcessException) JobResult(org.ow2.proactive.scheduler.common.job.JobResult) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) JobState(org.ow2.proactive.scheduler.common.job.JobState) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) File(java.io.File) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 15 with JobResult

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

the class TestJobWithInvalidSelectionScript method testJobWithInvalidSelectionScript.

@Test
public void testJobWithInvalidSelectionScript() throws Throwable {
    String task1Name = "task1";
    String task2Name = "task2";
    String task3Name = "task3";
    // cannot use SchedulerTHelper.testJobsubmission because
    // task 3 is never executed so no event can received
    // regarding this task.
    JobId id = schedulerHelper.submitJob(new File(jobDescriptor.toURI()).getAbsolutePath());
    // check events reception
    log("Job submitted, id " + id.toString());
    log("Waiting for jobSubmitted");
    schedulerHelper.waitForEventJobSubmitted(id);
    log("Waiting for job running");
    schedulerHelper.waitForEventJobRunning(id);
    log("Waiting for task running : " + task1Name);
    schedulerHelper.waitForEventTaskRunning(id, task1Name);
    log("Waiting for task finished : " + task1Name);
    schedulerHelper.waitForEventTaskFinished(id, task1Name);
    // second task will not even start
    try {
        log("Waiting for task *running : " + task2Name);
        schedulerHelper.waitForEventTaskRunning(id, task2Name, 2000);
        log("Waiting for task *finished : " + task2Name);
        schedulerHelper.waitForEventTaskFinished(id, task2Name, 2000);
        // should always go in the catch
        fail();
    } catch (ProActiveTimeoutException expected) {
    }
    // task 3 should not be started
    boolean task3Started = false;
    try {
        schedulerHelper.waitForEventTaskRunning(id, task3Name, 1000);
        // should always go in the catch
        fail();
    } catch (ProActiveTimeoutException e) {
    }
    schedulerHelper.killJob(id.toString());
    JobInfo jobInfo = schedulerHelper.waitForEventJobFinished(id);
    JobResult res = schedulerHelper.getJobResult(id);
    Map<String, TaskResult> results = res.getAllResults();
    // check that all tasks results are defined
    assertNotNull(results.get("task1").value());
    assertNull(results.get("task2"));
    assertNull(results.get("task3"));
    assertEquals(JobStatus.KILLED, jobInfo.getStatus());
    assertEquals(1, jobInfo.getNumberOfFinishedTasks());
    assertEquals(0, jobInfo.getNumberOfRunningTasks());
    assertEquals(0, jobInfo.getNumberOfPendingTasks());
}
Also used : ProActiveTimeoutException(org.objectweb.proactive.core.ProActiveTimeoutException) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) JobResult(org.ow2.proactive.scheduler.common.job.JobResult) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) File(java.io.File) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Aggregations

JobResult (org.ow2.proactive.scheduler.common.job.JobResult)39 JobId (org.ow2.proactive.scheduler.common.job.JobId)26 Test (org.junit.Test)25 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)24 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)22 File (java.io.File)16 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)9 JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)7 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)6 NativeTask (org.ow2.proactive.scheduler.common.task.NativeTask)6 JobResultImpl (org.ow2.proactive.scheduler.job.JobResultImpl)6 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)6 Job (org.ow2.proactive.scheduler.common.job.Job)4 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)4 ForkEnvironment (org.ow2.proactive.scheduler.common.task.ForkEnvironment)4 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)4 NonTerminatingJob (functionaltests.jobs.NonTerminatingJob)3 SimpleJob (functionaltests.jobs.SimpleJob)3 HashMap (java.util.HashMap)3 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)3