use of org.ow2.proactive.scheduler.common.task.ScriptTask 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.scheduler.common.task.ScriptTask in project scheduling by ow2-proactive.
the class RestSmartProxyTest method createInErrorJob.
private TaskFlowJob createInErrorJob() throws InvalidScriptException, UserException {
TaskFlowJob job = new TaskFlowJob();
job.setName("JobWithInErrorTask");
ScriptTask scriptTask = new ScriptTask();
scriptTask.setName(inerrorTaskName);
scriptTask.setScript(new TaskScript(new SimpleScript("syntax error", "python")));
scriptTask.setOnTaskError(OnTaskError.PAUSE_TASK);
scriptTask.setMaxNumberOfExecution(2);
job.addTask(scriptTask);
job.setInputSpace(userspace);
job.setOutputSpace(userspace);
return job;
}
use of org.ow2.proactive.scheduler.common.task.ScriptTask in project scheduling by ow2-proactive.
the class InternalJobFactory method createTask.
private static InternalTask createTask(Job userJob, InternalJob internalJob, ScriptTask task) throws JobCreationException {
InternalTask scriptTask;
if (isForkingTask()) {
scriptTask = new InternalForkedScriptTask(new ScriptExecutableContainer(task.getScript()), internalJob);
configureRunAsMe(task);
} else {
scriptTask = new InternalScriptTask(new ScriptExecutableContainer(task.getScript()), internalJob);
}
// set task common properties
try {
setTaskCommonProperties(userJob, task, scriptTask);
} catch (Exception e) {
throw new JobCreationException(e);
}
return scriptTask;
}
use of org.ow2.proactive.scheduler.common.task.ScriptTask in project scheduling by ow2-proactive.
the class TestDataspaceConcurrentKilling method createJobWithFileTransfers.
public Job createJobWithFileTransfers() throws UserException, InvalidScriptException {
TaskFlowJob job = new TaskFlowJob();
job.setName(JOB_NAME);
job.setOnTaskError(OnTaskError.CONTINUE_JOB_EXECUTION);
for (int i = 0; i < NB_TASKS; i++) {
ScriptTask st = new ScriptTask();
st.setName(TASK_NAME + i);
st.setScript(new TaskScript(new SimpleScript("new File(localspace, \"" + FILE_NAME + i + "\").createNewFile(); java.lang.Thread.sleep(1000)", "groovy")));
st.addOutputFiles(FILE_NAME + i, OutputAccessMode.TransferToUserSpace);
job.addTask(st);
}
return job;
}
use of org.ow2.proactive.scheduler.common.task.ScriptTask in project scheduling by ow2-proactive.
the class TestKillTaskWhileExecutingScripts method killEndlessScriptTask.
public void killEndlessScriptTask() throws Throwable {
log("Test : killing an Endless Script Task...");
String tname = "killEndlessScriptTask";
// pre script interruption
TaskFlowJob job = new TaskFlowJob();
job.setName(this.getClass().getSimpleName() + "_" + tname);
ScriptTask task1 = new ScriptTask();
task1.setName(tname);
task1.setScript(new TaskScript(endlessScript));
job.addTask(task1);
submitAndCheckJob(job, tname);
}
Aggregations