@Test public void testInterfaceEvent() throws Exception { anticipateDown(mDot1); mDot1.bringDown(); pDot1Smtp.doPoll(); m_network.processStatusChange(new Date()); verifyAnticipated(); anticipateUp(mDot1); mDot1.bringUp(); pDot1Icmp.doPoll(); m_network.processStatusChange(new Date()); verifyAnticipated(); }
@Test public void testIfOutage() { anticipateDown(mDot1); mDot1.bringDown(); pDot1Smtp.doPoll(); m_network.processStatusChange(new Date()); verifyAnticipated(); anticipateUp(mDot1); mDot1.bringUp(); pDot1Icmp.doPoll(); m_network.processStatusChange(new Date()); verifyAnticipated(); }
@Test public void testLingeringSvcDownOnIfUp() throws Exception { anticipateDown(mDot1); mDot1.bringDown(); pDot1Smtp.doPoll(); m_network.processStatusChange(new Date()); verifyAnticipated(); anticipateUp(mDot1); anticipateDown(mDot1Smtp); mDot1.bringUp(); mDot1Smtp.bringDown(); pDot1Icmp.doPoll(); m_network.processStatusChange(new Date()); verifyAnticipated(); anticipateUp(mDot1Smtp); mDot1Smtp.bringUp(); pDot1Smtp.doPoll(); m_network.processStatusChange(new Date()); verifyAnticipated(); }
@Test public void testCause() { anticipateDown(mDot1Smtp); mDot1Smtp.bringDown(); pDot1Smtp.doPoll(); m_network.processStatusChange(new Date()); verifyAnticipated(); anticipateDown(mDot1); mDot1.bringDown(); pDot1Icmp.doPoll(); m_network.processStatusChange(new Date()); verifyAnticipated(); PollEvent cause = pDot1.getCause(); assertNotNull(cause); assertEquals(cause, pDot1.getCause()); assertEquals(cause, pDot1Icmp.getCause()); assertFalse(cause.equals(pDot1Smtp.getCause())); }
@Test public void testPollUnresponsiveWithOutage() { m_pollContext.setServiceUnresponsiveEnabled(true); anticipateUnresponsive(mDot1); mDot1.bringUnresponsive(); pDot1Smtp.doPoll(); m_network.processStatusChange(new Date()); pDot1Icmp.doPoll(); m_network.processStatusChange(new Date()); assertUp(pDot1); verifyAnticipated(); anticipateDown(mDot1); mDot1.bringDown(); pDot1Smtp.doPoll(); m_network.processStatusChange(new Date()); verifyAnticipated(); anticipateUp(mDot1); mDot1.bringUp(); pDot1Icmp.doPoll(); m_network.processStatusChange(new Date()); verifyAnticipated(); anticipateUnresponsive(mDot1); mDot1.bringUnresponsive(); pDot1Smtp.doPoll(); m_network.processStatusChange(new Date()); pDot1Icmp.doPoll(); m_network.processStatusChange(new Date()); assertUp(pDot1); verifyAnticipated(); }
@Test public void testReparentOutages() { // create some outages in the database mDot1.bringDown(); pDot1Icmp.doPoll(); m_network.processStatusChange(new Date()); mDot1.bringUp(); pDot1Icmp.doPoll(); m_network.processStatusChange(new Date()); final String ifOutageOnNode1 = "select * from outages, ifServices, ipInterface where outages.ifServiceId = ifServices.id and ifServices.ipInterfaceId = ipInterface.id and ipInterface.nodeId = 1 and ipInterface.ipAddr = '192.168.1.1'"; final String ifOutageOnNode2 = "select * from outages, ifServices, ipInterface where outages.ifServiceId = ifServices.id and ifServices.ipInterfaceId = ipInterface.id and ipInterface.nodeId = 2 and ipInterface.ipAddr = '192.168.1.1'"; m_eventMgr.finishProcessingEvents(); assertEquals(2, m_db.countRows(ifOutageOnNode1)); assertEquals(0, m_db.countRows(ifOutageOnNode2)); m_db.reparentInterface(pDot1.getIpAddr(), pDot1.getNodeId(), pNode2.getNodeId()); pDot1.reparentTo(pNode2); assertEquals(0, m_db.countRows(ifOutageOnNode1)); assertEquals(2, m_db.countRows(ifOutageOnNode2)); }
@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); }
@Test public void testLoadInterface() throws Exception { anticipateDown(mDot1); mDot1.bringDown(); pDot1Smtp.doPoll(); m_network.processStatusChange(new Date()); verifyAnticipated(); PollEvent ifCause = pDot1.getCause(); // recreate the pollable network from the database m_network = createPollableNetwork(m_db, m_scheduler, m_pollerConfig, m_pollerConfig, m_pollContext); assignPollableMembers(m_network); assertElementHasCause(pDot1Smtp, ifCause); assertElementHasCause(pDot1Icmp, ifCause); assertElementHasCause(pDot1, ifCause); assertElementHasNullCause(pNode1); assertDown(pDot1Smtp); assertDown(pDot1Icmp); anticipateUp(mDot1); mDot1.bringUp(); pDot1Icmp.doPoll(); m_network.processStatusChange(new Date()); verifyAnticipated(); }
@Test public void testPollIfDownCritSvcUp() throws Exception { mDot1.bringDown(); pDot1.updateStatus(PollStatus.down()); pDot1Icmp.updateStatus(PollStatus.down()); pDot1.setCause(new DbPollEvent(1, EventConstants.INTERFACE_DOWN_EVENT_UEI, new Date())); m_network.recalculateStatus(); m_network.resetStatusChanged(); assertDown(pDot1Icmp); assertDown(pDot1); mDot1Icmp.bringUp(); pDot1Icmp.doPoll(); assertDown(pDot1Smtp); assertUp(pDot1Icmp); assertUp(pDot1); assertChanged(pDot1Icmp); assertChanged(pDot1); assertPoll(mDot1Smtp); assertPoll(mDot1Icmp); assertNoPoll(m_mockNetwork); }
@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(); }
@Test public void testPollIfDownNonCritSvcUp() throws Exception { mDot1.bringDown(); pDot1.updateStatus(PollStatus.down()); pDot1Icmp.updateStatus(PollStatus.down()); m_network.recalculateStatus(); m_network.resetStatusChanged(); assertDown(pDot1Icmp); assertDown(pDot1); mDot1Smtp.bringUp(); pDot1Smtp.doPoll(); assertDown(pDot1Icmp); assertDown(pDot1); assertUnchanged(pDot1Icmp); assertUnchanged(pDot1); assertNoPoll(m_mockNetwork); }
iface.bringDown();
@Test public void testPollIfDownCritSvcUndefSvcDownNoPoll() throws Exception { m_pollContext.setCriticalServiceName(null); m_pollContext.setPollingAllIfCritServiceUndefined(false); mDot1.bringDown(); pDot1.updateStatus(PollStatus.down()); pDot1Icmp.updateStatus(PollStatus.down()); pDot1Smtp.updateStatus(PollStatus.down()); m_network.recalculateStatus(); m_network.resetStatusChanged(); assertDown(pDot1Smtp); assertDown(pDot1Icmp); assertDown(pDot1); mDot1Smtp.bringUp(); pDot1Smtp.doPoll(); assertUp(pDot1Smtp); assertDown(pDot1Icmp); assertUp(pDot1); assertChanged(pDot1Smtp); assertUnchanged(pDot1Icmp); assertChanged(pDot1); assertPoll(mDot1Smtp); assertNoPoll(m_mockNetwork); }
@Test public void testPollIfDownCritSvcUndefSvcDown() throws Exception { m_pollContext.setCriticalServiceName(null); mDot1.bringDown(); pDot1.updateStatus(PollStatus.down()); pDot1Icmp.updateStatus(PollStatus.down()); pDot1Smtp.updateStatus(PollStatus.down()); m_network.recalculateStatus(); m_network.resetStatusChanged(); assertDown(pDot1Smtp); assertDown(pDot1Icmp); assertDown(pDot1); mDot1Smtp.bringUp(); pDot1Smtp.doPoll(); assertUp(pDot1Smtp); assertDown(pDot1Icmp); assertUp(pDot1); assertChanged(pDot1Smtp); assertUnchanged(pDot1Icmp); assertChanged(pDot1); assertPoll(mDot1Smtp); assertPoll(mDot1Icmp); assertNoPoll(m_mockNetwork); }
mDot1.bringDown();