use of org.opennms.netmgt.snmp.proxy.common.testutils.IPAddressGatheringTracker in project opennms by OpenNMS.
the class LocationAwareSnmpClientIT method canWalkIpAddressTableViaCurrentLocation.
/**
* Verifies that SNMP WALKs are successful, and return the same results when using
* the LocationAwareSnmpClient.
*/
@Test
public void canWalkIpAddressTableViaCurrentLocation() throws UnknownHostException, InterruptedException, ExecutionException {
// Gather the list of IP addresses
final IPAddressGatheringTracker tracker = new IPAddressGatheringTracker();
locationAwareSnmpClient.walk(agentConfig, tracker).withDescription(tracker.getDescription()).execute().get();
ExpectedResults.compareToKnownIpAddressList(tracker.getIpAddresses());
// Now determine their interface indices using a different type of tracker
final Set<SnmpInstId> ipAddrs = new TreeSet<SnmpInstId>();
for (final String ipAddr : tracker.getIpAddresses()) {
ipAddrs.add(new SnmpInstId(InetAddressUtils.toOid(InetAddressUtils.addr(ipAddr))));
}
IpAddrTable ipAddrTable = new IpAddrTable(agentConfig.getAddress(), ipAddrs);
locationAwareSnmpClient.walk(agentConfig, ipAddrTable).withDescription(tracker.getDescription()).execute().get();
ExpectedResults.compareToKnownIfIndices(ipAddrTable.getIfIndices());
}
use of org.opennms.netmgt.snmp.proxy.common.testutils.IPAddressGatheringTracker in project opennms by OpenNMS.
the class LocationAwareSnmpClientIT method canWalkIpAddressTableDirectly.
/**
* Verifies that SNMP WALKs are successful when directly using SnmpUtils.
*
* Used a basis for comparison.
*/
@Test
public void canWalkIpAddressTableDirectly() throws InterruptedException {
// Gather the list of IP addresses
final IPAddressGatheringTracker tracker = new IPAddressGatheringTracker();
try (SnmpWalker walker = SnmpUtils.createWalker(agentConfig, tracker.getDescription(), tracker)) {
walker.start();
walker.waitFor();
}
ExpectedResults.compareToKnownIpAddressList(tracker.getIpAddresses());
// Now determine their interface indices using a different type of tracker
final Set<SnmpInstId> ipAddrs = new TreeSet<SnmpInstId>();
for (final String ipAddr : tracker.getIpAddresses()) {
ipAddrs.add(new SnmpInstId(InetAddressUtils.toOid(InetAddressUtils.addr(ipAddr))));
}
IpAddrTable ipAddrTable = new IpAddrTable(agentConfig.getAddress(), ipAddrs);
try (SnmpWalker walker = SnmpUtils.createWalker(agentConfig, "ipAddrTable", ipAddrTable)) {
walker.start();
walker.waitFor();
}
ExpectedResults.compareToKnownIfIndices(ipAddrTable.getIfIndices());
}
use of org.opennms.netmgt.snmp.proxy.common.testutils.IPAddressGatheringTracker in project opennms by OpenNMS.
the class LocationAwareSnmpClientIT method canWalkIpAddressTableViaAnotherLocation.
/**
* Verifies that the IP Address tables can be walked when using a remote location.
*
* This should invoke the route in the Camel context initialize in this blueprint.
*/
@Test(timeout = 60000)
public void canWalkIpAddressTableViaAnotherLocation() throws Exception {
assertNotEquals(REMOTE_LOCATION_NAME, identity.getLocation());
final IPAddressGatheringTracker tracker = new IPAddressGatheringTracker();
locationAwareSnmpClient.walk(agentConfig, tracker).withDescription(tracker.getDescription()).withLocation(REMOTE_LOCATION_NAME).execute().get();
ExpectedResults.compareToKnownIpAddressList(tracker.getIpAddresses());
}
Aggregations