use of org.ow2.proactive.scheduler.rest.data.TaskResultImpl in project scheduling by ow2-proactive.
the class TestTaskResultData method testMultipleJobs.
@Test
public void testMultipleJobs() throws Throwable {
// two jobs have tasks with the same name
TaskFlowJob jobDef1 = new TaskFlowJob();
jobDef1.addTask(createDefaultTask("task1"));
TaskFlowJob jobDef2 = new TaskFlowJob();
jobDef2.addTask(createDefaultTask("task1"));
InternalJob job1 = defaultSubmitJobAndLoadInternal(true, jobDef1);
InternalJob job2 = defaultSubmitJobAndLoadInternal(true, jobDef2);
dbManager.updateAfterTaskFinished(job1, job1.getTask("task1"), new TaskResultImpl(null, new TestResult(0, "job1Res"), null, 0));
dbManager.updateAfterTaskFinished(job2, job2.getTask("task1"), new TaskResultImpl(null, new TestResult(0, "job2Res"), null, 0));
TestResult result;
result = (TestResult) dbManager.loadTaskResult(job1.getId(), "task1", 0).value();
Assert.assertEquals("job1Res", result.getB());
result = (TestResult) dbManager.loadTaskResult(job2.getId(), "task1", 0).value();
Assert.assertEquals("job2Res", result.getB());
}
use of org.ow2.proactive.scheduler.rest.data.TaskResultImpl in project scheduling by ow2-proactive.
the class TestTaskResultData method testLog4jLogs.
@Test
public void testLog4jLogs() throws Exception {
InternalJob job = saveSingleTask(createDefaultTask("task"));
InternalTask task = (InternalTask) job.getTasks().get(0);
LinkedList<LoggingEvent> events = new LinkedList<>();
for (int i = 0; i < 3; i++) {
events.add(new LoggingEvent("", Logger.getLogger(TestTaskResultData.class), Level.INFO, "info" + i, null));
events.add(new LoggingEvent("", Logger.getLogger(TestTaskResultData.class), Level.ERROR, "error" + i, null));
}
TaskResultImpl result = new TaskResultImpl(null, "result", new Log4JTaskLogs(events, "0"), 0);
dbManager.updateAfterTaskFinished(job, task, result);
TaskResult restoredResult = dbManager.loadLastTaskResult(task.getId());
TaskLogs logs = restoredResult.getOutput();
Assert.assertNotNull(logs);
String logsString = logs.getStdoutLogs(false);
Assert.assertTrue(logsString.contains("info0"));
Assert.assertTrue(logsString.contains("info1"));
Assert.assertTrue(logsString.contains("info2"));
logsString = logs.getStderrLogs(false);
Assert.assertTrue(logsString.contains("error0"));
Assert.assertTrue(logsString.contains("error1"));
Assert.assertTrue(logsString.contains("error2"));
}
use of org.ow2.proactive.scheduler.rest.data.TaskResultImpl in project scheduling by ow2-proactive.
the class TestUsageData method finishTask.
private void finishTask(InternalJob job, InternalTask task) throws Exception {
Thread.sleep(10);
TaskResultImpl res = new TaskResultImpl(null, "ok", null, 42);
job.terminateTask(false, task.getId(), null, null, res);
if (job.isFinished()) {
job.terminate();
}
dbManager.updateAfterTaskFinished(job, task, res);
}
use of org.ow2.proactive.scheduler.rest.data.TaskResultImpl in project scheduling by ow2-proactive.
the class SchedulerDBManagerTest method terminateJob.
private void terminateJob(int jobIndex, long finishedTime) throws Throwable {
InternalJob finishedJob = actualInternalJobs.get(jobIndex);
finishedJob.start();
finishedJob.terminate();
for (InternalTask task : finishedJob.getITasks()) {
TaskResultImpl result = new TaskResultImpl(task.getId(), "ok", null, 0);
FlowAction action = new FlowAction(FlowActionType.CONTINUE);
ChangedTasksInfo changesInfo = finishedJob.terminateTask(false, task.getId(), null, action, result);
task.setFinishedTime(finishedTime);
dbManager.updateAfterWorkflowTaskFinished(finishedJob, changesInfo, result);
}
}
use of org.ow2.proactive.scheduler.rest.data.TaskResultImpl 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);
}
Aggregations