use of org.ow2.proactive.scheduler.task.containers.ExecutableContainer in project scheduling by ow2-proactive.
the class TaskLauncherTest method javaTask.
@Test
public void javaTask() throws Throwable {
HashMap<String, byte[]> args = new HashMap<>();
args.put("number", AllObjects2BytesConverterHandler.convertObject2Byte("number", 123));
ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript(WaitAndPrint.class.getName(), "java", new Serializable[] { args })));
TaskLauncherInitializer initializer = new TaskLauncherInitializer();
initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job*1", 1000L));
TaskResult taskResult = runTaskLauncher(createLauncherWithInjectedMocks(initializer, new TestTaskLauncherFactory()), executableContainer);
assertThat((String) taskResult.value(), is(not("")));
assertThat(taskResult.getOutput().getAllLogs(false).contains("123"), is(true));
}
use of org.ow2.proactive.scheduler.task.containers.ExecutableContainer in project scheduling by ow2-proactive.
the class TaskLauncherTest method simpleTask.
@Test
public void simpleTask() throws Throwable {
ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("print('hello'); result='hello'", "groovy")));
TaskLauncherInitializer initializer = new TaskLauncherInitializer();
initializer.setPreScript(new SimpleScript("print('pre')", "groovy"));
initializer.setPostScript(new SimpleScript("print('post')", "groovy"));
initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
TaskResult taskResult = runTaskLauncher(createLauncherWithInjectedMocks(initializer, new TestTaskLauncherFactory()), executableContainer);
assertThat((String) taskResult.value(), is("hello"));
assertThat(taskResult.getOutput().getAllLogs(false).contains(String.format("prehellopost%n")), is(true));
}
use of org.ow2.proactive.scheduler.task.containers.ExecutableContainer in project scheduling by ow2-proactive.
the class TaskLauncherTest method thirdPartyCredentials.
@Test
public void thirdPartyCredentials() throws Throwable {
ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("print(credentials.get('password'))", "groovy")));
TaskLauncherInitializer initializer = new TaskLauncherInitializer();
initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
createLauncherWithInjectedMocks(initializer, new TestTaskLauncherFactory());
CredData credData = new CredData("john", "pwd");
credData.addThirdPartyCredential("password", "r00t");
final KeyPairProducer keyPairProducer = new KeyPairProducer();
final TaskLauncher spy = spy(taskLauncher);
doReturn(keyPairProducer.getKeyPair()).when(spy).getKeyPair();
Credentials thirdPartyCredentials = Credentials.createCredentials(credData, spy.generatePublicKey());
executableContainer.setCredentials(thirdPartyCredentials);
TaskResult taskResult = runTaskLauncher(spy, executableContainer);
final String allLogs = taskResult.getOutput().getAllLogs(false);
assertThat(allLogs.contains(String.format("r00t%n")), is(true));
}
use of org.ow2.proactive.scheduler.task.containers.ExecutableContainer 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.containers.ExecutableContainer 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());
}
Aggregations