use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.
the class NewSuspectScanIT method testScanNewSuspectWithForeignSource.
@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 testScanNewSuspectWithForeignSource() 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.REINITIALIZE_PRIMARY_SNMP_INTERFACE_EVENT_UEI, "Provisiond").setNodeid(nextNodeId).setInterface(addr("198.51.100.201")).getEvent());
anticipator.anticipateEvent(new EventBuilder(EventConstants.NODE_LABEL_CHANGED_EVENT_UEI, "Provisiond").setNodeid(nextNodeId).getEvent());
anticipator.anticipateEvent(new EventBuilder(EventConstants.PROVISION_SCAN_COMPLETE_UEI, "Provisiond").setNodeid(nextNodeId).getEvent());
final String foreignSource = "Testie";
NewSuspectScan scan = m_provisioner.createNewSuspectScan(addr("198.51.100.201"), foreignSource, MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID);
runScan(scan);
anticipator.verifyAnticipated(20000, 0, 0, 0, 0);
// Verify distpoller count
assertEquals(1, getDistPollerDao().countAll());
// Verify node count
assertEquals(1, getNodeDao().countAll());
List<OnmsNode> onmsNodes = getNodeDao().findByLabel("brozow.local");
OnmsNode onmsNode = onmsNodes.get(0);
assertEquals("Testie", onmsNode.getForeignSource());
assertEquals(MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID, onmsNode.getLocation().getLocationName());
final StringBuilder errorMsg = new StringBuilder();
// 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());
// NMS-8835: Now send another new suspect event for the same IP address and foreignSource
scan = m_provisioner.createNewSuspectScan(addr("198.51.100.201"), foreignSource, MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID);
runScan(scan);
// The node count should not increase
assertEquals(1, getNodeDao().countAll());
}
use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.
the class ProvisionerIT method testPopulateWithIpv6SnmpAndNodeScan.
// fail if we take more than five minutes
@Test(timeout = 300000)
@JUnitSnmpAgents({ @JUnitSnmpAgent(host = "10.1.15.245", resource = "classpath:/snmpwalk-demo.properties"), @JUnitSnmpAgent(host = "10.3.20.23", resource = "classpath:/snmpwalk-demo.properties"), @JUnitSnmpAgent(host = "2001:0470:e2f1:cafe:16c1:7cff:12d6:7bb9", resource = "classpath:/snmpwalk-demo.properties") })
public void testPopulateWithIpv6SnmpAndNodeScan() throws Exception {
final ForeignSource fs = new ForeignSource();
fs.setName("matt:");
fs.addDetector(new PluginConfig("SNMP", "org.opennms.netmgt.provision.detector.snmp.SnmpDetector"));
m_foreignSourceRepository.putDefaultForeignSource(fs);
importFromResource("classpath:/requisition_then_scanv6.xml", Boolean.TRUE.toString());
// Verify distpoller count
assertEquals(1, getDistPollerDao().countAll());
// Verify node count
assertEquals(1, getNodeDao().countAll());
// Verify ipinterface count
assertEquals(1, getInterfaceDao().countAll());
// Verify ifservices count
assertEquals(1, getMonitoredServiceDao().countAll());
// Verify service count
assertEquals(1, getServiceTypeDao().countAll());
// Verify snmpInterface count
assertEquals(1, getSnmpInterfaceDao().countAll());
runPendingScans();
// Verify distpoller count
assertEquals(1, getDistPollerDao().countAll());
// Verify node count
assertEquals(1, getNodeDao().countAll());
// Verify ipinterface count
assertEquals("Unexpected number of IP interfaces found: " + getInterfaceDao().findAll(), 3, getInterfaceDao().countAll());
// Verify ifservices count - discover snmp service on other if
assertEquals("Unexpected number of services found: " + getMonitoredServiceDao().findAll(), 3, getMonitoredServiceDao().countAll());
// Verify service count
assertEquals("Unexpected number of service types found: " + getServiceTypeDao().findAll(), 1, getServiceTypeDao().countAll());
// Verify snmpInterface count
assertEquals("Unexpected number of SNMP interfaces found: " + getSnmpInterfaceDao().findAll(), 6, getSnmpInterfaceDao().countAll());
// Ensure that collection is on for all ip interfaces
for (OnmsIpInterface iface : getInterfaceDao().findAll()) {
OnmsSnmpInterface snmpIface = iface.getSnmpInterface();
assertNotNull("Expected an snmp interface associated with " + iface.getIpAddress(), snmpIface);
assertTrue("Expected snmp interface associated with " + iface.getIpAddress() + " to have collection enabled.", snmpIface.isCollectionEnabled());
}
}
use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.
the class IfIndexNullIT method testNullIfIndex.
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = "192.0.2.201", port = 161, resource = "classpath:/snmpTestData-null.properties"), @JUnitSnmpAgent(host = "192.0.2.204", port = 161, resource = "classpath:/snmpTestData-null.properties") })
public void testNullIfIndex() throws Exception {
final CountDownLatch eventRecieved = anticipateEvents(1, EventConstants.PROVISION_SCAN_COMPLETE_UEI, EventConstants.PROVISION_SCAN_ABORTED_UEI);
m_provisioner.importModelFromResource(m_resourceLoader.getResource("classpath:/tec_dump.xml"), Boolean.TRUE.toString());
waitForEverything();
final List<OnmsNode> nodes = getNodeDao().findAll();
final OnmsNode node = nodes.get(0);
eventRecieved.await();
final NodeScan scan = m_provisioner.createNodeScan(node.getId(), node.getForeignSource(), node.getForeignId(), node.getLocation());
runScan(scan);
// Verify ipinterface count
assertEquals(2, getInterfaceDao().countAll());
}
use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.
the class EnLinkdSnmpIT method testDot1dStpPortTableWalk.
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = DLINK1_IP, port = 161, resource = DLINK1_SNMP_RESOURCE) })
public void testDot1dStpPortTableWalk() throws Exception {
String trackerName = "dot1dbaseStpTable";
final List<BridgeStpLink> links = new ArrayList<>();
SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(DLINK1_IP));
Dot1dStpPortTableTracker tracker = new Dot1dStpPortTableTracker() {
@Override
public void processDot1dStpPortRow(final Dot1dStpPortRow row) {
links.add(row.getLink());
}
};
try {
m_client.walk(config, tracker).withDescription(trackerName).withLocation(null).execute().get();
} catch (final InterruptedException e) {
LOG.error("run: collection interrupted, exiting", e);
return;
}
assertEquals(26, links.size());
int i = 0;
for (BridgeStpLink link : links) {
assertEquals(++i, link.getStpPort().intValue());
assertEquals(128, link.getStpPortPriority().intValue());
if (link.getStpPort() <= 6 || link.getStpPort() == 24)
assertEquals(BridgeDot1dStpPortState.DOT1D_STP_PORT_STATUS_FORWARDING, link.getStpPortState());
else
assertEquals(BridgeDot1dStpPortState.DOT1D_STP_PORT_STATUS_DISABLED, link.getStpPortState());
assertEquals(BridgeDot1dStpPortEnable.DOT1D_STP_PORT_ENABLED, link.getStpPortEnable());
assertEquals(2000000, link.getStpPortPathCost().intValue());
assertEquals("0000000000000000", link.getDesignatedRoot());
assertEquals(0, link.getDesignatedCost().intValue());
assertEquals("0000000000000000", link.getDesignatedBridge());
assertEquals("0000", link.getDesignatedPort());
}
}
use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.
the class EnLinkdSnmpIT method testIsisISAdjTableWalk.
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = SIEGFRIE_IP, port = 161, resource = SIEGFRIE_SNMP_RESOURCE) })
public void testIsisISAdjTableWalk() throws Exception {
final List<IsIsLink> links = new ArrayList<>();
String trackerName = "isisISAdjTable";
SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(SIEGFRIE_IP));
IsisISAdjTableTracker tracker = new IsisISAdjTableTracker() {
public void processIsisAdjRow(final IsIsAdjRow row) {
assertEquals(5, row.getColumnCount());
links.add(row.getIsisLink());
}
};
try {
m_client.walk(config, tracker).withDescription(trackerName).withLocation(null).execute().get();
} catch (final InterruptedException e) {
LOG.error("run: collection interrupted, exiting", e);
return;
}
assertEquals(2, links.size());
for (final IsIsLink link : links) {
assertEquals(1, link.getIsisISAdjIndex().intValue());
assertEquals(IsisISAdjState.up, link.getIsisISAdjState());
assertEquals(IsisISAdjNeighSysType.l1_IntermediateSystem, link.getIsisISAdjNeighSysType());
assertEquals(0, link.getIsisISAdjNbrExtendedCircID().intValue());
if (link.getIsisCircIndex().intValue() == 533) {
assertEquals("001f12accbf0", link.getIsisISAdjNeighSNPAAddress());
assertEquals("000110255062", link.getIsisISAdjNeighSysID());
} else if (link.getIsisCircIndex().intValue() == 552) {
assertEquals("0021590e47c2", link.getIsisISAdjNeighSNPAAddress());
assertEquals("000110088500", link.getIsisISAdjNeighSysID());
} else {
assertEquals(true, false);
}
}
}
Aggregations