use of org.apache.oozie.service.JPAService in project oozie by apache.
the class TestCoordRerunXCommand method testCoordRerunForBackwardSupport3.
/**
* Tests functionality of the coord rerun for backward support is true. </p> Insert a coordinator job with SUCCEEDED
* and coordinator actions with pending false. However, job's doneMaterialization is false to imitate update from
* 2.x to 3.0.1.
* Set oozie.service.StatusTransitService.backward.support.for.coord.status=true
* and use uri:oozie:coordinator:0.1 namespace, then, rerun the coord job for action 1 and action 2.
*
* @throws Exception
*/
public void testCoordRerunForBackwardSupport3() throws Exception {
Services.get().destroy();
setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_COORD_STATUS, "true");
services = new Services();
services.init();
Date start = DateUtils.parseDateOozieTZ("2009-02-01T01:00Z");
Date end = DateUtils.parseDateOozieTZ("2009-02-02T23:59Z");
CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, start, end, false, false, 3);
final JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
coordJob.setAppNamespace(SchemaService.COORDINATOR_NAMESPACE_URI_1);
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB_APPNAMESPACE, coordJob);
CoordinatorActionBean action1 = addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-rerun-action1.xml", 0);
CoordinatorActionBean action2 = addRecordToCoordActionTable(coordJob.getId(), 2, CoordinatorAction.Status.SUCCEEDED, "coord-rerun-action1.xml", 0);
CoordinatorActionBean action3 = addRecordToCoordActionTable(coordJob.getId(), 3, CoordinatorAction.Status.SUCCEEDED, "coord-rerun-action1.xml", 0);
String rerunScope = Integer.toString(1) + "-" + Integer.toString(2);
final OozieClient coordClient = LocalOozie.getCoordClient();
coordClient.reRunCoord(coordJob.getId(), RestConstants.JOB_COORD_SCOPE_ACTION, rerunScope, false, true);
coordJob = getCoordinatorJob(coordJob.getId());
assertEquals(CoordinatorJob.Status.SUCCEEDED, coordJob.getStatus());
action1 = getCoordinatorAction(action1.getId());
assertNotSame(action1.getStatus(), CoordinatorAction.Status.SUCCEEDED);
action2 = getCoordinatorAction(action2.getId());
assertNotSame(action2.getStatus(), CoordinatorAction.Status.SUCCEEDED);
}
use of org.apache.oozie.service.JPAService in project oozie by apache.
the class TestCoordResumeXCommand method testCoordSuspendWithErrorAndResumeWithErrorForRunning.
/**
* Test : suspend a RUNNINGWITHERROR coordinator job and check the status to RUNNINGWITHERROR on resume
*
* @throws Exception
*/
public void testCoordSuspendWithErrorAndResumeWithErrorForRunning() throws Exception {
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNINGWITHERROR, false, false);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(job.getId());
job = jpaService.execute(coordJobGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.RUNNINGWITHERROR);
new CoordSuspendXCommand(job.getId()).call();
job = jpaService.execute(coordJobGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.SUSPENDEDWITHERROR);
new CoordResumeXCommand(job.getId()).call();
job = jpaService.execute(coordJobGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.RUNNINGWITHERROR);
}
use of org.apache.oozie.service.JPAService in project oozie by apache.
the class TestCoordSuspendXCommand method testCoordSuspendWithErrorPostive2.
/**
* Test : suspend a PAUSEDWITHERROR coordinator job
*
* @throws Exception
*/
public void testCoordSuspendWithErrorPostive2() throws Exception {
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.PAUSEDWITHERROR, false, false);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(job.getId());
job = jpaService.execute(coordJobGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.PAUSEDWITHERROR);
new CoordSuspendXCommand(job.getId()).call();
job = jpaService.execute(coordJobGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.SUSPENDEDWITHERROR);
}
use of org.apache.oozie.service.JPAService in project oozie by apache.
the class TestCoordSuspendXCommand method testCoordSuspendNegative.
/**
* Negative Test : suspend a SUCCEEDED coordinator job
*
* @throws Exception
*/
public void testCoordSuspendNegative() throws Exception {
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, false);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(job.getId());
job = jpaService.execute(coordJobGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.SUCCEEDED);
new CoordSuspendXCommand(job.getId()).call();
job = jpaService.execute(coordJobGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.SUCCEEDED);
}
use of org.apache.oozie.service.JPAService in project oozie by apache.
the class TestCoordWfActionInfoXCommand method createTestData.
/**
* init the test case.
* 1 coordJob
* 5 coordAction created by the coordJob, while the 5th coordAction's workflow instance is null
* 4 wfJob match the 1st ~ 4th coordAction
* the 1st - 3rd wfAction has a wfAction named 'aa' each, but the 4th desn't.
*/
private void createTestData() throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull("Missing jpa service", jpaService);
coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, false);
wfJobs = new ArrayList<WorkflowJobBean>();
coordActions = new ArrayList<CoordinatorActionBean>();
for (int i = 0; i < 4; i++) {
WorkflowJobBean wfJob = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
wfJobs.add(wfJob);
}
for (int i = 0; i < 4; i++) {
CoordinatorActionBean coordAction = addRecordToCoordActionTable(coordJob.getId(), (i + 1), CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJobs.get(i).getId(), "SUCCEEDED", 0);
coordActions.add(coordAction);
}
// add a coordAction that doesnt create workflow instance yet
CoordinatorActionBean coordAction = addRecordToCoordActionTable(coordJob.getId(), 5, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", null, null, 0);
coordActions.add(coordAction);
// set the NominalTime,in order to keep the order of the coordAction.
for (int i = 0; i < 5; i++) {
setCoordActionNominalTime(coordActions.get(i).getId(), (i + 1) * 1000);
}
// create the case that the 4th wfJob doesnt have a action named "aa"
for (int i = 0; i < 4; i++) {
String name = (i == 3) ? "bb" : "aa";
addRecordToWfActionTable(wfJobs.get(i).getId(), name, WorkflowAction.Status.DONE);
}
}
Aggregations