Search in sources :

Example 1 with CoordinatorAction

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

the class TestOozieCLIMethods method createCoordinatorAction.

private static CoordinatorAction createCoordinatorAction(DataObject dtObject) {
    CoordinatorAction crdActionMock = mock(CoordinatorAction.class);
    when(crdActionMock.getId()).thenReturn(dtObject.deamonName);
    when(crdActionMock.getJobId()).thenReturn(dtObject.appName);
    when(crdActionMock.getActionNumber()).thenReturn(11);
    when(crdActionMock.getStatus()).thenReturn(CoordinatorAction.Status.SUBMITTED);
    return crdActionMock;
}
Also used : CoordinatorAction(org.apache.oozie.client.CoordinatorAction)

Example 2 with CoordinatorAction

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

the class TestOozieCLIMethods method createCoordinatorJob.

private static CoordinatorJob createCoordinatorJob(DataObject dtObject) {
    CoordinatorJob coordinatorJobMock = mock(CoordinatorJob.class);
    when(coordinatorJobMock.getId()).thenReturn(dtObject.deamonName);
    when(coordinatorJobMock.getAppName()).thenReturn(dtObject.appName);
    when(coordinatorJobMock.getAppPath()).thenReturn(dtObject.appPath);
    when(coordinatorJobMock.getConcurrency()).thenReturn(15);
    when(coordinatorJobMock.getStatus()).thenReturn(CoordinatorJob.Status.RUNNING);
    when(coordinatorJobMock.getUser()).thenReturn("test");
    when(coordinatorJobMock.getGroup()).thenReturn("test-group");
    ImmutableList.Builder<CoordinatorAction> builder = ImmutableList.builder();
    for (final String id : Arrays.asList("1", "2")) builder.add(createCoordinatorAction(new DataObject() {

        {
            this.deamonName = id;
            this.appName = "testCoordinatorAction";
        }
    }));
    when(coordinatorJobMock.getActions()).thenReturn(builder.build());
    return coordinatorJobMock;
}
Also used : CoordinatorJob(org.apache.oozie.client.CoordinatorJob) ImmutableList(com.google.common.collect.ImmutableList) CoordinatorAction(org.apache.oozie.client.CoordinatorAction)

Example 3 with CoordinatorAction

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

the class TestOozieCLIMethods method testValidateReadPrintCoordActionOutput.

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

        {
            this.deamonName = "testCoordinatorAction";
            this.appName = "testCoordinatorJobApp";
            this.appPath = "testCoordinatorJobAppPath";
        }
    };
    CoordinatorAction coordinatorAction = createCoordinatorAction(dtObject);
    assertPrintCoordActionOutput(readCoordAction(coordinatorAction), dtObject);
}
Also used : CoordinatorAction(org.apache.oozie.client.CoordinatorAction) Test(org.junit.Test)

Example 4 with CoordinatorAction

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

the class TestJsonToBean method testParseCoordinatorActions.

@SuppressWarnings("unchecked")
public void testParseCoordinatorActions() {
    JSONArray array = createJsonCoordinatorActionList();
    List<CoordinatorAction> list = JsonToBean.createCoordinatorActionList(array);
    assertEquals(2, list.size());
    assertEquals("ca1", list.get(0).getId());
    assertEquals("ca2", list.get(1).getId());
}
Also used : JSONArray(org.json.simple.JSONArray) CoordinatorAction(org.apache.oozie.client.CoordinatorAction)

Example 5 with CoordinatorAction

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

the class TestJsonToBean method testParseCoordinatorAction.

@SuppressWarnings("unchecked")
public void testParseCoordinatorAction() {
    JSONObject json = createJsonCoordinatorAction();
    CoordinatorAction action = JsonToBean.createCoordinatorAction(json);
    assertEquals("a", action.getId());
    assertEquals("b", action.getJobId());
    assertEquals(1, action.getActionNumber());
    assertEquals("c", action.getCreatedConf());
    assertEquals(JsonUtils.parseDateRfc822(CREATED_TIME), action.getCreatedTime());
    assertEquals(JsonUtils.parseDateRfc822(NOMINAL_TIME), action.getNominalTime());
    assertEquals("d", action.getExternalId());
    assertEquals(CoordinatorAction.Status.IGNORED, action.getStatus());
    assertEquals("e", action.getRunConf());
    assertEquals(JsonUtils.parseDateRfc822(LAST_MODIFIED), action.getLastModifiedTime());
    assertEquals("f", action.getMissingDependencies());
    assertEquals("ff", action.getPushMissingDependencies());
    assertEquals("g", action.getExternalStatus());
    assertEquals("h", action.getTrackerUri());
    assertEquals("i", action.getConsoleUrl());
    assertEquals("j", action.getErrorCode());
    assertEquals("k", action.getErrorMessage());
}
Also used : JSONObject(org.json.simple.JSONObject) CoordinatorAction(org.apache.oozie.client.CoordinatorAction)

Aggregations

CoordinatorAction (org.apache.oozie.client.CoordinatorAction)28 IOException (java.io.IOException)11 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)11 CoordinatorJob (org.apache.oozie.client.CoordinatorJob)9 XConfiguration (org.apache.oozie.util.XConfiguration)8 Configuration (org.apache.hadoop.conf.Configuration)7 List (java.util.List)6 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)6 CommandException (org.apache.oozie.command.CommandException)6 StoreException (org.apache.oozie.store.StoreException)6 CoordActionInputCheckXCommand (org.apache.oozie.command.coord.CoordActionInputCheckXCommand)4 CoordMaterializeTransitionXCommand (org.apache.oozie.command.coord.CoordMaterializeTransitionXCommand)4 File (java.io.File)3 BundleJob (org.apache.oozie.client.BundleJob)3 JDOMException (org.jdom.JDOMException)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 URI (java.net.URI)2 CoordinatorEngine (org.apache.oozie.CoordinatorEngine)2 BulkResponse (org.apache.oozie.client.BulkResponse)2 OozieClientException (org.apache.oozie.client.OozieClientException)2