use of org.apache.oozie.service.StatusTransitService.StatusTransitRunnable in project oozie by apache.
the class TestStatusTransitService method testCoordStatusTransitServiceSuspendAndResume.
/**
* Test : Suspend and resume a coordinator job which has finished materialization and all actions are succeeded.
* </p>
* Coordinator job changes to succeeded after resume
*
* @throws Exception
*/
public void testCoordStatusTransitServiceSuspendAndResume() throws Exception {
final JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, false, true, 2);
final String coordJobId = coordJob.getId();
final CoordinatorActionBean coordAction1_1 = addRecordToCoordActionTable(coordJobId, 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
final CoordinatorActionBean coordAction1_2 = addRecordToCoordActionTable(coordJobId, 2, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
this.addRecordToWfJobTable(coordAction1_1.getExternalId(), WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
this.addRecordToWfJobTable(coordAction1_2.getExternalId(), WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
new CoordSuspendXCommand(coordJobId).call();
CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(coordJobId);
coordJob = jpaService.execute(coordJobGetCmd);
assertEquals(Job.Status.SUSPENDED, coordJob.getStatus());
sleep(3000);
new CoordResumeXCommand(coordJobId).call();
coordJob = jpaService.execute(coordJobGetCmd);
Runnable runnable = new StatusTransitRunnable();
runnable.run();
waitFor(20 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
CoordinatorJobBean job = jpaService.execute(new CoordJobGetJPAExecutor(coordJobId));
return job.getStatus().equals(Job.Status.SUCCEEDED);
}
});
CoordinatorJobBean coordJob1 = jpaService.execute(new CoordJobGetJPAExecutor(coordJobId));
assertFalse(coordJob1.isPending());
assertEquals(Job.Status.SUCCEEDED, coordJob1.getStatus());
}
use of org.apache.oozie.service.StatusTransitService.StatusTransitRunnable in project oozie by apache.
the class TestStatusTransitService method testBundleStatusTransitServicePausedWithError.
/**
* Test : Check the transition of a PAUSED bundle job to PAUSEDWITHERROR
* @throws Exception
*/
public void testBundleStatusTransitServicePausedWithError() 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.PAUSED, 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);
BundleActionBean bundleAction = addRecordToBundleActionTable(bundleId, "action3", 0, Job.Status.FAILED);
bundleAction.setCoordId("test");
BundleActionQueryExecutor.getInstance().executeUpdate(BundleActionQuery.UPDATE_BUNDLE_ACTION_STATUS_PENDING_MODTIME_COORDID, bundleAction);
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.PAUSEDWITHERROR;
}
});
bundleJob = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
assertEquals(Job.Status.PAUSEDWITHERROR, bundleJob.getStatus());
}
use of org.apache.oozie.service.StatusTransitService.StatusTransitRunnable in project oozie by apache.
the class TestStatusTransitService method testCoordStatusTransitServicePausedWithError.
/**
* Test : all coord actions are running, job pending is reset
*
* @throws Exception
*/
public void testCoordStatusTransitServicePausedWithError() 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 = createCoordJob(CoordinatorJob.Status.PAUSEDWITHERROR, start, end, true, false, 3);
// set the pause time explicity to make sure the job is not unpaused
job.setPauseTime(DateUtils.parseDateOozieTZ("2009-02-01T01:00Z"));
final JPAService jpaService = Services.get().get(JPAService.class);
CoordJobInsertJPAExecutor coordInsertCmd = new CoordJobInsertJPAExecutor(job);
jpaService.execute(coordInsertCmd);
addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
addRecordToCoordActionTable(job.getId(), 2, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
addRecordToCoordActionTable(job.getId(), 3, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
final String jobId = job.getId();
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());
assertEquals(CoordinatorJob.Status.PAUSED, job.getStatus());
}
use of org.apache.oozie.service.StatusTransitService.StatusTransitRunnable in project oozie by apache.
the class TestStatusTransitService method testCoordStatusTransitServiceBackwardSupport.
/**
* Test : Keep the backward support for states on. 2 coord actions are running, 1 killed, check if job pending is reset
* and state changed to
* RUNNING. Make sure the status is not RUNNINGWITHERROR
*
* @throws Exception
*/
public void testCoordStatusTransitServiceBackwardSupport() throws Exception {
Services.get().destroy();
setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_STATES_WITHOUT_ERROR, "true");
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, false, 3);
addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.KILLED, "coord-action-get.xml", 0);
addRecordToCoordActionTable(job.getId(), 2, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
addRecordToCoordActionTable(job.getId(), 3, CoordinatorAction.Status.RUNNING, "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());
assertEquals(job.getStatus(), Job.Status.RUNNING);
}
use of org.apache.oozie.service.StatusTransitService.StatusTransitRunnable in project oozie by apache.
the class TestStatusTransitService method testCoordStatusTransitServiceUpdateLastModifiedTime.
public void testCoordStatusTransitServiceUpdateLastModifiedTime() throws Exception {
String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, true, false, 3);
Date lastModifiedDate = job.getLastModifiedTime();
addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 1);
final JPAService jpaService = Services.get().get(JPAService.class);
Runnable runnable = new StatusTransitRunnable();
runnable.run();
sleep(1000);
CoordJobGetJPAExecutor coordGetCmd = new CoordJobGetJPAExecutor(job.getId());
job = jpaService.execute(coordGetCmd);
// As state of job has not changed, lastModified should not be updated
assertEquals(lastModifiedDate.getTime(), job.getLastModifiedTime().getTime());
assertEquals(Job.Status.RUNNING, job.getStatus());
}
Aggregations