Search in sources :

Example 1 with WorkflowAction

use of org.apache.oozie.client.WorkflowAction in project oozie by apache.

the class TestOozieCLIMethods method testValidatePrintWorkflowActionOutput.

/**
 * Create {@code WorkflowAction} mock
 * call {@code new OozieCLI().printWorkflowAction() }
 * and validate {@code System.out} on match with expected pattern
 * <p>
 * Method do pass only if output matched with predefined pattern
 * </p>
 */
@Test
public void testValidatePrintWorkflowActionOutput() throws IOException {
    final DataObject dtObject = new DataObject() {

        {
            this.deamonName = "testWorkflowAction111";
            this.appName = "testWorkflowActionAppName";
            this.appPath = "unused";
        }
    };
    WorkflowAction workflowAction = createWorkflowAction(dtObject);
    assertPrintWorkflowActionOutput(readWorkflowActionOutput(workflowAction, true), dtObject);
    assertPrintWorkflowActionOutput(readWorkflowActionOutput(workflowAction, false), dtObject);
}
Also used : WorkflowAction(org.apache.oozie.client.WorkflowAction) Test(org.junit.Test)

Example 2 with WorkflowAction

use of org.apache.oozie.client.WorkflowAction in project oozie by apache.

the class TestJsonToBean method testParseWorkflowActions.

@SuppressWarnings("unchecked")
public void testParseWorkflowActions() {
    JSONArray array = createJsonWorkflowActionList();
    List<WorkflowAction> list = JsonToBean.createWorkflowActionList(array);
    assertEquals(2, list.size());
    assertEquals("a1", list.get(0).getId());
    assertEquals("a2", list.get(1).getId());
}
Also used : WorkflowAction(org.apache.oozie.client.WorkflowAction) JSONArray(org.json.simple.JSONArray)

Example 3 with WorkflowAction

use of org.apache.oozie.client.WorkflowAction in project oozie by apache.

the class FsActionExecutor method end.

@Override
public void end(Context context, WorkflowAction action) throws ActionExecutorException {
    String externalStatus = action.getExternalStatus();
    WorkflowAction.Status status = externalStatus.equals("OK") ? WorkflowAction.Status.OK : WorkflowAction.Status.ERROR;
    context.setEndData(status, getActionSignal(status));
    if (!context.getProtoActionConf().getBoolean(WorkflowXCommand.KEEP_WF_ACTION_DIR, false)) {
        try {
            FileSystem fs = context.getAppFileSystem();
            fs.delete(context.getActionDir(), true);
        } catch (Exception ex) {
            throw convertException(ex);
        }
    }
    LOG.info("Action ended with external status [{0}]", action.getExternalStatus());
}
Also used : WorkflowAction(org.apache.oozie.client.WorkflowAction) FileSystem(org.apache.hadoop.fs.FileSystem) URISyntaxException(java.net.URISyntaxException) ActionExecutorException(org.apache.oozie.action.ActionExecutorException) HadoopAccessorException(org.apache.oozie.service.HadoopAccessorException) IOException(java.io.IOException) AccessControlException(org.apache.hadoop.security.AccessControlException)

Example 4 with WorkflowAction

use of org.apache.oozie.client.WorkflowAction in project oozie by apache.

the class TestJsonWorkflowAction method testProperties.

public void testProperties() {
    WorkflowAction action = createNode();
    Assert.assertEquals("a", action.getId());
    Assert.assertEquals("b", action.getName());
    Assert.assertEquals("c", action.getType());
    Assert.assertEquals("d", action.getConf());
    Assert.assertEquals(WorkflowAction.Status.RUNNING, action.getStatus());
    Assert.assertEquals(1, action.getRetries());
    Assert.assertEquals(JsonUtils.parseDateRfc822(START_TIME), action.getStartTime());
    Assert.assertEquals(JsonUtils.parseDateRfc822(END_TIME), action.getEndTime());
    Assert.assertEquals("e", action.getTransition());
    Assert.assertEquals("ee", action.getData());
    Assert.assertEquals("stats", action.getStats());
    Assert.assertEquals("extChIDs", action.getExternalChildIDs());
    Assert.assertEquals("f", action.getExternalId());
    Assert.assertEquals("g", action.getExternalStatus());
    Assert.assertEquals("h", action.getTrackerUri());
    Assert.assertEquals("i", action.getConsoleUrl());
    Assert.assertEquals("j", action.getErrorCode());
    Assert.assertEquals("k", action.getErrorMessage());
}
Also used : WorkflowAction(org.apache.oozie.client.WorkflowAction)

Example 5 with WorkflowAction

use of org.apache.oozie.client.WorkflowAction in project oozie by apache.

the class TestSignalXCommand method checkSuspendActions.

private void checkSuspendActions(WorkflowJob wf, final OozieClient oc, final String jobId, final WorkflowJob.Status status, String[] prepActions, String[] okActions) throws Exception {
    // Wait for the WF to transition to status
    waitFor(30 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            WorkflowJob wf = oc.getJobInfo(jobId);
            return wf.getStatus() == status;
        }
    });
    wf = oc.getJobInfo(jobId);
    assertEquals(status, wf.getStatus());
    // Check the actions' statuses
    int numPrep = 0;
    int numOK = 0;
    for (WorkflowAction action : wf.getActions()) {
        boolean checked = false;
        for (String name : prepActions) {
            if (!checked && name.equals(action.getName())) {
                assertEquals("action [" + action.getName() + "] had incorrect status", WorkflowAction.Status.PREP, action.getStatus());
                numPrep++;
                checked = true;
            }
        }
        if (!checked) {
            for (String name : okActions) {
                if (!checked && name.equals(action.getName())) {
                    assertEquals("action [" + action.getName() + "] had incorrect status", WorkflowAction.Status.OK, action.getStatus());
                    numOK++;
                    checked = true;
                }
            }
        }
        if (!checked) {
            fail("Unexpected action [" + action.getName() + "] with status [" + action.getStatus() + "]");
        }
    }
    assertEquals(prepActions.length, numPrep);
    assertEquals(okActions.length, numOK);
}
Also used : WorkflowAction(org.apache.oozie.client.WorkflowAction) WorkflowJob(org.apache.oozie.client.WorkflowJob)

Aggregations

WorkflowAction (org.apache.oozie.client.WorkflowAction)41 FileSystem (org.apache.hadoop.fs.FileSystem)9 Path (org.apache.hadoop.fs.Path)8 IOException (java.io.IOException)6 ActionExecutorException (org.apache.oozie.action.ActionExecutorException)6 WorkflowJob (org.apache.oozie.client.WorkflowJob)6 Writer (java.io.Writer)5 Properties (java.util.Properties)5 OozieClient (org.apache.oozie.client.OozieClient)5 XConfiguration (org.apache.oozie.util.XConfiguration)5 OutputStreamWriter (java.io.OutputStreamWriter)4 Configuration (org.apache.hadoop.conf.Configuration)3 Element (org.jdom.Element)3 File (java.io.File)2 Reader (java.io.Reader)2 StringReader (java.io.StringReader)2 URISyntaxException (java.net.URISyntaxException)2 AccessControlException (org.apache.hadoop.security.AccessControlException)2 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)2 HadoopAccessorException (org.apache.oozie.service.HadoopAccessorException)2