use of org.ow2.proactive.scheduler.task.context.TaskContext 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.TaskContext in project scheduling by ow2-proactive.
the class TaskContextTest method nodesURLsAndHostsCanBeRepeated.
@Test
public void nodesURLsAndHostsCanBeRepeated() throws Exception {
TaskContext context = createTaskContext();
context.getOtherNodesURLs().add("host1");
context.getOtherNodesURLs().add("host1");
assertEquals(2, context.getOtherNodesURLs().size());
context.getNodesHosts().add("host1");
context.getNodesHosts().add("host1");
assertEquals(2, context.getNodesHosts().size());
}
use of org.ow2.proactive.scheduler.task.context.TaskContext 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.TaskContext 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.TaskContext 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