dummyCalc.init(Services.get().getConf());
// Case 1 workflow job submitted to dummy server,
// but before start running, the dummy server is down
createWorkflow("job-1");
SLARegistrationBean sla1 = TestSLAService._createSLARegistration("job-1", AppType.WORKFLOW_JOB);
sla1.setExpectedStart(new Date(System.currentTimeMillis() - 2 * 3600 * 1000)); // 2 hr before
sla1.setExpectedEnd(new Date(System.currentTimeMillis() - 1 * 3600 * 1000)); // 1 hr before
sla1.setExpectedDuration(10 * 60 * 1000); // 10 mins
dummyCalc.addRegistration(sla1.getId(), sla1);
// Case 2. workflow job submitted to dummy server, start running,
// then the dummy server is down
createWorkflow("job-2");
SLARegistrationBean sla2 = TestSLAService._createSLARegistration("job-2", AppType.WORKFLOW_JOB);
sla2.setExpectedStart(new Date(System.currentTimeMillis() - 2 * 3600 * 1000)); // 2hr before
sla2.setExpectedEnd(new Date(System.currentTimeMillis() + 1 * 3600 * 1000)); // 1hr ahead
sla2.setExpectedDuration(10 * 60 * 1000); // 10 mins
dummyCalc.addRegistration(sla2.getId(), sla2);
dummyCalc.addJobStatus(sla2.getId(), WorkflowJob.Status.RUNNING.name(), EventStatus.STARTED, new Date(),
new Date());
dummyCalc.updateAllSlaStatus();
dummyEhs.new EventWorker().run();
assertTrue(output.toString().contains(sla2.getId() + " Sla START - MISS!!!"));
// suppose dummy Server is down
dummyCalc.clear();
dummyCalc = null;
dummyOozie_1.teardown();
slaCalcMem.updateAllSlaStatus();
// Job 1 started running on the living server --> start miss
slaCalcMem.addJobStatus(sla1.getId(), WorkflowJob.Status.RUNNING.name(), EventStatus.STARTED, new Date(),
new Date());
// job 1 is added to slamap of living oozie server
assertNotNull(slaCalcMem.get(sla1.getId()));
ehs.new EventWorker().run();
assertTrue(output.toString().contains(sla1.getId() + " Sla START - MISS!!!"));
// Job 1 succeeded on the living server --> duration met and end miss
slaCalcMem.addJobStatus(sla1.getId(), WorkflowJob.Status.SUCCEEDED.name(), EventStatus.SUCCESS, new Date(),
new Date());
ehs.new EventWorker().run();
assertTrue(output.toString().contains(sla1.getId() + " Sla DURATION - MET!!!"));
assertTrue(output.toString().contains(sla1.getId() + " Sla END - MISS!!!"));
// Job 2 succeeded on the living server --> duration met and end met
slaCalcMem.addJobStatus(sla2.getId(), WorkflowJob.Status.SUCCEEDED.name(), EventStatus.SUCCESS, new Date(),
new Date());
// eventProc >= 7(already processed duration/end met), should be removed from slaMap
assertNull(slaCalcMem.get(sla2.getId()));
ehs.new EventWorker().run();
assertTrue(output.toString().contains(sla2.getId() + " Sla DURATION - MET!!!"));
assertTrue(output.toString().contains(sla2.getId() + " Sla END - MET!!!"));
}
finally {
if (dummyOozie_1 != null) {
dummyOozie_1.teardown();
}