Search in sources :

Example 36 with JobId

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

the class TestUnauthorizedScripts method testUnAuthorizedSelectionScripts.

@Test
public void testUnAuthorizedSelectionScripts() throws Exception {
    Job job = createJobSelection(unauthorizedSelectionScriptContent);
    JobId id = schedulerHelper.submitJob(job);
    Thread.sleep(10000);
    File selectionOut = new File(folder.getRoot().getAbsolutePath(), "selection.out");
    Assert.assertFalse("File created by the unauthorized selection script should NOT exist", selectionOut.exists());
    Assert.assertEquals(JobStatus.PENDING, schedulerHelper.getSchedulerInterface().getJobState(id).getStatus());
    schedulerHelper.getSchedulerInterface().killJob(id);
}
Also used : Job(org.ow2.proactive.scheduler.common.job.Job) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) File(java.io.File) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 37 with JobId

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

the class TestJobCleaningScriptVariables method testJobCleaningScriptVariables.

@Test
public void testJobCleaningScriptVariables() throws Throwable {
    HashMap<String, String> variables = new HashMap<>();
    File ko = new File(tmpDir.getRoot(), "ko");
    variables.put("path", ko.toString());
    variables.put("test", "initialValue");
    JobId jobId = schedulerHelper.submitJob(new File(jobDescriptor.toURI()).getAbsolutePath(), variables);
    schedulerHelper.waitForEventJobFinished(jobId);
    while (schedulerHelper.getResourceManager().getState().getFreeNodesNumber() != SchedulerStartForFunctionalTest.RM_NODE_NUMBER) ;
    if (ko.exists()) {
        String content;
        content = FileUtils.readFileToString(ko);
        Assert.fail(content);
    }
}
Also used : HashMap(java.util.HashMap) File(java.io.File) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test) SchedulerStartForFunctionalTest(functionaltests.utils.SchedulerStartForFunctionalTest)

Example 38 with JobId

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

Example 39 with JobId

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

the class TestTasksCompleteAfterSelectiontimeout method testJobCompleteAfterTimeout.

@Test(timeout = 30000)
public void testJobCompleteAfterTimeout() throws Throwable {
    String task1Name = "toBeCompletetd1";
    String task2Name = "toBeCompletetd2";
    String task3Name = "toBeCompletetd3";
    String task4Name = "toBeCompletetd4";
    String task5Name = "toBeCompletetd5";
    // cannot use SchedulerTHelper.testJobsubmission because
    // task 3 is never executed so no event can be 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);
    log("Waiting for task running : " + task2Name);
    schedulerHelper.waitForEventTaskRunning(id, task2Name);
    log("Waiting for task finished : " + task2Name);
    schedulerHelper.waitForEventTaskFinished(id, task2Name);
    log("Waiting for task running : " + task3Name);
    schedulerHelper.waitForEventTaskRunning(id, task3Name);
    log("Waiting for task finished : " + task3Name);
    schedulerHelper.waitForEventTaskFinished(id, task3Name);
    log("Waiting for task running : " + task4Name);
    schedulerHelper.waitForEventTaskRunning(id, task4Name);
    log("Waiting for task finished : " + task4Name);
    schedulerHelper.waitForEventTaskFinished(id, task4Name);
    log("Waiting for task running : " + task5Name);
    schedulerHelper.waitForEventTaskRunning(id, task5Name);
    log("Waiting for task finished : " + task5Name);
    schedulerHelper.waitForEventTaskFinished(id, task5Name);
}
Also used : File(java.io.File) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 40 with JobId

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

the class SchedulingServiceTest2 method testFailedTask.

private void testFailedTask(boolean failNativeTask) throws Exception {
    service.submitJob(createJob(createTestJob()));
    listener.assertEvents(SchedulerEvent.JOB_SUBMITTED);
    Map<JobId, JobDescriptor> jobsMap;
    JobDescriptor jobDesc;
    jobsMap = service.lockJobsToSchedule();
    assertEquals(1, jobsMap.size());
    jobDesc = jobsMap.values().iterator().next();
    Assert.assertEquals(2, jobDesc.getEligibleTasks().size());
    for (TaskDescriptor taskDesc : jobDesc.getEligibleTasks()) {
        taskStarted(jobDesc, (EligibleTaskDescriptor) taskDesc);
    }
    service.unlockJobsToSchedule(jobsMap.values());
    if (failNativeTask) {
        InternalTask nativeTask = ((JobDescriptorImpl) jobDesc).getInternal().getTask("nativeTask");
        // native task terminates with code 1, flag 'cancelJobOnError' was
        // set so job should be cancelled
        service.taskTerminatedWithResult(nativeTask.getId(), new TaskResultImpl(nativeTask.getId(), new RuntimeException(), null, 0));
    } else {
        InternalTask javaTask = ((JobDescriptorImpl) jobDesc).getInternal().getTask("javaTask");
        // java task terminates with exception, flag 'cancelJobOnError' was
        // set so job should be cancelled
        service.taskTerminatedWithResult(javaTask.getId(), new TaskResultImpl(javaTask.getId(), new RuntimeException(), null, 0));
    }
    jobsMap = service.lockJobsToSchedule();
    assertEquals(0, jobsMap.size());
    listener.assertEvents(SchedulerEvent.JOB_PENDING_TO_RUNNING, SchedulerEvent.JOB_UPDATED, SchedulerEvent.TASK_PENDING_TO_RUNNING, SchedulerEvent.TASK_PENDING_TO_RUNNING, SchedulerEvent.TASK_RUNNING_TO_FINISHED, SchedulerEvent.TASK_RUNNING_TO_FINISHED, SchedulerEvent.JOB_RUNNING_TO_FINISHED, SchedulerEvent.JOB_UPDATED);
    infrastructure.assertRequests(2);
}
Also used : TaskDescriptor(org.ow2.proactive.scheduler.common.TaskDescriptor) EligibleTaskDescriptor(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) JobDescriptor(org.ow2.proactive.scheduler.common.JobDescriptor) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) 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