use of org.ow2.proactive.scripting.SimpleScript 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.scripting.SimpleScript in project scheduling by ow2-proactive.
the class TestWorkflowIterationAwareness method testNativeJob.
/**
* native task through xml
*/
private void testNativeJob(String jobDescriptorPath) throws Throwable {
TaskFlowJob job = (TaskFlowJob) StaxJobFactory.getFactory().createJob(jobDescriptorPath);
switch(OperatingSystem.getOperatingSystem()) {
case windows:
((NativeTask) job.getTask("T1")).setPreScript(new SimpleScript(preScript, "groovy"));
((NativeTask) job.getTask("T1")).setPostScript(new SimpleScript(postScript, "groovy"));
String[] tab = ((NativeTask) job.getTask("T1")).getCommandLine();
tab[0] = "\"" + tab[0].replace("it.sh", "it.bat") + "\"";
tab[1] = tmpFolder;
((NativeTask) job.getTask("T1")).setCommandLine(tab);
break;
case unix:
job.getTask("T1").setPreScript(new SimpleScript(preScript, "groovy"));
job.getTask("T1").setPostScript(new SimpleScript(postScript, "groovy"));
break;
default:
throw new IllegalStateException("Unsupported operating system");
}
JobId id = TWorkflowJobs.testJobSubmission(schedulerHelper, job, null);
JobResult res = schedulerHelper.getJobResult(id);
Assert.assertFalse(schedulerHelper.getJobResult(id).hadException());
int n = 4;
for (Entry<String, TaskResult> result : res.getAllResults().entrySet()) {
String path = "";
switch(OperatingSystem.getOperatingSystem()) {
case windows:
File tmpdir = new File(tmpFolder, "native_result_");
path = tmpdir.getAbsolutePath();
break;
case unix:
path = System.getProperty("java.io.tmpdir") + "/native_result_";
break;
default:
throw new IllegalStateException("Operating system not supported");
}
if (result.getKey().equals("T1")) {
n--;
File f = new File(path + "0_0");
BufferedReader in = new BufferedReader(new FileReader(f));
checkResult(in.readLine(), "T1", "0", "0");
in.close();
f.delete();
} else if (result.getKey().equals("T1*1")) {
n--;
File f = new File(path + "0_1");
BufferedReader in = new BufferedReader(new FileReader(f));
checkResult(in.readLine(), "T1*1", "0", "1");
in.close();
f.delete();
} else if (result.getKey().equals("T1#1")) {
n--;
File f = new File(path + "1_0");
BufferedReader in = new BufferedReader(new FileReader(f));
checkResult(in.readLine(), "T1#1", "1", "0");
in.close();
f.delete();
} else if (result.getKey().equals("T1#1*1")) {
n--;
File f = new File(path + "1_1");
BufferedReader in = new BufferedReader(new FileReader(f));
checkResult(in.readLine(), "T1#1*1", "1", "1");
in.close();
f.delete();
}
}
assertTrue("Expected 4 tasks, misses " + n, n == 0);
schedulerHelper.removeJob(id);
schedulerHelper.waitForEventJobRemoved(id);
}
use of org.ow2.proactive.scripting.SimpleScript in project scheduling by ow2-proactive.
the class TestWorkflowIterationAwareness method testJavaJob.
/**
* java task through xml
*/
private void testJavaJob(String jobDescriptorPath) throws Throwable {
TaskFlowJob job = (TaskFlowJob) StaxJobFactory.getFactory().createJob(jobDescriptorPath);
((JavaTask) job.getTask("T1")).setPreScript(new SimpleScript(preScript, "groovy"));
((JavaTask) job.getTask("T1")).setPostScript(new SimpleScript(postScript, "groovy"));
JobId id = TWorkflowJobs.testJobSubmission(schedulerHelper, job, null);
JobResult res = schedulerHelper.getJobResult(id);
Assert.assertFalse(schedulerHelper.getJobResult(id).hadException());
int n = 4;
for (Entry<String, TaskResult> result : res.getAllResults().entrySet()) {
if (result.getKey().equals("T1")) {
n--;
checkResult(result.getValue().toString(), "T1", "0", "0");
} else if (result.getKey().equals("T1*1")) {
n--;
checkResult(result.getValue().toString(), "T1*1", "0", "1");
} else if (result.getKey().equals("T1#1")) {
n--;
checkResult(result.getValue().toString(), "T1#1", "1", "0");
} else if (result.getKey().equals("T1#1*1")) {
n--;
checkResult(result.getValue().toString(), "T1#1*1", "1", "1");
}
}
assertTrue("Expected 4 tasks, misses " + n, n == 0);
schedulerHelper.removeJob(id);
schedulerHelper.waitForEventJobRemoved(id);
}
use of org.ow2.proactive.scripting.SimpleScript 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.scripting.SimpleScript in project scheduling by ow2-proactive.
the class RunningTaskRecoveryWithDownNodeTest method submitJob.
private JobId submitJob() throws Exception {
TaskFlowJob job = new TaskFlowJob();
job.setName("JOB-" + RunningTaskRecoveryWithDownNodeTest.class.getSimpleName());
for (int i = 0; i < NUMBER_OF_TASKS; i++) {
ScriptTask st1 = new ScriptTask();
st1.setName(TASK_BASE_NAME + i);
st1.setScript(new TaskScript(new SimpleScript("Thread.sleep(60000)", "groovy")));
job.addTask(st1);
}
JobId jobid = schedulerHelper.submitJob(job);
schedulerHelper.waitForEventJobRunning(jobid);
return jobid;
}
Aggregations