use of org.ow2.proactive.scheduler.common.task.NativeTask in project scheduling by ow2-proactive.
the class TestTaskAttributes method testEmptyAttributes.
@Test
public void testEmptyAttributes() throws Exception {
JavaTask javaTask = createDefaultTask("task1");
InternalTask taskData = saveSingleTask(javaTask).getTask("task1");
Assert.assertNotNull(taskData.getId());
NativeTask nativeTask = new NativeTask();
nativeTask.setName("task1");
nativeTask.setCommandLine("commandline");
taskData = saveSingleTask(nativeTask).getTask("task1");
Assert.assertNotNull(taskData.getId());
}
use of org.ow2.proactive.scheduler.common.task.NativeTask in project scheduling by ow2-proactive.
the class TestTaskRuntimeData method testTaskTypes.
@Test
public void testTaskTypes() throws Exception {
TaskFlowJob jobDef = new TaskFlowJob();
JavaTask taskDef1 = createDefaultTask("task1");
jobDef.addTask(taskDef1);
JavaTask taskDef2 = createDefaultTask("task2");
taskDef2.setForkEnvironment(new ForkEnvironment());
jobDef.addTask(taskDef2);
NativeTask taskDef3 = new NativeTask();
taskDef3.setName("task3");
taskDef3.setCommandLine("commandline");
jobDef.addTask(taskDef3);
InternalJob job = defaultSubmitJobAndLoadInternal(false, jobDef);
// by default all tasks are executed in a forked JVM
for (int i = 1; i <= 3; i++) {
Assert.assertEquals(InternalForkedScriptTask.class, job.getTask("task" + i).getClass());
}
}
use of org.ow2.proactive.scheduler.common.task.NativeTask in project scheduling by ow2-proactive.
the class TestErrorAndFailure method testErrorAndFailure.
@Test
public void testErrorAndFailure() throws Throwable {
String javaCmd = System.getProperty("java.home") + "/bin/java";
log("Test 1 : Creating job...");
// creating job
TaskFlowJob submittedJob = new TaskFlowJob();
submittedJob.setName(this.getClass().getSimpleName() + "_12_tasks");
submittedJob.setDescription("12 tasks job testing the behavior of error code and normal task ending.");
submittedJob.setMaxNumberOfExecution(10);
NativeTask finalTask = new NativeTask();
finalTask.setName("TestMerge");
finalTask.setCommandLine(new String[] { javaCmd, "-cp", TestScheduler.testClasspath(), NativeTestWithRandomDefault.class.getName(), "final" });
for (int i = 1; i < 6; i++) {
NativeTask task = new NativeTask();
task.setName("Test" + i);
task.setCommandLine(new String[] { javaCmd, "-cp", TestScheduler.testClasspath(), NativeTestWithRandomDefault.class.getName(), "0" });
finalTask.addDependence(task);
submittedJob.addTask(task);
}
submittedJob.addTask(finalTask);
// test submission and event reception
JobId id = schedulerHelper.submitJob(submittedJob);
log("Job submitted, id " + id.toString());
log("Waiting for jobSubmitted Event");
Job receivedJob = schedulerHelper.waitForEventJobSubmitted(id);
assertEquals(receivedJob.getId(), id);
log("Waiting for job running");
JobInfo jInfo = schedulerHelper.waitForEventJobRunning(id);
assertEquals(jInfo.getJobId(), id);
// TODO how to check that ?
for (Task t : submittedJob.getTasks()) {
log("Waiting for task running : " + t.getName());
schedulerHelper.waitForEventTaskRunning(id, t.getName());
}
for (Task t : submittedJob.getTasks()) {
log("Waiting for task finished : " + t.getName());
schedulerHelper.waitForEventTaskFinished(id, t.getName());
}
log("Waiting for job finished");
jInfo = schedulerHelper.waitForEventJobFinished(id);
assertEquals(JobStatus.FINISHED, jInfo.getStatus());
// check job results
JobResult res = schedulerHelper.getJobResult(id);
// Check the results
Map<String, TaskResult> results = res.getAllResults();
// check that number of results correspond to number of tasks
assertEquals(submittedJob.getTasks().size(), results.size());
// remove jobs and check its event
schedulerHelper.removeJob(id);
log("Waiting for job removed");
jInfo = schedulerHelper.waitForEventJobRemoved(id);
assertEquals(JobStatus.FINISHED, jInfo.getStatus());
assertEquals(jInfo.getJobId(), id);
}
Aggregations