Search in sources :

Example 6 with MockInterface

use of org.opennms.netmgt.mock.MockInterface in project opennms by OpenNMS.

the class PollerQueryManagerDaoIT 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);
}
Also used : MockInterface(org.opennms.netmgt.mock.MockInterface) MockService(org.opennms.netmgt.mock.MockService) Test(org.junit.Test)

Example 7 with MockInterface

use of org.opennms.netmgt.mock.MockInterface in project opennms by OpenNMS.

the class PollerIT method testInterfaceOutagesClosedOnDelete.

@Test
public void testInterfaceOutagesClosedOnDelete() {
    MockInterface element = m_network.getInterface(1, "192.168.1.1");
    testOutagesClosedOnDelete(element);
}
Also used : MockInterface(org.opennms.netmgt.mock.MockInterface) Test(org.junit.Test)

Example 8 with MockInterface

use of org.opennms.netmgt.mock.MockInterface in project opennms by OpenNMS.

the class PollerIT method testReparentCausesStatusChange.

// test open outages for unmanaged services
@Test
public void testReparentCausesStatusChange() {
    m_pollerConfig.setNodeOutageProcessingEnabled(true);
    MockNode node1 = m_network.getNode(1);
    MockNode node2 = m_network.getNode(2);
    MockInterface dotOne = m_network.getInterface(1, "192.168.1.1");
    MockInterface dotTwo = m_network.getInterface(1, "192.168.1.2");
    MockInterface dotThree = m_network.getInterface(2, "192.168.1.3");
    //
    // Plan to bring down both nodes except the reparented interface
    // the node owning the interface should be up while the other is down
    // after reparenting we should got the old owner go down while the other
    // comes up.
    //
    anticipateDown(node2);
    anticipateDown(dotOne);
    // bring down both nodes but bring iface back up
    node1.bringDown();
    node2.bringDown();
    dotTwo.bringUp();
    Event reparentEvent = MockEventUtil.createReparentEvent("Test", "192.168.1.2", 1, 2);
    startDaemons();
    verifyAnticipated(2000);
    m_db.reparentInterface(dotTwo.getIpAddr(), dotTwo.getNodeId(), node2.getNodeId());
    dotTwo.moveTo(node2);
    resetAnticipated();
    anticipateDown(node1, true);
    anticipateUp(node2, true);
    anticipateDown(dotThree, true);
    m_eventMgr.sendEventToListeners(reparentEvent);
    verifyAnticipated(20000);
}
Also used : MockInterface(org.opennms.netmgt.mock.MockInterface) Event(org.opennms.netmgt.xml.event.Event) MockNode(org.opennms.netmgt.mock.MockNode) Test(org.junit.Test)

Example 9 with MockInterface

use of org.opennms.netmgt.mock.MockInterface in project opennms by OpenNMS.

the class PollerIT method testPolling.

@Test
public void testPolling() throws Exception {
    m_pollerConfig.setNodeOutageProcessingEnabled(false);
    // create a poll anticipator
    PollAnticipator anticipator = new PollAnticipator();
    // register it with the interfaces services
    MockInterface iface = m_network.getInterface(1, "192.168.1.2");
    iface.addAnticipator(anticipator);
    //
    // first ensure that polls are working while it is up
    //
    // anticipate three polls on all the interfaces services
    anticipator.anticipateAllServices(iface);
    anticipator.anticipateAllServices(iface);
    anticipator.anticipateAllServices(iface);
    // start the poller
    startDaemons();
    // wait for the polls to occur while its up... 1 poll per second plus overhead
    assertEquals(0, anticipator.waitForAnticipated(4500L).size());
}
Also used : PollAnticipator(org.opennms.netmgt.mock.PollAnticipator) MockInterface(org.opennms.netmgt.mock.MockInterface) Test(org.junit.Test)

Example 10 with MockInterface

use of org.opennms.netmgt.mock.MockInterface in project opennms by OpenNMS.

the class PollerIT method testUnmangedWithOpenOutageAtStartup.

// test open outages for unmanaged services
@Test
public void testUnmangedWithOpenOutageAtStartup() {
    // 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));
}
Also used : MockInterface(org.opennms.netmgt.mock.MockInterface) MockService(org.opennms.netmgt.mock.MockService) Event(org.opennms.netmgt.xml.event.Event) Test(org.junit.Test)

Aggregations

MockInterface (org.opennms.netmgt.mock.MockInterface)28 Test (org.junit.Test)24 Event (org.opennms.netmgt.xml.event.Event)13 MockService (org.opennms.netmgt.mock.MockService)8 Date (java.util.Date)7 MockNode (org.opennms.netmgt.mock.MockNode)7 PollAnticipator (org.opennms.netmgt.mock.PollAnticipator)4 MockVisitor (org.opennms.netmgt.mock.MockVisitor)3 MockVisitorAdapter (org.opennms.netmgt.mock.MockVisitorAdapter)3 ResultSet (java.sql.ResultSet)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Querier (org.opennms.core.utils.Querier)1 RowProcessor (org.opennms.core.utils.RowProcessor)1 Notification (org.opennms.netmgt.config.notifications.Notification)1 MockPathOutage (org.opennms.netmgt.mock.MockPathOutage)1 OnmsOutage (org.opennms.netmgt.model.OnmsOutage)1