use of org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId in project scheduling by ow2-proactive.
the class WalltimeTaskLauncherTest method walltime_during_task_execution.
@Test(timeout = 5000)
public void walltime_during_task_execution() throws Throwable {
ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("java.lang.Thread.sleep(10000)", "javascript")));
TaskLauncherInitializer initializer = new TaskLauncherInitializer();
initializer.setWalltime(500);
initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
TaskResult taskResult = runTaskLauncher(createLauncherWithInjectedMocks(initializer, new TestTaskLauncherFactory()), executableContainer);
assertEquals(WalltimeExceededException.class, taskResult.getException().getClass());
}
use of org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId in project scheduling by ow2-proactive.
the class WalltimeTaskLauncherTest method walltime_during_file_copy.
@Test(timeout = 5000)
public void walltime_during_file_copy() throws Throwable {
ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("", "javascript")));
TaskLauncherInitializer initializer = new TaskLauncherInitializer();
initializer.setWalltime(500);
initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
TaskResult taskResult = runTaskLauncher(createLauncherWithInjectedMocks(initializer, new SlowDataspacesTaskLauncherFactory()), executableContainer);
assertEquals(WalltimeExceededException.class, taskResult.getException().getClass());
}
use of org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId in project scheduling by ow2-proactive.
the class TaskContextSerializerTest method createTaskContext.
private TaskContext createTaskContext() throws NodeException, InvalidScriptException {
TaskLauncherInitializer taskLauncherInitializer = new TaskLauncherInitializer();
taskLauncherInitializer.setTaskId(TaskIdImpl.createTaskId(new JobIdImpl(1L, "testSerializeContextToFile"), "testSerializeContextToFile", 1L));
// Invoke method to test it
return new TaskContext(new ScriptExecutableContainer(new TaskScript(new ForkEnvironmentScript(new SimpleScript("", "python")))), taskLauncherInitializer, null, new NodeDataSpacesURIs(null, null, null, null, null, null), null, null);
}
use of org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId in project scheduling by ow2-proactive.
the class ForkedTaskExecutorRunAsMeTest method runAsMe_PasswordMethod.
@Test
public void runAsMe_PasswordMethod() throws Throwable {
TestTaskOutput taskOutput = new TestTaskOutput();
Decrypter decrypter = createCredentials(USERNAME, PASSWORD);
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("whoami", "native")));
container.setRunAsUser(true);
TaskContext taskContext = new TaskContext(container, initializer, null, new NodeDataSpacesURIs("", "", "", "", "", ""), "", "", decrypter);
TaskResultImpl result = taskExecutor.execute(taskContext, taskOutput.outputStream, taskOutput.error);
assertTaskResultOk(result);
assertEquals("admin\n", taskOutput.output());
}
use of org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId in project scheduling by ow2-proactive.
the class ForkedTaskExecutorTest method nonDaemonThreadsForkedJVMExit.
/**
* This test ensures that the forked JVM exited properly when non-daemon threads are created inside the task
*
* @throws Exception
*/
@Test(timeout = 30000)
public void nonDaemonThreadsForkedJVMExit() throws Exception {
String taskScript = CharStreams.toString(new InputStreamReader(getClass().getResourceAsStream("/task-nondaemon-thread.groovy"), Charsets.UTF_8));
TestTaskOutput taskOutput = new TestTaskOutput();
File workingDir = tmpFolder.newFolder();
ForkedTaskExecutor taskExecutor = new ForkedTaskExecutor(workingDir);
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(taskScript, "groovy"))), initializer, null, new NodeDataSpacesURIs("", "", "", "", "", ""), "", ""), taskOutput.outputStream, taskOutput.error);
Assert.assertFalse(result.hadException());
}
Aggregations