Search in sources :

Example 51 with TaskIdImpl.createTaskId

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));
}
Also used : ExecuterInformation(org.ow2.proactive.scheduler.task.internal.ExecuterInformation) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) ArrayList(java.util.ArrayList) TaskInfoImpl(org.ow2.proactive.scheduler.task.TaskInfoImpl) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 52 with TaskIdImpl.createTaskId

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);
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) File(java.io.File) JobId(org.ow2.proactive.scheduler.common.job.JobId) WaitAndPrint(org.ow2.proactive.scheduler.examples.WaitAndPrint) Test(org.junit.Test)

Example 53 with TaskIdImpl.createTaskId

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());
}
Also used : JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) Test(org.junit.Test)

Example 54 with TaskIdImpl.createTaskId

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);
}
Also used : TaskContext(org.ow2.proactive.scheduler.task.context.TaskContext) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) VariablesMap(org.ow2.proactive.scheduler.task.utils.VariablesMap) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) KeyException(java.security.KeyException) InvalidScriptException(org.ow2.proactive.scripting.InvalidScriptException) NodeException(org.objectweb.proactive.core.node.NodeException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) ScriptHandler(org.ow2.proactive.scripting.ScriptHandler) Test(org.junit.Test)

Example 55 with TaskIdImpl.createTaskId

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());
}
Also used : TaskContext(org.ow2.proactive.scheduler.task.context.TaskContext) TaskScript(org.ow2.proactive.scripting.TaskScript) InProcessTaskExecutor(org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) NodeDataSpacesURIs(org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)86 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)52 SimpleScript (org.ow2.proactive.scripting.SimpleScript)52 TaskScript (org.ow2.proactive.scripting.TaskScript)52 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)49 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)32 TaskContext (org.ow2.proactive.scheduler.task.context.TaskContext)30 NodeDataSpacesURIs (org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs)29 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)22 JobId (org.ow2.proactive.scheduler.common.job.JobId)19 InProcessTaskExecutor (org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor)19 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)18 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)15 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)14 InternalTaskFlowJob (org.ow2.proactive.scheduler.job.InternalTaskFlowJob)14 InternalScriptTask (org.ow2.proactive.scheduler.task.internal.InternalScriptTask)14 File (java.io.File)11 ArrayList (java.util.ArrayList)11 TaskLauncherInitializer (org.ow2.proactive.scheduler.task.TaskLauncherInitializer)10 ExecuterInformation (org.ow2.proactive.scheduler.task.internal.ExecuterInformation)10