use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.
the class NewSuspectScanIT method testScanNewSuspect.
@Test(timeout = 300000)
@JUnitSnmpAgents({ @JUnitSnmpAgent(host = "198.51.100.201", resource = "classpath:/snmpTestData3.properties"), @JUnitSnmpAgent(host = "198.51.100.204", resource = "classpath:/snmpTestData3.properties") })
public void testScanNewSuspect() throws Exception {
final int nextNodeId = m_nodeDao.getNextNodeId();
//Verify empty database
assertEquals(1, getDistPollerDao().countAll());
assertEquals(0, getNodeDao().countAll());
assertEquals(0, getInterfaceDao().countAll());
assertEquals(0, getMonitoredServiceDao().countAll());
assertEquals(0, getServiceTypeDao().countAll());
assertEquals(0, getSnmpInterfaceDao().countAll());
final EventAnticipator anticipator = m_eventSubscriber.getEventAnticipator();
anticipator.anticipateEvent(new EventBuilder(EventConstants.NODE_ADDED_EVENT_UEI, "Provisiond").setNodeid(nextNodeId).getEvent());
anticipator.anticipateEvent(new EventBuilder(EventConstants.NODE_GAINED_INTERFACE_EVENT_UEI, "Provisiond").setNodeid(nextNodeId).setInterface(addr("198.51.100.201")).getEvent());
anticipator.anticipateEvent(new EventBuilder(EventConstants.NODE_GAINED_INTERFACE_EVENT_UEI, "Provisiond").setNodeid(nextNodeId).setInterface(addr("198.51.100.204")).getEvent());
anticipator.anticipateEvent(new EventBuilder(EventConstants.NODE_GAINED_SERVICE_EVENT_UEI, "Provisiond").setNodeid(nextNodeId).setInterface(addr("198.51.100.201")).setService("SNMP").getEvent());
anticipator.anticipateEvent(new EventBuilder(EventConstants.NODE_GAINED_SERVICE_EVENT_UEI, "Provisiond").setNodeid(nextNodeId).setInterface(addr("198.51.100.204")).setService("SNMP").getEvent());
anticipator.anticipateEvent(new EventBuilder(EventConstants.NODE_LABEL_CHANGED_EVENT_UEI, "Provisiond").setNodeid(nextNodeId).getEvent());
anticipator.anticipateEvent(new EventBuilder(EventConstants.REINITIALIZE_PRIMARY_SNMP_INTERFACE_EVENT_UEI, "Provisiond").setNodeid(nextNodeId).setInterface(addr("198.51.100.201")).getEvent());
anticipator.anticipateEvent(new EventBuilder(EventConstants.PROVISION_SCAN_COMPLETE_UEI, "Provisiond").setNodeid(nextNodeId).getEvent());
final NewSuspectScan scan = m_provisioner.createNewSuspectScan(addr("198.51.100.201"), null, "my-custom-location");
runScan(scan);
anticipator.verifyAnticipated(20000, 0, 0, 0, 0);
//Verify distpoller count
assertEquals(1, getDistPollerDao().countAll());
//Verify node count
assertEquals(1, getNodeDao().countAll());
OnmsNode onmsNode = getNodeDao().get(nextNodeId);
assertEquals(null, onmsNode.getForeignSource());
assertEquals(null, onmsNode.getForeignId());
assertEquals("my-custom-location", onmsNode.getLocation().getLocationName());
final StringBuffer errorMsg = new StringBuffer();
//Verify ipinterface count
for (final OnmsIpInterface iface : getInterfaceDao().findAll()) {
errorMsg.append(iface.toString());
}
assertEquals(errorMsg.toString(), 2, getInterfaceDao().countAll());
//Verify ifservices count - discover snmp service on other if
assertEquals("Unexpected number of services found.", 2, getMonitoredServiceDao().countAll());
//Verify service count
assertEquals(1, getServiceTypeDao().countAll());
//Verify snmpInterface count
assertEquals(6, getSnmpInterfaceDao().countAll());
}
Aggregations