use of org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor in project scheduling by ow2-proactive.
the class InProcessTaskExecutorTest method taskWithFlowScript.
@Test
public void taskWithFlowScript() throws Exception {
TestTaskOutput taskOutput = new TestTaskOutput();
TaskLauncherInitializer initializer = new TaskLauncherInitializer();
initializer.setControlFlowScript(FlowScript.createReplicateFlowScript("print('flow'); runs=5", "groovy"));
initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
TaskResultImpl result = new InProcessTaskExecutor().execute(new TaskContext(new ScriptExecutableContainer(new TaskScript(new SimpleScript("print('hello'); result='hello'", "groovy"))), initializer, null, new NodeDataSpacesURIs("", "", "", "", "", ""), "", ""), taskOutput.outputStream, taskOutput.error);
assertEquals(FlowActionType.REPLICATE, result.getAction().getType());
assertEquals("helloflow", taskOutput.output());
}
use of org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor in project scheduling by ow2-proactive.
the class InProcessTaskExecutorTest method testPaUserVariableAvailabilityFromScriptEngine.
@Test
public void testPaUserVariableAvailabilityFromScriptEngine() throws Throwable {
TestTaskOutput taskOutput = new TestTaskOutput();
String jobOwner = "JohnDoe";
TaskLauncherInitializer initializer = new TaskLauncherInitializer();
initializer.setJobOwner(jobOwner);
initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
new InProcessTaskExecutor().execute(new TaskContext(new ScriptExecutableContainer(new TaskScript(new SimpleScript("print variables.get('PA_USER')", "python"))), initializer, null, new NodeDataSpacesURIs("", "", "", "", "", ""), "", ""), taskOutput.outputStream, taskOutput.error);
assertEquals(jobOwner, taskOutput.output().trim());
}
use of org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor in project scheduling by ow2-proactive.
the class ExecuteForkedTaskInsideNewJvm method fromForkedJVM.
private void fromForkedJVM(String contextPath) {
try {
TaskContext container = deserializeContext(contextPath);
TaskResultImpl result = new InProcessTaskExecutor().execute(container, System.out, System.err);
serializeTaskResult(result, contextPath);
} catch (Throwable throwable) {
throwable.printStackTrace(System.err);
try {
serializeTaskResult(throwable, contextPath);
} catch (Throwable couldNotSerializeException) {
System.err.println("Could not serialize exception as task result:");
couldNotSerializeException.printStackTrace(System.err);
}
System.exit(1);
}
}
use of org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor in project scheduling by ow2-proactive.
the class InProcessTaskExecutorTest method failingScript.
@Test
public void failingScript() throws Throwable {
TestTaskOutput taskOutput = new TestTaskOutput();
TaskLauncherInitializer initializer = new TaskLauncherInitializer();
initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
TaskResultImpl result = new InProcessTaskExecutor().execute(new TaskContext(new ScriptExecutableContainer(new TaskScript(new SimpleScript("dsfsdfsdf", "groovy"))), initializer, null, new NodeDataSpacesURIs("", "", "", "", "", ""), "", ""), taskOutput.outputStream, taskOutput.error);
assertTrue(result.hadException());
assertFalse(taskOutput.error().isEmpty());
}
use of org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor in project scheduling by ow2-proactive.
the class InProcessTaskExecutorTest method failingScriptTask.
@Test
public void failingScriptTask() throws Exception {
TestTaskOutput taskOutput = new TestTaskOutput();
TaskLauncherInitializer initializer = new TaskLauncherInitializer();
initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
TaskResultImpl result = new InProcessTaskExecutor().execute(new TaskContext(new ScriptExecutableContainer(new TaskScript(new SimpleScript("return 10/0", "groovy"))), initializer, null, new NodeDataSpacesURIs("", "", "", "", "", ""), "", ""), taskOutput.outputStream, taskOutput.error);
assertEquals("", taskOutput.output());
assertNotEquals("", taskOutput.error());
assertNotNull(result.getException());
}
Aggregations