Search in sources :

Example 26 with JobId

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

the class RunningTaskRecoveryWithDownNodeTest method action.

@Test
public void action() throws Throwable {
    this.createNodes();
    JobId jobid = this.submitJob();
    this.waitForAllTasksToRun(jobid);
    this.killSchedulerAndNodes();
    long timeForSchedulerToBeUp = this.recordSchedulerRestartTime();
    Scheduler scheduler = schedulerHelper.getSchedulerInterface();
    JobState jobState = scheduler.getJobState(jobid);
    this.checkTasks(jobState);
    this.waitForJobToFinish(jobid);
    this.checkJobResult(jobid, scheduler);
    this.checkSchedulerStateRecoveryDoesNotWaitTaskPingAttemptTimesFrequency(timeForSchedulerToBeUp);
}
Also used : Scheduler(org.ow2.proactive.scheduler.common.Scheduler) TestScheduler(functionaltests.utils.TestScheduler) JobState(org.ow2.proactive.scheduler.common.job.JobState) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 27 with JobId

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

the class RunningTaskRecoveryWithRecoveredNodeTestBase method action.

@Test
public void action() throws Throwable {
    nodes = schedulerHelper.createRMNodeStarterNodes(RunningTaskRecoveryWithForkedTaskExecutorTest.class.getSimpleName(), NB_NODES);
    JobId jobid = schedulerHelper.submitJob(new File(JOB_DESCRIPTOR.toURI()).getAbsolutePath());
    schedulerHelper.waitForEventJobRunning(jobid);
    TaskState taskState = schedulerHelper.getSchedulerInterface().getJobState(jobid).getTasks().get(0);
    schedulerHelper.waitForEventTaskRunning(taskState.getJobId(), taskState.getName());
    taskState = schedulerHelper.getSchedulerInterface().getJobState(jobid).getTasks().get(0);
    String firstExecutionHostInfo = taskState.getTaskInfo().getExecutionHostName();
    // wait and restart scheduler
    Thread.sleep(RESTART_SCHEDULER_INTER_TIME_IN_MILLISECONDS);
    TestScheduler.kill();
    Thread.sleep(RESTART_SCHEDULER_INTER_TIME_IN_MILLISECONDS);
    schedulerHelper = new SchedulerTHelper(false, new File(getSchedulerReStartConfigurationURL().toURI()).getAbsolutePath(), new File(RM_CONFIGURATION_RESTART.toURI()).getAbsolutePath(), null, false);
    Scheduler scheduler = schedulerHelper.getSchedulerInterface();
    TestListenJobLogs.TestAppender appender = new TestListenJobLogs.TestAppender(LOGGER_NAME);
    String loggerName = Log4JTaskLogs.JOB_LOGGER_PREFIX + jobid;
    logForwardingService.removeAllAppenders(LOGGER_NAME);
    logForwardingService.addAppender(loggerName, appender);
    scheduler.listenJobLogs(jobid, logForwardingService.getAppenderProvider());
    System.out.println("Number of nodes: " + schedulerHelper.getResourceManager().getState().getAllNodes().size());
    for (String freeNodeUrl : schedulerHelper.getResourceManager().getState().getFreeNodes()) {
        // previous executing node should not be free when the nodes are added back to the rm
        Assert.assertFalse(firstExecutionHostInfo.contains(freeNodeUrl));
    }
    // we should have just one running task
    JobState jobState = scheduler.getJobState(jobid);
    Assert.assertEquals(0, jobState.getNumberOfPendingTasks());
    Assert.assertEquals(1, jobState.getNumberOfRunningTasks());
    taskState = jobState.getTasks().get(0);
    Assert.assertEquals(firstExecutionHostInfo, taskState.getTaskInfo().getExecutionHostName());
    appender.waitForLoggingEvent(LOG_EVENT_TIMEOUT, TASK_LOG_OUTPUT_STARTING_STRING + MAXIMUM_STEP_IN_TASK_LOOP);
    schedulerHelper.waitForEventJobFinished(jobid);
    TaskResult taskResult = scheduler.getJobResult(jobid).getResult(TASK_NAME);
    Assert.assertFalse(taskResult.hadException());
    Assert.assertEquals(OK_TASK_RESULT_VALUE, taskResult.value());
    String logs = taskResult.getOutput().getStdoutLogs();
    for (int i = 0; i < MAXIMUM_STEP_IN_TASK_LOOP; i++) {
        Assert.assertTrue(logs.contains(TASK_LOG_OUTPUT_STARTING_STRING + i));
    }
}
Also used : SchedulerTHelper(functionaltests.utils.SchedulerTHelper) TestListenJobLogs(functionaltests.job.log.TestListenJobLogs) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) TestScheduler(functionaltests.utils.TestScheduler) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) File(java.io.File) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 28 with JobId

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

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

the class TestOperationsWhenUnlinked method testSubmitAndPause.

@Test
public void testSubmitAndPause() throws Throwable {
    Scheduler scheduler = schedulerHelper.getSchedulerInterface();
    log("Submitting job");
    JobId jobId1 = scheduler.submit(createJob());
    log("Killing RM");
    rmHelper.killRM();
    log("Waiting RM_DOWN event");
    schedulerHelper.waitForEventSchedulerState(SchedulerEvent.RM_DOWN, EVENT_TIMEOUT);
    log("Submitting new job");
    JobId jobId2 = scheduler.submit(createJob());
    if (!scheduler.pauseJob(jobId2)) {
        fail("Failed to pause job " + jobId2);
    }
    if (!scheduler.resumeJob(jobId2)) {
        fail("Failed to resume job " + jobId2);
    }
    log("Creating new RM");
    rmHelper = new RMTHelper();
    rmHelper.startRM(null, pnp_port);
    ResourceManager rm = rmHelper.getResourceManager();
    testNode = RMTHelper.createNode("test-node");
    String nodeUrl = testNode.getNode().getNodeInformation().getURL();
    rm.addNode(nodeUrl);
    rmHelper.waitForAnyNodeEvent(RMEventType.NODE_ADDED);
    log("Linking new RM");
    if (!scheduler.linkResourceManager(rmHelper.getLocalUrl())) {
        fail("Failed to link another RM");
    }
    log("Waiting when jobs finish");
    schedulerHelper.waitForEventJobFinished(jobId1, EVENT_TIMEOUT);
    schedulerHelper.waitForEventJobFinished(jobId2, EVENT_TIMEOUT);
    checkJobResult(scheduler, jobId1, 1);
    checkJobResult(scheduler, jobId2, 1);
}
Also used : Scheduler(org.ow2.proactive.scheduler.common.Scheduler) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) JobId(org.ow2.proactive.scheduler.common.job.JobId) ProActiveTest(org.ow2.tests.ProActiveTest)

Example 30 with JobId

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

the class TestRMReconnectionWhileRunning method testTaskIsNotStuckRunning.

/**
 * This case checks that even if exception was trown in main Scheduler loop it will not cause that jobId is running forever.
 * @throws Exception
 */
@Test
public void testTaskIsNotStuckRunning() throws Exception {
    ProActiveConfiguration.load();
    RMFactory.setOsJavaProperty();
    schedulerHelper = new SchedulerTHelper(false, true);
    schedulerHelper.createNodeSource("local", 3);
    schedulerHelper.getSchedulerInterface().changePolicy("functionaltests.rm.PolicyWhichThrowsExceptions");
    JobId jobId = schedulerHelper.submitJob(new File(runningJob.toURI()).getAbsolutePath());
    JobId jobId2 = schedulerHelper.submitJob(new File(runningJob1.toURI()).getAbsolutePath());
    JobId jobId3 = schedulerHelper.submitJob(new File(runningJob2.toURI()).getAbsolutePath());
    schedulerHelper.waitForEventTaskRunning(jobId, "running_task_for20s");
    schedulerHelper.waitForEventJobFinished(jobId2);
    schedulerHelper.waitForEventJobFinished(jobId3);
    assertJobFinished(jobId2);
    assertJobFinished(jobId3);
    assertJobFinished(jobId);
}
Also used : File(java.io.File) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

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