use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgent in project opennms by OpenNMS.
the class InstanceStrategyIntegrationTest method testAgentTimeout.
/*
* Test the poller's behaviour when the SNMP agent times outs. Verify:
* That the proper events are sent by the daemon. The AP state in the
* database after the poll.
*/
@Test
@JUnitSnmpAgent(host = "10.1.0.2", resource = SNMP_DATA_PATH + "10.1.0.2-walk.txt")
public void testAgentTimeout() throws Exception {
// Add AP1 to the default package
addNewAccessPoint("ap1", AP1_MAC, "default");
// Add a controller to the default package
addNewController("amc1", "10.1.0.2", "default");
// Set AP1 as UP
setOidValueForAccessPoint("10.1.0.2", AP1_MAC, 1);
// Make the SNMP agent timeout
SnmpAgentConfig agentConfig = SnmpPeerFactory.getInstance().getAgentConfig(InetAddressUtils.getInetAddress("10.1.0.2"));
Sleeper.getInstance().setSleepTime(agentConfig.getTimeout() + 1000);
try {
// Anticipate the event
anticipateApStatusEvent(AP1_MAC, "DOWN");
// Initialize and start the daemon
initApmdWithConfig(getStandardConfig());
m_apm.start();
// Verify the events
verifyAnticipated(POLLING_INTERVAL_DELTA + 2000);
// Verify the state of the AP in the database
OnmsAccessPoint ap1 = m_accessPointDao.get(AP1_MAC);
assertTrue(ap1.getStatus() == AccessPointStatus.OFFLINE);
} finally {
// Clear the timeout
Sleeper.getInstance().setSleepTime(0);
}
}
use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgent in project opennms by OpenNMS.
the class ProvisionerIT method testIfIndexChangeNms6567.
// fail if we take more than five minutes
@Test(timeout = 300000)
@JUnitSnmpAgent(host = "198.51.100.201", port = 161, resource = "classpath:/snmpTestData3.properties")
public void testIfIndexChangeNms6567() throws Exception {
importFromResource("classpath:/requisition_then_scan2.xml", Boolean.TRUE.toString());
final List<OnmsNode> nodes = getNodeDao().findAll();
final OnmsNode node = nodes.get(0);
runPendingScans();
m_nodeDao.flush();
assertEquals(2, getInterfaceDao().countAll());
// Verify the initial state of the ifIndex values
assertEquals(5, getInterfaceDao().get(node, "198.51.100.201").getIfIndex().intValue());
assertEquals(5, getInterfaceDao().get(node, "198.51.100.201").getSnmpInterface().getIfIndex().intValue());
assertEquals(4, getInterfaceDao().get(node, "198.51.100.204").getIfIndex().intValue());
assertEquals(4, getInterfaceDao().get(node, "198.51.100.204").getSnmpInterface().getIfIndex().intValue());
// This is a pretty pedantic check :)
assertEquals(4, getSnmpInterfaceDao().findByNodeIdAndIfIndex(node.getId(), 4).getIfIndex().intValue());
assertEquals(5, getSnmpInterfaceDao().findByNodeIdAndIfIndex(node.getId(), 5).getIfIndex().intValue());
// Swap the ifIndex values for the two interfaces
m_mockSnmpDataProvider.updateIntValue(new SnmpAgentAddress(InetAddressUtils.addr("198.51.100.201"), 161), ".1.3.6.1.2.1.4.20.1.2.198.51.100.201", 4);
m_mockSnmpDataProvider.updateIntValue(new SnmpAgentAddress(InetAddressUtils.addr("198.51.100.201"), 161), ".1.3.6.1.2.1.4.20.1.2.198.51.100.204", 5);
// Rescan
m_mockEventIpcManager.sendEventToListeners(nodeUpdated(node.getId()));
runPendingScans();
m_nodeDao.flush();
assertEquals(2, getInterfaceDao().countAll());
// Verify that the ifIndex fields on the interfaces have been updated
assertEquals(4, getInterfaceDao().get(node, "198.51.100.201").getIfIndex().intValue());
assertEquals(4, getInterfaceDao().get(node, "198.51.100.201").getSnmpInterface().getIfIndex().intValue());
assertEquals(5, getInterfaceDao().get(node, "198.51.100.204").getIfIndex().intValue());
assertEquals(5, getInterfaceDao().get(node, "198.51.100.204").getSnmpInterface().getIfIndex().intValue());
}
use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgent in project opennms by OpenNMS.
the class SnmpCollectorWithMibPropertiesIT method testCollect.
/**
* Test collection with MibObj Properties.
*
* @throws Exception the exception
*/
@Test
@JUnitCollector(datacollectionType = "snmp", datacollectionConfig = "/org/opennms/netmgt/config/datacollection-config-NMS8484.xml")
@JUnitSnmpAgent(resource = "/org/opennms/netmgt/snmp/airespace.properties")
public void testCollect() throws Exception {
System.setProperty("org.opennms.netmgt.collectd.SnmpCollector.limitCollectionToInstances", "true");
CollectionSet collectionSet = m_collectionSpecification.collect(m_collectionAgent);
assertEquals("collection status", CollectionStatus.SUCCEEDED, collectionSet.getStatus());
CollectorTestUtils.persistCollectionSet(m_rrdStrategy, m_resourceStorageDao, m_collectionSpecification, collectionSet);
Map<String, String> slot0 = m_resourceStorageDao.getStringAttributes(ResourcePath.get("snmp", "1", "bsnAPIfLoadParametersEntry", "132.178.97.20.31.224.0"));
assertEquals("AP84b2.6111.29ac", slot0.get("bsnAPName"));
assertEquals("0", slot0.get("slotNumber"));
Map<String, String> slot1 = m_resourceStorageDao.getStringAttributes(ResourcePath.get("snmp", "1", "bsnAPIfLoadParametersEntry", "132.178.97.20.31.224.1"));
assertEquals("AP84b2.6111.29ac", slot1.get("bsnAPName"));
assertEquals("1", slot1.get("slotNumber"));
}
use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgent in project opennms by OpenNMS.
the class SnmpCollectorWithMibPropertiesIT method testCollectCiscoQoS.
/**
* Test collection for Cisco QoS with MibObj Properties.
*
* @throws Exception the exception
*/
@Test
@JUnitCollector(datacollectionType = "snmp", datacollectionConfig = "/org/opennms/netmgt/config/datacollection-config-cisco-qos.xml")
@JUnitSnmpAgent(resource = "/org/opennms/netmgt/snmp/cisco-qos.properties")
public void testCollectCiscoQoS() throws Exception {
System.setProperty("org.opennms.netmgt.collectd.SnmpCollector.limitCollectionToInstances", "true");
CollectionSet collectionSet = m_collectionSpecification.collect(m_collectionAgent);
assertEquals("collection status", CollectionStatus.SUCCEEDED, collectionSet.getStatus());
CollectorTestUtils.persistCollectionSet(m_rrdStrategy, m_resourceStorageDao, m_collectionSpecification, collectionSet);
Map<String, String> map = m_resourceStorageDao.getStringAttributes(ResourcePath.get("snmp", "1", "cbQosCMStatsEntry", "290.508801"));
assertEquals("OUTBOUND-LLQ", map.get("cbQosClassMapPolicy"));
assertEquals("GESTION-ROUTING", map.get("cbQosClassMapName"));
assertEquals("Conexion Valencia", map.get("ifAlias"));
}
use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgent in project opennms by OpenNMS.
the class SnmpCollectorIT method verifyPersistedStringProperties.
@Test
@Transactional
@JUnitCollector(datacollectionConfig = "/org/opennms/netmgt/config/datacollection-brocade-no-ifaces-config.xml", datacollectionType = "snmp", anticipateRrds = { "1/brocadeFCPortIndex/1/swFCPortTxWords", "1/brocadeFCPortIndex/1/swFCPortRxWords", "1/brocadeFCPortIndex/2/swFCPortTxWords", "1/brocadeFCPortIndex/2/swFCPortRxWords", "1/brocadeFCPortIndex/3/swFCPortTxWords", "1/brocadeFCPortIndex/3/swFCPortRxWords", "1/brocadeFCPortIndex/4/swFCPortTxWords", "1/brocadeFCPortIndex/4/swFCPortRxWords", "1/brocadeFCPortIndex/5/swFCPortTxWords", "1/brocadeFCPortIndex/5/swFCPortRxWords", "1/brocadeFCPortIndex/6/swFCPortTxWords", "1/brocadeFCPortIndex/6/swFCPortRxWords", "1/brocadeFCPortIndex/7/swFCPortTxWords", "1/brocadeFCPortIndex/7/swFCPortRxWords", "1/brocadeFCPortIndex/8/swFCPortTxWords", "1/brocadeFCPortIndex/8/swFCPortRxWords" }, anticipateFiles = { "1", "1/brocadeFCPortIndex", "1/brocadeFCPortIndex/1/strings.properties", "1/brocadeFCPortIndex/1", "1/brocadeFCPortIndex/2/strings.properties", "1/brocadeFCPortIndex/2", "1/brocadeFCPortIndex/3/strings.properties", "1/brocadeFCPortIndex/3", "1/brocadeFCPortIndex/4/strings.properties", "1/brocadeFCPortIndex/4", "1/brocadeFCPortIndex/5/strings.properties", "1/brocadeFCPortIndex/5", "1/brocadeFCPortIndex/6/strings.properties", "1/brocadeFCPortIndex/6", "1/brocadeFCPortIndex/7/strings.properties", "1/brocadeFCPortIndex/7", "1/brocadeFCPortIndex/8/strings.properties", "1/brocadeFCPortIndex/8" })
@JUnitSnmpAgent(resource = "/org/opennms/netmgt/snmp/brocadeTestData1.properties")
public void verifyPersistedStringProperties() throws Exception {
// Perform the collection
CollectionSet collectionSet = m_collectionSpecification.collect(m_collectionAgent);
assertEquals("collection status", CollectionStatus.SUCCEEDED, collectionSet.getStatus());
// Persist
CollectorTestUtils.persistCollectionSet(m_rrdStrategy, m_resourceStorageDao, m_collectionSpecification, collectionSet);
// Verify results on disk
Map<String, String> properties = m_resourceStorageDao.getStringAttributes(ResourcePath.get("snmp", "1", "brocadeFCPortIndex", "1"));
// "string" attributes should convert the octets directly to a string
String value = properties.get("swFCPortName");
assertTrue(value.startsWith("..3DUfw"));
// "hexstring" attributes should convert the octets to a hex string
// see http://issues.opennms.org/browse/NMS-7367
value = properties.get("swFCPortWwn");
assertEquals("1100334455667788", value);
}
Aggregations