Search in sources :

Example 11 with WorkflowActionGetJPAExecutor

use of org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor 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");
    }
}
Also used : WorkflowJobGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor) CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) BundleActionGetJPAExecutor(org.apache.oozie.executor.jpa.BundleActionGetJPAExecutor) CoordActionGetJPAExecutor(org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean) BundleJobGetJPAExecutor(org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) BundleJobBean(org.apache.oozie.BundleJobBean) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) WorkflowActionGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService) BundleActionBean(org.apache.oozie.BundleActionBean)

Example 12 with WorkflowActionGetJPAExecutor

use of org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor 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");
    }
}
Also used : WorkflowJobGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor) CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) CoordActionGetJPAExecutor(org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor) WorkflowActionGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 13 with WorkflowActionGetJPAExecutor

use of org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor 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());
    }
}
Also used : WorkflowJobGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor) CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) CoordActionGetJPAExecutor(org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor) WorkflowActionGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 14 with WorkflowActionGetJPAExecutor

use of org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor 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");
    }
}
Also used : WorkflowJobGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) WorkflowActionGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 15 with WorkflowActionGetJPAExecutor

use of org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor 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");
    }
}
Also used : WorkflowJobGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor) CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) BundleActionGetJPAExecutor(org.apache.oozie.executor.jpa.BundleActionGetJPAExecutor) CoordActionGetJPAExecutor(org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean) BundleJobGetJPAExecutor(org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) BundleJobBean(org.apache.oozie.BundleJobBean) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) WorkflowActionGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService) BundleActionBean(org.apache.oozie.BundleActionBean)

Aggregations

WorkflowActionBean (org.apache.oozie.WorkflowActionBean)51 WorkflowActionGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor)51 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)47 JPAService (org.apache.oozie.service.JPAService)47 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)38 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)35 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)22 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)21 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)21 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)20 BundleActionBean (org.apache.oozie.BundleActionBean)9 BundleJobBean (org.apache.oozie.BundleJobBean)9 BundleActionGetJPAExecutor (org.apache.oozie.executor.jpa.BundleActionGetJPAExecutor)9 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)9 WorkflowInstance (org.apache.oozie.workflow.WorkflowInstance)9 Configuration (org.apache.hadoop.conf.Configuration)6 MapReduceActionExecutor (org.apache.oozie.action.hadoop.MapReduceActionExecutor)6 ActionExecutorContext (org.apache.oozie.command.wf.ActionXCommand.ActionExecutorContext)6 LiteWorkflowInstance (org.apache.oozie.workflow.lite.LiteWorkflowInstance)5 Date (java.util.Date)3