use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class TestJobCoverage method testJobCoverage.
@Test
public void testJobCoverage() throws Throwable {
JobState jstate;
TaskInfo tinfo;
JobInfo jinfo;
// removing temp file if existing
File w3File = new File(System.getProperty("java.io.tmpdir"), "WorkingAt3rdT2_13031984.tmp");
if (w3File.exists()) {
FileUtils.forceDelete(w3File);
}
// job submission
log("Submitting job...");
TaskFlowJob job = (TaskFlowJob) StaxJobFactory.getFactory().createJob(new File(jobDescriptor.toURI()).getAbsolutePath());
JobId id = schedulerHelper.submitJob(job);
// checking all processes
log("Checking all received events :");
jstate = schedulerHelper.waitForEventJobSubmitted(id);
assertEquals(JobStatus.PENDING, jstate.getStatus());
// checking task 1
log("Checking task1 process...");
tinfo = schedulerHelper.waitForEventTaskRunning(id, "task1");
jstate.update(tinfo);
jstate.update(tinfo.getJobInfo());
assertEquals(TaskStatus.RUNNING, tinfo.getStatus());
assertEquals(JobStatus.RUNNING, jstate.getStatus());
tinfo = schedulerHelper.waitForEventTaskFinished(id, "task1");
jstate.update(tinfo);
assertEquals(TaskStatus.FINISHED, tinfo.getStatus());
// checking task 2
log("Checking task2 process...");
tinfo = schedulerHelper.waitForEventTaskRunning(id, "task2");
jstate.update(tinfo);
assertEquals(TaskStatus.RUNNING, tinfo.getStatus());
tinfo = schedulerHelper.waitForEventTaskWaitingForRestart(id, "task2");
jstate.update(tinfo);
assertEquals(TaskStatus.WAITING_ON_ERROR, tinfo.getStatus());
tinfo = schedulerHelper.waitForEventTaskRunning(id, "task2");
jstate.update(tinfo);
assertEquals(TaskStatus.RUNNING, tinfo.getStatus());
tinfo = schedulerHelper.waitForEventTaskFinished(id, "task2");
jstate.update(tinfo);
assertEquals(TaskStatus.FAULTY, tinfo.getStatus());
// checking task 3
log("Checking task3 process...");
tinfo = schedulerHelper.waitForEventTaskRunning(id, "task3");
jstate.update(tinfo);
assertEquals(TaskStatus.RUNNING, tinfo.getStatus());
tinfo = schedulerHelper.waitForEventTaskWaitingForRestart(id, "task3");
jstate.update(tinfo);
assertEquals(TaskStatus.WAITING_ON_ERROR, tinfo.getStatus());
tinfo = schedulerHelper.waitForEventTaskRunning(id, "task3");
jstate.update(tinfo);
assertEquals(TaskStatus.RUNNING, tinfo.getStatus());
tinfo = schedulerHelper.waitForEventTaskWaitingForRestart(id, "task3");
jstate.update(tinfo);
assertEquals(TaskStatus.WAITING_ON_ERROR, tinfo.getStatus());
tinfo = schedulerHelper.waitForEventTaskRunning(id, "task3");
jstate.update(tinfo);
assertEquals(TaskStatus.RUNNING, tinfo.getStatus());
tinfo = schedulerHelper.waitForEventTaskFinished(id, "task3");
jstate.update(tinfo);
assertEquals(TaskStatus.FINISHED, tinfo.getStatus());
// checking task 4
log("Checking task4 process...");
tinfo = schedulerHelper.waitForEventTaskRunning(id, "task4");
jstate.update(tinfo);
assertEquals(TaskStatus.RUNNING, tinfo.getStatus());
tinfo = schedulerHelper.waitForEventTaskFinished(id, "task4");
jstate.update(tinfo);
assertEquals(TaskStatus.FAULTY, tinfo.getStatus());
// checking task 5
log("Checking task5 process...");
tinfo = schedulerHelper.waitForEventTaskRunning(id, "task5");
jstate.update(tinfo);
assertEquals(TaskStatus.RUNNING, tinfo.getStatus());
String hostName = tinfo.getExecutionHostName();
tinfo = schedulerHelper.waitForEventTaskWaitingForRestart(id, "task5");
jstate.update(tinfo);
assertEquals(TaskStatus.WAITING_ON_ERROR, tinfo.getStatus());
tinfo = schedulerHelper.waitForEventTaskRunning(id, "task5");
jstate.update(tinfo);
assertEquals(TaskStatus.RUNNING, tinfo.getStatus());
Assert.assertFalse(hostName.equals(tinfo.getExecutionHostName()));
hostName = tinfo.getExecutionHostName();
tinfo = schedulerHelper.waitForEventTaskWaitingForRestart(id, "task5");
jstate.update(tinfo);
assertEquals(TaskStatus.WAITING_ON_ERROR, tinfo.getStatus());
tinfo = schedulerHelper.waitForEventTaskRunning(id, "task5");
jstate.update(tinfo);
assertEquals(TaskStatus.RUNNING, tinfo.getStatus());
Assert.assertFalse(hostName.equals(tinfo.getExecutionHostName()));
tinfo = schedulerHelper.waitForEventTaskFinished(id, "task5");
jstate.update(tinfo);
assertEquals(TaskStatus.FAULTY, tinfo.getStatus());
// checking task 6
log("Checking task6 process...");
tinfo = schedulerHelper.waitForEventTaskRunning(id, "task6");
jstate.update(tinfo);
assertEquals(TaskStatus.RUNNING, tinfo.getStatus());
tinfo = schedulerHelper.waitForEventTaskFinished(id, "task6");
jstate.update(tinfo);
assertEquals(TaskStatus.FINISHED, tinfo.getStatus());
// checking task 7
log("Checking task7 process...");
tinfo = schedulerHelper.waitForEventTaskRunning(id, "task7");
jstate.update(tinfo);
assertEquals(TaskStatus.RUNNING, tinfo.getStatus());
tinfo = schedulerHelper.waitForEventTaskFinished(id, "task7");
jstate.update(tinfo);
assertEquals(TaskStatus.FAULTY, tinfo.getStatus());
// checking task 8
log("Checking task8 process...");
tinfo = schedulerHelper.waitForEventTaskRunning(id, "task8");
jstate.update(tinfo);
assertEquals(TaskStatus.RUNNING, tinfo.getStatus());
tinfo = schedulerHelper.waitForEventTaskWaitingForRestart(id, "task8");
jstate.update(tinfo);
assertEquals(TaskStatus.WAITING_ON_ERROR, tinfo.getStatus());
tinfo = schedulerHelper.waitForEventTaskRunning(id, "task8");
jstate.update(tinfo);
assertEquals(TaskStatus.RUNNING, tinfo.getStatus());
tinfo = schedulerHelper.waitForEventTaskFinished(id, "task8");
jstate.update(tinfo);
assertEquals(TaskStatus.FAULTY, tinfo.getStatus());
// waiting for job termination
log("Waiting for job to finish...");
jinfo = schedulerHelper.waitForEventJobFinished(id);
// checking results
log("Checking results...");
JobResult result = schedulerHelper.getJobResult(id);
assertEquals(8, result.getAllResults().size());
assertEquals(2, result.getPreciousResults().size());
assertNotNull(result.getPreciousResults().get("task1"));
assertNotNull(result.getPreciousResults().get("task6"));
assertEquals("Working", result.getPreciousResults().get("task1").value());
assertTrue(StackTraceUtil.getStackTrace(result.getResult("task2").getException()).contains("WorkingAt3rd - Status : Number is 1"));
assertTrue(result.getResult("task3").value().toString().contains("WorkingAt3rd - Status : OK / File deleted :"));
assertTrue(result.getResult("task4").getException().getCause().getMessage().contains("Throwing"));
assertTrue(result.getResult("task5").getException().getCause().getMessage().contains("Throwing"));
assertNotNull(result.getResult("task7").getException());
assertNotNull(result.getResult("task8").getException());
// checking end of the job...
jstate.update(jinfo);
assertEquals(0, jinfo.getNumberOfPendingTasks());
assertEquals(0, jinfo.getNumberOfRunningTasks());
assertEquals(8, jinfo.getNumberOfFinishedTasks());
assertEquals(8, jinfo.getTotalNumberOfTasks());
assertEquals(JobStatus.FINISHED, jinfo.getStatus());
assertEquals(0, jstate.getNumberOfPendingTasks());
assertEquals(0, jstate.getNumberOfRunningTasks());
assertEquals(8, jstate.getNumberOfFinishedTasks());
assertEquals(8, jstate.getTotalNumberOfTasks());
assertEquals(JobStatus.FINISHED, jstate.getStatus());
}
use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class SchedulerFrontendState method jobUpdatedFullData.
@Override
public synchronized void jobUpdatedFullData(JobState jobstate) {
ClientJobState storedJobState = new ClientJobState(jobstate);
dispatchJobUpdatedFullData(storedJobState);
}
use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class TestKilledJobResult method test.
@Test
public void test() throws Throwable {
TaskFlowJob job = new TaskFlowJob();
JavaTask task1 = new JavaTask();
task1.setName("task1");
task1.setExecutableClassName(TestJavaTask1.class.getName());
job.addTask(task1);
JavaTask task2 = new JavaTask();
task2.setName("task2");
task2.setExecutableClassName(TestJavaTask2.class.getName());
job.addTask(task2);
task2.addDependence(task1);
log("Submit job");
JobId jobId = schedulerHelper.submitJob(job);
log("Submitted job " + jobId);
log("Waiting for task1 to finish");
schedulerHelper.waitForEventTaskFinished(jobId, "task1");
schedulerHelper.waitForEventTaskRunning(jobId, "task2");
Scheduler scheduler = schedulerHelper.getSchedulerInterface();
log("Killing job");
scheduler.killJob(jobId);
log("Wait when job finishes");
schedulerHelper.waitForEventJobFinished(jobId);
JobResult jobResult = scheduler.getJobResult(jobId);
printResult(jobResult);
assertEquals(1, jobResult.getAllResults().size());
assertEquals("OK", jobResult.getAllResults().get("task1").value().toString());
JobInfo jobInfo = jobResult.getJobInfo();
assertEquals(JobStatus.KILLED, jobInfo.getStatus());
assertEquals(1, jobInfo.getNumberOfFinishedTasks());
assertEquals(2, jobInfo.getTotalNumberOfTasks());
assertEquals(0, jobInfo.getNumberOfPendingTasks());
assertEquals(0, jobInfo.getNumberOfRunningTasks());
JobState state = scheduler.getJobState(jobId);
assertEquals(JobStatus.KILLED, state.getStatus());
assertEquals(1, state.getNumberOfFinishedTasks());
assertEquals(2, state.getTotalNumberOfTasks());
assertEquals(0, state.getNumberOfPendingTasks());
assertEquals(0, state.getNumberOfRunningTasks());
assertEquals(2, state.getTasks().size());
assertEquals(TaskStatus.FINISHED, findTask(state, "task1").getStatus());
assertEquals(TaskStatus.ABORTED, findTask(state, "task2").getStatus());
TaskState taskState0 = state.getTasks().get(0);
TaskState taskState1 = state.getTasks().get(1);
assertTrue(taskState0.getStartTime() > 0);
assertTrue(taskState0.getFinishedTime() > 0);
assertTrue(taskState0.getExecutionDuration() >= 0);
assertTrue(taskState0.getExecutionDuration() <= taskState0.getFinishedTime() - taskState0.getStartTime());
assertTrue(taskState1.getStartTime() > 0);
assertTrue(taskState1.getFinishedTime() > 0);
assertTrue(taskState1.getExecutionDuration() >= 0);
assertTrue(taskState1.getExecutionDuration() <= taskState1.getFinishedTime() - taskState1.getStartTime());
}
use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class RunningTaskRecoveryWithDownNodeTest method checkTasks.
private void checkTasks(JobState jobState) {
int maximumNumberOfPendingTasks = jobState.getNumberOfPendingTasks();
for (int i = 0; i < maximumNumberOfPendingTasks; i++) {
TaskState taskState = jobState.getTasks().get(i);
TaskStatus taskStatus = taskState.getTaskInfo().getStatus();
assertThat(taskStatus.equals(TaskStatus.PENDING) || taskStatus.equals(TaskStatus.RUNNING)).isTrue();
}
}
use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class TestJobNodeAccessToken method testJobNodeAccessToken.
@Test
public void testJobNodeAccessToken() throws Throwable {
JobId id = schedulerHelper.submitJob(new File(simpleJob.toURI()).getAbsolutePath());
SchedulerTHelper.log("Job submitted, id " + id.toString());
schedulerHelper.waitForEventJobSubmitted(id);
JobId id2 = schedulerHelper.submitJob(new File(simpleJobWithToken.toURI()).getAbsolutePath());
SchedulerTHelper.log("Job submitted, id " + id2.toString());
schedulerHelper.waitForEventJobSubmitted(id2);
schedulerHelper.waitForEventJobFinished(id);
JobState js = schedulerHelper.getSchedulerInterface().getJobState(id2);
assertEquals(JobStatus.PENDING, js.getStatus());
// adding node with the token "test_token"
rm = schedulerHelper.getResourceManager();
byte[] creds = FileToBytesConverter.convertFileToByteArray(new File(PAResourceManagerProperties.getAbsolutePath(PAResourceManagerProperties.RM_CREDS.getValueAsString())));
String nsProps = "-D" + RMNodeStarter.NODE_ACCESS_TOKEN + "=test_token";
assertTrue(rm.createNodeSource(nsName, LocalInfrastructure.class.getName(), new Object[] { creds, 1, RMTHelper.DEFAULT_NODES_TIMEOUT, nsProps }, StaticPolicy.class.getName(), null, NODES_RECOVERABLE).getBooleanValue());
nsCreated = true;
// ns created
schedulerHelper.waitForNodeSourceEvent(RMEventType.NODESOURCE_CREATED, nsName);
// deploying
schedulerHelper.waitForAnyNodeEvent(RMEventType.NODE_ADDED);
// from deploying
schedulerHelper.waitForAnyNodeEvent(RMEventType.NODE_REMOVED);
// to configuring
schedulerHelper.waitForAnyNodeEvent(RMEventType.NODE_ADDED);
// free
schedulerHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
schedulerHelper.waitForEventJobFinished(id2);
}
Aggregations