* Test : Pause a RUNNING bundle, then check bundle action has been updated to PAUSED by BundleStatusUpdateXCommand
*
* @throws Exception
*/
public void testPauseBundleAndCoordinator() throws Exception {
BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.RUNNING, false);
final JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
Date pauseTime = new Date(new Date().getTime() - 30 * 1000);
job.setPauseTime(pauseTime);
jpaService.execute(new BundleJobUpdateJPAExecutor(job));
BundleActionBean bundleAction1 = this.addRecordToBundleActionTable(job.getId(), "action1", 0, Job.Status.RUNNING);
BundleActionBean bundleAction2 = this.addRecordToBundleActionTable(job.getId(), "action2", 0, Job.Status.RUNNING);
String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
CoordinatorJobBean coordJob1 = addRecordToCoordJobTable("action1", CoordinatorJob.Status.RUNNING, start, end, false);
CoordinatorJobBean coordJob2 = addRecordToCoordJobTable("action2", CoordinatorJob.Status.RUNNING, start, end, false);
coordJob1.setPauseTime(pauseTime);
coordJob1.setBundleId(job.getId());
jpaService.execute(new CoordJobUpdateJPAExecutor(coordJob1));
coordJob2.setPauseTime(pauseTime);
coordJob2.setBundleId(job.getId());
jpaService.execute(new CoordJobUpdateJPAExecutor(coordJob2));
BundleJobGetJPAExecutor bundleJobGetExecutor = new BundleJobGetJPAExecutor(job.getId());
job = jpaService.execute(bundleJobGetExecutor);
assertEquals(Job.Status.RUNNING, job.getStatus());
Runnable pauseStartRunnable = new PauseTransitRunnable();
pauseStartRunnable.run();
final String jobId = job.getId();
waitFor(10 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
BundleJobBean bJob1 = jpaService.execute(new BundleJobGetJPAExecutor(jobId));
return bJob1.getStatus() == Job.Status.PAUSED;
}
});
final String coordJobId1 = coordJob1.getId();
final String coordJobId2 = coordJob2.getId();