Search in sources :

Example 31 with Task

use of org.ow2.proactive.scheduler.common.task.Task in project scheduling by ow2-proactive.

the class TaskUsingCredentialsTest method jobs_using_third_party_credentials.

private void jobs_using_third_party_credentials() throws Exception {
    Scheduler scheduler = schedulerHelper.getSchedulerInterface();
    scheduler.putThirdPartyCredential("MY_APP_PASSWORD", "superpassword");
    TaskFlowJob job = (TaskFlowJob) StaxJobFactory.getFactory().createJob(new File(jobDescriptor.toURI()).getAbsolutePath());
    if (OperatingSystem.getOperatingSystem() == org.objectweb.proactive.utils.OperatingSystem.unix) {
        NativeTask nativeTask = new NativeTask();
        nativeTask.setCommandLine("echo", "$credentials_MY_APP_PASSWORD");
        job.addTask(nativeTask);
    }
    JobId jobId = scheduler.submit(job);
    schedulerHelper.waitForEventJobFinished(jobId);
    JobResult jobResult = schedulerHelper.getJobResult(jobId);
    for (TaskResult taskResult : jobResult.getAllResults().values()) {
        assertTrue("task " + taskResult.getTaskId().getReadableName() + " did not print the credential", taskResult.getOutput().getAllLogs(false).contains("superpassword"));
    }
}
Also used : JobResult(org.ow2.proactive.scheduler.common.job.JobResult) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) NativeTask(org.ow2.proactive.scheduler.common.task.NativeTask) File(java.io.File) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 32 with Task

use of org.ow2.proactive.scheduler.common.task.Task in project scheduling by ow2-proactive.

the class TestThirdPartyCredentialsDefined method createAndSubmitTaskPrintingCredentials.

public String createAndSubmitTaskPrintingCredentials() throws Exception {
    ScriptTask scriptTask = new ScriptTask();
    scriptTask.setName("task");
    scriptTask.setScript(new TaskScript(new SimpleScript("print credentials", "python")));
    TaskFlowJob job = new TaskFlowJob();
    job.addTask(scriptTask);
    JobId id = schedulerHelper.submitJob(job);
    schedulerHelper.waitForEventJobFinished(id);
    JobResult jobResult = schedulerHelper.getJobResult(id);
    TaskResult result = jobResult.getResult(scriptTask.getName());
    return result.getOutput().getStdoutLogs(false).replaceAll("\n|\r", "");
}
Also used : ScriptTask(org.ow2.proactive.scheduler.common.task.ScriptTask) TaskScript(org.ow2.proactive.scripting.TaskScript) JobResult(org.ow2.proactive.scheduler.common.job.JobResult) SimpleScript(org.ow2.proactive.scripting.SimpleScript) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 33 with Task

use of org.ow2.proactive.scheduler.common.task.Task in project scheduling by ow2-proactive.

the class BaseSchedulerDBTest method defaultSubmitJob.

public InternalJob defaultSubmitJob(TaskFlowJob job, String userName, long submittedTime) throws Exception {
    if (job.getTasks().isEmpty()) {
        job.addTask(createDefaultTask("default test task"));
    }
    InternalJob internalJob = InternalJobFactory.createJob(job, getDefaultCredentials());
    internalJob.setOwner(userName);
    internalJob.submitAction();
    if (submittedTime > 0) {
        internalJob.setSubmittedTime(submittedTime);
    }
    dbManager.newJobSubmitted(internalJob);
    return internalJob;
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob)

Example 34 with Task

use of org.ow2.proactive.scheduler.common.task.Task in project scheduling by ow2-proactive.

the class BaseSchedulerDBTest method createDefaultTask.

protected static JavaTask createDefaultTask(String taskName) {
    JavaTask task = new JavaTask();
    task.setName(taskName);
    task.setExecutableClassName(TestDummyExecutable.class.getName());
    return task;
}
Also used : JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask)

Example 35 with Task

use of org.ow2.proactive.scheduler.common.task.Task in project scheduling by ow2-proactive.

the class BaseSchedulerDBTest method saveSingleTask.

public InternalJob saveSingleTask(Task task) throws Exception {
    TaskFlowJob job = new TaskFlowJob();
    job.addTask(task);
    InternalJob jobData = defaultSubmitJobAndLoadInternal(true, job);
    Assert.assertEquals(1, jobData.getTasks().size());
    return jobData;
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob)

Aggregations

Test (org.junit.Test)152 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)112 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)100 JobId (org.ow2.proactive.scheduler.common.job.JobId)73 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)69 JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)68 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)60 ArrayList (java.util.ArrayList)49 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)48 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)43 Task (org.ow2.proactive.scheduler.common.task.Task)41 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)41 File (java.io.File)37 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)34 HashMap (java.util.HashMap)33 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)33 SimpleScript (org.ow2.proactive.scripting.SimpleScript)33 InternalScriptTask (org.ow2.proactive.scheduler.task.internal.InternalScriptTask)27 TaskScript (org.ow2.proactive.scripting.TaskScript)27 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)26