Search in sources :

Example 71 with TaskResultImpl

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

the class InProcessTaskExecutorTest method failingFlowScript.

@Test
public void failingFlowScript() throws Exception {
    TestTaskOutput taskOutput = new TestTaskOutput();
    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setControlFlowScript(FlowScript.createReplicateFlowScript(""));
    initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
    TaskResultImpl result = new InProcessTaskExecutor().execute(new TaskContext(new ScriptExecutableContainer(new TaskScript(new SimpleScript("print('hello'); result='hello'", "groovy"))), initializer, null, new NodeDataSpacesURIs("", "", "", "", "", ""), "", ""), taskOutput.outputStream, taskOutput.error);
    assertEquals("hello", taskOutput.output());
    assertNotEquals("", taskOutput.error());
    assertNotNull(result.getException());
}
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)

Example 72 with TaskResultImpl

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

the class SchedulerStateRestJobTaskResultTest method testValueOfJobResult.

@Test
public void testValueOfJobResult() throws Throwable {
    TaskResultImpl taskResult = new TaskResultImpl(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("42"), "mytask", 1), ObjectToByteConverter.ObjectStream.convert("hello"), null, null, false);
    JobResultImpl jobResultWithValue = new JobResultImpl();
    JobInfoImpl jobInfo = new JobInfoImpl();
    jobInfo.setJobId(new JobIdImpl(12, "myjob"));
    jobResultWithValue.setJobInfo(jobInfo);
    jobResultWithValue.addTaskResult("mytask", taskResult, false);
    when(mockOfScheduler.getJobResult("42")).thenReturn(jobResultWithValue);
    JobResultData jobResultData = restInterface.jobResult(sessionId, "42");
    TaskResultData taskResultData = jobResultData.getAllResults().get("mytask");
    assertNotNull(taskResultData);
    assertNotNull(taskResultData.getValue());
    assertEquals("hello", taskResultData.getValue());
    Map<String, String> jobResult = restInterface.jobResultValue(sessionId, "42");
    String result = jobResult.get("mytask");
    assertNotNull(result);
    assertEquals("hello", result);
}
Also used : JobResultImpl(org.ow2.proactive.scheduler.job.JobResultImpl) JobResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobResultData) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) TaskResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskResultData) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) JobInfoImpl(org.ow2.proactive.scheduler.job.JobInfoImpl) Test(org.junit.Test)

Example 73 with TaskResultImpl

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

the class SchedulerStateRestJobTaskResultTest method testValueOfJobResult_ExceptionNoMessage.

@Test
public void testValueOfJobResult_ExceptionNoMessage() throws Throwable {
    TaskResultImpl taskResultWithException = new TaskResultImpl(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("42"), "mytask", 1), null, new byte[0], null, false);
    JobResultImpl jobResultWithException = new JobResultImpl();
    jobResultWithException.addTaskResult("mytask", taskResultWithException, false);
    when(mockOfScheduler.getJobResult("42")).thenReturn(jobResultWithException);
    Map<String, String> jobResult = restInterface.jobResultValue(sessionId, "42");
    String exceptionStackTrace = jobResult.get("mytask");
    assertNotNull(exceptionStackTrace);
}
Also used : JobResultImpl(org.ow2.proactive.scheduler.job.JobResultImpl) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) Test(org.junit.Test)

Example 74 with TaskResultImpl

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

the class NoVncSecuredTargetResolverTest method testMagicStringFoundInLiveLogs.

@Test
public void testMagicStringFoundInLiveLogs() throws Exception {
    String sessionId = SharedSessionStoreTestUtils.createValidSession(schedulerMock);
    SharedSessionStore.getInstance().get(sessionId).getJobsOutputController().addJobOutputAppender("42", createLiveLogs("[Visualization_task@node2;10:38:06]PA_REMOTE_CONNECTION;42;1;vnc;node.grid.com:5900"));
    when(schedulerMock.getTaskResult("42", "remoteVisuTask")).thenReturn(new TaskResultImpl(TaskIdImpl.createTaskId(new JobIdImpl(42, "job"), "remoteVisuTask", 1), new byte[0], new byte[0], new SimpleTaskLogs("", ""), true));
    InetSocketAddress targetVncHost = new NoVncSecuredTargetResolver().doResolve(sessionId, "42", "remoteVisuTask");
    assertEquals(5900, targetVncHost.getPort());
    assertEquals("node.grid.com", targetVncHost.getHostName());
}
Also used : SimpleTaskLogs(org.ow2.proactive.scheduler.common.task.SimpleTaskLogs) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) InetSocketAddress(java.net.InetSocketAddress) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) Test(org.junit.Test)

Example 75 with TaskResultImpl

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

the class NoVncSecuredTargetResolverTest method testMagicStringFoundInLogs.

@Test
public void testMagicStringFoundInLogs() throws Exception {
    String sessionId = SharedSessionStoreTestUtils.createValidSession(schedulerMock);
    when(schedulerMock.getTaskResult("42", "remoteVisuTask")).thenReturn(new TaskResultImpl(TaskIdImpl.createTaskId(new JobIdImpl(42, "job"), "remoteVisuTask", 1), new byte[0], new byte[0], new SimpleTaskLogs("PA_REMOTE_CONNECTION;42;1;vnc;node.grid.com:5900", ""), true));
    InetSocketAddress targetVncHost = new NoVncSecuredTargetResolver().doResolve(sessionId, "42", "remoteVisuTask");
    assertEquals(5900, targetVncHost.getPort());
    assertEquals("node.grid.com", targetVncHost.getHostName());
}
Also used : SimpleTaskLogs(org.ow2.proactive.scheduler.common.task.SimpleTaskLogs) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) InetSocketAddress(java.net.InetSocketAddress) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) Test(org.junit.Test)

Aggregations

TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)73 Test (org.junit.Test)70 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)32 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)30 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)26 SimpleScript (org.ow2.proactive.scripting.SimpleScript)26 TaskScript (org.ow2.proactive.scripting.TaskScript)26 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)25 TaskContext (org.ow2.proactive.scheduler.task.context.TaskContext)25 NodeDataSpacesURIs (org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs)22 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)21 JobId (org.ow2.proactive.scheduler.common.job.JobId)16 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)16 InProcessTaskExecutor (org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor)15 HashMap (java.util.HashMap)13 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)13 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)13 SimpleTaskLogs (org.ow2.proactive.scheduler.common.task.SimpleTaskLogs)12 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)11 TaskLauncherInitializer (org.ow2.proactive.scheduler.task.TaskLauncherInitializer)10