Search in sources :

Example 11 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 12 with InvalidScriptException

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

the class TagTest method createReplicateTask.

private InternalScriptTask createReplicateTask(String name, InternalTask[] dependences, FlowBlock block, String matchingBlock, int nbRuns) throws InvalidScriptException {
    InternalScriptTask result = createTask(name, dependences, block, matchingBlock);
    FlowScript replicate = FlowScript.createReplicateFlowScript("runs = " + nbRuns + ";");
    result.setFlowScript(replicate);
    return result;
}
Also used : InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript)

Example 13 with InvalidScriptException

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

the class TagTest method testTaskLoggerWithTag.

@Test
public void testTaskLoggerWithTag() throws InvalidScriptException, UnknownTaskException {
    InternalScriptTask task1 = createLoopTask("T1", "loop = true;", null, "T1", false);
    task1.setTag("aTag");
    TaskLogger.getInstance().info(job.getTask("T1").getId(), "a message");
}
Also used : InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) Test(org.junit.Test) ProActiveTest(org.ow2.tests.ProActiveTest)

Example 14 with InvalidScriptException

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

the class TagTest method testTaskLogger.

/*
     * @Test
     * public void testReplicationLoopDoubleTag() throws Exception {
     * InternalTask T1 = createTask("T1", null, FlowBlock.START, "T5");
     * InternalTask T2 = createTask("T2", new InternalTask[]{T1}, FlowBlock.START, "T4");
     * InternalTask T3 = createTask("T3", new InternalTask[]{T2}, null, null);
     * InternalTask T4 = createLoopTask("T4", "loop = true;", new InternalTask[]{T3}, "T2", true);
     * InternalTask T5 = createLoopTask("T5", "loop = true;", new InternalTask[]{T4}, "T1", true);
     * 
     * job.getJobDescriptor().getEligibleTasks();
     * 
     * 
     * execute(new String[]{"T5"});
     * 
     * assertTags("REPLICATE-T1-1", new String[]{"T2*1", "T3*1", "T4*1", "T5*1", "T6*1"});
     * assertTags("REPLICATE-T1-2", new String[]{"T2*2", "T3*2", "T4*2", "T5*2", "T6*2"});
     * assertTags("REPLICATE-T2*1-3", new String[]{"T3*3", "T4*3", "T5*3"});
     * assertTags("REPLICATE-T2*1-4", new String[]{"T3*4", "T4*4", "T5*4"});
     * assertTags("REPLICATE-T2*2-5", new String[]{"T3*5", "T4*5", "T5*5"});
     * assertTags("REPLICATE-T2*2-6", new String[]{"T3*6", "T4*6", "T5*6"});
     * }
     */
@Test
public void testTaskLogger() throws InvalidScriptException, UnknownTaskException {
    InternalScriptTask task1 = createLoopTask("T1", "loop = true;", null, "T1", false);
    TaskLogger.getInstance().info(job.getTask("T1").getId(), "a message");
}
Also used : InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) Test(org.junit.Test) ProActiveTest(org.ow2.tests.ProActiveTest)

Example 15 with InvalidScriptException

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

the class InstallPackageCommand method execute.

@Override
public void execute(ApplicationContext currentContext) throws CLIException {
    SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
    ScriptResult scriptResult;
    Map<String, Object> schedulerProperties;
    String packageDirPath;
    try {
        packageDirPath = retrievePackagePath();
        schedulerProperties = retrieveSchedulerProperties(currentContext, scheduler);
        addSessionIdToSchedulerProperties(currentContext, schedulerProperties);
        scriptResult = executeScript(schedulerProperties, packageDirPath);
        if (scriptResult.errorOccured()) {
            logger.error("Failed to execute script: " + SCRIPT_PATH);
            throw new InvalidScriptException("Failed to execute script: " + scriptResult.getException().getMessage(), scriptResult.getException());
        } else {
            writeLine(currentContext, "Package('%s') successfully installed in the catalog", SOURCE_PACKAGE);
        }
    } catch (Exception e) {
        handleError(String.format("An error occurred while attempting to install package('%s') in the catalog", SOURCE_PACKAGE), e, currentContext);
    }
}
Also used : ScriptResult(org.ow2.proactive.scripting.ScriptResult) InvalidScriptException(org.ow2.proactive.scripting.InvalidScriptException) SchedulerRestInterface(org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) IOException(java.io.IOException) InvalidScriptException(org.ow2.proactive.scripting.InvalidScriptException) CLIException(org.ow2.proactive_grid_cloud_portal.cli.CLIException) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)

Aggregations

Test (org.junit.Test)27 SimpleScript (org.ow2.proactive.scripting.SimpleScript)27 VariablesMap (org.ow2.proactive.scheduler.task.utils.VariablesMap)15 ScriptHandler (org.ow2.proactive.scripting.ScriptHandler)15 ForkEnvironment (org.ow2.proactive.scheduler.common.task.ForkEnvironment)14 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)14 TaskContext (org.ow2.proactive.scheduler.task.context.TaskContext)14 TaskLauncherInitializer (org.ow2.proactive.scheduler.task.TaskLauncherInitializer)12 NodeDataSpacesURIs (org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs)12 TaskScript (org.ow2.proactive.scripting.TaskScript)12 FlowScript (org.ow2.proactive.scheduler.common.task.flow.FlowScript)11 Script (org.ow2.proactive.scripting.Script)11 HashMap (java.util.HashMap)6 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)6 InternalScriptTask (org.ow2.proactive.scheduler.task.internal.InternalScriptTask)6 InvalidScriptException (org.ow2.proactive.scripting.InvalidScriptException)6 ScriptTask (org.ow2.proactive.scheduler.common.task.ScriptTask)5 File (java.io.File)4 SelectionScript (org.ow2.proactive.scripting.SelectionScript)4 Serializable (java.io.Serializable)3