Search in sources :

Example 31 with JobState

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

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

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

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

the class ParallelTaskSchedulingTest method test.

@Test(timeout = 3600000)
public void test() throws Exception {
    ProActiveConfiguration.load();
    RMFactory.setOsJavaProperty();
    schedulerHelper = new SchedulerTHelper(false, SCHEDULER_CONFIGURATION_START.getPath(), RM_CONFIGURATION_START.getPath(), null);
    schedulerHelper.createNodeSourceWithInfiniteTimeout("local", numberOfNodes);
    final TaskFlowJob job = createJob(numberOfTasks);
    jobId = schedulerHelper.submitJob(job);
    schedulerHelper.waitForEventJobFinished(jobId);
    final JobState jobState = schedulerHelper.getSchedulerInterface().getJobState(jobId);
    final long timeToMeasure = jobState.getFinishedTime() - jobState.getStartTime();
    LOGGER.info(makeCSVString(ParallelTaskSchedulingTest.class.getSimpleName(), numberOfTasks, timeLimit, timeToMeasure, ((timeToMeasure < timeLimit) ? SUCCESS : FAILURE)));
}
Also used : SchedulerTHelper(functionaltests.utils.SchedulerTHelper) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JobState(org.ow2.proactive.scheduler.common.job.JobState) Test(org.junit.Test)

Example 35 with JobState

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

the class SchedulerEfficiencyMetricsTest method test.

@Test(timeout = 3600000)
public void test() throws Exception {
    ProActiveConfiguration.load();
    RMFactory.setOsJavaProperty();
    schedulerHelper = new SchedulerTHelper(false, SCHEDULER_CONFIGURATION_START.getPath(), RM_CONFIGURATION_START.getPath(), null);
    schedulerHelper.createNodeSourceWithInfiniteTimeout("local", taskNumber);
    final TaskFlowJob job = createJob(taskNumber, TASK_DURATION);
    long start = System.currentTimeMillis();
    jobId = schedulerHelper.submitJob(job);
    long submited = System.currentTimeMillis();
    schedulerHelper.waitForEventJobFinished(jobId);
    final JobState jobState = schedulerHelper.getSchedulerInterface().getJobState(jobId);
    final long finished = jobState.getFinishedTime();
    long latestTaskStart = Long.MIN_VALUE;
    for (TaskState taskState : jobState.getTasks()) {
        if (taskState.getStartTime() > latestTaskStart) {
            latestTaskStart = taskState.getStartTime();
        }
    }
    long TCT = submited - start;
    long TST = latestTaskStart - submited;
    long TTT = finished - latestTaskStart - TASK_DURATION;
    logAndAssert("TaskCreationTimeTest", TCT);
    logAndAssert("TaskSchedulingTimeTest", TST);
    logAndAssert("TaskTerminationTimeTest", TTT);
}
Also used : SchedulerTHelper(functionaltests.utils.SchedulerTHelper) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) Test(org.junit.Test)

Aggregations

JobState (org.ow2.proactive.scheduler.common.job.JobState)67 Test (org.junit.Test)34 JobId (org.ow2.proactive.scheduler.common.job.JobId)28 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)25 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)23 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)19 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)17 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)17 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)15 ArrayList (java.util.ArrayList)14 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)14 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)14 GET (javax.ws.rs.GET)13 Path (javax.ws.rs.Path)13 Produces (javax.ws.rs.Produces)13 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)13 File (java.io.File)12 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)9 ClientJobState (org.ow2.proactive.scheduler.job.ClientJobState)9 TaskStatesPage (org.ow2.proactive.scheduler.common.task.TaskStatesPage)8