use of org.ow2.proactive.scheduler.task.context.NodeInfo in project scheduling by ow2-proactive.
the class ForkedTaskVariablesManagerTest method testAddBindingsToScriptHandlerContainsCacheURI.
@Test
public void testAddBindingsToScriptHandlerContainsCacheURI() throws InvalidScriptException, NodeException, NoSuchFieldException, IllegalAccessException {
ScriptExecutableContainer scriptContainer = createScriptContainer();
TaskLauncherInitializer taskLauncherInitializer = new TaskLauncherInitializer();
taskLauncherInitializer.setForkEnvironment(new ForkEnvironment());
TaskContext taskContext = new TaskContext(scriptContainer, taskLauncherInitializer, null, new NodeDataSpacesURIs(null, testSetString, null, null, null, null), null, new NodeInfo(null, null, null, null));
// Expect taskResultArray to be inside the map
validateThatScriptHandlerBindingsContain(new ScriptHandler(), taskContext, new VariablesMap(), new HashMap<>(), new HashMap<String, String>(), new HashMap<String, String>(), SchedulerConstants.DS_CACHE_BINDING_NAME, testSetString);
}
use of org.ow2.proactive.scheduler.task.context.NodeInfo in project scheduling by ow2-proactive.
the class ForkedTaskVariablesManagerTest method testAddBindingsToScriptHandlerContainsScratchURI.
@Test
public void testAddBindingsToScriptHandlerContainsScratchURI() throws InvalidScriptException, NodeException, NoSuchFieldException, IllegalAccessException {
ScriptExecutableContainer scriptContainer = createScriptContainer();
TaskLauncherInitializer taskLauncherInitializer = new TaskLauncherInitializer();
taskLauncherInitializer.setForkEnvironment(new ForkEnvironment());
TaskContext taskContext = new TaskContext(scriptContainer, taskLauncherInitializer, null, new NodeDataSpacesURIs(testSetString, null, null, null, null, null), null, new NodeInfo(null, null, null, null));
// Expect taskResultArray to be inside the map
validateThatScriptHandlerBindingsContain(new ScriptHandler(), taskContext, new VariablesMap(), new HashMap<>(), new HashMap<String, String>(), new HashMap<String, String>(), SchedulerConstants.DS_SCRATCH_BINDING_NAME, testSetString);
}
use of org.ow2.proactive.scheduler.task.context.NodeInfo in project scheduling by ow2-proactive.
the class TaskContextVariableExtractorTest method testExtractWorkflowVariablesFromTaskLauncherInitializerInsideTaskContext.
@Test
public void testExtractWorkflowVariablesFromTaskLauncherInitializerInsideTaskContext() 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, new NodeInfo(null, null, null, null));
Map<String, Serializable> contextVariables = new TaskContextVariableExtractor().getAllVariables(taskContext);
assertThat((String) contextVariables.get(testVariable1Key), is(testVariable1Value));
assertThat((String) contextVariables.get(testVariable2Key), is(testVariable2Value));
}
use of org.ow2.proactive.scheduler.task.context.NodeInfo in project scheduling by ow2-proactive.
the class TaskContextVariableExtractorTest method testExtractTaskResultVariablesFromTaskResult.
@Test
public void testExtractTaskResultVariablesFromTaskResult() 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, new NodeInfo(null, null, null, null));
Map<String, byte[]> taskResultVariables = new HashMap<>();
// The task result variables are expected to be converted to byte streams.
taskResultVariables.put(taskResultPropagatedVariables1Key, AllObjects2BytesConverterHandler.convertObject2Byte(taskResultPropagatedVariables1Key, taskResultPropagatedVariables1Value));
TaskResultImpl taskResult = new TaskResultImpl(taskContext.getTaskId(), new Exception("Exception"));
taskResult.setPropagatedVariables(taskResultVariables);
Map<String, Serializable> contextVariables = new TaskContextVariableExtractor().getAllVariablesWithTaskResult(taskContext, taskResult);
assertThat((String) contextVariables.get(taskResultPropagatedVariables1Key), is(taskResultPropagatedVariables1Value));
}
use of org.ow2.proactive.scheduler.task.context.NodeInfo in project scheduling by ow2-proactive.
the class TaskContextVariableExtractorTest method testExtractNodefileVariablesAndProgressVariablesWithGivenNodesfile.
@Test
public void testExtractNodefileVariablesAndProgressVariablesWithGivenNodesfile() 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, new NodeInfo(null, null, null, null), null);
Map<String, Serializable> contextVariables = new TaskContextVariableExtractor().getAllNonTaskVariablesInjectNodesFile(taskContext, nodesfileContent);
assertThat("Nodes number must be equal to number of other nodes + 1 (for the own node).", (int) contextVariables.get(SchedulerVars.PA_NODESNUMBER.toString()), is(taskContext.getOtherNodesURLs().size() + 1));
assertThat("Node file content of passed node file must be represented as a variable.", (String) contextVariables.get(SchedulerVars.PA_NODESFILE.toString()), is(nodesfileContent));
assertThat("Task progress path must be represented as a variable.", (String) contextVariables.get(SchedulerVars.PA_TASK_PROGRESS_FILE.toString()), is(taskContext.getProgressFilePath()));
}
Aggregations