use of org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs in project scheduling by ow2-proactive.
the class InProcessTaskExecutorTest method contextVariables.
@Test
public void contextVariables() throws Throwable {
TestTaskOutput taskOutput = new TestTaskOutput();
TaskLauncherInitializer initializer = new TaskLauncherInitializer();
initializer.setReplicationIndex(42);
String printEnvVariables = "print(variables.get('PA_JOB_NAME') + '@' + " + "variables.get('PA_JOB_ID') + '@' + variables.get('PA_TASK_NAME') " + "+ '@' + variables.get('PA_TASK_ID') +'\\n')";
initializer.setPreScript(new SimpleScript(printEnvVariables, "groovy"));
initializer.setPostScript(new SimpleScript(printEnvVariables, "groovy"));
initializer.setTaskId(TaskIdImpl.createTaskId(new JobIdImpl(1000, "job"), "task", 42L));
new InProcessTaskExecutor().execute(new TaskContext(new ScriptExecutableContainer(new TaskScript(new SimpleScript(printEnvVariables, "groovy"))), initializer, null, new NodeDataSpacesURIs("", "", "", "", "", ""), "", ""), taskOutput.outputStream, taskOutput.error);
String[] lines = taskOutput.output().split("\\n");
assertEquals("job@1000@task@42", lines[0]);
assertEquals("job@1000@task@42", lines[1]);
assertEquals("job@1000@task@42", lines[2]);
}
use of org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs in project scheduling by ow2-proactive.
the class InProcessTaskExecutorTest method scriptArguments.
@Test
public void scriptArguments() throws Throwable {
TestTaskOutput taskOutput = new TestTaskOutput();
TaskLauncherInitializer initializer = new TaskLauncherInitializer();
String printEnvVariables = "print(args[0])";
initializer.setPreScript(new SimpleScript(printEnvVariables, "groovy", new Serializable[] { "Hello" }));
initializer.setTaskId(TaskIdImpl.createTaskId(new JobIdImpl(1000, "job"), "task", 42L));
new InProcessTaskExecutor().execute(new TaskContext(new ScriptExecutableContainer(new TaskScript(new SimpleScript("", "groovy"))), initializer, null, new NodeDataSpacesURIs("", "", "", "", "", ""), "", ""), taskOutput.outputStream, taskOutput.error);
assertEquals("Hello", taskOutput.output());
}
use of org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs in project scheduling by ow2-proactive.
the class InProcessTaskExecutorTest method taskWithFlowScript.
@Test
public void taskWithFlowScript() throws Exception {
TestTaskOutput taskOutput = new TestTaskOutput();
TaskLauncherInitializer initializer = new TaskLauncherInitializer();
initializer.setControlFlowScript(FlowScript.createReplicateFlowScript("print('flow'); runs=5", "groovy"));
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(FlowActionType.REPLICATE, result.getAction().getType());
assertEquals("helloflow", taskOutput.output());
}
use of org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs 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, null);
// Expect taskResultArray to be inside the map
validateThatScriptHandlerBindingsContain(new ScriptHandler(), taskContext, new VariablesMap(), new HashMap<String, String>(), new HashMap<String, String>(), SchedulerConstants.DS_SCRATCH_BINDING_NAME, testSetString);
}
use of org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs in project scheduling by ow2-proactive.
the class ForkedTaskVariablesManagerTest method testAddBindingsToScriptHandlerContainsInputURI.
@Test
public void testAddBindingsToScriptHandlerContainsInputURI() 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, testSetString, null, 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_INPUT_BINDING_NAME, testSetString);
}
Aggregations