use of org.ow2.proactive.scheduler.common.task.TaskInfo in project scheduling by ow2-proactive.
the class TaskResultCreatorTest method getMockedInternalTask.
private InternalTask getMockedInternalTask() {
InternalTask mockedInternalTask = mock(InternalScriptTask.class);
TaskInfo mockedTaskInfo = this.getMockedTaskInfo();
when(mockedInternalTask.getTaskInfo()).thenReturn(mockedTaskInfo);
when(mockedInternalTask.getId()).thenReturn(this.createTaskID());
when(mockedInternalTask.handleResultsArguments()).thenReturn(true);
return mockedInternalTask;
}
use of org.ow2.proactive.scheduler.common.task.TaskInfo in project scheduling by ow2-proactive.
the class TaskResultCreatorTest method getMockedTaskInfo.
private TaskInfo getMockedTaskInfo() {
TaskInfo mockedTaskInfo = mock(TaskInfo.class);
when(mockedTaskInfo.getJobId()).thenReturn(this.createJobId());
when(mockedTaskInfo.getTaskId()).thenReturn(this.createTaskID());
return mockedTaskInfo;
}
use of org.ow2.proactive.scheduler.common.task.TaskInfo in project scheduling by ow2-proactive.
the class JobDescriptorImplTest method testThatDoLoopPausesNewlyCreatedTasksIfJobIsPaused.
@Test
public void testThatDoLoopPausesNewlyCreatedTasksIfJobIsPaused() {
JobDescriptorImpl pausedJob = createEmptyJobDescriptor();
pausedJob.getInternal().setStatus(JobStatus.PAUSED);
// Create mocks for the loop root task
TaskId runningRootTaskId = TaskIdImpl.createTaskId(new JobIdImpl(1L, "Root"), "FirstLoopTask", 1L);
EligibleTaskDescriptorImpl mockLoopStartCurrentlyRunningTask = mock(EligibleTaskDescriptorImpl.class);
InternalTask mockInternalLoopRootTask = mock(InternalTask.class);
when(mockInternalLoopRootTask.getId()).thenReturn(runningRootTaskId);
when(mockLoopStartCurrentlyRunningTask.getTaskId()).thenReturn(runningRootTaskId);
when(mockLoopStartCurrentlyRunningTask.getInternal()).thenReturn(mockInternalLoopRootTask);
when(mockLoopStartCurrentlyRunningTask.getChildren()).thenReturn(new Vector<TaskDescriptor>());
// Create mocks for the new loop task
TaskId newLoopTaskId = TaskIdImpl.createTaskId(new JobIdImpl(1L, "Root"), "SecondLoopTask", 2L);
EligibleTaskDescriptorImpl mockLoopNewCreatedTaskForLoop = mock(EligibleTaskDescriptorImpl.class);
InternalTask mockInternalNewLoopTask = mock(InternalTask.class);
TaskInfo mockNewTaskTaskInfo = mock(TaskInfo.class);
when(mockNewTaskTaskInfo.getTaskId()).thenReturn(newLoopTaskId);
when(mockInternalNewLoopTask.getId()).thenReturn(newLoopTaskId);
when(mockInternalNewLoopTask.getStatus()).thenReturn(TaskStatus.SUBMITTED);
when(mockInternalNewLoopTask.getTaskInfo()).thenReturn(mockNewTaskTaskInfo);
when(mockLoopNewCreatedTaskForLoop.getTaskId()).thenReturn(newLoopTaskId);
when(mockLoopNewCreatedTaskForLoop.getInternal()).thenReturn(mockInternalNewLoopTask);
// Put the root loop task into running tasks, because it just terminated
pausedJob.getRunningTasks().put(mockLoopStartCurrentlyRunningTask.getTaskId(), mockLoopStartCurrentlyRunningTask);
// Put the new loop task into the Map, this is clue so that the test works
HashMap<TaskId, InternalTask> workflowTree = new HashMap<>();
workflowTree.put(newLoopTaskId, mockInternalNewLoopTask);
pausedJob.doLoop(mockLoopStartCurrentlyRunningTask.getTaskId(), workflowTree, mockLoopNewCreatedTaskForLoop.getInternal(), mockLoopNewCreatedTaskForLoop.getInternal());
verify(mockInternalNewLoopTask).setStatus(TaskStatus.PAUSED);
}
use of org.ow2.proactive.scheduler.common.task.TaskInfo in project scheduling by ow2-proactive.
the class AbstractSmartProxy method updateTask.
/**
* Check if the task concerned by this notification is awaited. Retrieve
* corresponding data if needed
*
* @param notification
*/
protected void updateTask(NotificationData<TaskInfo> notification) {
// am I interested in this task?
TaskInfo taskInfoData = notification.getData();
JobId id = taskInfoData.getJobId();
TaskId tid = taskInfoData.getTaskId();
String tname = tid.getReadableName();
TaskStatus status = taskInfoData.getStatus();
AwaitedJob aj = jobTracker.getAwaitedJob(id.toString());
if (aj == null)
return;
AwaitedTask at = aj.getAwaitedTask(tname);
if (at == null)
return;
at.setTaskId(tid.toString());
jobTracker.putAwaitedJob(id.toString(), aj);
switch(status) {
case ABORTED:
case NOT_RESTARTED:
case NOT_STARTED:
case SKIPPED:
{
log.debug("The task " + tname + " from job " + id + " couldn't start. No data will be transfered");
jobTracker.removeAwaitedTask(id.toString(), tname);
break;
}
case FINISHED:
{
log.debug("The task " + tname + " from job " + id + " is finished.");
if (aj.isAutomaticTransfer()) {
log.debug("Transferring data for finished task " + tname + " from job " + id);
try {
downloadTaskOutputFiles(aj, id.toString(), tname, aj.getLocalOutputFolder());
} catch (Throwable t) {
log.error("Error while handling data for finished task " + tname + " for job " + id + ", task will be removed");
jobTracker.removeAwaitedTask(id.toString(), tname);
}
}
break;
}
case FAILED:
case FAULTY:
{
log.debug("The task " + tname + " from job " + id + " is faulty.");
jobTracker.removeAwaitedTask(id.toString(), tname);
break;
}
}
}
use of org.ow2.proactive.scheduler.common.task.TaskInfo in project scheduling by ow2-proactive.
the class TestJobNativeSubmission method testJobNativeSubmission.
@Test
public void testJobNativeSubmission() throws Throwable {
// test submission and event reception
TaskFlowJob job = new TaskFlowJob();
NativeTask successfulTask = new NativeTask();
successfulTask.setName("successfulTask");
if (OperatingSystem.getOperatingSystem() == OperatingSystem.windows) {
successfulTask.setCommandLine("cmd", "/C", "ping 127.0.0.1 -n 10", ">", "NUL");
} else {
successfulTask.setCommandLine("ping", "-c", "5", "127.0.0.1");
}
job.addTask(successfulTask);
NativeTask invalidCommandTask = new NativeTask();
invalidCommandTask.setName("invalidCommandTask");
invalidCommandTask.addDependence(successfulTask);
invalidCommandTask.setCommandLine("invalid_command");
job.addTask(invalidCommandTask);
// SCHEDULING-1987
NativeTask taskReadingInput = new NativeTask();
taskReadingInput.setName("taskReadingInput");
if (OperatingSystem.getOperatingSystem() == OperatingSystem.windows) {
// wait for y/n
taskReadingInput.setCommandLine("choice");
} else {
// cat hangs for user's input
taskReadingInput.setCommandLine("cat");
}
job.addTask(taskReadingInput);
JobId id = schedulerHelper.submitJob(job);
log("Job submitted, id " + id.toString());
log("Waiting for jobSubmitted Event");
JobState receivedState = schedulerHelper.waitForEventJobSubmitted(id);
assertEquals(receivedState.getId(), id);
log("Waiting for job running");
JobInfo jInfo = schedulerHelper.waitForEventJobRunning(id);
assertEquals(jInfo.getJobId(), id);
assertEquals(JobStatus.RUNNING, jInfo.getStatus());
schedulerHelper.waitForEventTaskRunning(id, successfulTask.getName());
TaskInfo tInfo = schedulerHelper.waitForEventTaskFinished(id, successfulTask.getName());
assertEquals(TaskStatus.FINISHED, tInfo.getStatus());
schedulerHelper.waitForEventTaskRunning(id, invalidCommandTask.getName());
tInfo = schedulerHelper.waitForEventTaskFinished(id, invalidCommandTask.getName());
assertEquals(TaskStatus.FAULTY, tInfo.getStatus());
TaskInfo taskReadingInputInfo = schedulerHelper.waitForEventTaskFinished(id, taskReadingInput.getName());
if (OperatingSystem.getOperatingSystem() == OperatingSystem.windows) {
// choice fails when input is closed
assertEquals(TaskStatus.FAULTY, taskReadingInputInfo.getStatus());
} else {
assertEquals(TaskStatus.FINISHED, taskReadingInputInfo.getStatus());
}
schedulerHelper.waitForEventJobFinished(id);
// remove job
schedulerHelper.removeJob(id);
schedulerHelper.waitForEventJobRemoved(id);
}
Aggregations