Search in sources :

Example 1 with InvalidScriptException

use of org.ow2.proactive.scripting.InvalidScriptException in project scheduling by ow2-proactive.

the class SelectionScriptEvaluator method evaluateScript.

private static void evaluateScript(String selectionScript) {
    try {
        final ScriptHandler localHandler = ScriptLoader.createLocalHandler();
        final ScriptResult<Boolean> result = localHandler.handle(new SelectionScript(new File(selectionScript), null));
        if (result.errorOccured()) {
            result.getException().printStackTrace(System.err);
            System.exit(3);
        }
    } catch (InvalidScriptException e) {
        System.exit(2);
    }
}
Also used : SelectionScript(org.ow2.proactive.scripting.SelectionScript) InvalidScriptException(org.ow2.proactive.scripting.InvalidScriptException) File(java.io.File) ScriptHandler(org.ow2.proactive.scripting.ScriptHandler)

Example 2 with InvalidScriptException

use of org.ow2.proactive.scripting.InvalidScriptException in project scheduling by ow2-proactive.

the class TaskContextTest method createTaskContext.

private TaskContext createTaskContext() throws NodeException, InvalidScriptException {
    TaskLauncherInitializer taskLauncherInitializer = new TaskLauncherInitializer();
    taskLauncherInitializer.setTaskId(TaskIdImpl.createTaskId(new JobIdImpl(1L, "testSerializeContextToFile"), "testSerializeContextToFile", 1L));
    // Invoke method to test it
    return new TaskContext(new ScriptExecutableContainer(new TaskScript(new ForkEnvironmentScript(new SimpleScript("", "python")))), taskLauncherInitializer, null, new NodeDataSpacesURIs(null, null, null, null, null, null), null, new NodeInfo(null, null, null, null));
}
Also used : TaskContext(org.ow2.proactive.scheduler.task.context.TaskContext) TaskScript(org.ow2.proactive.scripting.TaskScript) NodeInfo(org.ow2.proactive.scheduler.task.context.NodeInfo) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) NodeDataSpacesURIs(org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs) ForkEnvironmentScript(org.ow2.proactive.scripting.ForkEnvironmentScript)

Example 3 with InvalidScriptException

use of org.ow2.proactive.scripting.InvalidScriptException in project scheduling by ow2-proactive.

the class CheckEligibleTaskDescriptorScriptTest method testOnlyEnvScriptContainsAPIBinding.

@Test
public void testOnlyEnvScriptContainsAPIBinding() throws InvalidScriptException {
    Script s = scriptWithApiBindingUser();
    FlowScript fs = flowScriptWithoutApiBinding();
    Script s2 = scriptWithoutApiBinding();
    Mockito.when(it.getPreScript()).thenReturn(s2);
    Mockito.when(it.getPostScript()).thenReturn(s2);
    Mockito.when(it.getCleaningScript()).thenReturn(s2);
    Mockito.when(sec.getScript()).thenReturn(s2);
    Mockito.when(fe.getEnvScript()).thenReturn(s);
    Mockito.when(it.getFlowScript()).thenReturn(fs);
    assertTrue(new CheckEligibleTaskDescriptorScript().isTaskContainsAPIBinding(etd));
}
Also used : SimpleScript(org.ow2.proactive.scripting.SimpleScript) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript) Script(org.ow2.proactive.scripting.Script) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript) Test(org.junit.Test)

Example 4 with InvalidScriptException

use of org.ow2.proactive.scripting.InvalidScriptException in project scheduling by ow2-proactive.

the class CheckEligibleTaskDescriptorScriptTest method testOnlyPreScriptContainsAPIBinding.

@Test
public void testOnlyPreScriptContainsAPIBinding() throws InvalidScriptException {
    Script s = scriptWithApiBindingUser();
    Script s2 = scriptWithoutApiBinding();
    FlowScript fs = flowScriptWithoutApiBinding();
    Mockito.when(it.getPreScript()).thenReturn(s);
    Mockito.when(it.getPostScript()).thenReturn(s2);
    Mockito.when(it.getCleaningScript()).thenReturn(s2);
    Mockito.when(sec.getScript()).thenReturn(s2);
    Mockito.when(fe.getEnvScript()).thenReturn(s2);
    Mockito.when(it.getFlowScript()).thenReturn(fs);
    assertTrue(new CheckEligibleTaskDescriptorScript().isTaskContainsAPIBinding(etd));
}
Also used : SimpleScript(org.ow2.proactive.scripting.SimpleScript) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript) Script(org.ow2.proactive.scripting.Script) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript) Test(org.junit.Test)

Example 5 with InvalidScriptException

use of org.ow2.proactive.scripting.InvalidScriptException in project scheduling by ow2-proactive.

the class CheckEligibleTaskDescriptorScriptTest method testOnlyInternalScriptContainsAPIBinding.

@Test
public void testOnlyInternalScriptContainsAPIBinding() throws InvalidScriptException {
    Script s = scriptWithApiBindingGlobal();
    Script s2 = scriptWithoutApiBinding();
    FlowScript fs = flowScriptWithoutApiBinding();
    Mockito.when(((EligibleTaskDescriptorImpl) etd).getInternal()).thenReturn(ist);
    Mockito.when(ist.getPreScript()).thenReturn(s2);
    Mockito.when(ist.getPostScript()).thenReturn(s2);
    Mockito.when(it.getCleaningScript()).thenReturn(s2);
    Mockito.when(sec.getScript()).thenReturn(s);
    Mockito.when(fe.getEnvScript()).thenReturn(s2);
    Mockito.when(it.getFlowScript()).thenReturn(fs);
    assertTrue(new CheckEligibleTaskDescriptorScript().isTaskContainsAPIBinding(etd));
}
Also used : SimpleScript(org.ow2.proactive.scripting.SimpleScript) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript) Script(org.ow2.proactive.scripting.Script) EligibleTaskDescriptorImpl(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptorImpl) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)28 SimpleScript (org.ow2.proactive.scripting.SimpleScript)25 VariablesMap (org.ow2.proactive.scheduler.task.utils.VariablesMap)16 ScriptHandler (org.ow2.proactive.scripting.ScriptHandler)16 ForkEnvironment (org.ow2.proactive.scheduler.common.task.ForkEnvironment)14 TaskContext (org.ow2.proactive.scheduler.task.context.TaskContext)14 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)13 TaskLauncherInitializer (org.ow2.proactive.scheduler.task.TaskLauncherInitializer)12 NodeDataSpacesURIs (org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs)12 NodeInfo (org.ow2.proactive.scheduler.task.context.NodeInfo)12 FlowScript (org.ow2.proactive.scheduler.common.task.flow.FlowScript)11 Script (org.ow2.proactive.scripting.Script)11 TaskScript (org.ow2.proactive.scripting.TaskScript)11 HashMap (java.util.HashMap)7 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)6 InvalidScriptException (org.ow2.proactive.scripting.InvalidScriptException)6 Serializable (java.io.Serializable)5 ScriptTask (org.ow2.proactive.scheduler.common.task.ScriptTask)5 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)5 InternalScriptTask (org.ow2.proactive.scheduler.task.internal.InternalScriptTask)5