use of org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor in project oozie by apache.
the class TestPurgeXCommand method testPurgeBundleWithCoordChildWithWFChild2.
/**
* Test : The workflow and coordinator should not get purged, but the bundle parent should get purged --> none will get purged
*
* @throws Exception
*/
public void testPurgeBundleWithCoordChildWithWFChild2() throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
BundleJobBean bundleJob = addRecordToBundleJobTable(Job.Status.SUCCEEDED, DateUtils.parseDateOozieTZ("2011-01-01T01:00Z"));
CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, false);
WorkflowJobBean wfJob = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
WorkflowActionBean wfAction = addRecordToWfActionTable(wfJob.getId(), "1", WorkflowAction.Status.OK);
CoordinatorActionBean coordAction = addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJob.getId(), "SUCCEEDED", 0);
BundleActionBean bundleAction = addRecordToBundleActionTable(bundleJob.getId(), coordJob.getId(), coordJob.getAppName(), 0, Job.Status.SUCCEEDED);
WorkflowJobGetJPAExecutor wfJobGetCmd = new WorkflowJobGetJPAExecutor(wfJob.getId());
WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(wfAction.getId());
CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(coordJob.getId());
CoordActionGetJPAExecutor coordActionGetCmd = new CoordActionGetJPAExecutor(coordAction.getId());
BundleJobGetJPAExecutor bundleJobGetCmd = new BundleJobGetJPAExecutor(bundleJob.getId());
BundleActionGetJPAExecutor bundleActionGetCmd = new BundleActionGetJPAExecutor(bundleJob.getId(), coordJob.getAppName());
wfJob = jpaService.execute(wfJobGetCmd);
wfAction = jpaService.execute(wfActionGetCmd);
coordJob = jpaService.execute(coordJobGetCmd);
coordAction = jpaService.execute(coordActionGetCmd);
bundleJob = jpaService.execute(bundleJobGetCmd);
bundleAction = jpaService.execute(bundleActionGetCmd);
assertEquals(WorkflowJob.Status.SUCCEEDED, wfJob.getStatus());
assertEquals(WorkflowAction.Status.OK, wfAction.getStatus());
assertEquals(CoordinatorJob.Status.SUCCEEDED, coordJob.getStatus());
assertEquals(CoordinatorAction.Status.SUCCEEDED, coordAction.getStatus());
assertEquals(BundleJobBean.Status.SUCCEEDED, bundleJob.getStatus());
assertEquals(BundleJobBean.Status.SUCCEEDED, bundleAction.getStatus());
new PurgeXCommand(getNumDaysToNotBePurged(wfJob.getEndTime()), getNumDaysToNotBePurged(coordJob.getLastModifiedTime()), 7, 10).call();
try {
jpaService.execute(bundleJobGetCmd);
} catch (JPAExecutorException je) {
fail("Bundle Job should not have been purged");
}
try {
jpaService.execute(bundleActionGetCmd);
} catch (JPAExecutorException je) {
fail("Bundle Action should not have been purged");
}
try {
jpaService.execute(coordJobGetCmd);
} catch (JPAExecutorException je) {
fail("Coordinator Job should not have been purged");
}
try {
jpaService.execute(coordActionGetCmd);
} catch (JPAExecutorException je) {
fail("Coordinator Action should not have been purged");
}
try {
jpaService.execute(wfJobGetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Job should not have been purged");
}
try {
jpaService.execute(wfActionGetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Action should not have been purged");
}
}
use of org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor in project oozie by apache.
the class TestBundleChangeXCommand method testBundleChangeNegative1.
/**
* Negative Test : pause time is not a valid date
*
* @throws Exception
*/
public void testBundleChangeNegative1() throws Exception {
BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.PREP, false);
String dateStr = "2099-01-01Ta1:00Z";
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
BundleJobGetJPAExecutor bundleJobGetCmd = new BundleJobGetJPAExecutor(job.getId());
job = jpaService.execute(bundleJobGetCmd);
assertEquals(job.getPauseTime(), null);
try {
new BundleJobChangeXCommand(job.getId(), "pausetime=" + dateStr).call();
fail("Should not reach here");
} catch (XException e) {
assertEquals(ErrorCode.E1317, e.getErrorCode());
}
}
use of org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor in project oozie by apache.
the class TestBundleJobSuspendXCommand method testBundleSuspend1.
/**
* Test : Suspend bundle job
*
* @throws Exception
*/
public void testBundleSuspend1() throws Exception {
BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.RUNNING, false);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
BundleJobGetJPAExecutor bundleJobGetCmd = new BundleJobGetJPAExecutor(job.getId());
job = jpaService.execute(bundleJobGetCmd);
assertEquals(Job.Status.RUNNING, job.getStatus());
new BundleJobSuspendXCommand(job.getId()).call();
job = jpaService.execute(bundleJobGetCmd);
assertEquals(Job.Status.SUSPENDED, job.getStatus());
}
use of org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor in project oozie by apache.
the class TestBundleJobSuspendXCommand method testBundleSuspend2.
/**
* Test : Suspend bundle job
*
* @throws Exception
*/
public void testBundleSuspend2() throws Exception {
BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.PREP, false);
final JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
Configuration jobConf = null;
try {
jobConf = new XConfiguration(new StringReader(job.getConf()));
} catch (IOException ioe) {
log.warn("Configuration parse error. read from DB :" + job.getConf(), ioe);
throw new CommandException(ErrorCode.E1005, ioe);
}
Path appPath = new Path(jobConf.get(OozieClient.BUNDLE_APP_PATH), "bundle.xml");
jobConf.set(OozieClient.BUNDLE_APP_PATH, appPath.toString());
BundleSubmitXCommand submitCmd = new BundleSubmitXCommand(jobConf);
submitCmd.call();
BundleJobGetJPAExecutor bundleJobGetCmd = new BundleJobGetJPAExecutor(submitCmd.getJob().getId());
job = jpaService.execute(bundleJobGetCmd);
assertEquals(Job.Status.PREP, job.getStatus());
new BundleStartXCommand(job.getId()).call();
job = jpaService.execute(bundleJobGetCmd);
assertEquals(Job.Status.RUNNING, job.getStatus());
sleep(2000);
List<BundleActionBean> actions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE, job.getId());
assertEquals(2, actions.size());
assertNotNull(actions.get(0).getCoordId());
assertNotNull(actions.get(1).getCoordId());
new BundleJobSuspendXCommand(job.getId()).call();
job = jpaService.execute(bundleJobGetCmd);
assertEquals(Job.Status.SUSPENDED, job.getStatus());
actions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE, job.getId());
assertEquals(true, actions.get(0).isPending());
assertEquals(true, actions.get(1).isPending());
final CoordJobGetJPAExecutor coordGetCmd1 = new CoordJobGetJPAExecutor(actions.get(0).getCoordId());
final CoordJobGetJPAExecutor coordGetCmd2 = new CoordJobGetJPAExecutor(actions.get(1).getCoordId());
waitFor(200000, new Predicate() {
public boolean evaluate() throws Exception {
CoordinatorJobBean job1 = jpaService.execute(coordGetCmd1);
return job1.getStatus().equals(CoordinatorJobBean.Status.SUSPENDED);
}
});
CoordinatorJobBean job1 = jpaService.execute(coordGetCmd1);
assertEquals(CoordinatorJobBean.Status.SUSPENDED, job1.getStatus());
waitFor(200000, new Predicate() {
public boolean evaluate() throws Exception {
CoordinatorJobBean job2 = jpaService.execute(coordGetCmd2);
return job2.getStatus().equals(CoordinatorJobBean.Status.SUSPENDED);
}
});
CoordinatorJobBean job2 = jpaService.execute(coordGetCmd2);
assertEquals(CoordinatorJobBean.Status.SUSPENDED, job2.getStatus());
}
use of org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor in project oozie by apache.
the class TestBundleJobSuspendXCommand method testBundleSuspend3.
/**
* Test : Suspend bundle job
*
* @throws Exception
*/
public void testBundleSuspend3() throws Exception {
BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.PREP, false);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
Configuration jobConf = null;
try {
jobConf = new XConfiguration(new StringReader(job.getConf()));
} catch (IOException ioe) {
log.warn("Configuration parse error. read from DB :" + job.getConf(), ioe);
throw new CommandException(ErrorCode.E1005, ioe);
}
Path appPath = new Path(jobConf.get(OozieClient.BUNDLE_APP_PATH), "bundle.xml");
jobConf.set(OozieClient.BUNDLE_APP_PATH, appPath.toString());
BundleSubmitXCommand submitCmd = new BundleSubmitXCommand(jobConf);
submitCmd.call();
BundleJobGetJPAExecutor bundleJobGetCmd = new BundleJobGetJPAExecutor(submitCmd.getJob().getId());
job = jpaService.execute(bundleJobGetCmd);
assertEquals(Job.Status.PREP, job.getStatus());
new BundleJobSuspendXCommand(job.getId()).call();
job = jpaService.execute(bundleJobGetCmd);
assertEquals(Job.Status.PREPSUSPENDED, job.getStatus());
}
Aggregations