Search in sources :

Example 16 with TaskInfo

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

the class TestVariablesPatternLateBindings method testPropagatedVariableResolution.

@Test
public void testPropagatedVariableResolution() throws Throwable {
    TaskFlowJob job = (TaskFlowJob) StaxJobFactory.getFactory().createJob(absolutePath(job_desc));
    JobId id = schedulerHelper.submitJob(job);
    TaskInfo taskInfo = schedulerHelper.waitForEventTaskFinished(id, "Groovy_Task2");
    // assert the task finished correctly
    assertEquals(TaskStatus.FINISHED, taskInfo.getStatus());
    // for the second task:
    String jobLog = schedulerHelper.getTaskResult(id, "Groovy_Task2").getOutput().getAllLogs();
    Assert.assertThat(jobLog, CoreMatchers.containsString("WORKFLOW_VAR1=workflow_value"));
    Assert.assertThat(jobLog, CoreMatchers.containsString("WORKFLOW_VAR2=var2_workflow_value"));
    Assert.assertThat(jobLog, CoreMatchers.containsString("WORKFLOW_VAR3=workflow_value"));
    Assert.assertThat(jobLog, CoreMatchers.containsString("WORKFLOW_VAR4=workflow_value_task_value"));
    Assert.assertThat(jobLog, CoreMatchers.containsString("TASK_VAR1=task_value"));
    Assert.assertThat(jobLog, CoreMatchers.containsString("TASK_VAR2=task_value_" + id.toString()));
    Assert.assertThat(jobLog, CoreMatchers.containsString("TASK_VAR3=task_value_task_value"));
    Assert.assertThat(jobLog, CoreMatchers.containsString("TASK_VAR4=task_value_inherited_value"));
    Assert.assertThat(jobLog, CoreMatchers.containsString("INHERITED_VAR1=inherited_value"));
    Assert.assertThat(jobLog, CoreMatchers.containsString("INHERITED_VAR2=inherited_value_" + id.toString()));
    Assert.assertThat(jobLog, CoreMatchers.containsString("INHERITED_VAR3=inherited_value_task_value"));
    Assert.assertThat(jobLog, CoreMatchers.containsString("INHERITED_VAR4=inherited_value_inherited_value"));
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 17 with TaskInfo

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

the class TestPreemptRestartKillTask method TestPreemtRestartKillTask.

private void TestPreemtRestartKillTask(String jobDescriptorPath) throws Exception {
    log("Submitting job");
    log(schedulerHelper.getSchedulerInterface().getClass().toString());
    schedulerHelper.addExtraNodes(3);
    JobId id = schedulerHelper.submitJob(jobDescriptorPath);
    log("Wait for event job submitted");
    schedulerHelper.waitForEventJobSubmitted(id);
    log("Wait for event t1 running");
    schedulerHelper.waitForEventTaskRunning(id, "t1");
    log("Wait for event t2 running");
    schedulerHelper.waitForEventTaskRunning(id, "t2");
    log("Wait for event t3 running");
    schedulerHelper.waitForEventTaskRunning(id, "t3");
    log("Wait for event t4 running");
    schedulerHelper.waitForEventTaskRunning(id, "t4");
    log("Preempt t1");
    schedulerHelper.getSchedulerInterface().preemptTask(id, "t1", 1);
    log("Wait for event t1 waiting for restart");
    // running jobs list must have only one job, task t1 must have number of execution to 0
    TaskInfo ti1 = schedulerHelper.waitForEventTaskWaitingForRestart(id, "t1");
    // task result for t1 must be available with TaskPreemptedException
    TaskResult tr1 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t1");
    log("Restart t2");
    schedulerHelper.getSchedulerInterface().restartTask(id, "t2", 1);
    log("Wait for event t2 waiting for restart");
    // running jobs list must have only one job, task t2 must have number of execution to 1
    TaskInfo ti2 = schedulerHelper.waitForEventTaskWaitingForRestart(id, "t2");
    // task result for t2 must be available with TaskRestartedException
    TaskResult tr2 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t2");
    log("Wait for event t2 running");
    schedulerHelper.waitForEventTaskRunning(id, "t2");
    log("Restart t2 again");
    schedulerHelper.getSchedulerInterface().restartTask(id, "t2", 1);
    log("Wait for event t2 waiting for restart again");
    // running jobs list must have only one job, task t2 must have number of execution to 2
    TaskInfo ti3 = schedulerHelper.waitForEventTaskWaitingForRestart(id, "t2");
    // task result for t2 must be available with TaskRestartedException
    TaskResult tr3 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t2");
    // ensure every tasks are running at this point
    schedulerHelper.waitForEventTaskRunning(id, "t1");
    schedulerHelper.waitForEventTaskRunning(id, "t2");
    log("Kill t3");
    schedulerHelper.getSchedulerInterface().killTask(id, "t3");
    log("Wait for event t3 finished");
    schedulerHelper.waitForEventTaskFinished(id, "t3");
    // task result for t3 must be available with TaskRestartedException
    TaskResult tr4 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t3");
    log("Kill t4");
    schedulerHelper.getSchedulerInterface().killTask(id, "t4");
    log("Wait for event job finished");
    // finished jobs list must have only one job
    JobInfo ji4 = schedulerHelper.waitForEventJobFinished(id);
    // task result for t4 must be TaskRestartedException
    JobState j4 = schedulerHelper.getSchedulerInterface().getJobState(id);
    TaskResult tr5 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t4");
    // check result j1
    assertEquals(2, ti1.getNumberOfExecutionLeft());
    assertTrue(tr1.getException() instanceof TaskPreemptedException);
    // check result j2
    assertEquals(3, ti2.getNumberOfExecutionLeft());
    assertTrue(tr2.getException() instanceof TaskRestartedException);
    // check result j3
    assertEquals(2, ti3.getNumberOfExecutionLeft());
    assertTrue(tr3.getException() instanceof TaskRestartedException);
    // check result tr4
    assertTrue(tr4.getException() instanceof TaskAbortedException);
    // check result j4
    assertEquals(JobStatus.CANCELED, ji4.getStatus());
    TaskStatus t1Status = getTask(j4, "t1").getStatus();
    assertTrue(t1Status.equals(TaskStatus.ABORTED) || t1Status.equals(TaskStatus.NOT_RESTARTED));
    TaskStatus t2Status = getTask(j4, "t2").getStatus();
    assertTrue(t2Status.equals(TaskStatus.ABORTED) || t2Status.equals(TaskStatus.NOT_RESTARTED));
    assertEquals(TaskStatus.FAULTY, getTask(j4, "t3").getStatus());
    assertEquals(TaskStatus.FAULTY, getTask(j4, "t4").getStatus());
    // check result tr5
    // 
    assertTrue(tr5.getException() instanceof Exception);
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) TaskPreemptedException(org.ow2.proactive.scheduler.common.exception.TaskPreemptedException) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) TaskRestartedException(org.ow2.proactive.scheduler.common.exception.TaskRestartedException) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskStatus(org.ow2.proactive.scheduler.common.task.TaskStatus) TaskAbortedException(org.ow2.proactive.scheduler.common.exception.TaskAbortedException) JobId(org.ow2.proactive.scheduler.common.job.JobId) TaskAbortedException(org.ow2.proactive.scheduler.common.exception.TaskAbortedException) TaskPreemptedException(org.ow2.proactive.scheduler.common.exception.TaskPreemptedException) TaskRestartedException(org.ow2.proactive.scheduler.common.exception.TaskRestartedException)

Example 18 with TaskInfo

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

the class TestPreemptRestartKillTaskSchema33 method TestPreemtRestartKillTask.

private void TestPreemtRestartKillTask(String jobDescriptorPath) throws Exception {
    log("Submitting job");
    schedulerHelper.addExtraNodes(3);
    JobId id = schedulerHelper.submitJob(jobDescriptorPath);
    log("Wait for event job submitted");
    schedulerHelper.waitForEventJobSubmitted(id);
    log("Wait for event t1 running");
    schedulerHelper.waitForEventTaskRunning(id, "t1");
    log("Wait for event t2 running");
    schedulerHelper.waitForEventTaskRunning(id, "t2");
    log("Wait for event t3 running");
    schedulerHelper.waitForEventTaskRunning(id, "t3");
    log("Wait for event t4 running");
    schedulerHelper.waitForEventTaskRunning(id, "t4");
    log("Preempt t1");
    schedulerHelper.getSchedulerInterface().preemptTask(id, "t1", 1);
    log("Wait for event t1 waiting for restart");
    // running jobs list must have only one job, task t1 must have number of execution to 0
    TaskInfo ti1 = schedulerHelper.waitForEventTaskWaitingForRestart(id, "t1");
    // task result for t1 must be available with TaskPreemptedException
    TaskResult tr1 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t1");
    log("Restart t2");
    schedulerHelper.getSchedulerInterface().restartTask(id, "t2", 1);
    log("Wait for event t2 waiting for restart");
    // running jobs list must have only one job, task t2 must have number of execution to 1
    TaskInfo ti2 = schedulerHelper.waitForEventTaskWaitingForRestart(id, "t2");
    // task result for t2 must be available with TaskRestartedException
    TaskResult tr2 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t2");
    log("Wait for event t2 running");
    schedulerHelper.waitForEventTaskRunning(id, "t2");
    log("Restart t2 again");
    schedulerHelper.getSchedulerInterface().restartTask(id, "t2", 1);
    log("Wait for event t2 waiting for restart again");
    // running jobs list must have only one job, task t2 must have number of execution to 2
    TaskInfo ti3 = schedulerHelper.waitForEventTaskWaitingForRestart(id, "t2");
    // task result for t2 must be available with TaskRestartedException
    TaskResult tr3 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t2");
    // ensure every tasks are running at this point
    schedulerHelper.waitForEventTaskRunning(id, "t1");
    schedulerHelper.waitForEventTaskRunning(id, "t2");
    log("Kill t3");
    schedulerHelper.getSchedulerInterface().killTask(id, "t3");
    log("Wait for event t3 finished");
    schedulerHelper.waitForEventTaskFinished(id, "t3");
    // task result for t3 must be available with TaskRestartedException
    TaskResult tr4 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t3");
    log("Kill t4");
    schedulerHelper.getSchedulerInterface().killTask(id, "t4");
    log("Wait for event job finished");
    // finished jobs list must have only one job
    JobInfo ji4 = schedulerHelper.waitForEventJobFinished(id);
    // task result for t4 must be TaskRestartedException
    JobState j4 = schedulerHelper.getSchedulerInterface().getJobState(id);
    TaskResult tr5 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t4");
    // check result j1
    assertEquals(2, ti1.getNumberOfExecutionLeft());
    assertTrue(tr1.getException() instanceof TaskPreemptedException);
    // check result j2
    assertEquals(3, ti2.getNumberOfExecutionLeft());
    assertTrue(tr2.getException() instanceof TaskRestartedException);
    // check result j3
    assertEquals(2, ti3.getNumberOfExecutionLeft());
    assertTrue(tr3.getException() instanceof TaskRestartedException);
    // check result tr4
    assertTrue(tr4.getException() instanceof TaskAbortedException);
    // check result j4
    assertEquals(JobStatus.CANCELED, ji4.getStatus());
    TaskStatus t1Status = getTask(j4, "t1").getStatus();
    assertTrue(t1Status.equals(TaskStatus.ABORTED) || t1Status.equals(TaskStatus.NOT_RESTARTED));
    TaskStatus t2Status = getTask(j4, "t2").getStatus();
    assertTrue(t2Status.equals(TaskStatus.ABORTED) || t2Status.equals(TaskStatus.NOT_RESTARTED));
    assertEquals(TaskStatus.FAULTY, getTask(j4, "t3").getStatus());
    assertEquals(TaskStatus.FAULTY, getTask(j4, "t4").getStatus());
    // check result tr5
    // 
    assertTrue(tr5.getException() instanceof Exception);
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) TaskPreemptedException(org.ow2.proactive.scheduler.common.exception.TaskPreemptedException) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) TaskRestartedException(org.ow2.proactive.scheduler.common.exception.TaskRestartedException) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskStatus(org.ow2.proactive.scheduler.common.task.TaskStatus) TaskAbortedException(org.ow2.proactive.scheduler.common.exception.TaskAbortedException) JobId(org.ow2.proactive.scheduler.common.job.JobId) TaskAbortedException(org.ow2.proactive.scheduler.common.exception.TaskAbortedException) TaskPreemptedException(org.ow2.proactive.scheduler.common.exception.TaskPreemptedException) TaskRestartedException(org.ow2.proactive.scheduler.common.exception.TaskRestartedException)

Example 19 with TaskInfo

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

the class TestTaskNotExecuted method testTaskNotExecuted.

private void testTaskNotExecuted(String jobDescriptorPath1, String jobDescriptorPath2, String jobDescriptorPath3) throws Exception {
    log("Submitting job 1");
    JobId id1 = schedulerHelper.submitJob(jobDescriptorPath1);
    log("Wait for event job 1 submitted");
    schedulerHelper.waitForEventJobSubmitted(id1);
    log("Wait for event t1 running");
    schedulerHelper.waitForEventTaskRunning(id1, "t0");
    schedulerHelper.waitForEventTaskFinished(id1, "t0");
    schedulerHelper.waitForEventJobFinished(id1);
    TaskResult tr1 = schedulerHelper.getSchedulerInterface().getTaskResult(id1, "t1");
    assertTrue(tr1.getException() instanceof TaskCouldNotStartException);
    log("Submitting job 2");
    JobId id2 = schedulerHelper.submitJob(jobDescriptorPath2);
    log("Wait for event job 2 submitted");
    schedulerHelper.waitForEventJobSubmitted(id2);
    log("Wait for event t2 running");
    schedulerHelper.waitForEventTaskRunning(id2, "t2");
    log("Restarting task");
    schedulerHelper.getSchedulerInterface().restartTask(id2, "t2", Integer.MAX_VALUE);
    TaskInfo ti2 = schedulerHelper.waitForEventTaskWaitingForRestart(id2, "t2");
    schedulerHelper.getSchedulerInterface().killJob(id2);
    schedulerHelper.waitForEventJobFinished(id2);
    JobState jobState = schedulerHelper.getSchedulerInterface().getJobState(id2);
    Assert.assertEquals(TaskStatus.NOT_RESTARTED, jobState.getTasks().get(0).getStatus());
    TaskResult tr2 = schedulerHelper.getSchedulerInterface().getTaskResult(id2, "t2");
    assertTrue(tr2.getException() instanceof TaskCouldNotRestartException);
    log("Submitting job 3");
    JobId id3 = schedulerHelper.submitJob(jobDescriptorPath3);
    log("Wait for event job 3 submitted");
    schedulerHelper.waitForEventJobSubmitted(id3);
    log("Wait for event T T1 T2 finished");
    schedulerHelper.waitForEventTaskFinished(id3, "T");
    schedulerHelper.waitForEventTaskFinished(id3, "T1");
    TaskResult tr3_1 = schedulerHelper.getSchedulerInterface().getTaskResult(id3, "T1");
    TaskResult tr3_2 = schedulerHelper.getSchedulerInterface().getTaskResult(id3, "T2");
    assertNull(tr3_1.getException());
    assertTrue(tr3_2.getException() instanceof TaskSkippedException);
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) TaskCouldNotStartException(org.ow2.proactive.scheduler.common.exception.TaskCouldNotStartException) TaskCouldNotRestartException(org.ow2.proactive.scheduler.common.exception.TaskCouldNotRestartException) TaskSkippedException(org.ow2.proactive.scheduler.common.exception.TaskSkippedException) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) JobState(org.ow2.proactive.scheduler.common.job.JobState) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 20 with TaskInfo

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

the class TestJobServerLogs method test.

@Test
public void test() throws Exception {
    JobId simpleJobId = schedulerHelper.submitJob(new File(simpleJobDescriptor.toURI()).getAbsolutePath());
    String taskName = "task1";
    TaskInfo ti = schedulerHelper.waitForEventTaskRunning(simpleJobId, taskName);
    String taskLogs = schedulerHelper.getSchedulerInterface().getTaskServerLogs(simpleJobId.toString(), taskName);
    if (!taskLogs.contains("task " + ti.getTaskId() + " (" + ti.getTaskId().getReadableName() + ")" + " started")) {
        log("Incorrect task server logs:");
        log(taskLogs);
        fail("Task " + ti.getTaskId() + " was not scheduled");
    }
    schedulerHelper.waitForEventJobFinished(simpleJobId);
    String jobLogs = schedulerHelper.getSchedulerInterface().getJobServerLogs(simpleJobId.toString());
    for (int i = 0; i < TASKS_IN_SIMPLE_JOB; i++) {
        TaskId taskId = TaskIdImpl.createTaskId(simpleJobId, "task" + (i + 1), i);
        String taskIdString = taskId.toString();
        String taskIdStringQuoted = Pattern.quote(taskIdString);
        if (!matchLine(jobLogs, "task " + taskIdStringQuoted + " \\(task[12]\\) started")) {
            log("Incorrect job server logs");
            log(jobLogs);
            fail("Task " + taskIdString + " was not scheduled");
        }
        if (!matchLine(jobLogs, "task " + taskIdStringQuoted + " \\(task[12]\\) finished")) {
            log("Incorrect job server logs");
            log(jobLogs);
            fail("Task " + taskIdString + " was not finished");
        }
    }
    checkRemoval(simpleJobId);
    JobId pendingJobId = schedulerHelper.submitJob(createPendingJob());
    Thread.sleep(5000);
    jobLogs = schedulerHelper.getSchedulerInterface().getJobServerLogs(pendingJobId.toString());
    if (!jobLogs.contains("will get 0 nodes")) {
        log("Incorrect job server logs");
        log(jobLogs);
        fail("RM output is not correct");
    }
    if (!jobLogs.contains(SCRIPT_OUTPUT)) {
        log("Incorrect job server logs");
        log(jobLogs);
        fail("No script output");
    }
    checkRemoval(pendingJobId);
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) File(java.io.File) JobId(org.ow2.proactive.scheduler.common.job.JobId) WaitAndPrint(org.ow2.proactive.scheduler.examples.WaitAndPrint) Test(org.junit.Test)

Aggregations

TaskInfo (org.ow2.proactive.scheduler.common.task.TaskInfo)26 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)15 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)14 JobId (org.ow2.proactive.scheduler.common.job.JobId)10 Test (org.junit.Test)8 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)7 JobState (org.ow2.proactive.scheduler.common.job.JobState)7 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)6 ArrayList (java.util.ArrayList)5 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)5 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)4 TaskStatus (org.ow2.proactive.scheduler.common.task.TaskStatus)4 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)4 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)4 File (java.io.File)3 TaskAbortedException (org.ow2.proactive.scheduler.common.exception.TaskAbortedException)3 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)3 JobInfoImpl (org.ow2.proactive.scheduler.job.JobInfoImpl)3 TaskInfoData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskInfoData)3 Page (org.ow2.proactive.scheduler.common.Page)2