Search in sources :

Example 1 with IPAddressGatheringTracker

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());
}
Also used : IpAddrTable(org.opennms.netmgt.provision.service.snmp.IpAddrTable) TreeSet(java.util.TreeSet) SnmpInstId(org.opennms.netmgt.snmp.SnmpInstId) IPAddressGatheringTracker(org.opennms.netmgt.snmp.proxy.common.testutils.IPAddressGatheringTracker) Test(org.junit.Test) CamelBlueprintTest(org.opennms.core.test.camel.CamelBlueprintTest)

Example 2 with IPAddressGatheringTracker

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());
}
Also used : SnmpWalker(org.opennms.netmgt.snmp.SnmpWalker) IpAddrTable(org.opennms.netmgt.provision.service.snmp.IpAddrTable) TreeSet(java.util.TreeSet) SnmpInstId(org.opennms.netmgt.snmp.SnmpInstId) IPAddressGatheringTracker(org.opennms.netmgt.snmp.proxy.common.testutils.IPAddressGatheringTracker) Test(org.junit.Test) CamelBlueprintTest(org.opennms.core.test.camel.CamelBlueprintTest)

Example 3 with IPAddressGatheringTracker

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());
}
Also used : IPAddressGatheringTracker(org.opennms.netmgt.snmp.proxy.common.testutils.IPAddressGatheringTracker) Test(org.junit.Test) CamelBlueprintTest(org.opennms.core.test.camel.CamelBlueprintTest)

Aggregations

Test (org.junit.Test)3 CamelBlueprintTest (org.opennms.core.test.camel.CamelBlueprintTest)3 IPAddressGatheringTracker (org.opennms.netmgt.snmp.proxy.common.testutils.IPAddressGatheringTracker)3 TreeSet (java.util.TreeSet)2 IpAddrTable (org.opennms.netmgt.provision.service.snmp.IpAddrTable)2 SnmpInstId (org.opennms.netmgt.snmp.SnmpInstId)2 SnmpWalker (org.opennms.netmgt.snmp.SnmpWalker)1