use of org.ow2.proactive.scheduler.common.task.flow.FlowScript in project scheduling by ow2-proactive.
the class CheckEligibleTaskDescriptorScriptTest method testAllScriptsContainAPIBinding.
@Test
public void testAllScriptsContainAPIBinding() throws InvalidScriptException {
Script s = scriptWithApiBindingClient();
Script s1 = scriptWithApiBindingUser();
Script s2 = scriptWithApiBindingGlobal();
FlowScript fs = flowScriptWithApiBindingClient();
Mockito.when(it.getPreScript()).thenReturn(s1);
Mockito.when(it.getPostScript()).thenReturn(s2);
Mockito.when(it.getCleaningScript()).thenReturn(s2);
Mockito.when(sec.getScript()).thenReturn(s);
Mockito.when(fe.getEnvScript()).thenReturn(s);
Mockito.when(it.getFlowScript()).thenReturn(fs);
assertTrue(new CheckEligibleTaskDescriptorScript().isTaskContainsAPIBinding(etd));
}
use of org.ow2.proactive.scheduler.common.task.flow.FlowScript in project scheduling by ow2-proactive.
the class CheckEligibleTaskDescriptorScriptTest method testAllScriptsNotContainAPIBinding.
@Test
public void testAllScriptsNotContainAPIBinding() throws InvalidScriptException {
Script s = scriptWithoutApiBinding();
FlowScript fs = flowScriptWithoutApiBinding();
Mockito.when(it.getPreScript()).thenReturn(s);
Mockito.when(it.getPostScript()).thenReturn(s);
Mockito.when(it.getCleaningScript()).thenReturn(s);
Mockito.when(sec.getScript()).thenReturn(s);
Mockito.when(fe.getEnvScript()).thenReturn(s);
Mockito.when(it.getFlowScript()).thenReturn(fs);
assertFalse(new CheckEligibleTaskDescriptorScript().isTaskContainsAPIBinding(etd));
}
use of org.ow2.proactive.scheduler.common.task.flow.FlowScript in project scheduling by ow2-proactive.
the class JobDescriptorImpl method isEntryPoint.
/**
* Tags all startable tasks as entry point
* a startable task : has no dependency, and is not target of an if control flow action
*
* @param t a Task
* @param otherTasks the other tasks contained in the job containing task t
* @return true if t is an entry point among all tasks in otherTasks, or false
*/
private boolean isEntryPoint(InternalTask t, List<InternalTask> otherTasks) {
List<TaskState> deps = t.getDependences();
boolean entryPoint = false;
// an entry point has no dependency
if (deps == null || deps.size() == 0) {
entryPoint = true;
} else {
return false;
}
// a entry point is not target of an if
for (Task t2 : otherTasks) {
if (t.equals(t2)) {
continue;
}
FlowScript sc = t2.getFlowScript();
if (sc != null) {
String actionType = sc.getActionType();
if (FlowActionType.parse(actionType).equals(FlowActionType.IF)) {
String tIf = sc.getActionTarget();
String tElse = sc.getActionTargetElse();
String tJoin = sc.getActionContinuation();
if (tIf != null && tIf.equals(t.getName())) {
return false;
}
if (tElse != null && tElse.equals(t.getName())) {
return false;
}
if (tJoin != null && tJoin.equals(t.getName())) {
return false;
}
}
}
}
return entryPoint;
}
use of org.ow2.proactive.scheduler.common.task.flow.FlowScript in project scheduling by ow2-proactive.
the class TestKillTaskWhileExecutingScripts method javaTaskKillEndlessFlowScript.
public void javaTaskKillEndlessFlowScript() throws Throwable {
log("Test Java Task : killing an Endless FlowScript ...");
String tname = "javaTaskKillEndlessFlowScript";
// pre script interruption
TaskFlowJob job = new TaskFlowJob();
job.setName(this.getClass().getSimpleName() + "_" + tname);
JavaTask task1 = new JavaTask();
task1.setName(tname);
task1.setExecutableClassName(EmptyExecutable.class.getName());
task1.setFlowScript(FlowScript.createLoopFlowScript(endlessScript, tname));
job.addTask(task1);
submitAndCheckJob(job, tname);
}
use of org.ow2.proactive.scheduler.common.task.flow.FlowScript in project scheduling by ow2-proactive.
the class TestJobRemove method createJob.
private TaskFlowJob createJob(int tasksNumber) throws Exception {
ForkEnvironment forkEnvironment = new ForkEnvironment();
forkEnvironment.addAdditionalClasspath("lib/ProActive/ProActive.jar", "compile/lib/ant.jar");
TaskFlowJob jobDef = new TaskFlowJob();
jobDef.addGenericInformation("k1", "v1");
jobDef.addGenericInformation("k2", "v2");
// add data with non-null ifBranch
JavaTask A = createDefaultTask("A");
A.setForkEnvironment(forkEnvironment);
FlowScript ifScript = FlowScript.createIfFlowScript("branch = \"if\";", "B", "C", null);
A.setFlowScript(ifScript);
jobDef.addTask(A);
JavaTask B = createDefaultTask("B");
B.setForkEnvironment(forkEnvironment);
jobDef.addTask(B);
JavaTask C = createDefaultTask("C");
C.setForkEnvironment(forkEnvironment);
jobDef.addTask(C);
for (int i = 0; i < tasksNumber; i++) {
JavaTask task1 = new JavaTask();
task1.setName("javaTask-" + i);
task1.setExecutableClassName(TestDummyExecutable.class.getName());
task1.addArgument("arg1", "arg1");
task1.addArgument("arg2", "arg2");
setAttributes(task1);
JavaTask task2 = new JavaTask();
task2.setName("forkedJavaTask-" + i);
task2.setExecutableClassName(TestDummyExecutable.class.getName());
ForkEnvironment forkEnv = new ForkEnvironment();
forkEnv.addAdditionalClasspath("lib/ProActive/ProActive.jar");
forkEnv.addAdditionalClasspath("compile/lib/ant.jar");
forkEnv.addJVMArgument("jvmArg1");
forkEnv.addJVMArgument("jvmArg2");
forkEnv.addSystemEnvironmentVariable("e1", "v1");
forkEnv.addSystemEnvironmentVariable("e2", "v2");
forkEnv.setEnvScript(new SimpleScript("env script", "javascript", new String[] { "param1", "param2" }));
task2.setForkEnvironment(forkEnv);
task2.addArgument("arg1", "arg1");
task2.addArgument("arg2", "arg2");
setAttributes(task2);
NativeTask task3 = new NativeTask();
task3.setName("nativeTask-" + i);
task3.setCommandLine("command1", "command2", "command3");
setAttributes(task3);
task1.addDependence(task2);
task3.addDependence(task2);
task1.setForkEnvironment(forkEnvironment);
task2.setForkEnvironment(forkEnvironment);
task3.setForkEnvironment(forkEnvironment);
jobDef.addTask(task1);
jobDef.addTask(task2);
jobDef.addTask(task3);
}
return jobDef;
}
Aggregations