use of org.opennms.netmgt.mock.MockNode in project opennms by OpenNMS.
the class NotifdIT method testMockNotificationInitialDelay.
@Test
public void testMockNotificationInitialDelay() throws Exception {
m_destinationPathManager.getPath("NoEscalate").setInitialDelay("1800ms");
MockNode node = m_network.getNode(1);
Date downDate = new Date(new Date().getTime() + 1800);
long finished = anticipateNotificationsForGroup("node 1 down.", "All services are down on node 1.", "InitialGroup", downDate, 0);
m_eventMgr.sendEventToListeners(node.createDownEvent(downDate));
verifyAnticipated(finished, 3000);
}
use of org.opennms.netmgt.mock.MockNode in project opennms by OpenNMS.
the class PollablesIT method addDownServiceToDownNode.
private void addDownServiceToDownNode(int nodeId, String nodeLabel, String nodeLocation, String ipAddr, String existingSvcName, String newSvcName) {
MockNode mNode = m_mockNetwork.getNode(nodeId);
PollableService pExistingSvc = m_network.getService(nodeId, getInetAddress(ipAddr), existingSvcName);
PollableInterface pIface = pExistingSvc.getInterface();
PollableNode pNode = pExistingSvc.getNode();
// before we start make sure the node is down
anticipateDown(mNode);
mNode.bringDown();
pExistingSvc.doPoll();
m_network.processStatusChange(new Date());
verifyAnticipated();
// ok the node is down.. here is the cause
PollEvent nodeCause = pNode.getCause();
// add a new mock service
MockService mSvc = m_mockNetwork.addService(nodeId, ipAddr, newSvcName);
m_db.writeService(mSvc);
// that is down
mSvc.bringDown();
// expect nothing since we already have node down event outstanding
// simulate a nodeGainedService event
PollableService pSvc = addServiceToNetwork(nodeId, nodeLabel, nodeLocation, ipAddr, newSvcName);
assertNotNull(pSvc);
// before the first poll everthing should have the node down cause
assertElementHasCause(pSvc, nodeCause);
assertElementHasCause(pExistingSvc, nodeCause);
assertElementHasCause(pIface, nodeCause);
assertElementHasCause(pNode, nodeCause);
// and should be mored down
assertDown(pSvc);
assertDown(pExistingSvc);
assertDown(pIface);
assertDown(pNode);
// now to the first poll
pSvc.doPoll();
// everything should still be down
assertDown(pSvc);
assertDown(pExistingSvc);
assertDown(pIface);
assertDown(pNode);
m_network.processStatusChange(new Date());
// and should have the same node down cause
assertElementHasCause(pSvc, nodeCause);
assertElementHasCause(pExistingSvc, nodeCause);
assertElementHasCause(pIface, nodeCause);
assertElementHasCause(pNode, nodeCause);
// verify we've received no events
verifyAnticipated();
}
Aggregations