Search in sources :

Example 1 with AppType

use of org.apache.oozie.AppType in project oozie by apache.

the class TestEventGeneration method testInvalidXMLCoordinatorFailsForNoDuplicates.

@Test
public void testInvalidXMLCoordinatorFailsForNoDuplicates() throws Exception {
    Date startTime = DateUtils.parseDateOozieTZ("2009-02-01T23:59Z");
    Date endTime = DateUtils.parseDateOozieTZ("2009-02-02T23:59Z");
    // test coordinator action events (failure from ActionStartX)
    ehs.getAppTypes().add("workflow_action");
    CoordinatorJobBean coord = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, startTime, endTime, false, false, 0);
    CoordinatorActionBean action = addRecordToCoordActionTable(coord.getId(), 1, CoordinatorAction.Status.RUNNING, "coord-action-sla1.xml", 0);
    WorkflowJobBean wf = addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING, action.getId());
    action.setExternalId(wf.getId());
    CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQuery.UPDATE_COORD_ACTION, action);
    String waId = _createWorkflowAction(wf.getId(), "wf-action");
    new ActionStartXCommand(waId, action.getType()).call();
    final CoordJobGetJPAExecutor readCmd2 = new CoordJobGetJPAExecutor(coord.getId());
    waitFor(1 * 100, new Predicate() {

        @Override
        public boolean evaluate() throws Exception {
            return jpaService.execute(readCmd2).getStatus() == CoordinatorJob.Status.KILLED;
        }
    });
    assertEquals(3, queue.size());
    HashMap<AppType, JobEvent> eventsMap = new HashMap<AppType, JobEvent>();
    while (queue.size() > 0) {
        JobEvent event = (JobEvent) queue.poll();
        eventsMap.put(event.getAppType(), event);
    }
    assertEquals(3, eventsMap.size());
    // Check the WF action
    {
        JobEvent wfActionEvent = eventsMap.get(AppType.WORKFLOW_ACTION);
        assertNotNull("There should be a WF action", wfActionEvent);
        assertEquals(EventStatus.FAILURE, wfActionEvent.getEventStatus());
        assertEquals(waId, wfActionEvent.getId());
        assertEquals(AppType.WORKFLOW_ACTION, wfActionEvent.getAppType());
    }
    // Check the WF job
    {
        JobEvent wfJobEvent = eventsMap.get(AppType.WORKFLOW_JOB);
        assertNotNull("There should be a WF job", wfJobEvent);
        assertEquals(EventStatus.FAILURE, wfJobEvent.getEventStatus());
        assertEquals(wf.getId(), wfJobEvent.getId());
        assertEquals(AppType.WORKFLOW_JOB, wfJobEvent.getAppType());
    }
    // Check the Coordinator action
    {
        JobEvent coordActionEvent = eventsMap.get(AppType.COORDINATOR_ACTION);
        assertNotNull("There should be a Coordinator action", coordActionEvent);
        assertEquals(EventStatus.FAILURE, coordActionEvent.getEventStatus());
        assertEquals(action.getId(), coordActionEvent.getId());
        assertEquals(AppType.COORDINATOR_ACTION, coordActionEvent.getAppType());
    }
    queue.clear();
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) HashMap(java.util.HashMap) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) Date(java.util.Date) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CommandException(org.apache.oozie.command.CommandException) JobEvent(org.apache.oozie.client.event.JobEvent) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) ActionStartXCommand(org.apache.oozie.command.wf.ActionStartXCommand) AppType(org.apache.oozie.AppType) Test(org.junit.Test)

Aggregations

Date (java.util.Date)1 HashMap (java.util.HashMap)1 AppType (org.apache.oozie.AppType)1 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)1 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)1 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)1 JobEvent (org.apache.oozie.client.event.JobEvent)1 CommandException (org.apache.oozie.command.CommandException)1 ActionStartXCommand (org.apache.oozie.command.wf.ActionStartXCommand)1 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)1 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)1 Test (org.junit.Test)1