Search in sources :

Example 11 with JUnitSnmpAgents

use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.

the class EnLinkdSnmpIT method testCdpCacheTableCollection.

@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = RPict001_IP, port = 161, resource = RPict001_SNMP_RESOURCE) })
public void testCdpCacheTableCollection() throws Exception {
    SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(RPict001_IP));
    class CdpCacheTableTrackerTester extends CdpCacheTableTracker {

        int count = 0;

        public int count() {
            return count;
        }
    }
    final CdpCacheTableTrackerTester cdpCacheTableTracker = new CdpCacheTableTrackerTester() {

        public void processCdpCacheRow(final CdpCacheRow row) {
            count++;
        }
    };
    String trackerName = "cdpCacheTable";
    try {
        m_client.walk(config, cdpCacheTableTracker).withDescription(trackerName).withLocation(null).execute().get();
    } catch (final InterruptedException e) {
        LOG.error("run: Cdp Linkd collection interrupted, exiting", e);
        return;
    }
    assertEquals(14, cdpCacheTableTracker.count());
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig) CdpCacheTableTracker(org.opennms.netmgt.enlinkd.snmp.CdpCacheTableTracker) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Example 12 with JUnitSnmpAgents

use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.

the class Nms7467EnIT method testCisco01Links.

@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = CISCO_WS_C2948_IP, port = 161, resource = CISCO_WS_C2948_SNMP_RESOURCE) })
public void testCisco01Links() throws Exception {
    m_nodeDao.save(builder.getCiscoWsC2948());
    m_nodeDao.flush();
    m_linkdConfig.getConfiguration().setUseBridgeDiscovery(false);
    m_linkdConfig.getConfiguration().setUseOspfDiscovery(false);
    m_linkdConfig.getConfiguration().setUseIsisDiscovery(false);
    m_linkdConfig.getConfiguration().setUseLldpDiscovery(false);
    assertTrue(!m_linkdConfig.useIsisDiscovery());
    assertTrue(!m_linkdConfig.useBridgeDiscovery());
    assertTrue(!m_linkdConfig.useOspfDiscovery());
    assertTrue(!m_linkdConfig.useLldpDiscovery());
    assertTrue(m_linkdConfig.useCdpDiscovery());
    final OnmsNode cisco01 = m_nodeDao.findByForeignId("linkd", CISCO_WS_C2948_NAME);
    assertTrue(m_linkd.scheduleNodeCollection(cisco01.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(cisco01.getId()));
    for (final OnmsNode node : m_nodeDao.findAll()) {
        assertNotNull(node.getCdpElement());
        printCdpElement(node.getCdpElement());
        assertEquals(TruthValue.TRUE, node.getCdpElement().getCdpGlobalRun());
        assertEquals(CISCO_WS_C2948_GLOBAL_DEVICEID, node.getCdpElement().getCdpGlobalDeviceId());
        assertEquals(CdpGlobalDeviceIdFormat.other, node.getCdpElement().getCdpGlobalDeviceIdFormat());
    }
    assertEquals(5, m_cdpLinkDao.countAll());
    for (CdpLink link : m_cdpLinkDao.findAll()) {
        assertNotNull(link);
        printCdpLink(link);
    }
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) CdpLink(org.opennms.netmgt.model.CdpLink) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Example 13 with JUnitSnmpAgents

use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.

the class Nms7563EnIT method testCisco01Links.

@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = CISCO01_IP, port = 161, resource = CISCO01_SNMP_RESOURCE) })
public void testCisco01Links() throws Exception {
    m_nodeDao.save(builder.getCisco01());
    m_nodeDao.flush();
    m_linkdConfig.getConfiguration().setUseBridgeDiscovery(false);
    m_linkdConfig.getConfiguration().setUseOspfDiscovery(false);
    m_linkdConfig.getConfiguration().setUseIsisDiscovery(false);
    assertTrue(!m_linkdConfig.useIsisDiscovery());
    assertTrue(!m_linkdConfig.useBridgeDiscovery());
    assertTrue(!m_linkdConfig.useOspfDiscovery());
    assertTrue(m_linkdConfig.useLldpDiscovery());
    assertTrue(m_linkdConfig.useCdpDiscovery());
    final OnmsNode cisco01 = m_nodeDao.findByForeignId("linkd", CISCO01_NAME);
    assertTrue(m_linkd.scheduleNodeCollection(cisco01.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(cisco01.getId()));
    for (final OnmsNode node : m_nodeDao.findAll()) {
        assertNotNull(node.getLldpElement());
        printLldpElement(node.getLldpElement());
        assertEquals(LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_MACADDRESS, node.getLldpElement().getLldpChassisIdSubType());
        assertEquals(CISCO01_LLDP_CHASSID_ID, node.getLldpElement().getLldpChassisId());
        assertEquals(CISCO01_LLDP_SYSNAME, node.getLldpElement().getLldpSysname());
        assertNotNull(node.getCdpElement());
        printCdpElement(node.getCdpElement());
        assertEquals(TruthValue.TRUE, node.getCdpElement().getCdpGlobalRun());
        assertEquals(CISCO01_CDP_GLOBAL_DEVICE_ID, node.getCdpElement().getCdpGlobalDeviceId());
    }
    assertEquals(1, m_lldpLinkDao.countAll());
    for (LldpLink link : m_lldpLinkDao.findAll()) {
        assertNotNull(link);
        printLldpLink(link);
        assertEquals(8, link.getLldpLocalPortNum().intValue());
        assertNull(link.getLldpPortIfindex());
        assertEquals(LldpPortIdSubType.LLDP_PORTID_SUBTYPE_INTERFACENAME, link.getLldpPortIdSubType());
        assertEquals("Fa0/8", link.getLldpPortId());
        assertEquals("FastEthernet0/8", link.getLldpPortDescr());
        assertEquals(LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_MACADDRESS, link.getLldpRemChassisIdSubType());
        assertEquals(SWITCH02_LLDP_CHASSID_ID, link.getLldpRemChassisId());
        assertEquals(SWITCH02_LLDP_SYSNAME, link.getLldpRemSysname());
        assertEquals(LldpPortIdSubType.LLDP_PORTID_SUBTYPE_LOCAL, link.getLldpRemPortIdSubType());
        assertEquals("24", link.getLldpRemPortId());
        assertEquals("24", link.getLldpRemPortDescr());
    }
    assertEquals(0, m_cdpLinkDao.countAll());
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) LldpLink(org.opennms.netmgt.model.LldpLink) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Example 14 with JUnitSnmpAgents

use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.

the class Nms7777DWEnIT method testLldpNoLinks.

@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = DW_IP, port = 161, resource = DW_SNMP_RESOURCE) })
public void testLldpNoLinks() throws Exception {
    m_nodeDao.save(builder.getDragonWaveRouter());
    m_nodeDao.flush();
    m_linkdConfig.getConfiguration().setUseBridgeDiscovery(false);
    m_linkdConfig.getConfiguration().setUseOspfDiscovery(false);
    m_linkdConfig.getConfiguration().setUseIsisDiscovery(false);
    m_linkdConfig.getConfiguration().setUseCdpDiscovery(false);
    assertTrue(!m_linkdConfig.useIsisDiscovery());
    assertTrue(!m_linkdConfig.useBridgeDiscovery());
    assertTrue(!m_linkdConfig.useOspfDiscovery());
    assertTrue(m_linkdConfig.useLldpDiscovery());
    assertTrue(!m_linkdConfig.useCdpDiscovery());
    final OnmsNode dw = m_nodeDao.findByForeignId("linkd", DW_NAME);
    assertTrue(m_linkd.scheduleNodeCollection(dw.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(dw.getId()));
    for (final OnmsNode node : m_nodeDao.findAll()) {
        if (node.getLldpElement() != null)
            printLldpElement(node.getLldpElement());
    }
    assertEquals(0, m_lldpLinkDao.countAll());
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Example 15 with JUnitSnmpAgents

use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.

the class Nms7918EnIT method testNms7918SAMASW01BftCollection.

@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = SAMASW01_IP, port = 161, resource = SAMASW01_SNMP_RESOURCE) })
public void testNms7918SAMASW01BftCollection() throws Exception {
    final OnmsNode samasw01 = m_nodeDao.findByForeignId("linkd", SAMASW01_NAME);
    m_linkdConfig.getConfiguration().setUseBridgeDiscovery(true);
    m_linkdConfig.getConfiguration().setUseCdpDiscovery(false);
    m_linkdConfig.getConfiguration().setUseOspfDiscovery(false);
    m_linkdConfig.getConfiguration().setUseLldpDiscovery(false);
    m_linkdConfig.getConfiguration().setUseIsisDiscovery(false);
    assertTrue(!m_linkdConfig.useLldpDiscovery());
    assertTrue(!m_linkdConfig.useCdpDiscovery());
    assertTrue(!m_linkdConfig.useOspfDiscovery());
    assertTrue(m_linkdConfig.useBridgeDiscovery());
    assertTrue(!m_linkdConfig.useIsisDiscovery());
    assertTrue(m_linkd.scheduleNodeCollection(samasw01.getId()));
    assertEquals(0, m_bridgeBridgeLinkDao.countAll());
    assertEquals(0, m_bridgeMacLinkDao.countAll());
    assertTrue(m_linkd.runSingleSnmpCollection(samasw01.getId()));
    assertEquals(0, m_bridgeBridgeLinkDao.countAll());
    assertEquals(0, m_bridgeMacLinkDao.countAll());
    List<BridgeMacLink> links = m_linkd.getQueryManager().useBridgeTopologyUpdateBFT(samasw01.getId());
    assertEquals(31, links.size());
    for (BridgeMacLink link : links) {
        System.err.println(link.printTopology());
    }
    assertTrue(m_linkd.runTopologyDiscovery(samasw01.getId()));
    assertEquals(0, m_bridgeBridgeLinkDao.countAll());
    assertEquals(0, m_bridgeMacLinkDao.countAll());
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) BridgeMacLink(org.opennms.netmgt.model.BridgeMacLink) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Aggregations

JUnitSnmpAgents (org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)66 Test (org.junit.Test)64 OnmsNode (org.opennms.netmgt.model.OnmsNode)38 SnmpAgentConfig (org.opennms.netmgt.snmp.SnmpAgentConfig)23 LldpLink (org.opennms.netmgt.model.LldpLink)14 ArrayList (java.util.ArrayList)8 BridgeMacLink (org.opennms.netmgt.model.BridgeMacLink)8 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)6 EventAnticipator (org.opennms.netmgt.dao.mock.EventAnticipator)4 LldpLocPortGetter (org.opennms.netmgt.enlinkd.snmp.LldpLocPortGetter)4 CdpLink (org.opennms.netmgt.model.CdpLink)4 IsIsLink (org.opennms.netmgt.model.IsIsLink)4 EventBuilder (org.opennms.netmgt.model.events.EventBuilder)4 CountDownLatch (java.util.concurrent.CountDownLatch)3 LldpElement (org.opennms.netmgt.model.LldpElement)3 OspfLink (org.opennms.netmgt.model.OspfLink)3 InetAddress (java.net.InetAddress)2 CdpGlobalGroupTracker (org.opennms.netmgt.enlinkd.snmp.CdpGlobalGroupTracker)2 LldpLocalGroupTracker (org.opennms.netmgt.enlinkd.snmp.LldpLocalGroupTracker)2 LldpRemTableTracker (org.opennms.netmgt.enlinkd.snmp.LldpRemTableTracker)2