use of org.opennms.netmgt.mock.MockNode in project opennms by OpenNMS.
the class PollerIT method testNullInterfaceOnNodeDown.
@Test
public void testNullInterfaceOnNodeDown() {
// NODE processing = true;
m_pollerConfig.setNodeOutageProcessingEnabled(true);
MockNode node = m_network.getNode(2);
MockService icmpService = m_network.getService(2, "192.168.1.3", "ICMP");
MockService smtpService = m_network.getService(2, "192.168.1.3", "SMTP");
MockService snmpService = m_network.getService(2, "192.168.1.3", "SNMP");
// start the poller
startDaemons();
anticipateDown(node);
icmpService.bringDown();
smtpService.bringDown();
snmpService.bringDown();
verifyAnticipated(10000);
// node is down at this point
boolean foundNodeDown = false;
for (final Event event : m_eventMgr.getEventAnticipator().getAnticipatedEventsReceived()) {
if (EventConstants.NODE_DOWN_EVENT_UEI.equals(event.getUei())) {
foundNodeDown = true;
assertNull(event.getInterfaceAddress());
}
}
assertTrue(foundNodeDown);
}
use of org.opennms.netmgt.mock.MockNode in project opennms by OpenNMS.
the class ProvisionerIT method testRequisitionedCategoriesNoPolicies.
@Test(timeout = 300000)
public void testRequisitionedCategoriesNoPolicies() throws Exception {
final int nextNodeId = m_nodeDao.getNextNodeId();
final MockNetwork network = new MockNetwork();
final MockNode node = network.addNode(nextNodeId, "test");
network.addInterface("172.16.1.1");
network.addService("ICMP");
anticipateCreationEvents(node);
m_eventAnticipator.anticipateEvent(getNodeCategoryEvent(nextNodeId, "test"));
// we should not get new update events on a re-import now, that happens during the scan phase
//m_eventAnticipator.anticipateEvent(new EventBuilder(EventConstants.NODE_UPDATED_EVENT_UEI, "Test").setNodeid(nextNodeId).getEvent());
//m_eventAnticipator.anticipateEvent(getNodeCategoryEvent(nextNodeId, "test"));
importFromResource("classpath:/provisioner-testCategories-oneCategory.xml", Boolean.TRUE.toString());
m_eventAnticipator.verifyAnticipated();
assertEquals(0, m_eventAnticipator.getUnanticipatedEvents().size());
m_eventAnticipator.reset();
m_eventAnticipator.anticipateEvent(nodeScanCompleted(nextNodeId));
m_eventAnticipator.setDiscardUnanticipated(true);
runPendingScans();
m_eventAnticipator.verifyAnticipated();
m_eventAnticipator.reset();
OnmsNode n = getNodeDao().get(nextNodeId);
assertEquals(1, n.getCategories().size());
assertEquals("TotallyMadeUpCategoryName", n.getCategories().iterator().next().getName());
// import again, should be the same
importFromResource("classpath:/provisioner-testCategories-oneCategory.xml", Boolean.TRUE.toString());
n = getNodeDao().get(nextNodeId);
assertEquals(1, n.getCategories().size());
assertEquals("TotallyMadeUpCategoryName", n.getCategories().iterator().next().getName());
runPendingScans();
n = getNodeDao().get(nextNodeId);
assertEquals(1, n.getCategories().size());
assertEquals("TotallyMadeUpCategoryName", n.getCategories().iterator().next().getName());
}
use of org.opennms.netmgt.mock.MockNode in project opennms by OpenNMS.
the class NotifdIT method testManualAcknowledge1.
@Test
public void testManualAcknowledge1() throws Exception {
m_destinationPathManager.getPath("NoEscalate").setInitialDelay("2000ms");
MockNode node = m_network.getNode(1);
Event e = node.createDownEvent();
m_eventMgr.sendEventToListeners(e);
m_db.acknowledgeNoticesForEvent(e);
verifyAnticipated(0, 0, 7000);
}
use of org.opennms.netmgt.mock.MockNode in project opennms by OpenNMS.
the class NotifdIT method testRoleNotification.
@Test
public void testRoleNotification() throws Exception {
MockNode node = m_network.getNode(1);
Date downDate = new Date();
long finishedDowns = anticipateNotificationsForRole("notification test", "Notification Test", "oncall", downDate, 0);
m_eventMgr.sendEventToListeners(MockEventUtil.createNodeEvent("Test", "uei.opennms.org/test/roleTestEvent", node));
verifyAnticipated(finishedDowns, 1000);
m_anticipator.reset();
}
use of org.opennms.netmgt.mock.MockNode in project opennms by OpenNMS.
the class NotifdIT method testAutoAcknowledge1.
@Test
public void testAutoAcknowledge1() throws Exception {
m_destinationPathManager.getPath("NoEscalate").setInitialDelay("2000ms");
MockNode node = m_network.getNode(1);
Event downEvent = node.createDownEvent();
Tticket tticket = new Tticket();
tticket.setContent("777");
tticket.setState("1");
downEvent.setTticket(tticket);
m_eventMgr.sendEventToListeners(downEvent);
sleep(1000);
Date date = new Date();
Event upEvent = node.createUpEvent(date);
long endTime = anticipateNotificationsForGroup("node 1 up.", "The node which was previously down is now up.", "UpGroup", date, 0);
m_eventMgr.sendEventToListeners(upEvent);
verifyAnticipated(endTime, 1000, 5000);
}
Aggregations