use of org.apache.oozie.service.StatusTransitService.StatusTransitRunnable in project oozie by apache.
the class TestStatusTransitService method testCoordStatusTransitServiceSuspendedByUser.
/**
* Test : coord job suspended by user and all coord actions are succeeded - pending update to false
*
* @throws Exception
*/
public void testCoordStatusTransitServiceSuspendedByUser() throws Exception {
String currentDateplusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
Date start = DateUtils.parseDateOozieTZ(currentDateplusMonth);
Date end = DateUtils.parseDateOozieTZ(currentDateplusMonth);
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.SUSPENDED, start, end, true, true, 3);
addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
addRecordToCoordActionTable(job.getId(), 2, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
addRecordToCoordActionTable(job.getId(), 3, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
final String jobId = job.getId();
final JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
Runnable runnable = new StatusTransitRunnable();
runnable.run();
waitFor(10 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
CoordinatorJobBean coordJob = jpaService.execute(new CoordJobGetJPAExecutor(jobId));
return coordJob.isPending() == false;
}
});
CoordJobGetJPAExecutor coordGetCmd = new CoordJobGetJPAExecutor(job.getId());
job = jpaService.execute(coordGetCmd);
assertFalse(job.isPending());
assertEquals(Job.Status.SUCCEEDED, job.getStatus());
}
use of org.apache.oozie.service.StatusTransitService.StatusTransitRunnable in project oozie by apache.
the class TestStatusTransitService method testCoordStatusTransitServiceSuspendedWithError.
/**
* Test : all coord actions suspended except one which is killed - check status change to SUSPENDEDWITHERROR
*
* @throws Exception
*/
public void testCoordStatusTransitServiceSuspendedWithError() throws Exception {
Services.get().destroy();
setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_STATES_WITHOUT_ERROR, "false");
services = new Services();
setClassesToBeExcluded(services.getConf(), excludedServices);
services.init();
String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, true, true, 4);
addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.KILLED, "coord-action-get.xml", 0);
addRecordToCoordActionTable(job.getId(), 2, CoordinatorAction.Status.SUSPENDED, "coord-action-get.xml", 0);
addRecordToCoordActionTable(job.getId(), 3, CoordinatorAction.Status.SUSPENDED, "coord-action-get.xml", 0);
addRecordToCoordActionTable(job.getId(), 4, CoordinatorAction.Status.SUSPENDED, "coord-action-get.xml", 0);
final String jobId = job.getId();
final JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
Runnable runnable = new StatusTransitRunnable();
runnable.run();
// Keeping wait time to 20s to ensure status is updated
waitFor(20 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
CoordinatorJobBean coordJob = jpaService.execute(new CoordJobGetJPAExecutor(jobId));
return coordJob.getStatus() == CoordinatorJob.Status.SUSPENDEDWITHERROR;
}
});
CoordJobGetJPAExecutor coordGetCmd = new CoordJobGetJPAExecutor(job.getId());
job = jpaService.execute(coordGetCmd);
assertEquals(CoordinatorJob.Status.SUSPENDEDWITHERROR, job.getStatus());
assertFalse(job.isPending());
}
use of org.apache.oozie.service.StatusTransitService.StatusTransitRunnable in project oozie by apache.
the class TestStatusTransitService method testCoordStatusTransitServiceKilledByUser2.
/**
* Test : coord job killed by user - pending update to false
*
* @throws Exception
*/
public void testCoordStatusTransitServiceKilledByUser2() throws Exception {
String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.KILLED, start, end, true, false, 3);
addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
addRecordToCoordActionTable(job.getId(), 2, CoordinatorAction.Status.KILLED, "coord-action-get.xml", 0);
addRecordToCoordActionTable(job.getId(), 3, CoordinatorAction.Status.KILLED, "coord-action-get.xml", 0);
final String jobId = job.getId();
final JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
Runnable runnable = new StatusTransitRunnable();
runnable.run();
waitFor(5 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
CoordinatorJobBean coordJob = jpaService.execute(new CoordJobGetJPAExecutor(jobId));
return coordJob.isPending() == false;
}
});
CoordJobGetJPAExecutor coordGetCmd = new CoordJobGetJPAExecutor(job.getId());
job = jpaService.execute(coordGetCmd);
assertFalse(job.isPending());
}
use of org.apache.oozie.service.StatusTransitService.StatusTransitRunnable in project oozie by apache.
the class TestStatusTransitService method testBundleStatusTransitServiceSucceeded1.
/**
* Test : all bundle actions are succeeded - bundle job's status will be updated to succeeded.
*
* @throws Exception
*/
public void testBundleStatusTransitServiceSucceeded1() throws Exception {
BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.RUNNING, false);
final JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
final String jobId = job.getId();
BundleActionBean ba1 = addRecordToBundleActionTable(jobId, "action1", 0, Job.Status.SUCCEEDED);
addRecordToBundleActionTable(jobId, "action2", 0, Job.Status.SUCCEEDED);
addRecordToBundleActionTable(jobId, "action3", 0, Job.Status.SUCCEEDED);
Runnable runnable = new StatusTransitRunnable();
runnable.run();
waitFor(5 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
BundleJobBean bundle = jpaService.execute(new BundleJobGetJPAExecutor(jobId));
return bundle.getStatus().equals(Job.Status.SUCCEEDED);
}
});
job = jpaService.execute(new BundleJobGetJPAExecutor(jobId));
assertEquals(Job.Status.SUCCEEDED, job.getStatus());
}
use of org.apache.oozie.service.StatusTransitService.StatusTransitRunnable in project oozie by apache.
the class TestStatusTransitService method testBundleStatusTransitServicePaused.
/**
* Test : Check the transition of a PAUSEDWITHERROR bundle job to PAUSED
* @throws Exception
*/
public void testBundleStatusTransitServicePaused() throws Exception {
Services.get().destroy();
setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_STATES_WITHOUT_ERROR, "false");
services = new Services();
setClassesToBeExcluded(services.getConf(), excludedServices);
services.init();
BundleJobBean bundleJob = createBundleJob(Job.Status.PAUSEDWITHERROR, true);
bundleJob.setPauseTime(DateUtils.parseDateOozieTZ("2009-02-01T01:00Z"));
final JPAService jpaService = Services.get().get(JPAService.class);
BundleJobInsertJPAExecutor bundleInsertjpa = new BundleJobInsertJPAExecutor(bundleJob);
jpaService.execute(bundleInsertjpa);
final String bundleId = bundleJob.getId();
addRecordToBundleActionTable(bundleId, "action1", 1, Job.Status.PAUSED);
addRecordToBundleActionTable(bundleId, "action2", 1, Job.Status.PAUSED);
addRecordToBundleActionTable(bundleId, "action3", 0, Job.Status.SUCCEEDED);
Runnable runnable = new StatusTransitRunnable();
runnable.run();
waitFor(5 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
BundleJobBean bundle = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
return bundle.getStatus() == Job.Status.PAUSED;
}
});
bundleJob = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
assertEquals(Job.Status.PAUSED, bundleJob.getStatus());
}
Aggregations