Search in sources :

Example 36 with SLARegistrationBean

use of org.apache.oozie.sla.SLARegistrationBean in project oozie by apache.

the class TestSLAEmailEventListener method testInvalidDestAddress.

public void testInvalidDestAddress() throws Exception {
    String id = "0000000-000000000000001-oozie-wrkf-C@1";
    SLACalcStatus event = _createSLACalcStatus(id);
    SLARegistrationBean eventBean = event.getSLARegistrationBean();
    Date startDate = DateUtils.parseDateUTC("2013-01-01T00:00Z");
    // set invalid address as alert contact
    eventBean.setAlertContact("invalidAddress");
    event.setEventStatus(EventStatus.START_MISS);
    event.setId(id);
    eventBean.setAppType(AppType.COORDINATOR_ACTION);
    eventBean.setAppName("Test-SLA-Start-Miss");
    eventBean.setUser("dummyuser");
    eventBean.setExpectedStart(startDate);
    eventBean.setNotificationMsg("notification of start miss");
    eventBean.setAppType(AppType.COORDINATOR_ACTION);
    event.setActualStart(DateUtils.parseDateUTC("2013-01-01T01:00Z"));
    slaEmailListener.onStartMiss(event);
    MimeMessage[] msgs = greenMail.getReceivedMessages();
    assertEquals(msgs.length, 0);
}
Also used : SLARegistrationBean(org.apache.oozie.sla.SLARegistrationBean) SLACalcStatus(org.apache.oozie.sla.SLACalcStatus) MimeMessage(javax.mail.internet.MimeMessage) Date(java.util.Date)

Example 37 with SLARegistrationBean

use of org.apache.oozie.sla.SLARegistrationBean in project oozie by apache.

the class TestSLAEmailEventListener method testMultipleDestAddress.

public void testMultipleDestAddress() throws Exception {
    String id = "0000000-000000000000001-oozie-wrkf-C@1";
    SLACalcStatus event = _createSLACalcStatus(id);
    SLARegistrationBean eventBean = event.getSLARegistrationBean();
    Date startDate = DateUtils.parseDateUTC("2013-01-01T00:00Z");
    // set multiple addresses as alert contact
    eventBean.setAlertContact("alert-receiver1@oozie.com, alert-receiver2@oozie.com");
    event.setEventStatus(EventStatus.START_MISS);
    event.setId(id);
    eventBean.setAppType(AppType.COORDINATOR_ACTION);
    eventBean.setAppName("Test-SLA-Start-Miss");
    eventBean.setUser("dummyuser");
    eventBean.setExpectedStart(startDate);
    eventBean.setNotificationMsg("notification of start miss");
    eventBean.setAppType(AppType.COORDINATOR_ACTION);
    event.setActualStart(DateUtils.parseDateUTC("2013-01-01T01:00Z"));
    slaEmailListener.onStartMiss(event);
    MimeMessage[] msgs = greenMail.getReceivedMessages();
    MimeMessage msg = msgs[0];
    assertEquals(msg.getFrom()[0].toString(), "oozie@localhost");
    assertEquals(msg.getRecipients(RecipientType.TO)[0].toString(), "alert-receiver1@oozie.com");
    assertEquals(msg.getRecipients(RecipientType.TO)[1].toString(), "alert-receiver2@oozie.com");
}
Also used : SLARegistrationBean(org.apache.oozie.sla.SLARegistrationBean) SLACalcStatus(org.apache.oozie.sla.SLACalcStatus) MimeMessage(javax.mail.internet.MimeMessage) Date(java.util.Date)

Example 38 with SLARegistrationBean

use of org.apache.oozie.sla.SLARegistrationBean in project oozie by apache.

the class TestSLARegistrationGetJPAExecutor method testSLARegistrationGet.

public void testSLARegistrationGet() throws Exception {
    Date current = new Date();
    final String jobId = "0000000-" + current.getTime() + "-TestSLARegGetJPAExecutor-W";
    _addRecordToSLARegistrationTable(jobId, AppType.WORKFLOW_JOB, current, new Date(), "END_MISS", "alert@example.com");
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    SLARegistrationBean bean = SLARegistrationQueryExecutor.getInstance().get(SLARegQuery.GET_SLA_REG_ALL, jobId);
    assertEquals(jobId, bean.getId());
    assertEquals(AppType.WORKFLOW_JOB, bean.getAppType());
    assertEquals(current, bean.getExpectedStart());
    assertEquals(2, bean.getSLAConfigMap().size());
    assertEquals("END_MISS", bean.getAlertEvents());
    assertEquals("alert@example.com", bean.getAlertContact());
}
Also used : SLARegistrationBean(org.apache.oozie.sla.SLARegistrationBean) JPAService(org.apache.oozie.service.JPAService) Date(java.util.Date)

Aggregations

SLARegistrationBean (org.apache.oozie.sla.SLARegistrationBean)38 Date (java.util.Date)21 SLACalcStatus (org.apache.oozie.sla.SLACalcStatus)18 ArrayList (java.util.ArrayList)8 MessageConsumer (javax.jms.MessageConsumer)8 Session (javax.jms.Session)8 TextMessage (javax.jms.TextMessage)8 MimeMessage (javax.mail.internet.MimeMessage)8 JPAService (org.apache.oozie.service.JPAService)8 SLAMessage (org.apache.oozie.client.event.message.SLAMessage)7 EntityManager (javax.persistence.EntityManager)6 Query (javax.persistence.Query)6 SLASummaryBean (org.apache.oozie.sla.SLASummaryBean)6 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)5 JsonBean (org.apache.oozie.client.rest.JsonBean)5 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)4 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)4 Test (org.junit.Test)4 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)3 SLARegQuery (org.apache.oozie.executor.jpa.SLARegistrationQueryExecutor.SLARegQuery)3