use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents 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);
}
use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents 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);
}
use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents 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());
}
}
use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents 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());
}
}
use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.
the class JUnitSnmpAgentExecutionListener method beforeTestMethod.
@Override
public void beforeTestMethod(final TestContext testContext) throws Exception {
super.beforeTestClass(testContext);
final JUnitSnmpAgents agents = findAgentListAnnotation(testContext);
final JUnitSnmpAgent agent = findAgentAnnotation(testContext);
// save the existing strategy property
String strategy = System.getProperty(STRATEGY_CLASS_PROPERTY);
testContext.setAttribute(STRATEGY_CLASS_KEY, strategy);
// if no annotations exists then do nothing
if (agents == null && agent == null) {
// no annotations found
return;
}
// determine if we should use the mock strategry
boolean useMockSnmpStrategy = shouldUseMockStrategy(agents, agent);
// override the configured strategy to use the mock strategy if necessary
if (useMockSnmpStrategy) {
strategy = MockSnmpStrategy.class.getName();
System.setProperty(STRATEGY_CLASS_PROPERTY, MockSnmpStrategy.class.getName());
LOG.info("Forcing JUnit SNMP Agent to use mock strategy");
}
LOG.debug("Initializing JUnit SNMP Agent with strategy: {}", strategy == null ? "default" : strategy);
final MockSnmpDataProvider provider = useMockSnmpStrategy ? new MockSnmpStrategyDataProvider() : new MockSnmpAgentDataProvider();
testContext.setAttribute(PROVIDER_KEY, provider);
if (agents != null) {
for (final JUnitSnmpAgent a : agents.value()) {
handleSnmpAgent(testContext, a, useMockSnmpStrategy, provider);
}
}
handleSnmpAgent(testContext, agent, useMockSnmpStrategy, provider);
if (testContext.getTestInstance() instanceof MockSnmpDataProviderAware) {
LOG.debug("injecting data provider into MockSnmpDataProviderAware test: {}", testContext.getTestInstance());
((MockSnmpDataProviderAware) testContext.getTestInstance()).setMockSnmpDataProvider(provider);
}
}
Aggregations