Search in sources :

Example 21 with ExecutableContainer

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

the class TaskLauncherTest method taskLogsAreCopiedToUserSpace.

@Test
public void taskLogsAreCopiedToUserSpace() throws Exception {
    ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("print('hello'); result='hello'", "groovy")));
    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setPreciousLogs(true);
    initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
    final TaskDataspaces dataspacesMock = mock(TaskDataspaces.class);
    when(dataspacesMock.getScratchFolder()).thenReturn(tmpFolder.newFolder());
    runTaskLauncher(createLauncherWithInjectedMocks(initializer, new TestTaskLauncherFactory() {

        @Override
        public TaskDataspaces createTaskDataspaces(TaskId taskId, NamingService namingService, boolean isRunAsUser) {
            return dataspacesMock;
        }
    }), executableContainer);
    verify(dataspacesMock, times(2)).copyScratchDataToOutput(Matchers.<List<OutputSelector>>any());
}
Also used : TaskScript(org.ow2.proactive.scripting.TaskScript) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) OutputSelector(org.ow2.proactive.scheduler.common.task.dataspaces.OutputSelector) TaskDataspaces(org.ow2.proactive.scheduler.task.data.TaskDataspaces) NamingService(org.objectweb.proactive.extensions.dataspaces.core.naming.NamingService) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) Test(org.junit.Test)

Example 22 with ExecutableContainer

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

the class TaskLauncherTest method nativeTask_WorkingDir_WithVariableReplacement.

@Test
public void nativeTask_WorkingDir_WithVariableReplacement() throws Throwable {
    String tempFolder = tmpFolder.newFolder().getCanonicalPath();
    ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript(pwdCommand(), "native")));
    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setJobVariables(singletonMap("folder", new JobVariable("folder", tempFolder)));
    initializer.setForkEnvironment(new ForkEnvironment("$folder"));
    initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
    TaskResult taskResult = runTaskLauncher(createLauncherWithInjectedMocks(initializer, new TestTaskLauncherFactory()), executableContainer);
    assertThat(taskResult.getOutput().getAllLogs(false).contains(String.format("%s%n", tempFolder)), is(true));
}
Also used : TaskScript(org.ow2.proactive.scripting.TaskScript) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment) Test(org.junit.Test)

Example 23 with ExecutableContainer

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

the class TaskLauncherTest method failedTask.

@Test
public void failedTask() throws Throwable {
    ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("failing task'", "groovy")));
    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
    TaskResult taskResult = runTaskLauncher(createLauncherWithInjectedMocks(initializer, new TestTaskLauncherFactory()), executableContainer);
    assertNotNull(taskResult.getException());
    assertNotEquals("", taskResult.getOutput().getStderrLogs(false).replace(HEADLESS_JAVA_LOG, ""));
}
Also used : TaskScript(org.ow2.proactive.scripting.TaskScript) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) Test(org.junit.Test)

Example 24 with ExecutableContainer

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

the class TaskLauncherTest method nativeTask_WorkingDir.

@Test
public void nativeTask_WorkingDir() throws Throwable {
    String tempFolder = tmpFolder.newFolder().getCanonicalPath();
    ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript(pwdCommand(), "native")));
    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setForkEnvironment(new ForkEnvironment(tempFolder));
    initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
    TaskResult taskResult = runTaskLauncher(createLauncherWithInjectedMocks(initializer, new TestTaskLauncherFactory()), executableContainer);
    assertThat(taskResult.getOutput().getAllLogs(false).contains(String.format("%s%n", tempFolder)), is(true));
}
Also used : TaskScript(org.ow2.proactive.scripting.TaskScript) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment) Test(org.junit.Test)

Example 25 with ExecutableContainer

use of org.ow2.proactive.scheduler.task.containers.ExecutableContainer 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());
}
Also used : TaskScript(org.ow2.proactive.scripting.TaskScript) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) Test(org.junit.Test)

Aggregations

ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)23 Test (org.junit.Test)22 SimpleScript (org.ow2.proactive.scripting.SimpleScript)21 TaskScript (org.ow2.proactive.scripting.TaskScript)21 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)13 Semaphore (java.util.concurrent.Semaphore)5 Repeat (org.ow2.proactive.utils.Repeat)5 File (java.io.File)4 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)4 TaskDataspaces (org.ow2.proactive.scheduler.task.data.TaskDataspaces)4 NamingService (org.objectweb.proactive.extensions.dataspaces.core.naming.NamingService)3 FileSelector (org.objectweb.proactive.extensions.dataspaces.vfs.selector.FileSelector)3 OutputSelector (org.ow2.proactive.scheduler.common.task.dataspaces.OutputSelector)3 JobVariable (org.ow2.proactive.scheduler.common.job.JobVariable)2 ForkEnvironment (org.ow2.proactive.scheduler.common.task.ForkEnvironment)2 InputSelector (org.ow2.proactive.scheduler.common.task.dataspaces.InputSelector)2 WaitAndPrint (org.ow2.proactive.scheduler.examples.WaitAndPrint)2 ExecutableContainer (org.ow2.proactive.scheduler.task.containers.ExecutableContainer)2 Stopwatch (com.google.common.base.Stopwatch)1 InputStreamReader (java.io.InputStreamReader)1