use of org.apache.oozie.SLAEventBean in project oozie by apache.
the class TestSLAEventsGetForFilterJPAExecutor method testGetSLAEventsForCoordActionId.
public void testGetSLAEventsForCoordActionId() throws Exception {
Map<String, List<String>> filterListAction1 = createFilterList("jobid", coordActionId1);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
// Use -1 instead of 0 because HSQLDB starts the event_id generator at 0 instead of 1
SLAEventsGetForFilterJPAExecutor slaEventsGetCmd = new SLAEventsGetForFilterJPAExecutor(-1, 100, filterListAction1, new long[1]);
List<SLAEventBean> list = jpaService.execute(slaEventsGetCmd);
assertNotNull(list);
assertEquals(3, list.size());
}
use of org.apache.oozie.SLAEventBean in project oozie by apache.
the class TestSLAEventsGetForSeqIdJPAExecutor method _testGetSLAEventsForSeqId.
private void _testGetSLAEventsForSeqId(String jobId, Date current) throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
SLAEventsGetJPAExecutor slaEventsGetAllCmd = new SLAEventsGetJPAExecutor();
List<SLAEventBean> fullList = jpaService.execute(slaEventsGetAllCmd);
assertNotNull(fullList);
long lastId = fullList.get(0).getEvent_id();
SLAEventsGetForSeqIdJPAExecutor slaEventsGetCmd = new SLAEventsGetForSeqIdJPAExecutor(lastId, 10, new long[1]);
List<SLAEventBean> list = jpaService.execute(slaEventsGetCmd);
assertNotNull(list);
assertEquals(2, list.size());
SLAEventBean seBean = list.get(0);
assertEquals(seBean.getSlaId(), jobId);
assertEquals(seBean.getUser(), getTestUser());
assertEquals(seBean.getGroupName(), getTestGroup());
assertEquals(seBean.getJobStatus(), Status.STARTED);
assertEquals(seBean.getStatusTimestamp().getTime(), current.getTime());
}
use of org.apache.oozie.SLAEventBean in project oozie by apache.
the class TestSLAEventsGetJPAExecutor method _testGetSLAEventsForSeqId.
private void _testGetSLAEventsForSeqId(String jobId) throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
SLAEventsGetJPAExecutor slaEventsGetAllCmd = new SLAEventsGetJPAExecutor();
List<SLAEventBean> list = jpaService.execute(slaEventsGetAllCmd);
assertNotNull(list);
assertEquals(3, list.size());
}
use of org.apache.oozie.SLAEventBean in project oozie by apache.
the class XDataTestCase method addRecordToSLAEventTable.
/**
* Insert sla event for testing.
*
* @param slaId sla id
* @param slaId app name
* @param status sla status
* @throws Exception thrown if unable to create sla bean
*/
@Deprecated
protected void addRecordToSLAEventTable(String slaId, String appName, SLAEvent.Status status, Date today) throws Exception {
SLAEventBean sla = new SLAEventBean();
sla.setSlaId(slaId);
sla.setAppName(appName);
sla.setParentClientId("parent-client-id");
sla.setParentSlaId("parent-sla-id");
sla.setExpectedStart(today);
sla.setExpectedEnd(today);
sla.setNotificationMsg("notification-msg");
sla.setAlertContact("alert-contact");
sla.setDevContact("dev-contact");
sla.setQaContact("qa-contact");
sla.setSeContact("se-contact");
sla.setAlertFrequency("alert-frequency");
sla.setAlertPercentage("alert-percentage");
sla.setUpstreamApps("upstream-apps");
sla.setAppType(SLAEvent.SlaAppType.WORKFLOW_JOB);
sla.setUser(getTestUser());
sla.setGroupName(getTestGroup());
sla.setJobStatus(status);
sla.setStatusTimestamp(today);
try {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
SLAEventInsertJPAExecutor slaInsertCmd = new SLAEventInsertJPAExecutor(sla);
jpaService.execute(slaInsertCmd);
} catch (JPAExecutorException je) {
je.printStackTrace();
fail("Unable to insert the test sla event record to table");
throw je;
}
}
use of org.apache.oozie.SLAEventBean in project oozie by apache.
the class TestSLADbXOperations method testCreateSlaRegistrationEventMinReqFields.
@SuppressWarnings("deprecation")
public void testCreateSlaRegistrationEventMinReqFields() throws Exception {
Date nomDate = DateUtils.parseDateOozieTZ("2014-01-01T01:01Z");
String slaXML = " <sla:info xmlns:sla='uri:oozie:sla:0.2'>" + " <sla:nominal-time>" + DateUtils.formatDateOozieTZ(nomDate) + "</sla:nominal-time>" + " <sla:should-end>5</sla:should-end>" + "</sla:info>";
Element eSla = XmlUtils.parseXml(slaXML);
SLAEventBean regEvent = SLADbXOperations.createSlaRegistrationEvent(eSla, "id1", SLAEvent.SlaAppType.WORKFLOW_JOB, "user1", "group1");
assertEquals(SLAEvent.SlaAppType.WORKFLOW_JOB, regEvent.getAppType());
assertEquals(new Date(nomDate.getTime() + 5 * 60 * 1000), regEvent.getExpectedEnd());
assertEquals("group1", regEvent.getGroupName());
assertEquals("id1", regEvent.getSlaId());
assertEquals("user1", regEvent.getUser());
}
Aggregations