Search in sources :

Example 66 with OnmsNode

use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.

the class Nms4930EnIT method testNms4930Network.

/*
     * The main fact is that this devices have only the Bridge MIb walk
     * dlink_DES has STP disabled
     * dlink_DGS has STP enabled but root is itself
     * 
     */
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = DLINK1_IP, port = 161, resource = DLINK1_SNMP_RESOURCE), @JUnitSnmpAgent(host = DLINK2_IP, port = 161, resource = DLINK2_SNMP_RESOURCE) })
public void testNms4930Network() throws Exception {
    final OnmsNode dlink1 = m_nodeDao.findByForeignId("linkd", DLINK1_NAME);
    final OnmsNode dlink2 = m_nodeDao.findByForeignId("linkd", DLINK2_NAME);
    final OnmsNode nodebetweendlink1dlink2 = m_nodeDao.findByForeignId("linkd", "10.100.1.7");
    final OnmsNode nodeonlink1dport6 = m_nodeDao.findByForeignId("linkd", "10.100.2.6");
    assertNotNull(nodebetweendlink1dlink2);
    assertNotNull(nodeonlink1dport6);
    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(dlink1.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(dlink2.getId()));
    assertEquals(0, m_bridgeBridgeLinkDao.countAll());
    assertEquals(0, m_bridgeMacLinkDao.countAll());
    assertTrue(m_linkd.runSingleSnmpCollection(dlink1.getId()));
    assertTrue(m_linkd.runTopologyDiscovery(dlink1.getId()));
    checkTopologyDlink1(dlink1);
    assertTrue(m_linkd.runSingleSnmpCollection(dlink2.getId()));
    assertTrue(m_linkd.runTopologyDiscovery(dlink2.getId()));
    checkTopology(dlink1, dlink2, nodeonlink1dport6, nodebetweendlink1dlink2);
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Example 67 with OnmsNode

use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.

the class Nms7918EnIT method testNms7918.

@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = ASW01_IP, port = 161, resource = ASW01_SNMP_RESOURCE), @JUnitSnmpAgent(host = SAMASW01_IP, port = 161, resource = SAMASW01_SNMP_RESOURCE), @JUnitSnmpAgent(host = STCASW01_IP, port = 161, resource = STCASW01_SNMP_RESOURCE) })
public void testNms7918() throws Exception {
    final OnmsNode stcasw01 = m_nodeDao.findByForeignId("linkd", STCASW01_NAME);
    final OnmsNode samasw01 = m_nodeDao.findByForeignId("linkd", SAMASW01_NAME);
    final OnmsNode asw01 = m_nodeDao.findByForeignId("linkd", ASW01_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);
    m_linkdConfig.getConfiguration().setMaxBft(3);
    assertTrue(!m_linkdConfig.useLldpDiscovery());
    assertTrue(!m_linkdConfig.useCdpDiscovery());
    assertTrue(!m_linkdConfig.useOspfDiscovery());
    assertTrue(m_linkdConfig.useBridgeDiscovery());
    assertTrue(!m_linkdConfig.useIsisDiscovery());
    assertTrue(m_linkd.scheduleNodeCollection(asw01.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(samasw01.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(stcasw01.getId()));
    assertEquals(0, m_bridgeElementDao.countAll());
    assertEquals(0, m_bridgeStpLinkDao.countAll());
    assertEquals(0, m_bridgeBridgeLinkDao.countAll());
    assertEquals(0, m_bridgeMacLinkDao.countAll());
    assertTrue(m_linkd.runSingleSnmpCollection(asw01.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(samasw01.getId()));
    assertTrue(m_linkd.runSingleSnmpCollection(stcasw01.getId()));
    assertEquals(3, m_bridgeElementDao.countAll());
    assertEquals(0, m_bridgeStpLinkDao.countAll());
    assertEquals(0, m_bridgeBridgeLinkDao.countAll());
    assertEquals(0, m_bridgeMacLinkDao.countAll());
    assertTrue(m_linkd.runTopologyDiscovery(asw01.getId()));
    assertTrue(m_linkd.runTopologyDiscovery(samasw01.getId()));
    assertTrue(m_linkd.runTopologyDiscovery(stcasw01.getId()));
    checkTopology(asw01, stcasw01, samasw01);
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Example 68 with OnmsNode

use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.

the class Nms7918EnIT method testNms7918SAMASW01Bft.

@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = SAMASW01_IP, port = 161, resource = SAMASW01_SNMP_RESOURCE) })
public void testNms7918SAMASW01Bft() 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()));
    assertTrue(!m_linkd.scheduleNodeCollection(samasw01.getId()));
    assertEquals(0, m_bridgeBridgeLinkDao.countAll());
    assertEquals(0, m_bridgeMacLinkDao.countAll());
    assertTrue(m_linkd.runSingleSnmpCollection(samasw01.getId()));
    assertEquals(1, m_bridgeElementDao.countAll());
    assertEquals(0, m_bridgeStpLinkDao.countAll());
    assertEquals(0, m_bridgeBridgeLinkDao.countAll());
    assertEquals(0, m_bridgeMacLinkDao.countAll());
    assertTrue(m_linkd.runTopologyDiscovery(samasw01.getId()));
    assertNull(m_linkd.getQueryManager().useBridgeTopologyUpdateBFT(samasw01.getId()));
    assertEquals(1, m_bridgeElementDao.countAll());
    assertEquals(0, m_bridgeStpLinkDao.countAll());
    assertEquals(0, m_bridgeBridgeLinkDao.countAll());
    assertEquals(31, m_bridgeMacLinkDao.countAll());
    for (BridgeMacLink link : m_bridgeMacLinkDao.findAll()) {
        System.err.println(link.printTopology());
    }
    assertTrue(m_linkd.runSingleSnmpCollection(samasw01.getId()));
    assertEquals(1, m_bridgeElementDao.countAll());
    assertEquals(0, m_bridgeStpLinkDao.countAll());
    assertEquals(0, m_bridgeBridgeLinkDao.countAll());
    assertEquals(31, m_bridgeMacLinkDao.countAll());
    Thread.sleep(5000);
    assertTrue(m_linkd.runTopologyDiscovery(samasw01.getId()));
    assertEquals(0, m_bridgeBridgeLinkDao.countAll());
    assertEquals(31, m_bridgeMacLinkDao.countAll());
    for (BridgeMacLink link : m_bridgeMacLinkDao.findAll()) {
        System.err.println(link.printTopology());
    }
}
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)

Example 69 with OnmsNode

use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.

the class Nms7918EnIT method testNms7918ASW01Bft.

@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = ASW01_IP, port = 161, resource = ASW01_SNMP_RESOURCE) })
public void testNms7918ASW01Bft() throws Exception {
    final OnmsNode asw01 = m_nodeDao.findByForeignId("linkd", ASW01_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(asw01.getId()));
    assertTrue(!m_linkd.scheduleNodeCollection(asw01.getId()));
    assertEquals(0, m_bridgeBridgeLinkDao.countAll());
    assertEquals(0, m_bridgeMacLinkDao.countAll());
    assertTrue(m_linkd.runSingleSnmpCollection(asw01.getId()));
    assertEquals(0, m_bridgeBridgeLinkDao.countAll());
    assertEquals(0, m_bridgeMacLinkDao.countAll());
    assertTrue(m_linkd.runTopologyDiscovery(asw01.getId()));
    assertNull(m_linkd.getQueryManager().useBridgeTopologyUpdateBFT(asw01.getId()));
    assertEquals(1, m_bridgeElementDao.countAll());
    assertEquals(0, m_bridgeStpLinkDao.countAll());
    assertEquals(0, m_bridgeBridgeLinkDao.countAll());
    assertEquals(40, m_bridgeMacLinkDao.countAll());
    for (BridgeMacLink link : m_bridgeMacLinkDao.findAll()) {
        System.err.println(link.printTopology());
    }
    assertTrue(m_linkd.runSingleSnmpCollection(asw01.getId()));
    assertEquals(1, m_bridgeElementDao.countAll());
    assertEquals(0, m_bridgeStpLinkDao.countAll());
    assertEquals(0, m_bridgeBridgeLinkDao.countAll());
    assertEquals(40, m_bridgeMacLinkDao.countAll());
    Thread.sleep(5000);
    assertTrue(m_linkd.runTopologyDiscovery(asw01.getId()));
    assertEquals(1, m_bridgeElementDao.countAll());
    assertEquals(0, m_bridgeStpLinkDao.countAll());
    assertEquals(0, m_bridgeBridgeLinkDao.countAll());
    assertEquals(40, m_bridgeMacLinkDao.countAll());
    for (BridgeMacLink link : m_bridgeMacLinkDao.findAll()) {
        System.err.println(link.printTopology());
    }
}
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)

Example 70 with OnmsNode

use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.

the class PollerServiceTest method testPoll.

public void testPoll() throws EventProxyException {
    final int expectedPolldId = 7;
    OnmsServiceType svcType = new OnmsServiceType();
    svcType.setId(3);
    svcType.setName("HTTP");
    OnmsNode node = new OnmsNode();
    node.setId(1);
    OnmsSnmpInterface snmpIface = new OnmsSnmpInterface(node, 1);
    OnmsIpInterface iface = new OnmsIpInterface("192.168.1.1", node);
    iface.setSnmpInterface(snmpIface);
    final OnmsMonitoredService monSvc = new OnmsMonitoredService(iface, svcType);
    m_eventProxy.send(isA(Event.class));
    expectLastCall().andAnswer(new IAnswer<Object>() {

        @Override
        public Object answer() throws Throwable {
            Event event = (Event) getCurrentArguments()[0];
            assertEquals("Incorrect uei for demandPollService event", EventConstants.DEMAND_POLL_SERVICE_EVENT_UEI, event.getUei());
            assertEquals("Incorrect nodeid for demandPollService event", monSvc.getNodeId().longValue(), event.getNodeid().longValue());
            assertEquals("Incorrect ipadr for demandPollService event", InetAddressUtils.str(monSvc.getIpAddress()), event.getInterface());
            assertEquals("Incorrect ifIndex for demandPollService event", monSvc.getIfIndex(), Integer.valueOf(event.getIfIndex()));
            assertEquals("Incorrect service for demandPollService event", monSvc.getServiceType().getName(), event.getService());
            EventUtils.requireParm(event, EventConstants.PARM_DEMAND_POLL_ID);
            assertEquals(expectedPolldId, EventUtils.getIntParm(event, EventConstants.PARM_DEMAND_POLL_ID, -1));
            return null;
        }
    });
    replay(m_eventProxy);
    m_pollerService.poll(monSvc, expectedPolldId);
    verify(m_eventProxy);
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) OnmsServiceType(org.opennms.netmgt.model.OnmsServiceType) OnmsSnmpInterface(org.opennms.netmgt.model.OnmsSnmpInterface) Event(org.opennms.netmgt.xml.event.Event) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService)

Aggregations

OnmsNode (org.opennms.netmgt.model.OnmsNode)496 Test (org.junit.Test)209 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)116 Transactional (org.springframework.transaction.annotation.Transactional)84 ArrayList (java.util.ArrayList)52 Date (java.util.Date)49 JUnitSnmpAgents (org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)38 OnmsEvent (org.opennms.netmgt.model.OnmsEvent)38 OnmsSnmpInterface (org.opennms.netmgt.model.OnmsSnmpInterface)38 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)37 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)36 InetAddress (java.net.InetAddress)35 Before (org.junit.Before)32 OnmsCategory (org.opennms.netmgt.model.OnmsCategory)31 OnmsResource (org.opennms.netmgt.model.OnmsResource)28 HashMap (java.util.HashMap)27 CriteriaBuilder (org.opennms.core.criteria.CriteriaBuilder)26 File (java.io.File)25 List (java.util.List)25 Path (javax.ws.rs.Path)23