use of org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId 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.TaskIdImpl.createTaskId 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.TaskIdImpl.createTaskId 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.TaskIdImpl.createTaskId 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));
}
use of org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId in project scheduling by ow2-proactive.
the class TaskLoggerTest method createFileAppenderTest.
@Test
public void createFileAppenderTest() throws Exception {
JobId jobid = new JobIdImpl(1000, "job");
TaskId taskId = TaskIdImpl.createTaskId(jobid, "task", 42L);
taskLogger = new TaskLogger(taskId, "myhost");
File logFolder = tempFolder.newFolder("logfolder");
File logAppender = taskLogger.createFileAppender(logFolder);
System.out.println(logAppender.getParentFile().getName());
assertEquals(logAppender.getParentFile().getName(), jobid.value());
assertEquals(logAppender.getName(), new TaskLoggerRelativePathGenerator(taskId).getFileName());
}
Aggregations