use of org.ow2.proactive.scheduler.task.context.TaskContext in project scheduling by ow2-proactive.
the class ForkedProcessBuilderCreatorTest method testEnvPrefixCommandIsAddedToCommandRunAsMeIsTrue.
@Test
public void testEnvPrefixCommandIsAddedToCommandRunAsMeIsTrue() throws Exception {
ForkedProcessBuilderCreator forkedProcessBuilderCreator = new ForkedProcessBuilderCreator();
setMocks(forkedProcessBuilderCreator);
TaskContext taskContext = createTaskContext();
taskContext.getExecutableContainer().setRunAsUser(true);
OSProcessBuilder processBuilder = forkedProcessBuilderCreator.createForkedProcessBuilder(createTaskContext(), tmpFolder.newFolder(), System.out, System.out, tmpFolder.newFolder());
assertThat(processBuilder.command(), hasItems(forkEnJavaCommandString));
}
use of org.ow2.proactive.scheduler.task.context.TaskContext in project scheduling by ow2-proactive.
the class ForkedJvmTaskExecutionCommandCreatorTest method createTaskContext.
private TaskContext createTaskContext() throws InvalidScriptException, NodeException {
ScriptExecutableContainer scriptContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("print('hello'); result='hello'", "javascript")));
TaskLauncherInitializer taskLauncherInitializer = getTaskLauncherInitializerWithWorkflowVariableAndForkEnvironment();
TaskContext taskContext = new TaskContext(scriptContainer, taskLauncherInitializer, null, new NodeDataSpacesURIs(null, null, null, null, null, null), null, null);
return taskContext;
}
use of org.ow2.proactive.scheduler.task.context.TaskContext 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.context.TaskContext in project scheduling by ow2-proactive.
the class ForkedTaskVariablesManagerTest method testExtractThirdPartyCredentials.
@Test
public void testExtractThirdPartyCredentials() throws Exception {
ScriptExecutableContainer scriptContainer = createScriptContainer();
TaskLauncherInitializer taskLauncherInitializer = new TaskLauncherInitializer();
taskLauncherInitializer.setForkEnvironment(new ForkEnvironment());
Decrypter decrypter = createCredentials(testUser, testPass);
TaskContext taskContext = new TaskContext(scriptContainer, taskLauncherInitializer, null, new NodeDataSpacesURIs(null, null, null, null, null, null), null, null, decrypter);
ForkedTaskVariablesManager forkedTaskVariablesManager = new ForkedTaskVariablesManager();
Map<String, String> creds = forkedTaskVariablesManager.extractThirdPartyCredentials(taskContext);
assertThat(creds.get(thirdPartyCred1Key), is(thirdPartyCred1Value));
}
use of org.ow2.proactive.scheduler.task.context.TaskContext 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