use of org.apache.oozie.executor.jpa.JPAExecutorException 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.executor.jpa.JPAExecutorException 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");
}
}
use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.
the class TestPurgeXCommand method testPurgeCoordWithWFChild3MoreThanLimit.
/**
* Test : The workflow should get purged, and the coordinator parent should get purged --> both will get purged
*
* @throws Exception
*/
public void testPurgeCoordWithWFChild3MoreThanLimit() 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(7, 7, 1, 10).call();
try {
jpaService.execute(coordJobGetCmd);
fail("Coordinator Job should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0604, je.getErrorCode());
}
try {
jpaService.execute(coordAction1GetCmd);
fail("Coordinator Action 1 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
try {
jpaService.execute(coordAction2GetCmd);
fail("Coordinator Action 2 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
try {
jpaService.execute(coordAction3GetCmd);
fail("Coordinator Action 3 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
try {
jpaService.execute(coordAction4GetCmd);
fail("Coordinator Action 4 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
try {
jpaService.execute(coordAction5GetCmd);
fail("Coordinator Action 5 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
try {
jpaService.execute(wfJob1GetCmd);
fail("Workflow Job 1 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0604, je.getErrorCode());
}
try {
jpaService.execute(wfJob2GetCmd);
fail("Workflow Job 2 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0604, je.getErrorCode());
}
try {
jpaService.execute(wfJob3GetCmd);
fail("Workflow Job 3 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0604, je.getErrorCode());
}
try {
jpaService.execute(wfJob4GetCmd);
fail("Workflow Job 4 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0604, je.getErrorCode());
}
try {
jpaService.execute(wfJob5GetCmd);
fail("Workflow Job 5 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0604, je.getErrorCode());
}
try {
jpaService.execute(wfAction1GetCmd);
fail("Workflow Action 1 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
try {
jpaService.execute(wfAction2GetCmd);
fail("Workflow Action 2 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
try {
jpaService.execute(wfAction3GetCmd);
fail("Workflow Action 3 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
try {
jpaService.execute(wfAction4GetCmd);
fail("Workflow Action 4 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
try {
jpaService.execute(wfAction5GetCmd);
fail("Workflow Action 5 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
}
use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.
the class TestPurgeXCommand method testPurgeWFWithSubWF2.
/**
* Test : The subworkflow shouldn't get purged, but the workflow parent should get purged --> neither will get purged
*
* @throws Exception
*/
public void testPurgeWFWithSubWF2() throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
WorkflowJobBean wfJob = addRecordToWfJobTableForNegCase(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
WorkflowActionBean wfAction = addRecordToWfActionTable(wfJob.getId(), "1", WorkflowAction.Status.OK);
WorkflowJobBean subwfJob = addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING, wfJob.getId());
WorkflowActionBean subwfAction = addRecordToWfActionTable(subwfJob.getId(), "1", WorkflowAction.Status.RUNNING);
WorkflowJobGetJPAExecutor wfJobGetCmd = new WorkflowJobGetJPAExecutor(wfJob.getId());
WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(wfAction.getId());
WorkflowJobGetJPAExecutor subwfJobGetCmd = new WorkflowJobGetJPAExecutor(subwfJob.getId());
WorkflowActionGetJPAExecutor subwfActionGetCmd = new WorkflowActionGetJPAExecutor(subwfAction.getId());
wfJob = jpaService.execute(wfJobGetCmd);
wfAction = jpaService.execute(wfActionGetCmd);
subwfJob = jpaService.execute(subwfJobGetCmd);
subwfAction = jpaService.execute(subwfActionGetCmd);
assertEquals(WorkflowJob.Status.SUCCEEDED, wfJob.getStatus());
assertEquals(WorkflowAction.Status.OK, wfAction.getStatus());
assertEquals(WorkflowJob.Status.RUNNING, subwfJob.getStatus());
assertEquals(WorkflowAction.Status.RUNNING, subwfAction.getStatus());
new PurgeXCommand(7, 1, 1, 10).call();
try {
jpaService.execute(wfJobGetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Job should not have been purged");
}
try {
jpaService.execute(wfActionGetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Action should not have been purged");
}
try {
jpaService.execute(subwfJobGetCmd);
} catch (JPAExecutorException je) {
fail("SubWorkflow Job should not have been purged");
}
try {
jpaService.execute(subwfActionGetCmd);
} catch (JPAExecutorException je) {
fail("SubWorkflow Action should not have been purged");
}
}
use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.
the class TestPurgeXCommand method testPurgeBundleWithCoordChildWithWFChild1.
/**
* Test : The workflow and coordinator should get purged, but the bundle parent shouldn't get purged --> none will get purged
*
* @throws Exception
*/
public void testPurgeBundleWithCoordChildWithWFChild1() throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
BundleJobBean bundleJob = addRecordToBundleJobTable(Job.Status.SUCCEEDED, DateUtils.parseDateOozieTZ("2011-01-01T01:00Z"));
CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, false);
WorkflowJobBean wfJob = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
WorkflowActionBean wfAction = addRecordToWfActionTable(wfJob.getId(), "1", WorkflowAction.Status.OK);
CoordinatorActionBean coordAction = addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJob.getId(), "SUCCEEDED", 0);
BundleActionBean bundleAction = addRecordToBundleActionTable(bundleJob.getId(), coordJob.getId(), coordJob.getAppName(), 0, Job.Status.SUCCEEDED);
WorkflowJobGetJPAExecutor wfJobGetCmd = new WorkflowJobGetJPAExecutor(wfJob.getId());
WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(wfAction.getId());
CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(coordJob.getId());
CoordActionGetJPAExecutor coordActionGetCmd = new CoordActionGetJPAExecutor(coordAction.getId());
BundleJobGetJPAExecutor bundleJobGetCmd = new BundleJobGetJPAExecutor(bundleJob.getId());
BundleActionGetJPAExecutor bundleActionGetCmd = new BundleActionGetJPAExecutor(bundleJob.getId(), coordJob.getAppName());
wfJob = jpaService.execute(wfJobGetCmd);
wfAction = jpaService.execute(wfActionGetCmd);
coordJob = jpaService.execute(coordJobGetCmd);
coordAction = jpaService.execute(coordActionGetCmd);
bundleJob = jpaService.execute(bundleJobGetCmd);
bundleAction = jpaService.execute(bundleActionGetCmd);
assertEquals(WorkflowJob.Status.SUCCEEDED, wfJob.getStatus());
assertEquals(WorkflowAction.Status.OK, wfAction.getStatus());
assertEquals(CoordinatorJob.Status.SUCCEEDED, coordJob.getStatus());
assertEquals(CoordinatorAction.Status.SUCCEEDED, coordAction.getStatus());
assertEquals(BundleJobBean.Status.SUCCEEDED, bundleJob.getStatus());
assertEquals(BundleJobBean.Status.SUCCEEDED, bundleAction.getStatus());
new PurgeXCommand(7, 7, getNumDaysToNotBePurged(bundleJob.getLastModifiedTime()), 10).call();
try {
jpaService.execute(bundleJobGetCmd);
} catch (JPAExecutorException je) {
fail("Bundle Job should not have been purged");
}
try {
jpaService.execute(bundleActionGetCmd);
} catch (JPAExecutorException je) {
fail("Bundle Action should not have been purged");
}
try {
jpaService.execute(coordJobGetCmd);
} catch (JPAExecutorException je) {
fail("Coordinator Job should not have been purged");
}
try {
jpaService.execute(coordActionGetCmd);
} catch (JPAExecutorException je) {
fail("Coordinator Action should not have been purged");
}
try {
jpaService.execute(wfJobGetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Job should not have been purged");
}
try {
jpaService.execute(wfActionGetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Action should not have been purged");
}
}
Aggregations