use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class TestTaskNotRestarted method test.
@Test
public void test() throws Exception {
Scheduler scheduler = schedulerHelper.getSchedulerInterface();
JobId jobId = scheduler.submit(createJob());
JobState jobState;
schedulerHelper.waitForEventTaskRunning(jobId, "task1");
jobState = scheduler.getJobState(jobId);
assertEquals(1, jobState.getTasks().size());
assertEquals(TaskStatus.RUNNING, jobState.getTasks().get(0).getStatus());
scheduler.restartTask(jobId, "task1", Integer.MAX_VALUE);
jobState = scheduler.getJobState(jobId);
assertEquals(1, jobState.getTasks().size());
assertEquals(TaskStatus.WAITING_ON_ERROR, jobState.getTasks().get(0).getStatus());
scheduler.killJob(jobId);
jobState = scheduler.getJobState(jobId);
assertEquals(1, jobState.getTasks().size());
assertEquals(TaskStatus.NOT_RESTARTED, jobState.getTasks().get(0).getStatus());
}
use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class TestTaskNotStarted method test.
@Test
public void test() throws Exception {
Scheduler scheduler = schedulerHelper.getSchedulerInterface();
JobId jobId;
JobState jobState;
jobId = scheduler.submit(createJob1());
jobState = scheduler.getJobState(jobId);
assertEquals(1, jobState.getTasks().size());
assertEquals(TaskStatus.SUBMITTED, jobState.getTasks().get(0).getStatus());
scheduler.killJob(jobId);
jobState = scheduler.getJobState(jobId);
assertEquals(1, jobState.getTasks().size());
assertEquals(TaskStatus.NOT_STARTED, jobState.getTasks().get(0).getStatus());
jobId = scheduler.submit(createJob2());
schedulerHelper.waitForEventJobRunning(jobId);
jobState = scheduler.getJobState(jobId);
assertEquals(2, jobState.getTasks().size());
assertEquals(TaskStatus.PENDING, getTask(jobState, "task2").getStatus());
scheduler.killJob(jobId);
jobState = scheduler.getJobState(jobId);
assertEquals(2, jobState.getTasks().size());
assertEquals(TaskStatus.NOT_STARTED, getTask(jobState, "task2").getStatus());
}
use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class TestTaskNotExecuted method testTaskNotExecuted.
private void testTaskNotExecuted(String jobDescriptorPath1, String jobDescriptorPath2, String jobDescriptorPath3) throws Exception {
log("Submitting job 1");
JobId id1 = schedulerHelper.submitJob(jobDescriptorPath1);
log("Wait for event job 1 submitted");
schedulerHelper.waitForEventJobSubmitted(id1);
log("Wait for event t1 running");
schedulerHelper.waitForEventTaskRunning(id1, "t0");
schedulerHelper.waitForEventTaskFinished(id1, "t0");
schedulerHelper.waitForEventJobFinished(id1);
TaskResult tr1 = schedulerHelper.getSchedulerInterface().getTaskResult(id1, "t1");
assertTrue(tr1.getException() instanceof TaskCouldNotStartException);
log("Submitting job 2");
JobId id2 = schedulerHelper.submitJob(jobDescriptorPath2);
log("Wait for event job 2 submitted");
schedulerHelper.waitForEventJobSubmitted(id2);
log("Wait for event t2 running");
schedulerHelper.waitForEventTaskRunning(id2, "t2");
log("Restarting task");
schedulerHelper.getSchedulerInterface().restartTask(id2, "t2", Integer.MAX_VALUE);
TaskInfo ti2 = schedulerHelper.waitForEventTaskWaitingForRestart(id2, "t2");
schedulerHelper.getSchedulerInterface().killJob(id2);
schedulerHelper.waitForEventJobFinished(id2);
JobState jobState = schedulerHelper.getSchedulerInterface().getJobState(id2);
Assert.assertEquals(TaskStatus.NOT_RESTARTED, jobState.getTasks().get(0).getStatus());
TaskResult tr2 = schedulerHelper.getSchedulerInterface().getTaskResult(id2, "t2");
assertTrue(tr2.getException() instanceof TaskCouldNotRestartException);
log("Submitting job 3");
JobId id3 = schedulerHelper.submitJob(jobDescriptorPath3);
log("Wait for event job 3 submitted");
schedulerHelper.waitForEventJobSubmitted(id3);
log("Wait for event T T1 T2 finished");
schedulerHelper.waitForEventTaskFinished(id3, "T");
schedulerHelper.waitForEventTaskFinished(id3, "T1");
TaskResult tr3_1 = schedulerHelper.getSchedulerInterface().getTaskResult(id3, "T1");
TaskResult tr3_2 = schedulerHelper.getSchedulerInterface().getTaskResult(id3, "T2");
assertNull(tr3_1.getException());
assertTrue(tr3_2.getException() instanceof TaskSkippedException);
}
use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class TestTaskRestartOnNodeFailure method checkJobResult.
private void checkJobResult(Scheduler scheduler, JobId jobId) throws Exception {
JobResult jobResult = scheduler.getJobResult(jobId);
assertEquals("Unexpected number of task results", 1, jobResult.getAllResults().size());
for (TaskResult taskResult : jobResult.getAllResults().values()) {
log("Task " + taskResult.getTaskId());
assertNull("Unexpected task result exception", taskResult.getException());
String output = taskResult.getOutput().getAllLogs(false);
log("Task output:");
log(output);
assertTrue("Unxepected output", output.contains("OK"));
}
}
use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class TestTaskRestartOnNodeFailure method testTaskKillNode.
private void testTaskKillNode(FileLock fileLock, boolean waitBeforeKill) throws Exception {
Path fileLockPath = fileLock.lock();
TestNode nodeToKill = startNode();
log("Submit job");
final JobId jobId = schedulerHelper.submitJob(createJob(fileLockPath.toString()));
log("Wait when node becomes busy");
RMNodeEvent event;
do {
event = schedulerHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED, TIMEOUT);
} while (!event.getNodeState().equals(NodeState.BUSY));
log("Wait when task starts");
schedulerHelper.waitForEventTaskRunning(jobId, "Test task");
/*
* Want to test two cases (existed at the time of this writing): - if wait some time before
* killing node then node failure is detected by the pinger thread - if kill node
* immediately then node failure is detected by the thread calling TaskLauncher.doTask
*/
if (waitBeforeKill) {
log("Wait some time");
Thread.sleep(5000);
}
log("Stop task node process (node " + nodeToKill.getNode().getNodeInformation().getURL() + ")");
nodeToKill.kill();
TestNode newNode = startNode();
log("Let task finish");
fileLock.unlock();
log("Wait when job finish");
schedulerHelper.waitForEventJobFinished(jobId, TIMEOUT);
event = schedulerHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, newNode.getNode().getNodeInformation().getURL(), TIMEOUT);
assertEquals(NodeState.BUSY, event.getNodeState());
event = schedulerHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, newNode.getNode().getNodeInformation().getURL(), TIMEOUT);
assertEquals(NodeState.FREE, event.getNodeState());
log("Check job result");
checkJobResult(schedulerHelper.getSchedulerInterface(), jobId);
schedulerHelper.getResourceManager().removeNode(newNode.getNodeURL(), true);
newNode.kill();
}
Aggregations