Search in sources :

Example 16 with TaskContext

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));
}
Also used : OSProcessBuilder(org.objectweb.proactive.extensions.processbuilder.OSProcessBuilder) TaskContext(org.ow2.proactive.scheduler.task.context.TaskContext) Test(org.junit.Test)

Example 17 with TaskContext

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;
}
Also used : TaskScript(org.ow2.proactive.scripting.TaskScript) TaskContext(org.ow2.proactive.scheduler.task.context.TaskContext) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) NodeDataSpacesURIs(org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs) TaskLauncherInitializer(org.ow2.proactive.scheduler.task.TaskLauncherInitializer)

Example 18 with 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);
}
Also used : TaskContext(org.ow2.proactive.scheduler.task.context.TaskContext) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) VariablesMap(org.ow2.proactive.scheduler.task.utils.VariablesMap) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment) NodeDataSpacesURIs(org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs) TaskLauncherInitializer(org.ow2.proactive.scheduler.task.TaskLauncherInitializer) ScriptHandler(org.ow2.proactive.scripting.ScriptHandler) Test(org.junit.Test)

Example 19 with TaskContext

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));
}
Also used : TaskContext(org.ow2.proactive.scheduler.task.context.TaskContext) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) Decrypter(org.ow2.proactive.scheduler.task.utils.Decrypter) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment) NodeDataSpacesURIs(org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs) TaskLauncherInitializer(org.ow2.proactive.scheduler.task.TaskLauncherInitializer) Test(org.junit.Test)

Example 20 with TaskContext

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);
}
Also used : TaskContext(org.ow2.proactive.scheduler.task.context.TaskContext) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) VariablesMap(org.ow2.proactive.scheduler.task.utils.VariablesMap) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment) NodeDataSpacesURIs(org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs) TaskLauncherInitializer(org.ow2.proactive.scheduler.task.TaskLauncherInitializer) ScriptHandler(org.ow2.proactive.scripting.ScriptHandler) Test(org.junit.Test)

Aggregations

ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)52 Test (org.junit.Test)51 TaskContext (org.ow2.proactive.scheduler.task.context.TaskContext)51 NodeDataSpacesURIs (org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs)43 SimpleScript (org.ow2.proactive.scripting.SimpleScript)40 TaskScript (org.ow2.proactive.scripting.TaskScript)40 TaskLauncherInitializer (org.ow2.proactive.scheduler.task.TaskLauncherInitializer)30 InProcessTaskExecutor (org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor)20 ForkEnvironment (org.ow2.proactive.scheduler.common.task.ForkEnvironment)17 Serializable (java.io.Serializable)16 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)14 ScriptHandler (org.ow2.proactive.scripting.ScriptHandler)13 VariablesMap (org.ow2.proactive.scheduler.task.utils.VariablesMap)12 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)10 HashMap (java.util.HashMap)9 TestTaskOutput (org.ow2.proactive.scheduler.task.TestTaskOutput)9 ForkedTaskExecutor (org.ow2.proactive.scheduler.task.executors.ForkedTaskExecutor)9 File (java.io.File)7 Decrypter (org.ow2.proactive.scheduler.task.utils.Decrypter)6 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)5