use of org.apache.oozie.service.JPAService in project oozie by apache.
the class TestPurgeXCommand method testPurgeXCommandFailed.
/**
* Test : purge wf job and action failed
*
* @throws Exception
*/
public void testPurgeXCommandFailed() throws Exception {
WorkflowJobBean job = this.addRecordToWfJobTableForNegCase(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
WorkflowActionBean action = this.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.RUNNING);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
WorkflowJobGetJPAExecutor wfJobGetCmd = new WorkflowJobGetJPAExecutor(job.getId());
WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(action.getId());
job = jpaService.execute(wfJobGetCmd);
action = jpaService.execute(wfActionGetCmd);
assertEquals(job.getStatus(), WorkflowJob.Status.RUNNING);
assertEquals(action.getStatus(), WorkflowAction.Status.RUNNING);
WorkflowInstance wfInstance = job.getWorkflowInstance();
assertEquals(wfInstance.getStatus(), WorkflowInstance.Status.RUNNING);
new PurgeXCommand(7, 1, 1, 10).call();
try {
jpaService.execute(wfJobGetCmd);
} catch (JPAExecutorException ce) {
ce.printStackTrace();
fail("Workflow Job should not have been purged");
}
try {
jpaService.execute(wfActionGetCmd);
} catch (JPAExecutorException ce) {
fail("Workflow Action should have been purged");
}
}
use of org.apache.oozie.service.JPAService in project oozie by apache.
the class TestPurgeXCommand method testPurgeLotsOfJobs.
/**
* Test : Test purging a lot of jobs (with different parent-child relationships and purge-eligibility) in one go
*
* @throws Exception
*/
public void testPurgeLotsOfJobs() throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
/* Job relationships:
bundleJobA yes yes
coordJobA yes ^
wfJobA yes ^
subwfJobA yes ^
bundleJobB no no
coordJobB yes ^
wfJobB no ^
coordJobC no no
wfJobC no ^
subwfJobC yes ^
coordJobD yes no
wfJobD no ^
wfJobE yes yes
wfJobF yes no
subwfJobF no ^
*/
BundleJobBean bundleJobA = addRecordToBundleJobTable(Job.Status.SUCCEEDED, DateUtils.parseDateOozieTZ("2011-05-01T01:00Z"));
BundleJobBean bundleJobB = addRecordToBundleJobTable(Job.Status.SUCCEEDED, DateUtils.parseDateOozieTZ("2011-06-01T01:00Z"));
CoordinatorJobBean coordJobA = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, false);
setLastModifiedTime(coordJobA, "2011-03-01T01:00Z");
CoordinatorJobBean coordJobB = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, false);
setLastModifiedTime(coordJobB, "2011-03-01T01:00Z");
CoordinatorJobBean coordJobC = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, false);
setLastModifiedTime(coordJobC, "2011-07-01T01:00Z");
CoordinatorJobBean coordJobD = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, false);
setLastModifiedTime(coordJobD, "2011-06-01T01:00Z");
WorkflowJobBean wfJobA = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
setEndTime(wfJobA, "2011-02-01T01:00Z");
WorkflowJobBean wfJobB = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
setEndTime(wfJobB, "2011-03-01T01:00Z");
WorkflowJobBean wfJobC = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
setEndTime(wfJobC, "2011-06-01T01:00Z");
WorkflowJobBean wfJobD = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
setEndTime(wfJobD, "2011-06-01T01:00Z");
WorkflowJobBean wfJobE = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
setEndTime(wfJobE, "2011-01-01T01:00Z");
WorkflowJobBean wfJobF = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
setEndTime(wfJobF, "2011-01-01T01:00Z");
WorkflowActionBean wfActionA = addRecordToWfActionTable(wfJobA.getId(), "1", WorkflowAction.Status.OK);
WorkflowActionBean wfActionB = addRecordToWfActionTable(wfJobB.getId(), "1", WorkflowAction.Status.OK);
WorkflowActionBean wfActionC = addRecordToWfActionTable(wfJobC.getId(), "1", WorkflowAction.Status.OK);
WorkflowActionBean wfActionD = addRecordToWfActionTable(wfJobD.getId(), "1", WorkflowAction.Status.OK);
WorkflowActionBean wfActionE = addRecordToWfActionTable(wfJobE.getId(), "1", WorkflowAction.Status.OK);
WorkflowActionBean wfActionF = addRecordToWfActionTable(wfJobF.getId(), "1", WorkflowAction.Status.OK);
WorkflowJobBean subwfJobA = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, wfJobA.getId());
setEndTime(subwfJobA, "2011-01-01T01:00Z");
WorkflowJobBean subwfJobC = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, wfJobC.getId());
setEndTime(subwfJobC, "2011-01-01T01:00Z");
WorkflowJobBean subwfJobF = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, wfJobF.getId());
setEndTime(subwfJobF, "2011-04-01T01:00Z");
WorkflowActionBean subwfActionA = addRecordToWfActionTable(subwfJobA.getId(), "1", WorkflowAction.Status.OK);
WorkflowActionBean subwfActionC = addRecordToWfActionTable(subwfJobC.getId(), "1", WorkflowAction.Status.OK);
WorkflowActionBean subwfActionF = addRecordToWfActionTable(subwfJobF.getId(), "1", WorkflowAction.Status.OK);
CoordinatorActionBean coordActionA = addRecordToCoordActionTable(coordJobA.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJobA.getId(), "SUCCEEDED", 0);
CoordinatorActionBean coordActionB = addRecordToCoordActionTable(coordJobB.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJobB.getId(), "SUCCEEDED", 0);
CoordinatorActionBean coordActionC = addRecordToCoordActionTable(coordJobC.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJobC.getId(), "SUCCEEDED", 0);
CoordinatorActionBean coordActionD = addRecordToCoordActionTable(coordJobD.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJobD.getId(), "SUCCEEDED", 0);
BundleActionBean bundleActionA = addRecordToBundleActionTable(bundleJobA.getId(), coordJobA.getId(), coordJobA.getAppName(), 0, Job.Status.SUCCEEDED);
BundleActionBean bundleActionB = addRecordToBundleActionTable(bundleJobB.getId(), coordJobB.getId(), coordJobB.getAppName(), 0, Job.Status.SUCCEEDED);
WorkflowJobGetJPAExecutor wfJobAGetCmd = new WorkflowJobGetJPAExecutor(wfJobA.getId());
WorkflowJobGetJPAExecutor wfJobBGetCmd = new WorkflowJobGetJPAExecutor(wfJobB.getId());
WorkflowJobGetJPAExecutor wfJobCGetCmd = new WorkflowJobGetJPAExecutor(wfJobC.getId());
WorkflowJobGetJPAExecutor wfJobDGetCmd = new WorkflowJobGetJPAExecutor(wfJobD.getId());
WorkflowJobGetJPAExecutor wfJobEGetCmd = new WorkflowJobGetJPAExecutor(wfJobE.getId());
WorkflowJobGetJPAExecutor wfJobFGetCmd = new WorkflowJobGetJPAExecutor(wfJobF.getId());
WorkflowActionGetJPAExecutor wfActionAGetCmd = new WorkflowActionGetJPAExecutor(wfActionA.getId());
WorkflowActionGetJPAExecutor wfActionBGetCmd = new WorkflowActionGetJPAExecutor(wfActionB.getId());
WorkflowActionGetJPAExecutor wfActionCGetCmd = new WorkflowActionGetJPAExecutor(wfActionC.getId());
WorkflowActionGetJPAExecutor wfActionDGetCmd = new WorkflowActionGetJPAExecutor(wfActionD.getId());
WorkflowActionGetJPAExecutor wfActionEGetCmd = new WorkflowActionGetJPAExecutor(wfActionE.getId());
WorkflowActionGetJPAExecutor wfActionFGetCmd = new WorkflowActionGetJPAExecutor(wfActionF.getId());
WorkflowJobGetJPAExecutor subwfJobAGetCmd = new WorkflowJobGetJPAExecutor(subwfJobA.getId());
WorkflowJobGetJPAExecutor subwfJobCGetCmd = new WorkflowJobGetJPAExecutor(subwfJobC.getId());
WorkflowJobGetJPAExecutor subwfJobFGetCmd = new WorkflowJobGetJPAExecutor(subwfJobF.getId());
WorkflowActionGetJPAExecutor subwfActionAGetCmd = new WorkflowActionGetJPAExecutor(subwfActionA.getId());
WorkflowActionGetJPAExecutor subwfActionCGetCmd = new WorkflowActionGetJPAExecutor(subwfActionC.getId());
WorkflowActionGetJPAExecutor subwfActionFGetCmd = new WorkflowActionGetJPAExecutor(subwfActionF.getId());
CoordJobGetJPAExecutor coordJobAGetCmd = new CoordJobGetJPAExecutor(coordJobA.getId());
CoordJobGetJPAExecutor coordJobBGetCmd = new CoordJobGetJPAExecutor(coordJobB.getId());
CoordJobGetJPAExecutor coordJobCGetCmd = new CoordJobGetJPAExecutor(coordJobC.getId());
CoordJobGetJPAExecutor coordJobDGetCmd = new CoordJobGetJPAExecutor(coordJobD.getId());
CoordActionGetJPAExecutor coordActionAGetCmd = new CoordActionGetJPAExecutor(coordActionA.getId());
CoordActionGetJPAExecutor coordActionBGetCmd = new CoordActionGetJPAExecutor(coordActionB.getId());
CoordActionGetJPAExecutor coordActionCGetCmd = new CoordActionGetJPAExecutor(coordActionC.getId());
CoordActionGetJPAExecutor coordActionDGetCmd = new CoordActionGetJPAExecutor(coordActionD.getId());
BundleJobGetJPAExecutor bundleJobAGetCmd = new BundleJobGetJPAExecutor(bundleJobA.getId());
BundleJobGetJPAExecutor bundleJobBGetCmd = new BundleJobGetJPAExecutor(bundleJobB.getId());
BundleActionGetJPAExecutor bundleActionAGetCmd = new BundleActionGetJPAExecutor(bundleJobA.getId(), coordJobA.getAppName());
BundleActionGetJPAExecutor bundleActionBGetCmd = new BundleActionGetJPAExecutor(bundleJobB.getId(), coordJobB.getAppName());
wfJobA = jpaService.execute(wfJobAGetCmd);
wfJobB = jpaService.execute(wfJobBGetCmd);
wfJobC = jpaService.execute(wfJobCGetCmd);
wfJobD = jpaService.execute(wfJobDGetCmd);
wfJobE = jpaService.execute(wfJobEGetCmd);
wfJobF = jpaService.execute(wfJobFGetCmd);
wfActionA = jpaService.execute(wfActionAGetCmd);
wfActionB = jpaService.execute(wfActionBGetCmd);
wfActionC = jpaService.execute(wfActionCGetCmd);
wfActionD = jpaService.execute(wfActionDGetCmd);
wfActionE = jpaService.execute(wfActionEGetCmd);
wfActionF = jpaService.execute(wfActionFGetCmd);
subwfJobA = jpaService.execute(subwfJobAGetCmd);
subwfJobC = jpaService.execute(subwfJobCGetCmd);
subwfJobF = jpaService.execute(subwfJobFGetCmd);
subwfActionA = jpaService.execute(subwfActionAGetCmd);
subwfActionC = jpaService.execute(subwfActionCGetCmd);
subwfActionF = jpaService.execute(subwfActionFGetCmd);
coordJobA = jpaService.execute(coordJobAGetCmd);
coordJobB = jpaService.execute(coordJobBGetCmd);
coordJobC = jpaService.execute(coordJobCGetCmd);
coordJobD = jpaService.execute(coordJobDGetCmd);
coordActionA = jpaService.execute(coordActionAGetCmd);
coordActionB = jpaService.execute(coordActionBGetCmd);
coordActionC = jpaService.execute(coordActionCGetCmd);
coordActionD = jpaService.execute(coordActionDGetCmd);
bundleJobA = jpaService.execute(bundleJobAGetCmd);
bundleJobB = jpaService.execute(bundleJobBGetCmd);
bundleActionA = jpaService.execute(bundleActionAGetCmd);
bundleActionB = jpaService.execute(bundleActionBGetCmd);
assertEquals(WorkflowJob.Status.SUCCEEDED, wfJobA.getStatus());
assertEquals(WorkflowJob.Status.SUCCEEDED, wfJobB.getStatus());
assertEquals(WorkflowJob.Status.SUCCEEDED, wfJobC.getStatus());
assertEquals(WorkflowJob.Status.SUCCEEDED, wfJobD.getStatus());
assertEquals(WorkflowJob.Status.SUCCEEDED, wfJobE.getStatus());
assertEquals(WorkflowJob.Status.SUCCEEDED, wfJobF.getStatus());
assertEquals(WorkflowAction.Status.OK, wfActionA.getStatus());
assertEquals(WorkflowAction.Status.OK, wfActionB.getStatus());
assertEquals(WorkflowAction.Status.OK, wfActionC.getStatus());
assertEquals(WorkflowAction.Status.OK, wfActionD.getStatus());
assertEquals(WorkflowAction.Status.OK, wfActionE.getStatus());
assertEquals(WorkflowAction.Status.OK, wfActionF.getStatus());
assertEquals(WorkflowJob.Status.SUCCEEDED, subwfJobA.getStatus());
assertEquals(WorkflowJob.Status.SUCCEEDED, subwfJobC.getStatus());
assertEquals(WorkflowJob.Status.SUCCEEDED, subwfJobF.getStatus());
assertEquals(WorkflowAction.Status.OK, subwfActionA.getStatus());
assertEquals(WorkflowAction.Status.OK, subwfActionC.getStatus());
assertEquals(WorkflowAction.Status.OK, subwfActionF.getStatus());
assertEquals(CoordinatorJob.Status.SUCCEEDED, coordJobA.getStatus());
assertEquals(CoordinatorJob.Status.SUCCEEDED, coordJobB.getStatus());
assertEquals(CoordinatorJob.Status.SUCCEEDED, coordJobC.getStatus());
assertEquals(CoordinatorJob.Status.SUCCEEDED, coordJobD.getStatus());
assertEquals(CoordinatorAction.Status.SUCCEEDED, coordActionA.getStatus());
assertEquals(CoordinatorAction.Status.SUCCEEDED, coordActionB.getStatus());
assertEquals(CoordinatorAction.Status.SUCCEEDED, coordActionC.getStatus());
assertEquals(CoordinatorAction.Status.SUCCEEDED, coordActionD.getStatus());
assertEquals(BundleJobBean.Status.SUCCEEDED, bundleJobA.getStatus());
assertEquals(BundleJobBean.Status.SUCCEEDED, bundleJobB.getStatus());
assertEquals(BundleJobBean.Status.SUCCEEDED, bundleActionA.getStatus());
assertEquals(BundleJobBean.Status.SUCCEEDED, bundleActionB.getStatus());
new PurgeXCommand(getNumDaysToNotBePurged(wfJobB.getEndTime()), getNumDaysToNotBePurged(coordJobC.getLastModifiedTime()), getNumDaysToNotBePurged(bundleJobB.getLastModifiedTime()), 10).call();
try {
jpaService.execute(bundleJobAGetCmd);
fail("Bundle Job A should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0604, je.getErrorCode());
}
try {
jpaService.execute(bundleActionAGetCmd);
fail("Bundle Action A should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
try {
jpaService.execute(bundleJobBGetCmd);
} catch (JPAExecutorException je) {
fail("Bundle Job B should not have been purged");
}
try {
jpaService.execute(bundleActionBGetCmd);
} catch (JPAExecutorException je) {
fail("Bundle Action B should not have been purged");
}
try {
jpaService.execute(coordJobAGetCmd);
fail("Coordinator Job A should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0604, je.getErrorCode());
}
try {
jpaService.execute(coordActionAGetCmd);
fail("Coordinator Action A should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
try {
jpaService.execute(coordJobBGetCmd);
} catch (JPAExecutorException je) {
fail("Coordinator Job B should not have been purged");
}
try {
jpaService.execute(coordActionBGetCmd);
} catch (JPAExecutorException je) {
fail("Coordinator Action B should not have been purged");
}
try {
jpaService.execute(coordJobCGetCmd);
} catch (JPAExecutorException je) {
fail("Coordinator Job C should not have been purged");
}
try {
jpaService.execute(coordActionCGetCmd);
} catch (JPAExecutorException je) {
fail("Coordinator Action C should not have been purged");
}
try {
jpaService.execute(coordJobDGetCmd);
} catch (JPAExecutorException je) {
fail("Coordinator Job D should not have been purged");
}
try {
jpaService.execute(coordActionDGetCmd);
} catch (JPAExecutorException je) {
fail("Coordinator Action D should not have been purged");
}
try {
jpaService.execute(wfJobAGetCmd);
fail("Workflow Job A should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0604, je.getErrorCode());
}
try {
jpaService.execute(wfActionAGetCmd);
fail("Workflow Action A should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
try {
jpaService.execute(wfJobBGetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Job B should not have been purged");
}
try {
jpaService.execute(wfActionBGetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Action B should not have been purged");
}
try {
jpaService.execute(wfJobCGetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Job C should not have been purged");
}
try {
jpaService.execute(wfActionCGetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Action C should not have been purged");
}
try {
jpaService.execute(wfJobDGetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Job D should not have been purged");
}
try {
jpaService.execute(wfActionDGetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Action D should not have been purged");
}
try {
jpaService.execute(wfJobEGetCmd);
fail("Workflow Job E should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0604, je.getErrorCode());
}
try {
jpaService.execute(wfActionEGetCmd);
fail("Workflow Action E should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
try {
jpaService.execute(wfJobFGetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Job F should not have been purged");
}
try {
jpaService.execute(wfActionFGetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Action F should not have been purged");
}
try {
jpaService.execute(subwfJobAGetCmd);
fail("SubWorkflow Job A should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0604, je.getErrorCode());
}
try {
jpaService.execute(subwfActionAGetCmd);
fail("SubWorkflow Action A should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
try {
jpaService.execute(subwfJobCGetCmd);
} catch (JPAExecutorException je) {
fail("SubWorkflow Job C should not have been purged");
}
try {
jpaService.execute(subwfActionCGetCmd);
} catch (JPAExecutorException je) {
fail("SubWorkflow Action C should not have been purged");
}
try {
jpaService.execute(subwfJobFGetCmd);
} catch (JPAExecutorException je) {
fail("SubWorkflow Job F should not have been purged");
}
try {
jpaService.execute(subwfActionFGetCmd);
} catch (JPAExecutorException je) {
fail("SubWorkflow Action F should not have been purged");
}
}
use of org.apache.oozie.service.JPAService in project oozie by apache.
the class TestPurgeXCommand method testKillCoordPurgeXCommand.
/**
* Test : purge killed coord job and action successfully
*
* @throws Exception
*/
public void testKillCoordPurgeXCommand() throws Exception {
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.KILLED, false, false);
CoordinatorActionBean action = addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.KILLED, "coord-action-get.xml", 0);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobGetJPAExecutor coordJobGetExecutor = new CoordJobGetJPAExecutor(job.getId());
CoordActionGetJPAExecutor coordActionGetExecutor = new CoordActionGetJPAExecutor(action.getId());
job = jpaService.execute(coordJobGetExecutor);
action = jpaService.execute(coordActionGetExecutor);
assertEquals(job.getStatus(), CoordinatorJob.Status.KILLED);
assertEquals(action.getStatus(), CoordinatorAction.Status.KILLED);
new PurgeXCommand(1, 7, 1, 10).call();
try {
jpaService.execute(coordJobGetExecutor);
fail("Coordinator Job should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0604, je.getErrorCode());
}
try {
jpaService.execute(coordActionGetExecutor);
fail("Coordinator Action should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
}
use of org.apache.oozie.service.JPAService in project oozie by apache.
the class TestPurgeXCommand method testSucCoordPurgeXCommand.
/**
* Test : purge succeeded coord job and action successfully
*
* @throws Exception
*/
public void testSucCoordPurgeXCommand() throws Exception {
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, false);
CoordinatorActionBean action = addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobGetJPAExecutor coordJobGetExecutor = new CoordJobGetJPAExecutor(job.getId());
CoordActionGetJPAExecutor coordActionGetExecutor = new CoordActionGetJPAExecutor(action.getId());
job = jpaService.execute(coordJobGetExecutor);
action = jpaService.execute(coordActionGetExecutor);
assertEquals(job.getStatus(), CoordinatorJob.Status.SUCCEEDED);
assertEquals(action.getStatus(), CoordinatorAction.Status.SUCCEEDED);
new PurgeXCommand(1, 7, 1, 10).call();
try {
jpaService.execute(coordJobGetExecutor);
fail("Coordinator Job should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0604, je.getErrorCode());
}
try {
jpaService.execute(coordActionGetExecutor);
fail("Coordinator Action should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
}
use of org.apache.oozie.service.JPAService in project oozie by apache.
the class TestPurgeXCommand method testPurgeCoordWithWFChild2MoreThanLimit.
/**
* Test : The workflows should not get purged, but the coordinator parent should get purged --> none will get purged
* There are more workflow children than the limit
*
* @throws Exception
*/
public void testPurgeCoordWithWFChild2MoreThanLimit() throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, false);
WorkflowJobBean wfJob1 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
WorkflowJobBean wfJob2 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
WorkflowJobBean wfJob3 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
WorkflowJobBean wfJob4 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
WorkflowJobBean wfJob5 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
WorkflowActionBean wfAction1 = addRecordToWfActionTable(wfJob1.getId(), "1", WorkflowAction.Status.OK);
WorkflowActionBean wfAction2 = addRecordToWfActionTable(wfJob2.getId(), "1", WorkflowAction.Status.OK);
WorkflowActionBean wfAction3 = addRecordToWfActionTable(wfJob3.getId(), "1", WorkflowAction.Status.OK);
WorkflowActionBean wfAction4 = addRecordToWfActionTable(wfJob4.getId(), "1", WorkflowAction.Status.OK);
WorkflowActionBean wfAction5 = addRecordToWfActionTable(wfJob5.getId(), "1", WorkflowAction.Status.OK);
CoordinatorActionBean coordAction1 = addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJob1.getId(), "SUCCEEDED", 0);
CoordinatorActionBean coordAction2 = addRecordToCoordActionTable(coordJob.getId(), 2, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJob2.getId(), "SUCCEEDED", 0);
CoordinatorActionBean coordAction3 = addRecordToCoordActionTable(coordJob.getId(), 3, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJob3.getId(), "SUCCEEDED", 0);
CoordinatorActionBean coordAction4 = addRecordToCoordActionTable(coordJob.getId(), 4, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJob4.getId(), "SUCCEEDED", 0);
CoordinatorActionBean coordAction5 = addRecordToCoordActionTable(coordJob.getId(), 5, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJob5.getId(), "SUCCEEDED", 0);
WorkflowJobGetJPAExecutor wfJob1GetCmd = new WorkflowJobGetJPAExecutor(wfJob1.getId());
WorkflowJobGetJPAExecutor wfJob2GetCmd = new WorkflowJobGetJPAExecutor(wfJob2.getId());
WorkflowJobGetJPAExecutor wfJob3GetCmd = new WorkflowJobGetJPAExecutor(wfJob3.getId());
WorkflowJobGetJPAExecutor wfJob4GetCmd = new WorkflowJobGetJPAExecutor(wfJob4.getId());
WorkflowJobGetJPAExecutor wfJob5GetCmd = new WorkflowJobGetJPAExecutor(wfJob5.getId());
WorkflowActionGetJPAExecutor wfAction1GetCmd = new WorkflowActionGetJPAExecutor(wfAction1.getId());
WorkflowActionGetJPAExecutor wfAction2GetCmd = new WorkflowActionGetJPAExecutor(wfAction2.getId());
WorkflowActionGetJPAExecutor wfAction3GetCmd = new WorkflowActionGetJPAExecutor(wfAction3.getId());
WorkflowActionGetJPAExecutor wfAction4GetCmd = new WorkflowActionGetJPAExecutor(wfAction4.getId());
WorkflowActionGetJPAExecutor wfAction5GetCmd = new WorkflowActionGetJPAExecutor(wfAction5.getId());
CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(coordJob.getId());
CoordActionGetJPAExecutor coordAction1GetCmd = new CoordActionGetJPAExecutor(coordAction1.getId());
CoordActionGetJPAExecutor coordAction2GetCmd = new CoordActionGetJPAExecutor(coordAction2.getId());
CoordActionGetJPAExecutor coordAction3GetCmd = new CoordActionGetJPAExecutor(coordAction3.getId());
CoordActionGetJPAExecutor coordAction4GetCmd = new CoordActionGetJPAExecutor(coordAction4.getId());
CoordActionGetJPAExecutor coordAction5GetCmd = new CoordActionGetJPAExecutor(coordAction5.getId());
wfJob1 = jpaService.execute(wfJob1GetCmd);
wfJob2 = jpaService.execute(wfJob2GetCmd);
wfJob3 = jpaService.execute(wfJob3GetCmd);
wfJob4 = jpaService.execute(wfJob4GetCmd);
wfJob5 = jpaService.execute(wfJob5GetCmd);
wfAction1 = jpaService.execute(wfAction1GetCmd);
wfAction2 = jpaService.execute(wfAction2GetCmd);
wfAction3 = jpaService.execute(wfAction3GetCmd);
wfAction4 = jpaService.execute(wfAction4GetCmd);
wfAction5 = jpaService.execute(wfAction5GetCmd);
coordJob = jpaService.execute(coordJobGetCmd);
coordAction1 = jpaService.execute(coordAction1GetCmd);
coordAction2 = jpaService.execute(coordAction2GetCmd);
coordAction3 = jpaService.execute(coordAction3GetCmd);
coordAction4 = jpaService.execute(coordAction4GetCmd);
coordAction5 = jpaService.execute(coordAction5GetCmd);
assertEquals(WorkflowJob.Status.SUCCEEDED, wfJob1.getStatus());
assertEquals(WorkflowJob.Status.SUCCEEDED, wfJob2.getStatus());
assertEquals(WorkflowJob.Status.SUCCEEDED, wfJob3.getStatus());
assertEquals(WorkflowJob.Status.SUCCEEDED, wfJob4.getStatus());
assertEquals(WorkflowJob.Status.SUCCEEDED, wfJob5.getStatus());
assertEquals(WorkflowAction.Status.OK, wfAction1.getStatus());
assertEquals(WorkflowAction.Status.OK, wfAction2.getStatus());
assertEquals(WorkflowAction.Status.OK, wfAction3.getStatus());
assertEquals(WorkflowAction.Status.OK, wfAction4.getStatus());
assertEquals(WorkflowAction.Status.OK, wfAction5.getStatus());
assertEquals(CoordinatorJob.Status.SUCCEEDED, coordJob.getStatus());
assertEquals(CoordinatorAction.Status.SUCCEEDED, coordAction1.getStatus());
assertEquals(CoordinatorAction.Status.SUCCEEDED, coordAction2.getStatus());
assertEquals(CoordinatorAction.Status.SUCCEEDED, coordAction3.getStatus());
assertEquals(CoordinatorAction.Status.SUCCEEDED, coordAction4.getStatus());
assertEquals(CoordinatorAction.Status.SUCCEEDED, coordAction5.getStatus());
new PurgeXCommand(getNumDaysToNotBePurged(wfJob1.getEndTime()), 7, 1, 3).call();
try {
jpaService.execute(coordJobGetCmd);
} catch (JPAExecutorException je) {
fail("Coordinator Job should not have been purged");
}
try {
jpaService.execute(coordAction1GetCmd);
} catch (JPAExecutorException je) {
fail("Coordinator Action 1 should not have been purged");
}
try {
jpaService.execute(coordAction2GetCmd);
} catch (JPAExecutorException je) {
fail("Coordinator Action 2 should not have been purged");
}
try {
jpaService.execute(coordAction3GetCmd);
} catch (JPAExecutorException je) {
fail("Coordinator Action 3 should not have been purged");
}
try {
jpaService.execute(coordAction4GetCmd);
} catch (JPAExecutorException je) {
fail("Coordinator Action 4 should not have been purged");
}
try {
jpaService.execute(coordAction5GetCmd);
} catch (JPAExecutorException je) {
fail("Coordinator Action 5 should not have been purged");
}
try {
jpaService.execute(wfJob1GetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Job 1 should not have been purged");
}
try {
jpaService.execute(wfJob2GetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Job 2 should not have been purged");
}
try {
jpaService.execute(wfJob3GetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Job 3 should not have been purged");
}
try {
jpaService.execute(wfJob4GetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Job 4 should not have been purged");
}
try {
jpaService.execute(wfJob5GetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Job 5 should not have been purged");
}
try {
jpaService.execute(wfAction1GetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Action 1 should not have been purged");
}
try {
jpaService.execute(wfAction2GetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Action 2 should not have been purged");
}
try {
jpaService.execute(wfAction3GetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Action 3 should not have been purged");
}
try {
jpaService.execute(wfAction4GetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Action 4 should not have been purged");
}
try {
jpaService.execute(wfAction5GetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Action 5 should not have been purged");
}
}
Aggregations