use of org.apache.oozie.command.coord.CoordActionStartXCommand in project oozie by apache.
the class TestSLAEventGeneration method testCoordinatorActionCommandsSubmitAndStart.
/**
* Test for SLA Events generated through Coordinator Action commands
* CoordSubmitX and CoordStartX
*
* @throws Exception
*/
@Test
public void testCoordinatorActionCommandsSubmitAndStart() throws Exception {
// reduce noise from WF Job events (also default) by setting it to only
// coord action
ehs.setAppTypes(new HashSet<String>(Arrays.asList(new String[] { "coordinator_action" })));
ehs.getEventQueue().clear();
SLAService slas = services.get(SLAService.class);
String coordXml = IOUtils.getResourceAsString("coord-action-sla.xml", -1);
Path appPath = getFsTestCaseDir();
writeToFile(coordXml, appPath, "coordinator.xml");
Configuration conf = new XConfiguration();
conf.set(OozieClient.COORDINATOR_APP_PATH, appPath.toString());
String wfXml = IOUtils.getResourceAsString("wf-credentials.xml", -1);
writeToFile(wfXml, appPath, "workflow.xml");
conf.set("wfAppPath", appPath.toString());
conf.set(OozieClient.USER_NAME, getTestUser());
cal.setTime(new Date());
// for start_miss
cal.add(Calendar.MINUTE, -20);
Date nominal = cal.getTime();
String nominalTime = DateUtils.formatDateOozieTZ(nominal);
conf.set("nominal_time", nominalTime);
conf.set("start", "2009-01-02T08:01Z");
conf.set("frequency", "coord:days(1)");
conf.set("end", "2009-01-03T08:00Z");
cal.setTime(nominal);
// as per the sla xml
cal.add(Calendar.MINUTE, 10);
String expectedStart = DateUtils.formatDateOozieTZ(cal.getTime());
cal.setTime(nominal);
// as per the sla xml
cal.add(Calendar.MINUTE, 30);
String expectedEnd = DateUtils.formatDateOozieTZ(cal.getTime());
String appName = "test-coord-sla";
// testing creation of new sla registration via Submit + Materialize
// command
String jobId = new CoordSubmitXCommand(conf).call();
// waiting for materialize command to run
Thread.sleep(500);
final CoordActionGetJPAExecutor getCmd = new CoordActionGetJPAExecutor(jobId + "@1");
CoordinatorActionBean action = jpa.execute(getCmd);
String actionId = action.getId();
SLACalcStatus slaEvent = slas.getSLACalculator().get(actionId);
assertEquals(actionId, slaEvent.getId());
assertEquals(appName, slaEvent.getAppName());
assertEquals(AppType.COORDINATOR_ACTION, slaEvent.getAppType());
assertEquals(nominalTime, DateUtils.formatDateOozieTZ(slaEvent.getNominalTime()));
assertEquals(expectedStart, DateUtils.formatDateOozieTZ(slaEvent.getExpectedStart()));
assertEquals(expectedEnd, DateUtils.formatDateOozieTZ(slaEvent.getExpectedEnd()));
assertEquals(30 * 60 * 1000, slaEvent.getExpectedDuration());
assertEquals(alert_events, slaEvent.getAlertEvents());
slas.runSLAWorker();
slaEvent = skipToSLAEvent();
assertTrue(SLAStatus.NOT_STARTED == slaEvent.getSLAStatus());
assertEquals(EventStatus.START_MISS, slaEvent.getEventStatus());
// test that sla processes the Job Event from Start command
ehs.getEventQueue().clear();
action.setStatus(CoordinatorAction.Status.SUBMITTED);
CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQuery.UPDATE_COORD_ACTION_STATUS_PENDING_TIME, action);
new CoordActionStartXCommand(actionId, getTestUser(), appName, jobId).call();
slaEvent = slas.getSLACalculator().get(actionId);
// resetting for testing sla event
slaEvent.setEventProcessed(0);
SLASummaryBean suBean = new SLASummaryBean();
suBean.setId(actionId);
suBean.setEventProcessed(0);
SLASummaryQueryExecutor.getInstance().executeUpdate(SLASummaryQuery.UPDATE_SLA_SUMMARY_EVENTPROCESSED, suBean);
ehs.new EventWorker().run();
slaEvent = skipToSLAEvent();
assertEquals(actionId, slaEvent.getId());
assertNotNull(slaEvent.getActualStart());
assertEquals(SLAStatus.IN_PROCESS, slaEvent.getSLAStatus());
assertEquals(CoordinatorAction.Status.RUNNING.name(), slaEvent.getJobStatus());
}
use of org.apache.oozie.command.coord.CoordActionStartXCommand in project oozie by apache.
the class TestReRunXCommand method testRerunDisableForChild.
/**
* Rerun workflow should run by parent only if configuration has been set to
* true for oozie.wf.child.disable.rerun , Default it is disabled.
* @throws Exception
*/
public void testRerunDisableForChild() throws Exception {
final OozieClient wfClient = LocalOozie.getClient();
Date start = DateUtils.parseDateOozieTZ("2009-12-15T01:00Z");
Date end = DateUtils.parseDateOozieTZ("2009-12-16T01:00Z");
CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, false, false, 1);
CoordinatorActionBean action = addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.SUBMITTED, "coord-action-start-escape-strings.xml", 0);
String actionId = action.getId();
new CoordActionStartXCommand(actionId, getTestUser(), "myapp", "myjob").call();
final JPAService jpaService = Services.get().get(JPAService.class);
action = jpaService.execute(new CoordActionGetJPAExecutor(actionId));
if (action.getStatus() == CoordinatorAction.Status.SUBMITTED) {
fail("CoordActionStartCommand didn't work because the status for action id" + actionId + " is :" + action.getStatus() + " expected to be NOT SUBMITTED (i.e. RUNNING)");
}
final String wfId = action.getExternalId();
wfClient.kill(wfId);
waitFor(15 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
return wfClient.getJobInfo(wfId).getStatus() == WorkflowJob.Status.KILLED;
}
});
Properties newConf = wfClient.createConfiguration();
newConf.setProperty(OozieClient.RERUN_FAIL_NODES, "true");
Services.get().getConf().setBoolean(ReRunXCommand.DISABLE_CHILD_RERUN, true);
try {
wfClient.reRun(wfId, newConf);
fail("OozieClientException should have been thrown (" + ErrorCode.E0755 + " Rerun is not allowed through child workflow, please re-run through the parent)");
} catch (OozieClientException ex) {
assertEquals(ErrorCode.E0755.toString(), ex.getErrorCode());
}
Services.get().getConf().setBoolean(ReRunXCommand.DISABLE_CHILD_RERUN, false);
wfClient.reRun(wfId, newConf);
waitFor(15 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
return wfClient.getJobInfo(wfId).getStatus() == WorkflowJob.Status.SUCCEEDED;
}
});
assertEquals(WorkflowJob.Status.SUCCEEDED, wfClient.getJobInfo(wfId).getStatus());
}
use of org.apache.oozie.command.coord.CoordActionStartXCommand in project oozie by apache.
the class TestCoordInputLogicPush method startCoordAction.
private void startCoordAction(final String jobId) throws CommandException, JPAExecutorException {
new CoordMaterializeTransitionXCommand(jobId, 3600).call();
new CoordActionInputCheckXCommand(jobId + "@1", jobId).call();
new CoordPushDependencyCheckXCommand(jobId + "@1").call();
new CoordActionInputCheckXCommand(jobId + "@1", jobId).call();
waitFor(50 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
CoordinatorActionBean actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
return !actionBean.getStatus().equals(CoordinatorAction.Status.WAITING);
}
});
CoordinatorAction actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
assertFalse("Action status should not be waiting", actionBean.getStatus().equals(CoordinatorAction.Status.WAITING));
waitFor(50 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
CoordinatorActionBean actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
return !actionBean.getStatus().equals(CoordinatorAction.Status.READY);
}
});
CoordinatorJob coordJob = CoordJobQueryExecutor.getInstance().get(CoordJobQuery.GET_COORD_JOB, jobId);
new CoordActionStartXCommand(actionBean.getId(), coordJob.getUser(), coordJob.getAppName(), actionBean.getJobId()).call();
}
use of org.apache.oozie.command.coord.CoordActionStartXCommand in project oozie by apache.
the class TestCoordinatorInputLogic method startCoordAction.
private void startCoordAction(final String jobId, final CoordinatorAction.Status coordActionStatus) throws CommandException, JPAExecutorException {
new CoordMaterializeTransitionXCommand(jobId, 3600).call();
new CoordActionInputCheckXCommand(jobId + "@1", jobId).call();
waitFor(50 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
CoordinatorActionBean actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
return !actionBean.getStatus().equals(CoordinatorAction.Status.WAITING);
}
});
CoordinatorAction actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
assertFalse(actionBean.getStatus().equals(coordActionStatus));
CoordinatorJob coordJob = CoordJobQueryExecutor.getInstance().get(CoordJobQuery.GET_COORD_JOB, jobId);
new CoordActionStartXCommand(actionBean.getId(), coordJob.getUser(), coordJob.getAppName(), actionBean.getJobId()).call();
}
use of org.apache.oozie.command.coord.CoordActionStartXCommand in project oozie by apache.
the class TestReRunXCommand method testRerunWithExistingCoodConf.
// rerun should use existing coord conf
public void testRerunWithExistingCoodConf() throws Exception {
final OozieClient wfClient = LocalOozie.getClient();
Date start = DateUtils.parseDateOozieTZ("2009-12-15T01:00Z");
Date end = DateUtils.parseDateOozieTZ("2009-12-16T01:00Z");
CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, false, false, 1);
CoordinatorActionBean action = addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.SUBMITTED, "coord-action-start-escape-strings.xml", 0);
String actionId = action.getId();
new CoordActionStartXCommand(actionId, getTestUser(), "myapp", "myjob").call();
final JPAService jpaService = Services.get().get(JPAService.class);
action = jpaService.execute(new CoordActionGetJPAExecutor(actionId));
if (action.getStatus() == CoordinatorAction.Status.SUBMITTED) {
fail("CoordActionStartCommand didn't work because the status for action id" + actionId + " is :" + action.getStatus() + " expected to be NOT SUBMITTED (i.e. RUNNING)");
}
final String wfId = action.getExternalId();
wfClient.kill(wfId);
waitFor(15 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
return wfClient.getJobInfo(wfId).getStatus() == WorkflowJob.Status.KILLED;
}
});
Properties newConf = wfClient.createConfiguration();
newConf.setProperty(OozieClient.RERUN_FAIL_NODES, "true");
wfClient.reRun(wfId, newConf);
waitFor(15 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
return wfClient.getJobInfo(wfId).getStatus() == WorkflowJob.Status.SUCCEEDED;
}
});
assertEquals(WorkflowJob.Status.SUCCEEDED, wfClient.getJobInfo(wfId).getStatus());
}
Aggregations