use of org.ow2.proactive.scheduler.common.task.ForkEnvironment in project scheduling by ow2-proactive.
the class ForkedProcessBuilderCreator method executeForkEnvironmentScriptAndExtractVariables.
private ScriptResult executeForkEnvironmentScriptAndExtractVariables(TaskContext context, PrintStream outputSink, PrintStream errorSink, OSProcessBuilder processBuilder) throws Exception {
ScriptResult forkEnvironmentScriptResult = null;
ForkEnvironment forkEnvironment = context.getInitializer().getForkEnvironment();
if (forkEnvironment != null) {
if (forkEnvironment.getEnvScript() != null) {
if (!context.getInitializer().isAuthorizedForkEnvironmentScript()) {
throw new SecurityException("Unauthorized fork environment script: " + System.getProperty("line.separator") + forkEnvironment.getEnvScript().fetchScript());
}
forkEnvironmentScriptResult = forkEnvironmentScriptExecutor.executeForkEnvironmentScript(context, outputSink, errorSink);
}
try {
processBuilder.environment().putAll(// by existing environment variables, variables and credentials
taskContextVariableExtractor.extractVariablesThirdPartyCredentialsAndSystemEnvironmentVariables(context));
} catch (IllegalArgumentException processEnvironmentReadOnly) {
throw new IllegalStateException("Cannot use runAsMe mode and set system environment properties", processEnvironmentReadOnly);
}
}
return forkEnvironmentScriptResult;
}
use of org.ow2.proactive.scheduler.common.task.ForkEnvironment in project scheduling by ow2-proactive.
the class ForkedJvmTaskExecutionCommandCreatorTest method testExecCommandOverwritesJavaHomeFromForkEnvironment.
@Test
public void testExecCommandOverwritesJavaHomeFromForkEnvironment() throws Exception {
ForkEnvironment forkEnvironment = createForkEnvironment();
forkEnvironment.setJavaHome(forkenvironmentJavaHome);
javaCommandContains(Arrays.asList(forkenvironmentJavaHome), forkEnvironment);
}
use of org.ow2.proactive.scheduler.common.task.ForkEnvironment in project scheduling by ow2-proactive.
the class ForkedJvmTaskExecutionCommandCreatorTest method createForkEnvironment.
private ForkEnvironment createForkEnvironment() {
ForkEnvironment forkEnv = new ForkEnvironment();
forkEnv.addJVMArgument(forkEnvJvmArguments[0]);
forkEnv.addJVMArgument(forkEnvJvmArguments[1]);
forkEnv.addAdditionalClasspath(additionalClasspath);
return forkEnv;
}
use of org.ow2.proactive.scheduler.common.task.ForkEnvironment 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.common.task.ForkEnvironment 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));
}
Aggregations