Search in sources :

Example 21 with VariablesMap

use of org.ow2.proactive.scheduler.task.utils.VariablesMap in project scheduling by ow2-proactive.

the class ForkedTaskVariablesManagerTest method testAddBindingsToScriptHandlerContainsCredentials.

@Test
public void testAddBindingsToScriptHandlerContainsCredentials() throws InvalidScriptException, NodeException, NoSuchFieldException, IllegalAccessException {
    Map<String, String> thirdPartyCredentials = new HashMap<>();
    thirdPartyCredentials.put(testCred1Key, testCred1Value);
    // Expect taskResultArray to be inside the map
    validateThatScriptHandlerBindingsContain(new ScriptHandler(), createTaskContext(null), new VariablesMap(), thirdPartyCredentials, new HashMap<String, String>(), SchedulerConstants.CREDENTIALS_VARIABLE, thirdPartyCredentials);
}
Also used : HashMap(java.util.HashMap) VariablesMap(org.ow2.proactive.scheduler.task.utils.VariablesMap) ScriptHandler(org.ow2.proactive.scripting.ScriptHandler) Test(org.junit.Test)

Example 22 with VariablesMap

use of org.ow2.proactive.scheduler.task.utils.VariablesMap in project scheduling by ow2-proactive.

the class ForkedTaskVariablesManagerTest method testAddBindingsToScriptHandlerContainsPreviousTaskResults.

@Test
public void testAddBindingsToScriptHandlerContainsPreviousTaskResults() throws InvalidScriptException, NodeException, NoSuchFieldException, IllegalAccessException {
    // Create task result array
    TaskResultImpl taskResult = new TaskResultImpl(TaskIdImpl.createTaskId(new JobIdImpl(jobIdValue, jobNameValue), taskNameValue, taskIdValue), new Exception("Exception"));
    TaskResult[] taskResultArray = { taskResult };
    // Create TaskContext with task result array
    TaskContext taskContext = createTaskContext(taskResultArray);
    // Expect taskResultArray to be inside the map
    validateThatScriptHandlerBindingsContain(new ScriptHandler(), taskContext, new VariablesMap(), new HashMap<String, String>(), new HashMap<String, String>(), SchedulerConstants.RESULTS_VARIABLE, taskResultArray);
}
Also used : TaskContext(org.ow2.proactive.scheduler.task.context.TaskContext) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) VariablesMap(org.ow2.proactive.scheduler.task.utils.VariablesMap) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) KeyException(java.security.KeyException) InvalidScriptException(org.ow2.proactive.scripting.InvalidScriptException) NodeException(org.objectweb.proactive.core.node.NodeException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) ScriptHandler(org.ow2.proactive.scripting.ScriptHandler) Test(org.junit.Test)

Example 23 with VariablesMap

use of org.ow2.proactive.scheduler.task.utils.VariablesMap 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);
}
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 24 with VariablesMap

use of org.ow2.proactive.scheduler.task.utils.VariablesMap in project scheduling by ow2-proactive.

the class ForkedTaskVariablesManagerTest method testAddBindingsToScriptHandlerContainsSchedulerNodeClientVariable.

@Test
public void testAddBindingsToScriptHandlerContainsSchedulerNodeClientVariable() throws InvalidScriptException, NodeException, NoSuchFieldException, IllegalAccessException, KeyException, NoSuchAlgorithmException {
    ScriptExecutableContainer scriptContainer = createScriptContainer();
    TaskLauncherInitializer taskLauncherInitializer = new TaskLauncherInitializer();
    taskLauncherInitializer.setForkEnvironment(new ForkEnvironment());
    taskLauncherInitializer.setSchedulerRestUrl("http://localhost:8080/rest");
    Decrypter decrypter = createCredentials(testUser, testPass);
    TaskContext taskContext = new TaskContext(scriptContainer, taskLauncherInitializer, null, new NodeDataSpacesURIs(null, null, null, null, null, null), null, null, decrypter);
    // variable should belong to the expected class
    validateThatScriptHandlerBindingsInstanceOf(new ScriptHandler(), taskContext, new VariablesMap(), new HashMap<String, String>(), new HashMap<String, String>(), SchedulerConstants.SCHEDULER_CLIENT_BINDING_NAME, SchedulerNodeClient.class);
}
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) 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 25 with VariablesMap

use of org.ow2.proactive.scheduler.task.utils.VariablesMap in project scheduling by ow2-proactive.

the class ForkedTaskVariablesManagerTest method testAddBindingsToScriptHandlerContainsCacheURI.

@Test
public void testAddBindingsToScriptHandlerContainsCacheURI() 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, testSetString, 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_CACHE_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

VariablesMap (org.ow2.proactive.scheduler.task.utils.VariablesMap)22 Test (org.junit.Test)20 ScriptHandler (org.ow2.proactive.scripting.ScriptHandler)17 HashMap (java.util.HashMap)13 TaskContext (org.ow2.proactive.scheduler.task.context.TaskContext)10 ForkEnvironment (org.ow2.proactive.scheduler.common.task.ForkEnvironment)9 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)9 TaskLauncherInitializer (org.ow2.proactive.scheduler.task.TaskLauncherInitializer)8 NodeDataSpacesURIs (org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs)8 Serializable (java.io.Serializable)7 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)4 SchedulerNodeClient (org.ow2.proactive.scheduler.task.client.SchedulerNodeClient)4 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 JobVariable (org.ow2.proactive.scheduler.common.job.JobVariable)3 RemoteSpace (org.ow2.proactive.scheduler.common.task.dataspaces.RemoteSpace)3 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)3 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 LoginException (javax.security.auth.login.LoginException)2