/** * <p>getService</p> * * @param nodeid a int. * @param ipAddr a {@link java.lang.String} object. * @param svcName a {@link java.lang.String} object. * @return a {@link org.opennms.netmgt.mock.MockService} object. */ public MockService getService(int nodeid, String ipAddr, String svcName) { final MockInterface iface = getInterface(nodeid, ipAddr); LOG.debug("getService({}, {}, {}) = {}", nodeid, ipAddr, svcName, iface); return (iface == null ? null : iface.getService(svcName)); }
/** * <p>addService</p> * * @param nodeId a int. * @param ipAddr a {@link java.lang.String} object. * @param svcName a {@link java.lang.String} object. * @return a {@link org.opennms.netmgt.mock.MockService} object. */ public MockService addService(int nodeId, String ipAddr, String svcName) { int serviceId = getServiceId(svcName); m_currentService = getInterface(nodeId, ipAddr).addService(svcName, serviceId); return m_currentService; }
@Test public void testInterfaceDeleted() { MockInterface iface = m_network.getInterface(1, "192.168.1.1"); testElementDeleted(iface); }
@Test public void testInterfaceOutagesClosedOnDelete() { MockInterface element = m_network.getInterface(1, "192.168.1.1"); testOutagesClosedOnDelete(element); }
@Test public void testInterfaceDeleted() { MockInterface iface = m_network.getInterface(1, "192.168.1.1"); testElementDeleted(iface); }
@Test public void testInterfaceOutagesClosedOnDelete() { MockInterface element = m_network.getInterface(1, "192.168.1.1"); testOutagesClosedOnDelete(element); }
@Test public void testInterfaceDownUp() { testElementDownUp(m_network.getInterface(1, "192.168.1.1")); }
@Test public void testInterfaceDownUp() { testElementDownUp(m_network.getInterface(1, "192.168.1.1")); }
@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); }
public void testEventProcessing() { testEventProcessing(m_network.getService(2, "192.168.1.3", "ICMP")); testEventProcessing(m_network.getNode(2)); testEventProcessing(m_network.getInterface(1, "192.168.1.2")); }
@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); }
public void testCreateInterfaces() { MockNode router = m_network.getNode(1); MockInterface iface = m_network.getInterface(1, "192.168.1.1"); assertEquals("192.168.1.1", iface.getIpAddr()); assertEquals(router, iface.getNode()); MockInterface iface2 = m_network.getInterface(1, "192.168.1.2"); assertEquals("192.168.1.2", iface2.getIpAddr()); assertEquals(router, iface2.getNode()); MockNode server = m_network.getNode(2); MockInterface iface3 = m_network.getInterface(2, "192.168.1.3"); assertEquals(server.getNodeId(), iface3.getNode().getNodeId()); assertEquals(server, iface3.getNode()); MockNode ipv6 = m_network.getNode(3); MockInterface iface4 = m_network.getInterface(3, "fe80:0000:0000:0000:0000:0000:0000:00ff"); assertEquals(ipv6.getNodeId(), iface4.getNode().getNodeId()); assertEquals(ipv6, iface4.getNode()); }
@Test public void testDontPollDuringScheduledOutages() { long start = System.currentTimeMillis(); MockInterface iface = m_network.getInterface(1, "192.168.1.2"); m_pollerConfig.addScheduledOutage(m_pollerConfig.getPackage("TestPackage"), "TestOutage", start, start + 5000, iface.getIpAddr()); MockUtil.println("Begin Outage"); startDaemons(); long now = System.currentTimeMillis(); sleep(3000 - (now - start)); MockUtil.println("End Outage"); assertEquals(0, iface.getPollCount()); sleep(5000); assertTrue(0 < iface.getPollCount()); }
@Test public void testDontPollDuringScheduledOutages() { long start = System.currentTimeMillis(); MockInterface iface = m_network.getInterface(1, "192.168.1.2"); m_pollerConfig.addScheduledOutage(m_pollerConfig.getPackage("TestPackage"), "TestOutage", start, start + 5000, iface.getIpAddr()); MockUtil.println("Begin Outage"); startDaemons(); long now = System.currentTimeMillis(); sleep(3000 - (now - start)); MockUtil.println("End Outage"); assertEquals(0, iface.getPollCount()); sleep(5000); assertTrue(0 < iface.getPollCount()); }
public void testCreateServices() { MockInterface rtrIface = m_network.getInterface(1, "192.168.1.2"); MockInterface svrIface = m_network.getInterface(2, "192.168.1.3"); MockService icmpSvc = m_network.getService(1, "192.168.1.2", "ICMP"); MockService icmpSvc2 = m_network.getService(1, "192.168.1.1", "ICMP"); MockService httpSvc = m_network.getService(2, "192.168.1.3", "HTTP"); assertEquals("ICMP", icmpSvc.getSvcName()); assertEquals(rtrIface, icmpSvc.getInterface()); assertEquals("HTTP", httpSvc.getSvcName()); assertEquals(svrIface, httpSvc.getInterface()); assertTrue(icmpSvc.getSvcId() == icmpSvc2.getSvcId()); assertFalse(icmpSvc.getSvcId() == httpSvc.getSvcId()); }
public void testSetPollStatus() throws Exception { // service poll status testServicePoll(m_network.getService(1, "192.168.1.1", "SMTP")); testServicePoll(m_network.getService(1, "192.168.1.1", "ICMP")); testServicePoll(m_network.getService(1, "192.168.1.2", "SMTP")); testServicePoll(m_network.getService(2, "192.168.1.3", "HTTP")); // interface poll status testServicePoll(m_network.getInterface(1, "192.168.1.1")); // node poll status testServicePoll(m_network.getNode(2)); }
@Test public void testInterfaceWithNoCriticalService() { m_pollerConfig.setNodeOutageProcessingEnabled(true); MockInterface iface = m_network.getInterface(3, "192.168.1.4"); MockService svc = iface.getService("SMTP"); MockService otherService = iface.getService("HTTP"); startDaemons(); anticipateDown(iface); iface.bringDown(); verifyAnticipated(8000); anticipateUp(iface); anticipateDown(otherService, true); svc.bringUp(); verifyAnticipated(8000); }
@Test public void testInterfaceWithNoCriticalService() { m_pollerConfig.setNodeOutageProcessingEnabled(true); MockInterface iface = m_network.getInterface(3, "192.168.1.4"); MockService svc = iface.getService("SMTP"); MockService otherService = iface.getService("HTTP"); startDaemons(); anticipateDown(iface); iface.bringDown(); verifyAnticipated(8000); anticipateUp(iface); anticipateDown(otherService, true); svc.bringUp(); verifyAnticipated(8000); }
public void testPollStatus() { MockNode node = m_network.getNode(1); MockInterface iface = m_network.getInterface(1, "192.168.1.2"); assertEquals(PollStatus.up(), node.getPollStatus()); assertEquals(PollStatus.up(), iface.getPollStatus()); node.bringDown(); assertEquals(PollStatus.down(), node.getPollStatus()); assertEquals(PollStatus.down(), iface.getPollStatus()); iface.bringUp(); assertEquals(PollStatus.up(), node.getPollStatus()); assertEquals(PollStatus.up(), iface.getPollStatus()); node.bringUp(); assertEquals(PollStatus.up(), node.getPollStatus()); assertEquals(PollStatus.up(), iface.getPollStatus()); }