use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.
the class TestPurgeXCommand method testPurgeCoordWithWFChildWithSubWF1.
/**
* Test : The subworkflow and workflow should get purged, but the coordinator parent shouldn't get purged --> none will get
* purged
*
* @throws Exception
*/
public void testPurgeCoordWithWFChildWithSubWF1() throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
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);
WorkflowJobBean subwfJob = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, wfJob.getId());
WorkflowActionBean subwfAction = addRecordToWfActionTable(subwfJob.getId(), "1", WorkflowAction.Status.OK);
CoordinatorActionBean coordAction = addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJob.getId(), "SUCCEEDED", 0);
WorkflowJobGetJPAExecutor wfJobGetCmd = new WorkflowJobGetJPAExecutor(wfJob.getId());
WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(wfAction.getId());
WorkflowJobGetJPAExecutor subwfJobGetCmd = new WorkflowJobGetJPAExecutor(subwfJob.getId());
WorkflowActionGetJPAExecutor subwfActionGetCmd = new WorkflowActionGetJPAExecutor(subwfAction.getId());
CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(coordJob.getId());
CoordActionGetJPAExecutor coordActionGetCmd = new CoordActionGetJPAExecutor(coordAction.getId());
wfJob = jpaService.execute(wfJobGetCmd);
wfAction = jpaService.execute(wfActionGetCmd);
subwfJob = jpaService.execute(subwfJobGetCmd);
subwfAction = jpaService.execute(subwfActionGetCmd);
coordJob = jpaService.execute(coordJobGetCmd);
coordAction = jpaService.execute(coordActionGetCmd);
assertEquals(WorkflowJob.Status.SUCCEEDED, wfJob.getStatus());
assertEquals(WorkflowAction.Status.OK, wfAction.getStatus());
assertEquals(WorkflowJob.Status.SUCCEEDED, subwfJob.getStatus());
assertEquals(WorkflowAction.Status.OK, subwfAction.getStatus());
assertEquals(CoordinatorJob.Status.SUCCEEDED, coordJob.getStatus());
assertEquals(CoordinatorAction.Status.SUCCEEDED, coordAction.getStatus());
new PurgeXCommand(7, getNumDaysToNotBePurged(coordJob.getLastModifiedTime()), 1, 10).call();
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");
}
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 testBundlePurgeXCommandFailed.
/**
* Test : purge bundle job and action failed
*
* @throws Exception
*/
public void testBundlePurgeXCommandFailed() throws Exception {
BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.RUNNING, DateUtils.parseDateOozieTZ("2011-01-01T01:00Z"));
this.addRecordToBundleActionTable(job.getId(), "action1", 0, Job.Status.RUNNING);
this.addRecordToBundleActionTable(job.getId(), "action2", 0, Job.Status.SUCCEEDED);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
BundleJobGetJPAExecutor bundleJobGetExecutor = new BundleJobGetJPAExecutor(job.getId());
job = jpaService.execute(bundleJobGetExecutor);
assertEquals(Job.Status.RUNNING, job.getStatus());
BundleActionGetJPAExecutor bundleActionGetExecutor1 = new BundleActionGetJPAExecutor(job.getId(), "action1");
BundleActionBean action1 = jpaService.execute(bundleActionGetExecutor1);
assertEquals(Job.Status.RUNNING, action1.getStatus());
BundleActionGetJPAExecutor bundleActionGetExecutor2 = new BundleActionGetJPAExecutor(job.getId(), "action2");
BundleActionBean action2 = jpaService.execute(bundleActionGetExecutor2);
assertEquals(Job.Status.SUCCEEDED, action2.getStatus());
new PurgeXCommand(1, 1, 7, 10).call();
try {
jpaService.execute(bundleJobGetExecutor);
} catch (JPAExecutorException je) {
fail("Bundle Job should not have been purged");
}
try {
jpaService.execute(bundleActionGetExecutor1);
} catch (JPAExecutorException je) {
fail("Bundle Action should not have been purged");
}
try {
jpaService.execute(bundleActionGetExecutor2);
} catch (JPAExecutorException je) {
fail("Bundle Action should not have been purged");
}
}
use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.
the class TestPurgeXCommand method testFailCoordPurgeXCommand.
/**
* Test : purge failed coord job and action successfully
*
* @throws Exception
*/
public void testFailCoordPurgeXCommand() throws Exception {
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.FAILED, false, false);
CoordinatorActionBean action = addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.FAILED, "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.FAILED);
assertEquals(action.getStatus(), CoordinatorAction.Status.FAILED);
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 testKillJobPurgeXCommand.
/**
* Test : purge killed wf job and action successfully
*
* @throws Exception
*/
public void testKillJobPurgeXCommand() throws Exception {
WorkflowJobBean job = this.addRecordToWfJobTable(WorkflowJob.Status.KILLED, WorkflowInstance.Status.KILLED);
WorkflowActionBean action = this.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.KILLED);
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.KILLED);
assertEquals(action.getStatus(), WorkflowAction.Status.KILLED);
WorkflowInstance wfInstance = job.getWorkflowInstance();
assertEquals(wfInstance.getStatus(), WorkflowInstance.Status.KILLED);
new PurgeXCommand(7, 1, 1, 10).call();
try {
jpaService.execute(wfJobGetCmd);
fail("Workflow Job should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0604, je.getErrorCode());
}
try {
jpaService.execute(wfActionGetCmd);
fail("Workflow 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 testPurgeWFWithEndedSubWFWithNullEndTimeValidLastModifiedTime.
/**
* Test : The subworkflow should get purged, and the workflow parent should get purged --> both will get purged
* Subworkflow has terminated, last modified time is known, but end time is null
*
* @throws Exception
*/
public void testPurgeWFWithEndedSubWFWithNullEndTimeValidLastModifiedTime() throws Exception {
final JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
WorkflowJobBean wfJob = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
WorkflowActionBean wfAction1 = addRecordToWfActionTable(wfJob.getId(), "1", WorkflowAction.Status.OK);
WorkflowJobBean subwfJob1 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, wfJob.getId());
subwfJob1.setEndTime(null);
WorkflowActionBean subwfAction1 = addRecordToWfActionTable(subwfJob1.getId(), "1", WorkflowAction.Status.OK);
final WorkflowJobGetJPAExecutor wfJobGetCmd = new WorkflowJobGetJPAExecutor(wfJob.getId());
final WorkflowActionGetJPAExecutor wfAction1GetCmd = new WorkflowActionGetJPAExecutor(wfAction1.getId());
final WorkflowJobGetJPAExecutor subwfJob1GetCmd = new WorkflowJobGetJPAExecutor(subwfJob1.getId());
final WorkflowActionGetJPAExecutor subwfAction1GetCmd = new WorkflowActionGetJPAExecutor(subwfAction1.getId());
wfJob = jpaService.execute(wfJobGetCmd);
wfAction1 = jpaService.execute(wfAction1GetCmd);
subwfJob1 = jpaService.execute(subwfJob1GetCmd);
subwfAction1 = jpaService.execute(subwfAction1GetCmd);
assertEquals(WorkflowJob.Status.SUCCEEDED, wfJob.getStatus());
assertEquals(WorkflowAction.Status.OK, wfAction1.getStatus());
assertEquals(WorkflowJob.Status.SUCCEEDED, subwfJob1.getStatus());
assertEquals(WorkflowAction.Status.OK, subwfAction1.getStatus());
final QueryExecutor<WorkflowJobBean, WorkflowJobQueryExecutor.WorkflowJobQuery> workflowJobQueryExecutor = WorkflowJobQueryExecutor.getInstance();
workflowJobQueryExecutor.executeUpdate(WorkflowJobQuery.UPDATE_WORKFLOW, subwfJob1);
final int wfOlderThanDays = 7;
final int coordOlderThanDays = 1;
final int bundleOlderThanDays = 1;
final int limit = 3;
new PurgeXCommand(wfOlderThanDays, coordOlderThanDays, bundleOlderThanDays, limit).call();
try {
jpaService.execute(wfJobGetCmd);
fail("Workflow Job should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0604, je.getErrorCode());
}
try {
jpaService.execute(subwfJob1GetCmd);
fail("SubWorkflow Job 1 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0604, je.getErrorCode());
}
}
Aggregations