Search in sources :

Example 51 with TaskResult

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

the class TestScriptTask method test_getTaskResult_nullReturningScriptTask_shouldSucceed.

/**
 * SCHEDULING-2199 NPE is thrown when retrieving the result of a ScriptTask,
 *  if the result is 'null'.
 */
private void test_getTaskResult_nullReturningScriptTask_shouldSucceed() throws Throwable {
    TaskFlowJob job = (TaskFlowJob) StaxJobFactory.getFactory().createJob(new File(job_null_returning_script_task.toURI()).getAbsolutePath());
    JobId id = schedulerHelper.submitJob(job);
    schedulerHelper.waitForEventJobFinished(id);
    TaskResult taskResult = schedulerHelper.getTaskResult(id, "task");
    assertNull(taskResult.value());
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) File(java.io.File) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 52 with TaskResult

use of org.ow2.proactive.scheduler.common.task.TaskResult 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 53 with TaskResult

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

the class TerminateNotificationTest method testTerminate.

@Test
public void testTerminate() throws TerminateTaskException {
    TaskId taskId = TaskIdImpl.createTaskId(new JobIdImpl(666, "readableName"), "task-name", 777L);
    TaskResult taskResult = new TaskResultImpl(taskId, new Throwable());
    terminateNotification.terminate(taskId, taskResult);
    Mockito.verify(schedulingService, Mockito.times(1)).taskTerminatedWithResult(taskId, taskResult);
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) Test(org.junit.Test)

Example 54 with TaskResult

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

the class TaskResultCreatorTest method testPausedTasksAreCheckedForATaskId.

@Test
public void testPausedTasksAreCheckedForATaskId() throws UnknownTaskException {
    TaskResultCreator taskResultCreator = new TaskResultCreator();
    TaskResultImpl mockedTaskResultImpl = mock(TaskResultImpl.class);
    Map<TaskId, TaskResult> loadTaskResultsValue = new HashMap<>();
    loadTaskResultsValue.put(this.createTaskID(), mockedTaskResultImpl);
    SchedulerDBManager mockedschedulerDbManager = mock(SchedulerDBManager.class);
    when(mockedschedulerDbManager.loadTasksResults(any(JobId.class), any(List.class))).thenReturn(loadTaskResultsValue);
    JobDescriptorImpl mockedJobDescriptorHasPausedTask = this.getMockedJobDescriptorWithPausedTask();
    taskResultCreator.getTaskResult(mockedschedulerDbManager, this.getMockedInternalJob(mockedJobDescriptorHasPausedTask), this.getMockedInternalTask());
    verify(mockedJobDescriptorHasPausedTask, atLeastOnce()).getPausedTasks();
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) HashMap(java.util.HashMap) SchedulerDBManager(org.ow2.proactive.scheduler.core.db.SchedulerDBManager) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) List(java.util.List) JobDescriptorImpl(org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 55 with TaskResult

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

the class TaskResultCreatorTest method testThatNotFoundTaskResultIsHandled.

@Test
public void testThatNotFoundTaskResultIsHandled() throws UnknownTaskException {
    TaskResultCreator taskResultCreator = new TaskResultCreator();
    TaskResultImpl mockedTaskResultImpl = mock(TaskResultImpl.class);
    Map<TaskId, TaskResult> loadTaskResultsValue = new HashMap<>();
    loadTaskResultsValue.put(this.createTaskID(), mockedTaskResultImpl);
    SchedulerDBManager mockedschedulerDbManager = mock(SchedulerDBManager.class);
    when(mockedschedulerDbManager.loadTasksResults(any(JobId.class), any(List.class))).thenThrow(DatabaseManagerException.class);
    taskResultCreator.getTaskResult(mockedschedulerDbManager, this.getMockedInternalJob(this.getMockedJobDescriptorWithPausedTask()), this.getMockedInternalTask());
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) HashMap(java.util.HashMap) SchedulerDBManager(org.ow2.proactive.scheduler.core.db.SchedulerDBManager) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) List(java.util.List) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Aggregations

TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)99 Test (org.junit.Test)54 JobId (org.ow2.proactive.scheduler.common.job.JobId)38 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)28 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)25 SimpleScript (org.ow2.proactive.scripting.SimpleScript)25 File (java.io.File)24 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)23 TaskScript (org.ow2.proactive.scripting.TaskScript)23 HashMap (java.util.HashMap)22 JobResult (org.ow2.proactive.scheduler.common.job.JobResult)22 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)18 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)17 GET (javax.ws.rs.GET)16 Path (javax.ws.rs.Path)16 Produces (javax.ws.rs.Produces)16 GZIP (org.jboss.resteasy.annotations.GZIP)16 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)14 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)12 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)12