use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestCoordResumeXCommand method testCoordSuspendWithErrorAndResumeWithErrorForRunning.
/**
* Test : suspend a RUNNINGWITHERROR coordinator job and check the status to RUNNINGWITHERROR on resume
*
* @throws Exception
*/
public void testCoordSuspendWithErrorAndResumeWithErrorForRunning() throws Exception {
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNINGWITHERROR, false, false);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(job.getId());
job = jpaService.execute(coordJobGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.RUNNINGWITHERROR);
new CoordSuspendXCommand(job.getId()).call();
job = jpaService.execute(coordJobGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.SUSPENDEDWITHERROR);
new CoordResumeXCommand(job.getId()).call();
job = jpaService.execute(coordJobGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.RUNNINGWITHERROR);
}
use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestCoordSubmitXCommand method testBasicSubmitWithCronFrequency.
private void testBasicSubmitWithCronFrequency(String appXml, Boolean isValidFrequency) throws Exception {
Configuration conf = new XConfiguration();
File appPathFile = new File(getTestCaseDir(), "coordinator.xml");
writeToFile(appXml, appPathFile);
conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile.toURI().toString());
conf.set(OozieClient.USER_NAME, getTestUser());
CoordSubmitXCommand sc = new CoordSubmitXCommand(conf);
if (isValidFrequency) {
String jobId = sc.call();
assertEquals(jobId.substring(jobId.length() - 2), "-C");
CoordinatorJobBean job = (CoordinatorJobBean) sc.getJob();
assertEquals(job.getTimeUnitStr(), "CRON");
} else {
try {
String jobId = sc.call();
} catch (Exception ex) {
assertTrue(ex.getMessage().contains("Invalid coordinator cron frequency"));
}
}
}
use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestCoordSubmitXCommand method testSubmitWithTimeout.
/**
* Test timeout setting
*
* @throws Exception
*/
public void testSubmitWithTimeout() throws Exception {
Configuration conf = new XConfiguration();
File appPathFile = new File(getTestCaseDir(), "coordinator.xml");
// timeout unit = DAY
String appXml1 = "<coordinator-app name=\"NAME\" frequency=\"${coord:days(1)}\" " + "start=\"2009-02-01T01:00Z\" end=\"2009-02-03T23:59Z\" timezone=\"UTC\" " + "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='uri:oozie:coordinator:0.2'> " + "<controls> <timeout>${coord:days(10)}</timeout> </controls> " + "<action> <workflow> <app-path>hdfs:///tmp/workflows/</app-path> </workflow> " + "</action> </coordinator-app>";
writeToFile(appXml1, appPathFile);
conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile.toURI().toString());
conf.set(OozieClient.USER_NAME, getTestUser());
CoordSubmitXCommand sc = new CoordSubmitXCommand(conf);
String jobId = sc.call();
assertEquals(jobId.substring(jobId.length() - 2), "-C");
CoordinatorJobBean job = checkCoordJobs(jobId);
assertEquals(job.getTimeout(), 14400);
// timeout unit = HOUR
String appXml2 = "<coordinator-app name=\"NAME\" frequency=\"${coord:days(1)}\" " + "start=\"2009-02-01T01:00Z\" end=\"2009-02-03T23:59Z\" timezone=\"UTC\" " + "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='uri:oozie:coordinator:0.2'> " + "<controls> <timeout>${coord:hours(10)}</timeout> </controls> " + "<action> <workflow> <app-path>hdfs:///tmp/workflows/</app-path> </workflow> " + "</action> </coordinator-app>";
writeToFile(appXml2, appPathFile);
conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile.toURI().toString());
conf.set(OozieClient.USER_NAME, getTestUser());
sc = new CoordSubmitXCommand(conf);
jobId = sc.call();
job = checkCoordJobs(jobId);
assertEquals(job.getTimeout(), 600);
// timeout unit = MINUTE
String appXml3 = "<coordinator-app name=\"NAME\" frequency=\"${coord:days(1)}\" " + "start=\"2009-02-01T01:00Z\" end=\"2009-02-03T23:59Z\" timezone=\"UTC\" " + "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='uri:oozie:coordinator:0.2'> " + "<controls> <timeout>${coord:minutes(10)}</timeout> </controls> " + "<action> <workflow> <app-path>hdfs:///tmp/workflows/</app-path> </workflow> " + "</action> </coordinator-app>";
writeToFile(appXml3, appPathFile);
conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile.toURI().toString());
conf.set(OozieClient.USER_NAME, getTestUser());
sc = new CoordSubmitXCommand(conf);
jobId = sc.call();
job = checkCoordJobs(jobId);
assertEquals(job.getTimeout(), 10);
// timeout unit = MONTH
String appXml4 = "<coordinator-app name=\"NAME\" frequency=\"${coord:months(1)}\" " + "start=\"2009-02-01T01:00Z\" end=\"2009-02-03T23:59Z\" timezone=\"UTC\" " + "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='uri:oozie:coordinator:0.2'> " + "<controls> <timeout>${coord:months(1)}</timeout> </controls> " + "<action> <workflow> <app-path>hdfs:///tmp/workflows/</app-path> </workflow> " + "</action> </coordinator-app>";
writeToFile(appXml4, appPathFile);
conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile.toURI().toString());
conf.set(OozieClient.USER_NAME, getTestUser());
sc = new CoordSubmitXCommand(conf);
jobId = sc.call();
job = checkCoordJobs(jobId);
assertEquals(job.getTimeout(), 43200);
}
use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestCoordSuspendXCommand method testCoordSuspendWithErrorPostive2.
/**
* Test : suspend a PAUSEDWITHERROR coordinator job
*
* @throws Exception
*/
public void testCoordSuspendWithErrorPostive2() throws Exception {
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.PAUSEDWITHERROR, false, false);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(job.getId());
job = jpaService.execute(coordJobGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.PAUSEDWITHERROR);
new CoordSuspendXCommand(job.getId()).call();
job = jpaService.execute(coordJobGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.SUSPENDEDWITHERROR);
}
use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestCoordSuspendXCommand method testCoordSuspendNegative.
/**
* Negative Test : suspend a SUCCEEDED coordinator job
*
* @throws Exception
*/
public void testCoordSuspendNegative() throws Exception {
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, false);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(job.getId());
job = jpaService.execute(coordJobGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.SUCCEEDED);
new CoordSuspendXCommand(job.getId()).call();
job = jpaService.execute(coordJobGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.SUCCEEDED);
}
Aggregations