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());
}
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());
}
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);
}
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();
}
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());
}
Aggregations