use of org.apache.oozie.client.CoordinatorJob in project oozie by apache.
the class TestOozieCLIMethods method createBundleJob.
private static BundleJob createBundleJob(DataObject dtObject) {
BundleJob bundleJobMock = mock(BundleJob.class);
when(bundleJobMock.getId()).thenReturn(dtObject.deamonName);
when(bundleJobMock.getAppName()).thenReturn(dtObject.appName);
when(bundleJobMock.getAppPath()).thenReturn(dtObject.appPath);
when(bundleJobMock.getStatus()).thenReturn(org.apache.oozie.client.Job.Status.RUNNING);
CoordinatorJob coordinatorJobMock = createCoordinatorJob(dtObject);
when(bundleJobMock.getCoordinators()).thenReturn(ImmutableList.of(coordinatorJobMock));
return bundleJobMock;
}
use of org.apache.oozie.client.CoordinatorJob in project oozie by apache.
the class TestOozieCLIMethods method testValidatePrintCoordJobsOutput.
/**
* Create {@code CoordinatorJob} mock,
* call {@code new OozieCLI().printCoordJobs() }
* 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 testValidatePrintCoordJobsOutput() throws IOException {
final DataObject dtObject1 = new DataObject() {
{
this.deamonName = "testCoordJob1";
this.appName = "testCoordinatorJobApp1";
this.appPath = "testCoordinatorJobAppPath1";
}
};
final DataObject dtObject2 = new DataObject() {
{
this.deamonName = "testCoordJob2";
this.appName = "testCoordinatorJobApp2";
this.appPath = "testCoordinatorJobAppPath2";
}
};
final ImmutableList<CoordinatorJob> coordJobs = ImmutableList.of(createCoordinatorJob(dtObject1), createCoordinatorJob(dtObject2));
Pattern pattern = Pattern.compile(dtObject1.deamonName + "[\\s]+" + dtObject1.appName + "[\\s]+" + dtObject1.appPath);
assertPrintCoordJobsOutput(readCoordJobsOutput(coordJobs, true), pattern);
pattern = Pattern.compile(dtObject1.deamonName + "[\\s]+" + dtObject1.appName);
assertPrintCoordJobsOutput(readCoordJobsOutput(coordJobs, false), pattern);
}
use of org.apache.oozie.client.CoordinatorJob 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;
}
use of org.apache.oozie.client.CoordinatorJob in project oozie by apache.
the class TestJsonToBean method testParseCoordinatorJob.
@SuppressWarnings("unchecked")
public void testParseCoordinatorJob() {
JSONObject json = createJsonCoordinatorJob();
CoordinatorJob job = JsonToBean.createCoordinatorJob(json);
assertEquals("a", job.getAppPath());
assertEquals("b", job.getAppName());
assertEquals("c", job.getId());
assertEquals("d", job.getConf());
assertEquals(CoordinatorJob.Status.RUNNING, job.getStatus());
assertEquals(CoordinatorJob.Execution.FIFO, job.getExecutionOrder());
assertEquals("1", job.getFrequency());
assertEquals(CoordinatorJob.Timeunit.DAY, job.getTimeUnit());
assertEquals("e", job.getTimeZone());
assertEquals(2, job.getConcurrency());
assertEquals(3, job.getTimeout());
assertEquals(JsonUtils.parseDateRfc822(LAST_ACTION), job.getLastActionTime());
assertEquals(JsonUtils.parseDateRfc822(NEXT_MATERIALIZED), job.getNextMaterializedTime());
assertEquals(JsonUtils.parseDateRfc822(CREATED_TIME), job.getCreatedTime());
assertEquals(JsonUtils.parseDateRfc822(START_TIME), job.getStartTime());
assertEquals(JsonUtils.parseDateRfc822(END_TIME), job.getEndTime());
assertEquals(JsonUtils.parseDateRfc822(PAUSE_TIME), job.getPauseTime());
assertEquals("f", job.getUser());
assertEquals("g", job.getGroup());
assertEquals("h", job.getConsoleUrl());
assertEquals(2, job.getActions().size());
assertEquals("ca1", job.getActions().get(0).getId());
assertEquals("ca2", job.getActions().get(1).getId());
// Test backward compatibility with 3.x. 3.x will not be forward compatible with 4.x though.
// i.e 4.1 client can be used with 3.x server. But 3.x client cannot be used with 4.x server.
// Frequency was a int in 3.x but was changed to String in 4.x for cron support
json.put(JsonTags.COORDINATOR_JOB_FREQUENCY, 1L);
CoordinatorJob oozie3xjob = JsonToBean.createCoordinatorJob(json);
assertEquals("1", oozie3xjob.getFrequency());
}
use of org.apache.oozie.client.CoordinatorJob in project oozie by apache.
the class TestJsonToBean method testParseCoordinatorJobs.
@SuppressWarnings("unchecked")
public void testParseCoordinatorJobs() {
JSONArray array = createJsonCoordinatorJobList();
List<CoordinatorJob> list = JsonToBean.createCoordinatorJobList(array);
assertEquals(2, list.size());
assertEquals("cj1", list.get(0).getId());
assertEquals("cj2", list.get(1).getId());
}
Aggregations