Search in sources :

Example 71 with TaskScript

use of org.ow2.proactive.scripting.TaskScript in project scheduling by ow2-proactive.

the class InProcessTaskExecutorTest method result_from_parent_task.

@Test
public void result_from_parent_task() throws Throwable {
    TestTaskOutput taskOutput = new TestTaskOutput();
    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setTaskId(TaskIdImpl.createTaskId(new JobIdImpl(1000, "job"), "task", 42L));
    TaskResult[] previousTasksResults = { new TaskResultImpl(null, "aresult", null, 0) };
    new InProcessTaskExecutor().execute(new TaskContext(new ScriptExecutableContainer(new TaskScript(new SimpleScript("print(results[0]);", "groovy"))), initializer, previousTasksResults, new NodeDataSpacesURIs("", "", "", "", "", ""), "", ""), taskOutput.outputStream, taskOutput.error);
    assertEquals("aresult", taskOutput.output());
}
Also used : TaskContext(org.ow2.proactive.scheduler.task.context.TaskContext) TaskScript(org.ow2.proactive.scripting.TaskScript) InProcessTaskExecutor(org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor) SimpleScript(org.ow2.proactive.scripting.SimpleScript) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) NodeDataSpacesURIs(org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs) Test(org.junit.Test)

Example 72 with TaskScript

use of org.ow2.proactive.scripting.TaskScript in project scheduling by ow2-proactive.

the class InProcessTaskExecutorTest method schedulerHomeIsInVariables.

@Test
public void schedulerHomeIsInVariables() throws Throwable {
    TestTaskOutput taskOutput = new TestTaskOutput();
    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
    new InProcessTaskExecutor().execute(new TaskContext(new ScriptExecutableContainer(new TaskScript(new SimpleScript("print(variables.get('PA_SCHEDULER_HOME'))", "groovy"))), initializer, null, new NodeDataSpacesURIs("", "", "", "", "", ""), "", ""), taskOutput.outputStream, taskOutput.error);
    assertEquals(ClasspathUtils.findSchedulerHome(), taskOutput.output());
}
Also used : TaskContext(org.ow2.proactive.scheduler.task.context.TaskContext) TaskScript(org.ow2.proactive.scripting.TaskScript) InProcessTaskExecutor(org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) NodeDataSpacesURIs(org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs) Test(org.junit.Test)

Example 73 with TaskScript

use of org.ow2.proactive.scripting.TaskScript in project scheduling by ow2-proactive.

the class InProcessTaskExecutorTest method multiNodesURLsAreBounded.

@Test
public void multiNodesURLsAreBounded() throws Throwable {
    TestTaskOutput taskOutput = new TestTaskOutput();
    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
    ScriptExecutableContainer printNodesFileTask = new ScriptExecutableContainer(new TaskScript(new SimpleScript("println nodesurl.size()", "groovy")));
    printNodesFileTask.setNodes(mockedNodeSet());
    TaskContext context = new TaskContext(printNodesFileTask, initializer, null, new NodeDataSpacesURIs(tmpFolder.newFolder().getAbsolutePath(), "", "", "", "", ""), "", "thisHost");
    TaskResultImpl taskResult = new InProcessTaskExecutor().execute(context, taskOutput.outputStream, taskOutput.error);
    assertTaskResultOk(taskResult);
    assertEquals(String.format("1%n"), taskOutput.output());
}
Also used : TaskScript(org.ow2.proactive.scripting.TaskScript) TaskContext(org.ow2.proactive.scheduler.task.context.TaskContext) InProcessTaskExecutor(org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) NodeDataSpacesURIs(org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs) Test(org.junit.Test)

Example 74 with TaskScript

use of org.ow2.proactive.scripting.TaskScript in project scheduling by ow2-proactive.

the class InProcessTaskExecutorTest method failingFlowScript.

@Test
public void failingFlowScript() throws Exception {
    TestTaskOutput taskOutput = new TestTaskOutput();
    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setControlFlowScript(FlowScript.createReplicateFlowScript(""));
    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("hello", taskOutput.output());
    assertNotEquals("", taskOutput.error());
    assertNotNull(result.getException());
}
Also used : TaskContext(org.ow2.proactive.scheduler.task.context.TaskContext) TaskScript(org.ow2.proactive.scripting.TaskScript) InProcessTaskExecutor(org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) NodeDataSpacesURIs(org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs) Test(org.junit.Test)

Example 75 with TaskScript

use of org.ow2.proactive.scripting.TaskScript in project scheduling by ow2-proactive.

the class RestSmartProxyTest method createInErrorJob.

private TaskFlowJob createInErrorJob() throws InvalidScriptException, UserException {
    TaskFlowJob job = new TaskFlowJob();
    job.setName("JobWithInErrorTask");
    ScriptTask scriptTask = new ScriptTask();
    scriptTask.setName(inerrorTaskName);
    scriptTask.setScript(new TaskScript(new SimpleScript("syntax error", "python")));
    scriptTask.setOnTaskError(OnTaskError.PAUSE_TASK);
    scriptTask.setMaxNumberOfExecution(2);
    job.addTask(scriptTask);
    job.setInputSpace(userspace);
    job.setOutputSpace(userspace);
    return job;
}
Also used : ScriptTask(org.ow2.proactive.scheduler.common.task.ScriptTask) TaskScript(org.ow2.proactive.scripting.TaskScript) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SimpleScript(org.ow2.proactive.scripting.SimpleScript)

Aggregations

TaskScript (org.ow2.proactive.scripting.TaskScript)78 SimpleScript (org.ow2.proactive.scripting.SimpleScript)76 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)64 Test (org.junit.Test)59 NodeDataSpacesURIs (org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs)31 TaskContext (org.ow2.proactive.scheduler.task.context.TaskContext)31 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)19 TaskLauncherInitializer (org.ow2.proactive.scheduler.task.TaskLauncherInitializer)19 InProcessTaskExecutor (org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor)19 ScriptTask (org.ow2.proactive.scheduler.common.task.ScriptTask)12 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)11 Serializable (java.io.Serializable)10 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)10 File (java.io.File)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 ForkEnvironment (org.ow2.proactive.scheduler.common.task.ForkEnvironment)8 HashMap (java.util.HashMap)6 Semaphore (java.util.concurrent.Semaphore)5