use of org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId in project scheduling by ow2-proactive.
the class LiveJobsTest method testTaskTerminatedWithResultSuspendTaskOnErrorLastExecution.
@Test(timeout = 60000)
public void testTaskTerminatedWithResultSuspendTaskOnErrorLastExecution() throws UnknownTaskException {
InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
JobId id = new JobIdImpl(666L, "test-name");
job.setId(id);
List<InternalTask> tasksList = new ArrayList<>();
InternalTask internalTask = new InternalScriptTask(job);
TaskId taskId = TaskIdImpl.createTaskId(id, "task-name", 0L);
internalTask.setId(taskId);
internalTask.setName("task-name");
internalTask.setStatus(TaskStatus.RUNNING);
internalTask.setExecuterInformation(Mockito.mock(ExecuterInformation.class));
TaskInfoImpl taskInfoImpl = (TaskInfoImpl) internalTask.getTaskInfo();
taskInfoImpl.setNumberOfExecutionLeft(0);
internalTask.setOnTaskError(OnTaskError.PAUSE_TASK);
tasksList.add(internalTask);
job.setTasks(tasksList);
liveJobs.jobSubmitted(job);
liveJobs.lockJobsToSchedule();
liveJobs.taskStarted(job, job.getTask("task-name"), null);
TaskResultImpl result = new TaskResultImpl(taskId, new Exception(), null, 330);
liveJobs.taskTerminatedWithResult(taskId, result);
assertThat(taskInfoImpl.getNumberOfExecutionLeft(), is(-1));
assertThat(taskInfoImpl.getStatus(), is(TaskStatus.IN_ERROR));
assertThat(job.getStatus(), is(JobStatus.IN_ERROR));
}
use of org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId 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.task.TaskIdImpl.createTaskId in project scheduling by ow2-proactive.
the class TestTaskIdImpl method testGetReplicationIndex.
@Test
public void testGetReplicationIndex() throws Exception {
TaskId taskNoReplicationIndex = TaskIdImpl.createTaskId(new JobIdImpl(1L, "job"), "task", 1);
TaskId taskReplicationIndexSmallerThan9 = TaskIdImpl.createTaskId(new JobIdImpl(1L, "job"), "task*1", 1);
TaskId taskReplicationIndexGreaterThan9 = TaskIdImpl.createTaskId(new JobIdImpl(1L, "job"), "task*10", 1);
TaskId taskReplicatedAndIterated = TaskIdImpl.createTaskId(new JobIdImpl(1L, "job"), "task#10*10", 1);
assertEquals(0, taskNoReplicationIndex.getReplicationIndex());
assertEquals(1, taskReplicationIndexSmallerThan9.getReplicationIndex());
assertEquals(10, taskReplicationIndexGreaterThan9.getReplicationIndex());
assertEquals(10, taskReplicatedAndIterated.getReplicationIndex());
}
use of org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId in project scheduling by ow2-proactive.
the class ForkedTaskVariablesManagerTest method testAddBindingsToScriptHandlerContainsPreviousTaskResults.
@Test
public void testAddBindingsToScriptHandlerContainsPreviousTaskResults() throws InvalidScriptException, NodeException, NoSuchFieldException, IllegalAccessException {
// Create task result array
TaskResultImpl taskResult = new TaskResultImpl(TaskIdImpl.createTaskId(new JobIdImpl(jobIdValue, jobNameValue), taskNameValue, taskIdValue), new Exception("Exception"));
TaskResult[] taskResultArray = { taskResult };
// Create TaskContext with task result array
TaskContext taskContext = createTaskContext(taskResultArray);
// Expect taskResultArray to be inside the map
validateThatScriptHandlerBindingsContain(new ScriptHandler(), taskContext, new VariablesMap(), new HashMap<String, String>(), new HashMap<String, String>(), SchedulerConstants.RESULTS_VARIABLE, taskResultArray);
}
use of org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId in project scheduling by ow2-proactive.
the class InProcessTaskExecutorTest method testPaUserVariableAvailabilityFromScriptEngine.
@Test
public void testPaUserVariableAvailabilityFromScriptEngine() throws Throwable {
TestTaskOutput taskOutput = new TestTaskOutput();
String jobOwner = "JohnDoe";
TaskLauncherInitializer initializer = new TaskLauncherInitializer();
initializer.setJobOwner(jobOwner);
initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
new InProcessTaskExecutor().execute(new TaskContext(new ScriptExecutableContainer(new TaskScript(new SimpleScript("print variables.get('PA_USER')", "python"))), initializer, null, new NodeDataSpacesURIs("", "", "", "", "", ""), "", ""), taskOutput.outputStream, taskOutput.error);
assertEquals(jobOwner, taskOutput.output().trim());
}
Aggregations