use of org.ow2.proactive.scheduler.task.TaskLauncherInitializer 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());
}
use of org.ow2.proactive.scheduler.task.TaskLauncherInitializer 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());
}
use of org.ow2.proactive.scheduler.task.TaskLauncherInitializer 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));
}
use of org.ow2.proactive.scheduler.task.TaskLauncherInitializer 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, ""));
}
use of org.ow2.proactive.scheduler.task.TaskLauncherInitializer 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));
}
Aggregations