use of org.ow2.proactive.scripting.SimpleScript in project scheduling by ow2-proactive.
the class TestExecRemote method processBuilderScript.
private void processBuilderScript(String miscDir, boolean isLinux, String valueToEcho, HashSet<String> nodesUrls) throws Exception {
File sFile = new File(miscDir + "processBuilder.groovy");
RMTHelper.log("Test 4 - Test " + sFile);
String[] cmd = (isLinux) ? new String[] { "/bin/bash", "-c", "echo " + valueToEcho } : new String[] { "cmd.exe", "/c", "@(echo " + valueToEcho + ")" };
SimpleScript script = new SimpleScript(sFile, cmd);
List<ScriptResult<Object>> results = rmHelper.getResourceManager().executeScript(script, TargetType.NODE_URL.toString(), nodesUrls);
assertFalse("The results must not be empty", results.size() == 0);
for (ScriptResult<Object> res : results) {
String output = res.getOutput();
assertTrue("The script output must contains " + valueToEcho, output.contains(valueToEcho));
}
}
use of org.ow2.proactive.scripting.SimpleScript in project scheduling by ow2-proactive.
the class FlowScript method createContinueFlowScript.
public static FlowScript createContinueFlowScript() throws InvalidScriptException {
FlowScript fs = new FlowScript(new SimpleScript("", "javascript"));
fs.setActionType(FlowActionType.CONTINUE);
return fs;
}
use of org.ow2.proactive.scripting.SimpleScript in project scheduling by ow2-proactive.
the class Job2XMLTransformerTest method argumentsInScript.
@Test
public void argumentsInScript() throws Exception {
File xmlFile = tmpFolder.newFile();
TaskFlowJob job = new TaskFlowJob();
job.setName("simpleJob");
String[] params = { "param1", "param2" };
SimpleScript script = new SimpleScript("\nprint('arguments[0]='+arguments[0])\n", "javascript", params);
ScriptTask task = new ScriptTask();
task.setName("testTask");
task.setScript(new TaskScript(script));
job.addTask(task);
new Job2XMLTransformer().job2xmlFile(job, xmlFile);
TaskFlowJob recreatedJob = (TaskFlowJob) (JobFactory.getFactory().createJob(xmlFile.getAbsolutePath()));
Assert.assertEquals("param1", ((ScriptTask) recreatedJob.getTask("testTask")).getScript().getParameters()[0].toString());
Assert.assertEquals("param2", ((ScriptTask) recreatedJob.getTask("testTask")).getScript().getParameters()[1].toString());
}
use of org.ow2.proactive.scripting.SimpleScript in project scheduling by ow2-proactive.
the class InProcessTaskExecutorTest method testPaUserVariableAvailabilityFromScriptEngine.
@Test
public void testPaUserVariableAvailabilityFromScriptEngine() throws Throwable {
TestTaskOutput taskOutput = new TestTaskOutput();
String jobOwner = "JohnDoe";
TaskLauncherInitializer initializer = new TaskLauncherInitializer();
initializer.setJobOwner(jobOwner);
initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
new InProcessTaskExecutor().execute(new TaskContext(new ScriptExecutableContainer(new TaskScript(new SimpleScript("print variables.get('PA_USER')", "python"))), initializer, null, new NodeDataSpacesURIs("", "", "", "", "", ""), "", ""), taskOutput.outputStream, taskOutput.error);
assertEquals(jobOwner, taskOutput.output().trim());
}
use of org.ow2.proactive.scripting.SimpleScript in project scheduling by ow2-proactive.
the class KillTaskLauncherTest method finished_but_terminate_not_called_back.
@Test
@Repeat(value = repetitions, parallel = parallel, timeout = timeout)
public void finished_but_terminate_not_called_back() throws Throwable {
final ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("result='done'", "javascript")));
TaskLauncherInitializer initializer = new TaskLauncherInitializer();
initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
final TaskLauncher taskLauncher = createLauncherWithInjectedMocks(initializer, new TestTaskLauncherFactory(new Semaphore(0)));
final TaskLauncher taskLauncherPA = PAActiveObject.turnActive(taskLauncher);
TaskResultWaiter taskResultWaiter = new TaskResultWaiter();
WaitForResultNotification waitForResultNotification = new WaitForResultNotification(taskResultWaiter);
waitForResultNotification = PAActiveObject.turnActive(waitForResultNotification);
taskLauncherPA.doTask(executableContainer, null, waitForResultNotification);
assertEquals("done", taskResultWaiter.getTaskResult().value());
assertTaskLauncherIsTerminated(taskLauncherPA);
PAActiveObject.terminateActiveObject(taskLauncherPA, true);
}
Aggregations