use of org.ow2.proactive.scheduler.task.utils.VariablesMap in project scheduling by ow2-proactive.
the class TestStaxJobFactory method testCreateJobShouldUseVariableMapToReplaceTaskGenericInfoVariables.
@Test
public void testCreateJobShouldUseVariableMapToReplaceTaskGenericInfoVariables() throws Exception {
Map<String, String> variablesMap = Maps.newHashMap();
variablesMap.put("task_generic_info", "updated_task_generic_info_value2");
TaskFlowJob testJob = (TaskFlowJob) factory.createJob(jobDescriptorUri, variablesMap);
assertEquals("updated_task_generic_info_value2", testJob.getTask("task1").getGenericInformation().get("task_generic_info"));
}
use of org.ow2.proactive.scheduler.task.utils.VariablesMap in project scheduling by ow2-proactive.
the class TestStaxJobFactory method testCreateJobShouldUseVariableMapToReplaceJobNameVariable.
@Test
public void testCreateJobShouldUseVariableMapToReplaceJobNameVariable() throws Exception {
Map<String, String> variablesMap = Maps.newHashMap();
variablesMap.put("job_name", "updated_job_name2");
Job testScriptJob = factory.createJob(jobDescriptorUri, variablesMap);
assertEquals("updated_job_name2", testScriptJob.getName());
}
use of org.ow2.proactive.scheduler.task.utils.VariablesMap in project scheduling by ow2-proactive.
the class ForkedTaskVariablesManagerTest method testAddBindingsToScriptHandlerContainsOutputURI.
@Test
public void testAddBindingsToScriptHandlerContainsOutputURI() 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, null, null, testSetString, null, null), null, null);
// Expect taskResultArray to be inside the map
validateThatScriptHandlerBindingsContain(new ScriptHandler(), taskContext, new VariablesMap(), new HashMap<String, String>(), new HashMap<String, String>(), SchedulerConstants.DS_OUTPUT_BINDING_NAME, testSetString);
}
use of org.ow2.proactive.scheduler.task.utils.VariablesMap in project scheduling by ow2-proactive.
the class ForkedTaskVariablesManagerTest method testScriptParametersAreReplaced.
@Test
public void testScriptParametersAreReplaced() throws InvalidScriptException {
ForkedTaskVariablesManager forkedTaskVariablesManager = new ForkedTaskVariablesManager();
// Create a variable $[something] inside a python script
Serializable[] parameters = new Serializable[] { "$" + testVariable1Key };
Script script = new SimpleScript("print 'hello'", "python", parameters);
// Create a hash map with key as varialbe name and value as variable value.
Map<String, Serializable> variables = new HashMap<>();
variables.put(testVariable1Key, testVariable1Value);
VariablesMap variablesMap = new VariablesMap();
variablesMap.setInheritedMap(variables);
// Replace that variable inside the script parameters with its value in the hash map
forkedTaskVariablesManager.replaceScriptParameters(script, new HashMap<String, String>(), variablesMap, System.out);
assertThat((String) parameters[0], is(testVariable1Value));
}
use of org.ow2.proactive.scheduler.task.utils.VariablesMap in project scheduling by ow2-proactive.
the class ForkedTaskVariablesManagerTest method testAddBindingsToScriptHandlerContainsGlobalURI.
@Test
public void testAddBindingsToScriptHandlerContainsGlobalURI() 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, null, null, null, null, testSetString), null, null);
// Expect taskResultArray to be inside the map
validateThatScriptHandlerBindingsContain(new ScriptHandler(), taskContext, new VariablesMap(), new HashMap<String, String>(), new HashMap<String, String>(), SchedulerConstants.DS_GLOBAL_BINDING_NAME, testSetString);
}
Aggregations