use of org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs in project scheduling by ow2-proactive.
the class InProcessTaskExecutorTest method resultMetadata.
@Test
public void resultMetadata() throws Throwable {
TestTaskOutput taskOutput = new TestTaskOutput();
Map<String, String> metadata = ImmutableMap.of("pre", "pre", "post", "post", "task", "task");
TaskLauncherInitializer initializer = new TaskLauncherInitializer();
initializer.setPreScript(new SimpleScript(SchedulerConstants.RESULT_METADATA_VARIABLE + ".put('pre','pre')", "groovy"));
initializer.setPostScript(new SimpleScript(SchedulerConstants.RESULT_METADATA_VARIABLE + ".put('post','post')", "groovy"));
initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
TaskResultImpl result = new InProcessTaskExecutor().execute(new TaskContext(new ScriptExecutableContainer(new TaskScript(new SimpleScript(SchedulerConstants.RESULT_METADATA_VARIABLE + ".put('task','task')", "groovy"))), initializer, null, new NodeDataSpacesURIs("", "", "", "", "", ""), "", ""), taskOutput.outputStream, taskOutput.error);
assertEquals(metadata, result.getMetadata());
}
use of org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs in project scheduling by ow2-proactive.
the class TaskContextTest method createTaskContext.
private TaskContext createTaskContext() throws NodeException, InvalidScriptException {
TaskLauncherInitializer taskLauncherInitializer = new TaskLauncherInitializer();
taskLauncherInitializer.setTaskId(TaskIdImpl.createTaskId(new JobIdImpl(1L, "testSerializeContextToFile"), "testSerializeContextToFile", 1L));
// Invoke method to test it
return new TaskContext(new ScriptExecutableContainer(new TaskScript(new ForkEnvironmentScript(new SimpleScript("", "python")))), taskLauncherInitializer, null, new NodeDataSpacesURIs(null, null, null, null, null, null), null, null);
}
use of org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs in project scheduling by ow2-proactive.
the class TaskContextSerializerTest method createTaskContext.
private TaskContext createTaskContext() throws NodeException, InvalidScriptException {
TaskLauncherInitializer taskLauncherInitializer = new TaskLauncherInitializer();
taskLauncherInitializer.setTaskId(TaskIdImpl.createTaskId(new JobIdImpl(1L, "testSerializeContextToFile"), "testSerializeContextToFile", 1L));
// Invoke method to test it
return new TaskContext(new ScriptExecutableContainer(new TaskScript(new ForkEnvironmentScript(new SimpleScript("", "python")))), taskLauncherInitializer, null, new NodeDataSpacesURIs(null, null, null, null, null, null), null, null);
}
use of org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs in project scheduling by ow2-proactive.
the class TaskContextVariableExtractorTest method testExtractTaskResultVariablesGetAllNonTaskVariables.
@Test
public void testExtractTaskResultVariablesGetAllNonTaskVariables() throws Exception {
ScriptExecutableContainer scriptContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("print('hello'); result='hello'", "javascript")));
TaskLauncherInitializer taskLauncherInitializer = getTaskLauncherInitializerWithWorkflowVariables();
TaskContext taskContext = new TaskContext(scriptContainer, taskLauncherInitializer, null, new NodeDataSpacesURIs(null, null, null, null, null, null), null, null);
Map<String, Serializable> scopeVariables = new TaskContextVariableExtractor().getAllNonTaskVariables(taskContext);
Assert.assertThat(scopeVariables.toString(), CoreMatchers.containsString("PA_TASK_NAME=TestTaskName"));
}
use of org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs in project scheduling by ow2-proactive.
the class TaskContextVariableExtractorTest method testExtractThrowsExceptionIfVariablesAreInvalidByteStream.
@Test(expected = Exception.class)
public void testExtractThrowsExceptionIfVariablesAreInvalidByteStream() throws Exception {
ScriptExecutableContainer scriptContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("print('hello'); result='hello'", "javascript")));
TaskLauncherInitializer taskLauncherInitializer = getTaskLauncherInitializerWithWorkflowVariables();
Map<String, byte[]> taskResultVariables = new HashMap<>();
// The task result variables are expected to be converted to byte streams.
taskResultVariables.put(taskResultPropagatedVariables1Key, taskResultPropagatedVariables1Value.getBytes());
TaskResultImpl taskResult = new TaskResultImpl(taskLauncherInitializer.getTaskId(), new Exception("Exception"));
taskResult.setPropagatedVariables(taskResultVariables);
TaskResult[] taskResultArray = { taskResult };
TaskContext taskContext = new TaskContext(scriptContainer, taskLauncherInitializer, taskResultArray, new NodeDataSpacesURIs(null, null, null, null, null, null), null, null);
new TaskContextVariableExtractor().getAllVariables(taskContext);
}
Aggregations