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"));
}
}
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", "");
}
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;
}
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;
}
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;
}
Aggregations