use of org.apache.oozie.command.wf.SubmitXCommand in project oozie by apache.
the class TestSLAEventGeneration method _testWorkflowJobSubmitStart.
private void _testWorkflowJobSubmitStart(Configuration conf, SLAService slas, boolean isNew) throws Exception {
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);
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());
// testing creation of new sla registration via Submit command
SubmitXCommand sc = new SubmitXCommand(conf);
String jobId = sc.call();
SLACalcStatus slaEvent = slas.getSLACalculator().get(jobId);
assertEquals(jobId, slaEvent.getId());
assertEquals("test-wf-job-sla", slaEvent.getAppName());
assertEquals(AppType.WORKFLOW_JOB, slaEvent.getAppType());
assertEquals(nominalTime, DateUtils.formatDateOozieTZ(slaEvent.getNominalTime()));
assertEquals(expectedStart, DateUtils.formatDateOozieTZ(slaEvent.getExpectedStart()));
assertEquals(expectedEnd, DateUtils.formatDateOozieTZ(slaEvent.getExpectedEnd()));
if (isNew) {
assertEquals(30 * 60 * 1000, slaEvent.getExpectedDuration());
assertEquals(alert_events, slaEvent.getAlertEvents());
}
slas.runSLAWorker();
slaEvent = skipToSLAEvent();
assertEquals(SLAStatus.NOT_STARTED, slaEvent.getSLAStatus());
assertEquals(EventStatus.START_MISS, slaEvent.getEventStatus());
// test that sla processes the Job Event from Start command
new StartXCommand(jobId).call();
slaEvent = slas.getSLACalculator().get(jobId);
// resetting to receive sla events
slaEvent.setEventProcessed(0);
SLASummaryBean suBean = new SLASummaryBean();
suBean.setId(jobId);
suBean.setEventProcessed(0);
SLASummaryQueryExecutor.getInstance().executeUpdate(SLASummaryQuery.UPDATE_SLA_SUMMARY_EVENTPROCESSED, suBean);
waitForEventGeneration(200);
ehs.new EventWorker().run();
waitForEventGeneration(300);
slaEvent = skipToSLAEvent();
assertEquals(jobId, slaEvent.getId());
assertNotNull(slaEvent.getActualStart());
assertEquals(SLAStatus.IN_PROCESS, slaEvent.getSLAStatus());
assertEquals(WorkflowJob.Status.RUNNING.name(), slaEvent.getJobStatus());
ehs.getEventQueue().clear();
}
use of org.apache.oozie.command.wf.SubmitXCommand in project oozie by apache.
the class TestSLAEventGeneration method _testWorkflowJobKillCommand.
private void _testWorkflowJobKillCommand(Configuration conf, SLAService slas) throws Exception {
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);
// test that sla processes the Job Event from Kill command
// submit new job
String jobId = new SubmitXCommand(conf).call();
new KillXCommand(jobId).call();
// wait for wf-action kill event to generate
waitForEventGeneration(200);
ehs.new EventWorker().run();
// time for listeners to run
waitForEventGeneration(300);
SLACalcStatus slaEvent = skipToSLAEvent();
assertEquals(jobId, slaEvent.getId());
assertNotNull(slaEvent.getActualEnd());
assertEquals(EventStatus.END_MISS, slaEvent.getEventStatus());
assertEquals(SLAStatus.MISS, slaEvent.getSLAStatus());
assertEquals(WorkflowJob.Status.KILLED.name(), slaEvent.getJobStatus());
}
Aggregations