Search in sources :

Example 1 with BundleKillXCommand

use of org.apache.oozie.command.bundle.BundleKillXCommand in project oozie by apache.

the class TestStatusTransitService method testBundleStatusNotTransitionFromKilled.

/**
 * Test : kill a bundle job with coord jobs as DONEWITHERROR
 * <p/>
 * Bundle status should be kill.
 *
 * @throws Exception
 */
public void testBundleStatusNotTransitionFromKilled() throws Exception {
    BundleJobBean bundleJob = this.addRecordToBundleJobTable(Job.Status.RUNNING, true);
    final JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    final String bundleId = bundleJob.getId();
    addRecordToBundleActionTable(bundleId, "action1", 0, Job.Status.DONEWITHERROR);
    addRecordToBundleActionTable(bundleId, "action2", 0, Job.Status.DONEWITHERROR);
    String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
    Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    addRecordToCoordJobTableWithBundle(bundleId, "action1", CoordinatorJob.Status.DONEWITHERROR, start, end, false, true, 2);
    addRecordToCoordJobTableWithBundle(bundleId, "action2", CoordinatorJob.Status.DONEWITHERROR, start, end, false, true, 2);
    new BundleKillXCommand(bundleId).call();
    waitFor(5 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            BundleJobBean bundle = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
            return bundle.getStatus() == Job.Status.KILLED;
        }
    });
    bundleJob = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
    assertEquals(Job.Status.KILLED, bundleJob.getStatus());
    Runnable runnable = new StatusTransitRunnable();
    runnable.run();
    waitFor(15 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            BundleJobBean bundle = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
            return bundle.getStatus() == Job.Status.KILLED;
        }
    });
    bundleJob = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
    assertEquals(Job.Status.KILLED, bundleJob.getStatus());
}
Also used : BundleJobGetJPAExecutor(org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor) BundleJobBean(org.apache.oozie.BundleJobBean) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) Date(java.util.Date) BundleKillXCommand(org.apache.oozie.command.bundle.BundleKillXCommand) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException)

Aggregations

Date (java.util.Date)1 BundleJobBean (org.apache.oozie.BundleJobBean)1 BundleKillXCommand (org.apache.oozie.command.bundle.BundleKillXCommand)1 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)1 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)1 StatusTransitRunnable (org.apache.oozie.service.StatusTransitService.StatusTransitRunnable)1