@Test public void testEscalate() throws Exception { MockInterface iface = m_network.getInterface(1, "192.168.1.1"); Date now = new Date(); anticipateNotificationsForGroup("interface 192.168.1.1 down.", "All services are down on interface 192.168.1.1, dot1 interface alias.", "InitialGroup", now, 0); long endTime = anticipateNotificationsForGroup("interface 192.168.1.1 down.", "All services are down on interface 192.168.1.1, dot1 interface alias.", "EscalationGroup", now.getTime()+2500, 0); m_eventMgr.sendEventToListeners(iface.createDownEvent(now)); verifyAnticipated(endTime, 3000); }
Event event = iface.createDownEvent(downDate); m_eventMgr.sendEventToListeners(event);
@Test public void testRebuildParameterMap() throws Exception { MockInterface iface = m_network.getInterface(1, "192.168.1.1"); Date downDate = new Date(); anticipateNotificationsForGroup("interface 192.168.1.1 down.", "All services are down on interface 192.168.1.1", "InitialGroup", downDate, 0); //bring node down now Event event = iface.createDownEvent(downDate); m_eventMgr.sendEventToListeners(event); sleep(1000); Collection<Integer> notifIds = m_db.findNoticesForEvent(event); Notification[] notification = m_notificationManager.getNotifForEvent(event); int index = 0; for (Integer notifId : notifIds) { Map<String, String> originalMap = m_eventProcessor.buildParameterMap(notification[index], event, notifId.intValue()); Map<String, String> resolutionMap = new HashMap<String, String>(originalMap); resolutionMap.put(NotificationManager.PARAM_SUBJECT, "RESOLVED: "+resolutionMap.get(NotificationManager.PARAM_SUBJECT)); resolutionMap.put(NotificationManager.PARAM_TEXT_MSG, "RESOLVED: "+resolutionMap.get(NotificationManager.PARAM_TEXT_MSG)); resolutionMap.put(NotificationManager.PARAM_NUM_MSG, "RESOLVED: "+resolutionMap.get(NotificationManager.PARAM_NUM_MSG)); Map<String, String> rebuiltMap = m_notifd.getBroadcastEventProcessor().rebuildParameterMap(notifId.intValue(), "RESOLVED: ", m_notifd.getConfigManager().getConfiguration().getNumericSkipResolutionPrefix()); assertEquals(resolutionMap, rebuiltMap); index++; } }
@Test public void testManualAcknowledge2() throws Exception { MockInterface iface = m_network.getInterface(1, "192.168.1.1"); Date downDate = new Date(); long finishedDowns = anticipateNotificationsForGroup("interface 192.168.1.1 down.", "All services are down on interface 192.168.1.1, dot1 interface alias.", "InitialGroup", downDate, 0); //bring node down now Event event = iface.createDownEvent(downDate); m_eventMgr.sendEventToListeners(event); sleep(1000); m_db.acknowledgeNoticesForEvent(event); sleep(5000); verifyAnticipated(finishedDowns, 1000); }
@Test public void testAutoAcknowledge2() throws Exception { MockInterface iface = m_network.getInterface(1, "192.168.1.1"); Date downDate = new Date(); anticipateNotificationsForGroup("interface 192.168.1.1 down.", "All services are down on interface 192.168.1.1, dot1 interface alias.", "InitialGroup", downDate, 0); //bring node down now Event event = iface.createDownEvent(downDate); m_eventMgr.sendEventToListeners(event); sleep(1000); Date date = new Date(); Event upEvent = iface.createUpEvent(date); anticipateNotificationsForGroup("RESOLVED: interface 192.168.1.1 down.", "RESOLVED: All services are down on interface 192.168.1.1, dot1 interface alias.", "InitialGroup", date, 0); long endTime = anticipateNotificationsForGroup("interface 192.168.1.1 up.", "The interface which was previously down is now up.", "UpGroup", date, 0); m_eventMgr.sendEventToListeners(upEvent); verifyAnticipated(endTime, 1000, 5000); }
/** * see http://bugzilla.opennms.org/cgi-bin/bugzilla/show_bug.cgi?id=731 * @throws Exception */ @Test public void testBug731() throws Exception { MockInterface iface = m_network.getInterface(1, "192.168.1.1"); Date downDate = new Date(); anticipateNotificationsForGroup("interface 192.168.1.1 down.", "All services are down on interface 192.168.1.1, dot1 interface alias.", "InitialGroup", downDate, 0); //bring node down now Event event = iface.createDownEvent(downDate); m_eventMgr.sendEventToListeners(event); sleep(1000); Date date = new Date(); Event upEvent = iface.createUpEvent(date); anticipateNotificationsForGroup("RESOLVED: interface 192.168.1.1 down.", "RESOLVED: All services are down on interface 192.168.1.1, dot1 interface alias.", "InitialGroup", date, 0); long endTime = anticipateNotificationsForGroup("interface 192.168.1.1 up.", "The interface which was previously down is now up.", "UpGroup", date, 0); m_eventMgr.sendEventToListeners(upEvent); verifyAnticipated(endTime, 1000, 5000); }
@Test public void testLoadInterfaceWithMissingOutage() throws Exception { // create an outage for only the SMTP svc but with an if down event mDot4.bringDown(); Event ifDownEvent = mDot4.createDownEvent(); m_db.writeEvent(ifDownEvent); m_db.createOutage(mDot4Smtp, ifDownEvent); // recreate the pollable network from the database m_network = createPollableNetwork(m_db, m_scheduler, m_pollerConfig, m_pollerConfig, m_pollContext); assignPollableMembers(m_network); resetAnticipated(); assertElementHasCause(pDot4Smtp, ifDownEvent); assertElementHasCause(pDot4, ifDownEvent); // see if cause is pushed down to service without outage assertElementHasCause(pDot4Http, ifDownEvent); assertDown(pDot4Smtp); assertDown(pDot4Http); anticipateUp(mDot4); mDot4.bringUp(); pDot4Http.doPoll(); m_network.processStatusChange(new Date()); verifyAnticipated(); }