use of org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId in project scheduling by ow2-proactive.
the class TaskLoggerTest method multipleRemoveLoggers.
@Test
public void multipleRemoveLoggers() throws Exception {
List<TaskLogger> loggers = new ArrayList<>(1000);
for (int i = 0; i < 1000; i++) {
loggers.add(new TaskLogger(TaskIdImpl.createTaskId(new JobIdImpl(1000, "job"), "task", i), "myhost"));
}
for (int i = 0; i < 1000; i++) {
loggers.get(i).close();
assertNull(LogManager.exists(loggers.get(i).getName()));
}
assertNull(LogManager.exists(Log4JTaskLogs.getLoggerName("" + 1000)));
}
use of org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId in project scheduling by ow2-proactive.
the class TaskLoggerTest method printAndGetLogs.
@Test
public void printAndGetLogs() throws Exception {
taskLogger = new TaskLogger(TaskIdImpl.createTaskId(new JobIdImpl(1000, "job"), "task", 42L), "myhost");
assertEquals("", taskLogger.getLogs().getAllLogs(false));
taskLogger.getOutputSink().println("hello");
assertEquals(String.format("hello%n"), taskLogger.getLogs().getAllLogs(false));
assertEquals(String.format("hello%n"), taskLogger.getLogs().getStdoutLogs(false));
taskLogger.getErrorSink().println("error");
assertEquals(String.format("hello%nerror%n"), taskLogger.getLogs().getAllLogs(false));
assertEquals(String.format("error%n"), taskLogger.getLogs().getStderrLogs(false));
}
use of org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId 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());
}
use of org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId in project scheduling by ow2-proactive.
the class ForkedTaskExecutorTest method failToFindJava.
@Test
public void failToFindJava() throws Throwable {
System.setProperty("java.home", "does not exist");
TestTaskOutput taskOutput = new TestTaskOutput();
ForkedTaskExecutor taskExecutor = new ForkedTaskExecutor(tmpFolder.newFolder());
TaskLauncherInitializer initializer = new TaskLauncherInitializer();
initializer.setTaskId((TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L)));
TaskResultImpl result = taskExecutor.execute(new TaskContext(new ScriptExecutableContainer(new TaskScript(new SimpleScript("print('hello'); result='hello'", "javascript"))), initializer, null, new NodeDataSpacesURIs("", "", "", "", "", ""), "", ""), taskOutput.outputStream, taskOutput.error);
assertNotNull(result.getException());
}
use of org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId in project scheduling by ow2-proactive.
the class ForkedTaskExecutorTest method runAsMe_userDoesNotExist.
@Test
public void runAsMe_userDoesNotExist() throws Throwable {
TestTaskOutput taskOutput = new TestTaskOutput();
Decrypter decrypter = createCredentials("somebody_that_does_not_exists");
ForkedTaskExecutor taskExecutor = new ForkedTaskExecutor(tmpFolder.newFolder());
TaskLauncherInitializer initializer = new TaskLauncherInitializer();
initializer.setTaskId((TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L)));
ScriptExecutableContainer container = new ScriptExecutableContainer(new TaskScript(new SimpleScript("print('hello'); result='hello'", "javascript")));
container.setRunAsUser(true);
TaskContext taskContext = new TaskContext(container, initializer, null, new NodeDataSpacesURIs("", "", "", "", "", ""), "", "", decrypter);
TaskResultImpl result = taskExecutor.execute(taskContext, taskOutput.outputStream, taskOutput.error);
assertNotNull(result.getException());
}
Aggregations