Search in sources :

Example 16 with ExecutableContainer

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

the class KillTaskLauncherTest method finished_but_terminate_not_called_back.

@Test
@Repeat(value = repetitions, parallel = parallel, timeout = timeout)
public void finished_but_terminate_not_called_back() throws Throwable {
    final ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("result='done'", "javascript")));
    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
    final TaskLauncher taskLauncher = createLauncherWithInjectedMocks(initializer, new TestTaskLauncherFactory(new Semaphore(0)));
    final TaskLauncher taskLauncherPA = PAActiveObject.turnActive(taskLauncher);
    TaskResultWaiter taskResultWaiter = new TaskResultWaiter();
    WaitForResultNotification waitForResultNotification = new WaitForResultNotification(taskResultWaiter);
    waitForResultNotification = PAActiveObject.turnActive(waitForResultNotification);
    taskLauncherPA.doTask(executableContainer, null, waitForResultNotification);
    assertEquals("done", taskResultWaiter.getTaskResult().value());
    assertTaskLauncherIsTerminated(taskLauncherPA);
    PAActiveObject.terminateActiveObject(taskLauncherPA, true);
}
Also used : TaskScript(org.ow2.proactive.scripting.TaskScript) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) Semaphore(java.util.concurrent.Semaphore) Test(org.junit.Test) Repeat(org.ow2.proactive.utils.Repeat)

Example 17 with ExecutableContainer

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

the class KillTaskLauncherTest method kill_while_sleeping_in_task.

@Test
@Repeat(value = repetitions, parallel = parallel, timeout = timeout)
public void kill_while_sleeping_in_task() throws Exception {
    final ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("java.lang.Thread.sleep(10000)", "javascript")));
    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
    Semaphore taskRunning = new Semaphore(0);
    final TaskLauncher taskLauncher = createLauncherWithInjectedMocks(initializer, new TestTaskLauncherFactory(taskRunning));
    final TaskLauncher taskLauncherPA = PAActiveObject.turnActive(taskLauncher);
    taskLauncherPA.doTask(executableContainer, null, null);
    taskRunning.acquire();
    taskLauncherPA.kill();
    assertTaskLauncherIsTerminated(taskLauncherPA);
    PAActiveObject.terminateActiveObject(taskLauncherPA, true);
}
Also used : TaskScript(org.ow2.proactive.scripting.TaskScript) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) Semaphore(java.util.concurrent.Semaphore) Test(org.junit.Test) Repeat(org.ow2.proactive.utils.Repeat)

Example 18 with ExecutableContainer

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

the class KillTaskLauncherTest method kill_when_copying.

@Test
@Repeat(value = repetitions, parallel = parallel, timeout = timeout)
public void kill_when_copying() throws Throwable {
    final ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("result='done'", "javascript")));
    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
    Semaphore taskRunning = new Semaphore(0);
    final TaskLauncher taskLauncher = createLauncherWithInjectedMocks(initializer, new SlowDataspacesTaskLauncherFactory(taskRunning));
    final TaskLauncher taskLauncherPA = PAActiveObject.turnActive(taskLauncher);
    taskLauncherPA.doTask(executableContainer, null, null);
    taskRunning.acquire();
    taskLauncherPA.kill();
    assertTaskLauncherIsTerminated(taskLauncherPA);
    PAActiveObject.terminateActiveObject(taskLauncherPA, true);
}
Also used : TaskScript(org.ow2.proactive.scripting.TaskScript) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) Semaphore(java.util.concurrent.Semaphore) Test(org.junit.Test) Repeat(org.ow2.proactive.utils.Repeat)

Example 19 with ExecutableContainer

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

the class TaskLauncherDataSpacesTest method output_file_using_task_id_in_its_selector.

@Test
public void output_file_using_task_id_in_its_selector() throws Throwable {
    ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("new File('output_' + variables.get('PA_TASK_ID') + '.txt').text = 'hello'", "groovy")));
    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
    initializer.setTaskOutputFiles(singletonList(new OutputSelector(new FileSelector("output_${PA_TASK_ID}.txt"), OutputAccessMode.TransferToGlobalSpace)));
    TaskResult taskResult = runTaskLauncher(createLauncherWithInjectedMocks(initializer, taskLauncherFactory), executableContainer);
    assertTaskResultOk(taskResult);
    assertTrue(new File(taskLauncherFactory.getDataSpaces().getGlobalURI(), "output_1000.txt").exists());
}
Also used : TaskScript(org.ow2.proactive.scripting.TaskScript) OutputSelector(org.ow2.proactive.scheduler.common.task.dataspaces.OutputSelector) SimpleScript(org.ow2.proactive.scripting.SimpleScript) FileSelector(org.objectweb.proactive.extensions.dataspaces.vfs.selector.FileSelector) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) File(java.io.File) Test(org.junit.Test)

Example 20 with ExecutableContainer

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

the class TaskLauncherTest method taskLogsAreNotCopiedToUserSpace_PreciousLogsDisabled.

@Test
public void taskLogsAreNotCopiedToUserSpace_PreciousLogsDisabled() throws Exception {
    ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("print('hello'); result='hello'", "groovy")));
    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setPreciousLogs(false);
    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(1)).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)

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