Search in sources :

Example 21 with TaskLauncherInitializer

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

the class TaskContextVariableExtractorTest method testExtractTaskResultVariablesGetAllNonTaskVariables.

@Test
public void testExtractTaskResultVariablesGetAllNonTaskVariables() throws Exception {
    ScriptExecutableContainer scriptContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("print('hello'); result='hello'", "javascript")));
    TaskLauncherInitializer taskLauncherInitializer = getTaskLauncherInitializerWithWorkflowVariables();
    TaskContext taskContext = new TaskContext(scriptContainer, taskLauncherInitializer, null, new NodeDataSpacesURIs(null, null, null, null, null, null), null, null);
    Map<String, Serializable> scopeVariables = new TaskContextVariableExtractor().getAllNonTaskVariables(taskContext);
    Assert.assertThat(scopeVariables.toString(), CoreMatchers.containsString("PA_TASK_NAME=TestTaskName"));
}
Also used : Serializable(java.io.Serializable) TaskScript(org.ow2.proactive.scripting.TaskScript) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) TaskLauncherInitializer(org.ow2.proactive.scheduler.task.TaskLauncherInitializer) Test(org.junit.Test)

Example 22 with TaskLauncherInitializer

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

the class TaskContextVariableExtractorTest method testExtractThrowsExceptionIfVariablesAreInvalidByteStream.

@Test(expected = Exception.class)
public void testExtractThrowsExceptionIfVariablesAreInvalidByteStream() throws Exception {
    ScriptExecutableContainer scriptContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("print('hello'); result='hello'", "javascript")));
    TaskLauncherInitializer taskLauncherInitializer = getTaskLauncherInitializerWithWorkflowVariables();
    Map<String, byte[]> taskResultVariables = new HashMap<>();
    // The task result variables are expected to be converted to byte streams.
    taskResultVariables.put(taskResultPropagatedVariables1Key, taskResultPropagatedVariables1Value.getBytes());
    TaskResultImpl taskResult = new TaskResultImpl(taskLauncherInitializer.getTaskId(), new Exception("Exception"));
    taskResult.setPropagatedVariables(taskResultVariables);
    TaskResult[] taskResultArray = { taskResult };
    TaskContext taskContext = new TaskContext(scriptContainer, taskLauncherInitializer, taskResultArray, new NodeDataSpacesURIs(null, null, null, null, null, null), null, null);
    new TaskContextVariableExtractor().getAllVariables(taskContext);
}
Also used : TaskScript(org.ow2.proactive.scripting.TaskScript) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) HashMap(java.util.HashMap) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) TaskLauncherInitializer(org.ow2.proactive.scheduler.task.TaskLauncherInitializer) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) Test(org.junit.Test)

Example 23 with TaskLauncherInitializer

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

the class ForkedProcessBuilderCreatorTest method createTaskLauncherInitializer.

private TaskLauncherInitializer createTaskLauncherInitializer() {
    TaskLauncherInitializer taskLauncherInitializer = new TaskLauncherInitializer();
    TaskId taskId = createTaskId();
    taskLauncherInitializer.setTaskId(taskId);
    taskLauncherInitializer.setIterationIndex(iterationIndexValue);
    taskLauncherInitializer.setJobOwner(jobOwnerValue);
    taskLauncherInitializer.setReplicationIndex(taskReplicationValue);
    return taskLauncherInitializer;
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskLauncherInitializer(org.ow2.proactive.scheduler.task.TaskLauncherInitializer)

Example 24 with TaskLauncherInitializer

use of org.ow2.proactive.scheduler.task.TaskLauncherInitializer 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 25 with TaskLauncherInitializer

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

the class ForkedJvmTaskExecutionCommandCreatorTest method createTaskLauncherInitializer.

private TaskLauncherInitializer createTaskLauncherInitializer() {
    TaskLauncherInitializer taskLauncherInitializer = new TaskLauncherInitializer();
    TaskId taskId = createTaskId();
    taskLauncherInitializer.setTaskId(taskId);
    taskLauncherInitializer.setIterationIndex(iterationIndexValue);
    taskLauncherInitializer.setJobOwner(jobOwnerValue);
    taskLauncherInitializer.setReplicationIndex(taskReplicationValue);
    return taskLauncherInitializer;
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskLauncherInitializer(org.ow2.proactive.scheduler.task.TaskLauncherInitializer)

Aggregations

ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)71 Test (org.junit.Test)66 SimpleScript (org.ow2.proactive.scripting.SimpleScript)61 TaskScript (org.ow2.proactive.scripting.TaskScript)61 NodeDataSpacesURIs (org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs)41 TaskContext (org.ow2.proactive.scheduler.task.context.TaskContext)41 TaskLauncherInitializer (org.ow2.proactive.scheduler.task.TaskLauncherInitializer)37 InProcessTaskExecutor (org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor)19 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)18 ForkEnvironment (org.ow2.proactive.scheduler.common.task.ForkEnvironment)16 Serializable (java.io.Serializable)10 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)10 HashMap (java.util.HashMap)9 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)9 TestTaskOutput (org.ow2.proactive.scheduler.task.TestTaskOutput)9 ForkedTaskExecutor (org.ow2.proactive.scheduler.task.executors.ForkedTaskExecutor)9 File (java.io.File)8 VariablesMap (org.ow2.proactive.scheduler.task.utils.VariablesMap)8 ScriptHandler (org.ow2.proactive.scripting.ScriptHandler)8 JobVariable (org.ow2.proactive.scheduler.common.job.JobVariable)7