use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class TestJobServerLogs method test.
@Test
public void test() throws Exception {
JobId simpleJobId = schedulerHelper.submitJob(new File(simpleJobDescriptor.toURI()).getAbsolutePath());
String taskName = "task1";
TaskInfo ti = schedulerHelper.waitForEventTaskRunning(simpleJobId, taskName);
String taskLogs = schedulerHelper.getSchedulerInterface().getTaskServerLogs(simpleJobId.toString(), taskName);
if (!taskLogs.contains("task " + ti.getTaskId() + " (" + ti.getTaskId().getReadableName() + ")" + " started")) {
log("Incorrect task server logs:");
log(taskLogs);
fail("Task " + ti.getTaskId() + " was not scheduled");
}
schedulerHelper.waitForEventJobFinished(simpleJobId);
String jobLogs = schedulerHelper.getSchedulerInterface().getJobServerLogs(simpleJobId.toString());
for (int i = 0; i < TASKS_IN_SIMPLE_JOB; i++) {
TaskId taskId = TaskIdImpl.createTaskId(simpleJobId, "task" + (i + 1), i);
String taskIdString = taskId.toString();
String taskIdStringQuoted = Pattern.quote(taskIdString);
if (!matchLine(jobLogs, "task " + taskIdStringQuoted + " \\(task[12]\\) started")) {
log("Incorrect job server logs");
log(jobLogs);
fail("Task " + taskIdString + " was not scheduled");
}
if (!matchLine(jobLogs, "task " + taskIdStringQuoted + " \\(task[12]\\) finished")) {
log("Incorrect job server logs");
log(jobLogs);
fail("Task " + taskIdString + " was not finished");
}
}
checkRemoval(simpleJobId);
JobId pendingJobId = schedulerHelper.submitJob(createPendingJob());
Thread.sleep(5000);
jobLogs = schedulerHelper.getSchedulerInterface().getJobServerLogs(pendingJobId.toString());
if (!jobLogs.contains("will get 0 nodes")) {
log("Incorrect job server logs");
log(jobLogs);
fail("RM output is not correct");
}
if (!jobLogs.contains(SCRIPT_OUTPUT)) {
log("Incorrect job server logs");
log(jobLogs);
fail("No script output");
}
checkRemoval(pendingJobId);
}
use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class TestJobServerLogs method checkNoLogsFromAPI.
private void checkNoLogsFromAPI(JobId jobId, List<TaskState> tasks) throws Exception {
Scheduler scheduler = schedulerHelper.getSchedulerInterface();
try {
scheduler.getJobServerLogs(jobId.toString());
fail("getJobServerLogs should throw an exception for a removed job");
} catch (UnknownJobException expected) {
}
for (TaskState taskState : tasks) {
try {
scheduler.getTaskServerLogs(jobId.toString(), taskState.getName());
fail("getTaskServerLogs should throw an exception for a removed job");
} catch (UnknownJobException expected) {
}
}
}
use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class TestJobServerLogs method checkRemoval.
public void checkRemoval(JobId jobId) throws Exception {
JobState jobState = schedulerHelper.getSchedulerInterface().getJobState(jobId);
List<TaskState> tasks = jobState.getTasks();
checkJobAndTaskLogFiles(jobId, tasks, true);
// Before it was only job removal but it was bug prone (for pendingJob only)
// because the following sequence of the events could happen:
// 1. SchedulerMethodImpl main loop retrieves info about this forever pending job
// 2. we call removeJob
// 3. SchedulerMethodImpl main loop asks for RM::getRMNodes.
//
// Third action would print "[SelectionManager.doSelectNodes] "scheduler"..." to the task log
// which would actually re-created removed log file which would cause an error
// in the last line of this method
// that is why kill the job and after wait 5s to make sure that
// iteration of SchedulerMethodImpl main loop is finished,
// and finally, we remove job with its log files.
schedulerHelper.killJob(jobId.value());
Thread.sleep(5000);
schedulerHelper.removeJob(jobId);
schedulerHelper.waitForEventJobRemoved(jobId);
System.out.println("Suppose to remove all logs at " + simpleDateFormat.format(new Date()));
checkNoLogsFromAPI(jobId, tasks);
checkJobAndTaskLogFiles(jobId, tasks, false);
}
use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class TestPreciousLogs method testPreciousLogs.
private void testPreciousLogs(boolean createJavaTask, boolean forkEnv) throws Exception {
TaskFlowJob job = new TaskFlowJob();
job.setName(this.getClass().getSimpleName());
Map<String, List<String>> expectedOutput = new LinkedHashMap<>();
for (int i = 0; i < 3; i++) {
String forkOutput = "forkOutput-" + i;
String preOutput = "preOutput-" + i;
String postOutput = "postOutput-" + i;
List<String> expectedTaskOutput = new ArrayList<>();
expectedTaskOutput.add(TASK_OUTPUT);
expectedTaskOutput.add(preOutput);
expectedTaskOutput.add(postOutput);
Task task;
if (createJavaTask) {
JavaTask javaTask = new JavaTask();
javaTask.setExecutableClassName(TestJavaTask.class.getName());
if (forkEnv) {
ForkEnvironment env = new ForkEnvironment();
env.setEnvScript(createScript(forkOutput));
javaTask.setForkEnvironment(env);
expectedTaskOutput.add(forkOutput);
}
task = javaTask;
} else {
NativeTask nativeTask = new NativeTask();
File script = new File(getClass().getResource("/functionaltests/executables/test_echo_task.sh").getFile());
if (!script.exists()) {
Assert.fail("Can't find script " + script.getAbsolutePath());
}
nativeTask.setCommandLine(script.getAbsolutePath());
task = nativeTask;
}
task.setMaxNumberOfExecution(1);
task.setOnTaskError(OnTaskError.CANCEL_JOB);
task.setPreciousLogs(true);
task.setName("Task-" + i);
task.setPreScript(createScript(preOutput));
task.setPostScript(createScript(postOutput));
expectedOutput.put(task.getName(), expectedTaskOutput);
job.addTask(task);
}
JobId jobId = schedulerHelper.testJobSubmission(job);
Scheduler scheduler = schedulerHelper.getSchedulerInterface();
String userURI = scheduler.getUserSpaceURIs().get(0);
String userPath = new File(new URI(userURI)).getAbsolutePath();
JobResult jobResult = scheduler.getJobResult(jobId);
Map<String, TaskResult> results = jobResult.getAllResults();
for (String taskName : expectedOutput.keySet()) {
File taskLog = new File(userPath + "/" + jobId.value(), String.format("TaskLogs-%s-%s.log", jobId.value(), results.get(taskName).getTaskId().value()));
if (!taskLog.exists()) {
Assert.fail("Task log file " + taskLog.getAbsolutePath() + " doesn't exist");
}
String output = new String(FileToBytesConverter.convertFileToByteArray(taskLog));
System.out.println("Log file for " + taskName + ":");
System.out.println(output);
for (String expectedLine : expectedOutput.get(taskName)) {
Assert.assertTrue("Output doesn't contain line " + expectedLine, output.contains(expectedLine));
}
}
}
use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class TestJobMultiNodesWalltime method testJobMultiNodesWalltime.
@Test
public void testJobMultiNodesWalltime() throws Throwable {
// submit job
JobId id = schedulerHelper.submitJob(new File(jobDescriptor.toURI()).getAbsolutePath());
// connect to RM
schedulerHelper.addExtraNodes(3);
// wait job is running
schedulerHelper.waitForEventJobRunning(id);
// wait for job to be finished
schedulerHelper.waitForEventJobFinished(id, TIMEOUT);
// remove job
schedulerHelper.removeJob(id);
schedulerHelper.waitForEventJobRemoved(id);
}
Aggregations