use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class TestNativeTaskPaths method testNativeTaskPaths.
@Test
public void testNativeTaskPaths() throws Throwable {
File in = File.createTempFile("input", "space");
in.delete();
in.mkdir();
String inPath = in.getAbsolutePath();
File out = File.createTempFile("output", "space");
out.delete();
out.mkdir();
File outc = new File(out, OutVarsFileC);
File outd = new File(out, OutVarsFileD);
if (outc.exists()) {
outc.delete();
}
if (outd.exists()) {
outd.delete();
}
File scriptTestEnv = null;
if (OperatingSystem.getOperatingSystem() == OperatingSystem.unix) {
scriptTestEnv = new File(inPath + File.separator + scriptCLinux);
scriptTestEnv.createNewFile();
PrintWriter out3 = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(scriptTestEnv))));
out3.print(scriptCLinuxContent);
out3.close();
} else {
scriptTestEnv = new File(inPath + File.separator + scriptCWindows);
scriptTestEnv.createNewFile();
PrintWriter out3 = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(scriptTestEnv))));
out3.print(scriptCWindowsContent);
out3.close();
}
TaskFlowJob job = new TaskFlowJob();
job.setName(this.getClass().getSimpleName());
job.setInputSpace(in.toURI().toURL().toString());
job.setOutputSpace(out.toURI().toURL().toString());
// // testing paths pattern
// NativeTask C = new NativeTask();
// C.setName("C");
// C.addOutputFiles(OutVarsFileC, OutputAccessMode.TransferToOutputSpace);
// switch (OperatingSystem.getOperatingSystem()) {
// case windows:
// C.setCommandLine(new String[] { "cmd", "/C",
// "echo \"$JAVA\" \"$PROACTIVE_HOME\" > $LOCALSPACE\\" + OutVarsFileC });
// break;
// case unix:
// C.setCommandLine(new String[] { "/bin/bash", "-c",
// "echo \\\"$JAVA\\\" \\\"$PROACTIVE_HOME\\\" > $LOCALSPACE/" + OutVarsFileC });
// break;
// default:
// throw new IllegalStateException("Unsupported operating system");
// }
// job.addTask(C);
// testing $USERSPACE environment variable
NativeTask D = new NativeTask();
D.setName("D");
if (OperatingSystem.getOperatingSystem() == OperatingSystem.unix) {
D.addInputFiles(scriptCLinux, InputAccessMode.TransferFromInputSpace);
} else {
D.addInputFiles(scriptCWindows, InputAccessMode.TransferFromInputSpace);
}
D.addOutputFiles(OutVarsFileD, OutputAccessMode.TransferToOutputSpace);
switch(OperatingSystem.getOperatingSystem()) {
case windows:
D.setCommandLine(new String[] { "cmd", "/C", scriptCWindows });
break;
case unix:
D.setCommandLine(new String[] { "/bin/bash", "-c", "chmod u+x $localspace/" + scriptCLinux + "; $localspace/" + scriptCLinux });
break;
default:
throw new IllegalStateException("Unsupported operating system");
}
D.setForkEnvironment(new ForkEnvironment("$LOCALSPACE"));
job.addTask(D);
Scheduler sched = schedulerHelper.getSchedulerInterface();
JobId id = sched.submit(job);
schedulerHelper.waitForEventJobFinished(id);
String contentExpected = "foo";
JobResult jr = schedulerHelper.getJobResult(id);
Assert.assertFalse(jr.hadException());
logger.info("Expected : '" + contentExpected + "'");
// logger.info(jr.getAllResults().get("C").getOutput().getAllLogs(true));
// String receivedc = IOUtils.toString(outc.toURI()).trim();
// logger.info("Received C : '" + receivedc + "'");
// Assert.assertEquals(contentExpected.toLowerCase(), receivedc.toLowerCase());
logger.info(jr.getAllResults().get("D").getOutput().getAllLogs(true));
String receivedd = IOUtils.toString(outd.toURI()).trim();
logger.info("Received D : '" + receivedd + "'");
Assert.assertEquals(contentExpected.toLowerCase(), receivedd.toLowerCase());
}
use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class TestVariablesPatternLateBindings method testPropagatedVariableResolution.
@Test
public void testPropagatedVariableResolution() throws Throwable {
TaskFlowJob job = (TaskFlowJob) StaxJobFactory.getFactory().createJob(absolutePath(job_desc));
JobId id = schedulerHelper.submitJob(job);
TaskInfo taskInfo = schedulerHelper.waitForEventTaskFinished(id, "Groovy_Task2");
// assert the task finished correctly
assertEquals(TaskStatus.FINISHED, taskInfo.getStatus());
// for the second task:
String jobLog = schedulerHelper.getTaskResult(id, "Groovy_Task2").getOutput().getAllLogs();
Assert.assertThat(jobLog, CoreMatchers.containsString("WORKFLOW_VAR1=workflow_value"));
Assert.assertThat(jobLog, CoreMatchers.containsString("WORKFLOW_VAR2=var2_workflow_value"));
Assert.assertThat(jobLog, CoreMatchers.containsString("WORKFLOW_VAR3=workflow_value"));
Assert.assertThat(jobLog, CoreMatchers.containsString("WORKFLOW_VAR4=workflow_value_task_value"));
Assert.assertThat(jobLog, CoreMatchers.containsString("TASK_VAR1=task_value"));
Assert.assertThat(jobLog, CoreMatchers.containsString("TASK_VAR2=task_value_" + id.toString()));
Assert.assertThat(jobLog, CoreMatchers.containsString("TASK_VAR3=task_value_task_value"));
Assert.assertThat(jobLog, CoreMatchers.containsString("TASK_VAR4=task_value_inherited_value"));
Assert.assertThat(jobLog, CoreMatchers.containsString("INHERITED_VAR1=inherited_value"));
Assert.assertThat(jobLog, CoreMatchers.containsString("INHERITED_VAR2=inherited_value_" + id.toString()));
Assert.assertThat(jobLog, CoreMatchers.containsString("INHERITED_VAR3=inherited_value_task_value"));
Assert.assertThat(jobLog, CoreMatchers.containsString("INHERITED_VAR4=inherited_value_inherited_value"));
}
use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class JobRemoveHandlerTest method init.
@Before
public void init() throws Exception {
jobId = new JobIdImpl(id, jobName);
MockitoAnnotations.initMocks(this);
Mockito.when(infrastructure.getDBManager()).thenReturn(dbManager);
Mockito.when(infrastructure.getRMProxiesManager()).thenReturn(rmProxiesManager);
Mockito.when(rmProxiesManager.getRmUrl()).thenReturn(null);
Mockito.when(dbManager.loadJobWithTasksIfNotRemoved(jobId)).thenReturn(Collections.singletonList(job));
Mockito.when(job.getJobInfo()).thenReturn(jobInfo);
service = new SchedulingService(infrastructure, listener, null, policyClassName, schedulingMethod);
jobRemoveHandler = new JobRemoveHandler(service, jobId);
}
use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class LiveJobsTest method testResumeUnstartedJob.
@Test(timeout = 60000)
public void testResumeUnstartedJob() {
InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
JobId id = new JobIdImpl(666L, "test-name");
job.setId(id);
List<InternalTask> tasksList = new ArrayList<>();
InternalTask internalTask = new InternalScriptTask(job);
tasksList.add(internalTask);
job.setTasks(tasksList);
liveJobs.jobSubmitted(job);
assertThat(liveJobs.resumeJob(id), is(false));
}
use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class LiveJobsTest method testFinishInErrorTaskDoesNotFinishPendingTask.
@Test(timeout = 60000)
public void testFinishInErrorTaskDoesNotFinishPendingTask() throws UnknownTaskException, UnknownJobException {
InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CONTINUE_JOB_EXECUTION, "description");
JobId id = new JobIdImpl(666L, "test-name");
job.setId(id);
List<InternalTask> tasksList = new ArrayList<>();
InternalTask internalTask = new InternalScriptTask(job);
internalTask.setName("task-name");
internalTask.setStatus(TaskStatus.PENDING);
tasksList.add(internalTask);
job.setTasks(tasksList);
liveJobs.jobSubmitted(job);
liveJobs.finishInErrorTask(job.getId(), "task-name");
assertThat(internalTask.getStatus(), is(TaskStatus.PENDING));
}
Aggregations