use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class TestUnauthorizedScripts method testUnAuthorizedSelectionScripts.
@Test
public void testUnAuthorizedSelectionScripts() throws Exception {
Job job = createJobSelection(unauthorizedSelectionScriptContent);
JobId id = schedulerHelper.submitJob(job);
Thread.sleep(10000);
File selectionOut = new File(folder.getRoot().getAbsolutePath(), "selection.out");
Assert.assertFalse("File created by the unauthorized selection script should NOT exist", selectionOut.exists());
Assert.assertEquals(JobStatus.PENDING, schedulerHelper.getSchedulerInterface().getJobState(id).getStatus());
schedulerHelper.getSchedulerInterface().killJob(id);
}
use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class TestJobCleaningScriptVariables method testJobCleaningScriptVariables.
@Test
public void testJobCleaningScriptVariables() throws Throwable {
HashMap<String, String> variables = new HashMap<>();
File ko = new File(tmpDir.getRoot(), "ko");
variables.put("path", ko.toString());
variables.put("test", "initialValue");
JobId jobId = schedulerHelper.submitJob(new File(jobDescriptor.toURI()).getAbsolutePath(), variables);
schedulerHelper.waitForEventJobFinished(jobId);
while (schedulerHelper.getResourceManager().getState().getFreeNodesNumber() != SchedulerStartForFunctionalTest.RM_NODE_NUMBER) ;
if (ko.exists()) {
String content;
content = FileUtils.readFileToString(ko);
Assert.fail(content);
}
}
use of org.ow2.proactive.scheduler.common.job.JobId 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.job.JobId in project scheduling by ow2-proactive.
the class TestTasksCompleteAfterSelectiontimeout method testJobCompleteAfterTimeout.
@Test(timeout = 30000)
public void testJobCompleteAfterTimeout() throws Throwable {
String task1Name = "toBeCompletetd1";
String task2Name = "toBeCompletetd2";
String task3Name = "toBeCompletetd3";
String task4Name = "toBeCompletetd4";
String task5Name = "toBeCompletetd5";
// cannot use SchedulerTHelper.testJobsubmission because
// task 3 is never executed so no event can be 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);
log("Waiting for task running : " + task2Name);
schedulerHelper.waitForEventTaskRunning(id, task2Name);
log("Waiting for task finished : " + task2Name);
schedulerHelper.waitForEventTaskFinished(id, task2Name);
log("Waiting for task running : " + task3Name);
schedulerHelper.waitForEventTaskRunning(id, task3Name);
log("Waiting for task finished : " + task3Name);
schedulerHelper.waitForEventTaskFinished(id, task3Name);
log("Waiting for task running : " + task4Name);
schedulerHelper.waitForEventTaskRunning(id, task4Name);
log("Waiting for task finished : " + task4Name);
schedulerHelper.waitForEventTaskFinished(id, task4Name);
log("Waiting for task running : " + task5Name);
schedulerHelper.waitForEventTaskRunning(id, task5Name);
log("Waiting for task finished : " + task5Name);
schedulerHelper.waitForEventTaskFinished(id, task5Name);
}
use of org.ow2.proactive.scheduler.common.job.JobId 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