Search in sources :

Example 11 with TaskLogs

use of org.ow2.proactive.scheduler.common.task.TaskLogs in project scheduling by ow2-proactive.

the class TestTaskScriptVariables method testTaskVariables.

@Test
public void testTaskVariables() throws Throwable {
    TaskFlowJob job = (TaskFlowJob) StaxJobFactory.getFactory().createJob(new File(jobDescriptor.toURI()).getAbsolutePath());
    JobId id = schedulerHelper.submitJob(job);
    schedulerHelper.waitForEventJobFinished(id);
    // Wait for cleaning scripts to be executed
    Thread.sleep(2000);
    // Get logs and task output
    String logs = schedulerHelper.getJobServerLogs(id);
    TaskLogs outputVariables = schedulerHelper.getTaskResult(id, "taskVariables").getOutput();
    String[] outputVariablesLines = outputVariables.getStdoutLogs(false).split(System.lineSeparator());
    TaskLogs outputChild = schedulerHelper.getTaskResult(id, "childTask").getOutput();
    String[] outputChildLines = outputChild.getStdoutLogs(false).split(System.lineSeparator());
    TaskLogs outputInherited = schedulerHelper.getTaskResult(id, "inheritedVariablesTask").getOutput();
    String[] outputInheritedlines = outputInherited.getStdoutLogs(false).split(System.lineSeparator());
    TaskLogs outputNoVariables = schedulerHelper.getTaskResult(id, "taskNoVariables").getOutput();
    String[] outputNoVariablesLines = outputNoVariables.getStdoutLogs(false).split(System.lineSeparator());
    // Tests variable access
    assertEquals("testvarjob3", job.getVariables().get("TESTVAR3").getValue());
    // Selection files access
    assertTrue(logs.contains("testvartask0"));
    // Fork environment, pre, scriptExecutable, post scripts
    assertEquals(5, outputVariablesLines.length);
    assertEquals("testvartask1", outputVariablesLines[0]);
    assertEquals("testvartask2", outputVariablesLines[1]);
    assertEquals("testvartask3", outputVariablesLines[2]);
    assertEquals("testvartask4", outputVariablesLines[3]);
    // Inherited value
    assertEquals("testvarjob6", outputVariablesLines[4]);
    // Test that child tasks don't have access to task variables
    assertEquals(8, outputChildLines.length);
    assertEquals("testvarjob0", outputChildLines[0]);
    assertEquals("testvarjob1", outputChildLines[1]);
    assertEquals("testvarjob2", outputChildLines[2]);
    assertEquals("testvarjob3", outputChildLines[3]);
    assertEquals("testvarjob4", outputChildLines[4]);
    assertEquals("testvarjob5", outputChildLines[5]);
    assertEquals("testvarjob6", outputChildLines[6]);
    assertEquals("testvar7modified", outputChildLines[7]);
    // Test that inherited variables are propagated correctly
    assertEquals(6, outputInheritedlines.length);
    assertEquals("testvartask0", outputInheritedlines[0]);
    assertEquals("testvarjob1", outputInheritedlines[1]);
    assertEquals("testvartask7", outputInheritedlines[2]);
    assertEquals("testvar8propagated", outputInheritedlines[3]);
    assertEquals("testvartask9", outputInheritedlines[4]);
    assertEquals("testvartask10", outputInheritedlines[5]);
    // Test that other tasks don't have access to task variables
    assertEquals(8, outputNoVariablesLines.length);
    assertEquals("testvarjob0", outputNoVariablesLines[0]);
    assertEquals("testvarjob1", outputNoVariablesLines[1]);
    assertEquals("testvarjob2", outputNoVariablesLines[2]);
    assertEquals("testvarjob3", outputNoVariablesLines[3]);
    assertEquals("testvarjob4", outputNoVariablesLines[4]);
    assertEquals("testvarjob5", outputNoVariablesLines[5]);
    assertEquals("testvarjob6", outputNoVariablesLines[6]);
    assertEquals("testvarjob7", outputNoVariablesLines[7]);
    // Cleaning script
    assertTrue(logs.contains("(taskVariables) testvartask5"));
    // Variables use into generic information
    Map<String, String> genericInformations = job.getGenericInformation();
    assertEquals(1, genericInformations.size());
    assertEquals("testvarjob0", genericInformations.get("jobGI"));
    genericInformations = job.getTask("taskVariables").getGenericInformation();
    assertEquals(1, genericInformations.size());
    assertEquals("testvartask1", genericInformations.get("taskVariablesGI"));
    genericInformations = job.getTask("childTask").getGenericInformation();
    assertEquals(1, genericInformations.size());
    assertEquals("testvarjob4", genericInformations.get("childTaskGI"));
    genericInformations = job.getTask("taskNoVariables").getGenericInformation();
    assertEquals(1, genericInformations.size());
    assertEquals("testvarjob2", genericInformations.get("taskNoVariablesGI"));
    // Variables use into node configuration
    assertEquals(2, job.getTask("taskVariables").getParallelEnvironment().getNodesNumber());
    assertEquals(1, job.getTask("childTask").getParallelEnvironment().getNodesNumber());
    assertEquals(1, job.getTask("taskNoVariables").getParallelEnvironment().getNodesNumber());
}
Also used : TaskLogs(org.ow2.proactive.scheduler.common.task.TaskLogs) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) File(java.io.File) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 12 with TaskLogs

use of org.ow2.proactive.scheduler.common.task.TaskLogs in project scheduling by ow2-proactive.

the class TestTaskResultData method testSimpleLogs.

@Test
public void testSimpleLogs() throws Exception {
    InternalJob job = saveSingleTask(createDefaultTask("task"));
    InternalTask task = (InternalTask) job.getTasks().get(0);
    TaskResultImpl result = new TaskResultImpl(null, "result", new SimpleTaskLogs("stdLogs", "errorLogs"), 0);
    dbManager.updateAfterTaskFinished(job, task, result);
    TaskResult restoredResult = dbManager.loadLastTaskResult(task.getId());
    TaskLogs logs = restoredResult.getOutput();
    Assert.assertNotNull(logs);
    Assert.assertEquals("stdLogs", logs.getStdoutLogs(false));
    Assert.assertEquals("errorLogs", logs.getStderrLogs(false));
}
Also used : TaskLogs(org.ow2.proactive.scheduler.common.task.TaskLogs) Log4JTaskLogs(org.ow2.proactive.scheduler.common.task.Log4JTaskLogs) SimpleTaskLogs(org.ow2.proactive.scheduler.common.task.SimpleTaskLogs) SimpleTaskLogs(org.ow2.proactive.scheduler.common.task.SimpleTaskLogs) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 File (java.io.File)5 TaskLogs (org.ow2.proactive.scheduler.common.task.TaskLogs)4 InputStream (java.io.InputStream)3 JobId (org.ow2.proactive.scheduler.common.job.JobId)3 Log4JTaskLogs (org.ow2.proactive.scheduler.common.task.Log4JTaskLogs)3 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)3 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)3 ArrayList (java.util.ArrayList)2 LoggingEvent (org.apache.log4j.spi.LoggingEvent)2 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)2 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)2 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)2 SimpleTaskLogs (org.ow2.proactive.scheduler.common.task.SimpleTaskLogs)2 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)2 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)2 InternalTaskFlowJob (org.ow2.proactive.scheduler.job.InternalTaskFlowJob)2 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)2 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)2 BufferedInputStream (java.io.BufferedInputStream)1