diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2021-01-22 08:32:39 -0500 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-22 08:32:39 -0500 | 
| commit | 75691bb7c4c7c16bb200421ca5defd94abdfd594 (patch) | |
| tree | 59d59c815a6f98d47e1e28b5c4481dc616145b4e | |
| parent | ddbda04e87f3b2989fa8cfe4b737586b10366d7f (diff) | |
| parent | 6ea2bd40d8fee4aba48a2bfbb9ac1abe85bc6ffd (diff) | |
Merge pull request #7904 from volta-networks/fix_test_oid_walk
tests: update snmp test infastructure api test_oid_walk
| -rw-r--r-- | tests/topotests/lib/snmptest.py | 11 | ||||
| -rwxr-xr-x | tests/topotests/simple-snmp-test/test_simple_snmp.py | 2 | 
2 files changed, 9 insertions, 4 deletions
diff --git a/tests/topotests/lib/snmptest.py b/tests/topotests/lib/snmptest.py index ba5835dcf7..910e901ade 100644 --- a/tests/topotests/lib/snmptest.py +++ b/tests/topotests/lib/snmptest.py @@ -80,11 +80,14 @@ class SnmpTester(object):      def _parse_multiline(self, snmp_output):          results = snmp_output.strip().split("\r\n") -        out_dict = {} +        out_dict = {} +        out_list = []          for response in results:              out_dict[self._get_snmp_oid(response)] = self._get_snmp_value(response) -        return out_dict +            out_list.append(self._get_snmp_value(response)) + +        return out_dict, out_list      def get(self, oid):          cmd = "snmpget {0} {1}".format(self._snmp_config(), oid) @@ -114,7 +117,7 @@ class SnmpTester(object):          return self.get_next(oid) == value      def test_oid_walk(self, oid, values, oids=None): -        results_dict = self.walk(oid) +        results_dict, results_list = self.walk(oid)          print("res {}".format(results_dict))          if oids is not None:              index = 0 @@ -124,4 +127,4 @@ class SnmpTester(object):                  index += 1              return True -        return results_dict.values() == values +        return results_list == values diff --git a/tests/topotests/simple-snmp-test/test_simple_snmp.py b/tests/topotests/simple-snmp-test/test_simple_snmp.py index 3dcbfe44a0..1e56252ea3 100755 --- a/tests/topotests/simple-snmp-test/test_simple_snmp.py +++ b/tests/topotests/simple-snmp-test/test_simple_snmp.py @@ -130,6 +130,8 @@ def test_r1_bgp_version():      r1_snmp = SnmpTester(r1, "1.1.1.1", "public", "2c")      assert r1_snmp.test_oid("bgpVersin", None)      assert r1_snmp.test_oid("bgpVersion", "10") +    assert r1_snmp.test_oid_walk("bgpVersion", ["10"]) +    assert r1_snmp.test_oid_walk("bgpVersion", ["10"], ["0"])  if __name__ == "__main__":  | 
