use of org.ow2.proactive.scheduler.task.TaskLauncherInitializer in project scheduling by ow2-proactive.
the class WalltimeTaskLauncherTest method walltime_forked_task.
@Test(timeout = 5000)
public void walltime_forked_task() throws Throwable {
ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("for(;;){}", "javascript")));
TaskLauncherInitializer initializer = new TaskLauncherInitializer();
initializer.setWalltime(500);
initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
TaskResult taskResult = runTaskLauncher(createLauncherWithInjectedMocks(initializer, new ForkingTaskLauncherFactory()), executableContainer);
assertEquals(WalltimeExceededException.class, taskResult.getException().getClass());
}
use of org.ow2.proactive.scheduler.task.TaskLauncherInitializer in project scheduling by ow2-proactive.
the class TaskContextVariableExtractorTest 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;
}
use of org.ow2.proactive.scheduler.task.TaskLauncherInitializer in project scheduling by ow2-proactive.
the class TaskContextVariableExtractorTest method testExtractWorkflowVariablesFromTaskLauncherInitializerInsideTaskContext.
@Test
public void testExtractWorkflowVariablesFromTaskLauncherInitializerInsideTaskContext() 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> contextVariables = new TaskContextVariableExtractor().getAllVariables(taskContext);
assertThat((String) contextVariables.get(testVariable1Key), is(testVariable1Value));
assertThat((String) contextVariables.get(testVariable2Key), is(testVariable2Value));
}
use of org.ow2.proactive.scheduler.task.TaskLauncherInitializer in project scheduling by ow2-proactive.
the class TaskContextVariableExtractorTest method getTaskLauncherInitializerWithWorkflowVariables.
private TaskLauncherInitializer getTaskLauncherInitializerWithWorkflowVariables() {
// Create and setup task launcher initializer
TaskLauncherInitializer taskLauncherInitializer = createTaskLauncherInitializer();
Map<String, JobVariable> variablesToPut = new HashMap<>();
variablesToPut.put(testVariable1Key, new JobVariable(testVariable1Key, testVariable1Value));
taskLauncherInitializer.setJobVariables(variablesToPut);
Map<String, TaskVariable> variablesToPut2 = new HashMap<>();
variablesToPut2.put(testVariable2Key, new TaskVariable(testVariable2Key, testVariable2Value, null, false));
taskLauncherInitializer.setTaskVariables(variablesToPut2);
return taskLauncherInitializer;
}
use of org.ow2.proactive.scheduler.task.TaskLauncherInitializer in project scheduling by ow2-proactive.
the class TaskContextVariableExtractorTest method testExtractTaskResultVariablesFromPreviousTaskResultsInsideTheTaskContext.
@Test
public void testExtractTaskResultVariablesFromPreviousTaskResultsInsideTheTaskContext() 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, AllObjects2BytesConverterHandler.convertObject2Byte(taskResultPropagatedVariables1Key, taskResultPropagatedVariables1Value));
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);
Map<String, Serializable> contextVariables = new TaskContextVariableExtractor().getAllVariables(taskContext);
assertThat((String) contextVariables.get(taskResultPropagatedVariables1Key), is(taskResultPropagatedVariables1Value));
}
Aggregations