use of org.opennms.netmgt.mock.MockInterface in project opennms by OpenNMS.
the class PollerQueryManagerDaoIT method testUnmangedWithOpenOutageAtStartup.
// test open outages for unmanaged services
@Test
public void testUnmangedWithOpenOutageAtStartup() throws InterruptedException {
// before we start we need to initialize the database
// create an outage for the service
MockService svc = m_network.getService(1, "192.168.1.1", "SMTP");
MockInterface iface = m_network.getInterface(1, "192.168.1.2");
Event svcLostEvent = MockEventUtil.createNodeLostServiceEvent("Test", svc);
m_db.writeEvent(svcLostEvent);
createOutages(svc, svcLostEvent);
Event ifaceDownEvent = MockEventUtil.createInterfaceDownEvent("Test", iface);
m_db.writeEvent(ifaceDownEvent);
createOutages(iface, ifaceDownEvent);
// mark the service as unmanaged
m_db.setServiceStatus(svc, 'U');
m_db.setInterfaceStatus(iface, 'U');
// assert that we have an open outage
assertEquals(1, m_db.countOpenOutagesForService(svc));
assertEquals(1, m_db.countOutagesForService(svc));
assertEquals(iface.getServices().size(), m_db.countOutagesForInterface(iface));
assertEquals(iface.getServices().size(), m_db.countOpenOutagesForInterface(iface));
startDaemons();
// assert that we have no open outages
assertEquals(0, m_db.countOpenOutagesForService(svc));
assertEquals(1, m_db.countOutagesForService(svc));
assertEquals(0, m_db.countOpenOutagesForInterface(iface));
assertEquals(iface.getServices().size(), m_db.countOutagesForInterface(iface));
}
use of org.opennms.netmgt.mock.MockInterface in project opennms by OpenNMS.
the class PollerIT method testDontPollDuringScheduledOutages.
// what about scheduled outages?
@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());
}
use of org.opennms.netmgt.mock.MockInterface in project opennms by OpenNMS.
the class PollerIT method testInterfaceWithNoCriticalService.
@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);
}
Aggregations