Search in sources :

Example 86 with JobId

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

the class TestTaskNotRestarted method test.

@Test
public void test() throws Exception {
    Scheduler scheduler = schedulerHelper.getSchedulerInterface();
    JobId jobId = scheduler.submit(createJob());
    JobState jobState;
    schedulerHelper.waitForEventTaskRunning(jobId, "task1");
    jobState = scheduler.getJobState(jobId);
    assertEquals(1, jobState.getTasks().size());
    assertEquals(TaskStatus.RUNNING, jobState.getTasks().get(0).getStatus());
    scheduler.restartTask(jobId, "task1", Integer.MAX_VALUE);
    jobState = scheduler.getJobState(jobId);
    assertEquals(1, jobState.getTasks().size());
    assertEquals(TaskStatus.WAITING_ON_ERROR, jobState.getTasks().get(0).getStatus());
    scheduler.killJob(jobId);
    jobState = scheduler.getJobState(jobId);
    assertEquals(1, jobState.getTasks().size());
    assertEquals(TaskStatus.NOT_RESTARTED, jobState.getTasks().get(0).getStatus());
}
Also used : Scheduler(org.ow2.proactive.scheduler.common.Scheduler) JobState(org.ow2.proactive.scheduler.common.job.JobState) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 87 with JobId

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

the class TestTaskNotStarted method test.

@Test
public void test() throws Exception {
    Scheduler scheduler = schedulerHelper.getSchedulerInterface();
    JobId jobId;
    JobState jobState;
    jobId = scheduler.submit(createJob1());
    jobState = scheduler.getJobState(jobId);
    assertEquals(1, jobState.getTasks().size());
    assertEquals(TaskStatus.SUBMITTED, jobState.getTasks().get(0).getStatus());
    scheduler.killJob(jobId);
    jobState = scheduler.getJobState(jobId);
    assertEquals(1, jobState.getTasks().size());
    assertEquals(TaskStatus.NOT_STARTED, jobState.getTasks().get(0).getStatus());
    jobId = scheduler.submit(createJob2());
    schedulerHelper.waitForEventJobRunning(jobId);
    jobState = scheduler.getJobState(jobId);
    assertEquals(2, jobState.getTasks().size());
    assertEquals(TaskStatus.PENDING, getTask(jobState, "task2").getStatus());
    scheduler.killJob(jobId);
    jobState = scheduler.getJobState(jobId);
    assertEquals(2, jobState.getTasks().size());
    assertEquals(TaskStatus.NOT_STARTED, getTask(jobState, "task2").getStatus());
}
Also used : Scheduler(org.ow2.proactive.scheduler.common.Scheduler) JobState(org.ow2.proactive.scheduler.common.job.JobState) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 88 with JobId

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

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

the class TestTaskRestartOnNodeFailure method checkJobResult.

private void checkJobResult(Scheduler scheduler, JobId jobId) throws Exception {
    JobResult jobResult = scheduler.getJobResult(jobId);
    assertEquals("Unexpected number of task results", 1, jobResult.getAllResults().size());
    for (TaskResult taskResult : jobResult.getAllResults().values()) {
        log("Task " + taskResult.getTaskId());
        assertNull("Unexpected task result exception", taskResult.getException());
        String output = taskResult.getOutput().getAllLogs(false);
        log("Task output:");
        log(output);
        assertTrue("Unxepected output", output.contains("OK"));
    }
}
Also used : JobResult(org.ow2.proactive.scheduler.common.job.JobResult) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult)

Example 90 with JobId

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

the class TestTaskRestartOnNodeFailure method testTaskKillNode.

private void testTaskKillNode(FileLock fileLock, boolean waitBeforeKill) throws Exception {
    Path fileLockPath = fileLock.lock();
    TestNode nodeToKill = startNode();
    log("Submit job");
    final JobId jobId = schedulerHelper.submitJob(createJob(fileLockPath.toString()));
    log("Wait when node becomes busy");
    RMNodeEvent event;
    do {
        event = schedulerHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED, TIMEOUT);
    } while (!event.getNodeState().equals(NodeState.BUSY));
    log("Wait when task starts");
    schedulerHelper.waitForEventTaskRunning(jobId, "Test task");
    /*
         * Want to test two cases (existed at the time of this writing): - if wait some time before
         * killing node then node failure is detected by the pinger thread - if kill node
         * immediately then node failure is detected by the thread calling TaskLauncher.doTask
         */
    if (waitBeforeKill) {
        log("Wait some time");
        Thread.sleep(5000);
    }
    log("Stop task node process (node " + nodeToKill.getNode().getNodeInformation().getURL() + ")");
    nodeToKill.kill();
    TestNode newNode = startNode();
    log("Let task finish");
    fileLock.unlock();
    log("Wait when job finish");
    schedulerHelper.waitForEventJobFinished(jobId, TIMEOUT);
    event = schedulerHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, newNode.getNode().getNodeInformation().getURL(), TIMEOUT);
    assertEquals(NodeState.BUSY, event.getNodeState());
    event = schedulerHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, newNode.getNode().getNodeInformation().getURL(), TIMEOUT);
    assertEquals(NodeState.FREE, event.getNodeState());
    log("Check job result");
    checkJobResult(schedulerHelper.getSchedulerInterface(), jobId);
    schedulerHelper.getResourceManager().removeNode(newNode.getNodeURL(), true);
    newNode.kill();
}
Also used : Path(java.nio.file.Path) TestNode(functionaltests.utils.TestNode) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Aggregations

JobId (org.ow2.proactive.scheduler.common.job.JobId)179 Test (org.junit.Test)121 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)73 File (java.io.File)58 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)57 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)55 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)55 JobState (org.ow2.proactive.scheduler.common.job.JobState)51 ArrayList (java.util.ArrayList)45 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)43 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)42 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)40 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)38 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)37 JobResult (org.ow2.proactive.scheduler.common.job.JobResult)36 Path (javax.ws.rs.Path)35 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)35 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)34 Produces (javax.ws.rs.Produces)33 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)33