]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: update snmp test infastructure api test_oid_walk 7904/head
authorKaren Schoener <karen@voltanet.io>
Thu, 21 Jan 2021 16:35:11 +0000 (11:35 -0500)
committerKaren Schoener <karen@voltanet.io>
Thu, 21 Jan 2021 16:43:03 +0000 (11:43 -0500)
Update test_oid_walk to either validate specific oids or
to validate all rows walked.

Signed-off-by: Karen Schoener <karen@voltanet.io>
tests/topotests/lib/snmptest.py
tests/topotests/simple-snmp-test/test_simple_snmp.py

index ba5835dcf757fc8674e727bca93887df790124f0..910e901adeb85d8810fbb6d1e87326cd253313ce 100644 (file)
@@ -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
index 2b609ef14c54dd07f34cbc335452a88aeec81153..25bb9f71952e2d20299c7fab9419122b42cdcc1f 100755 (executable)
@@ -120,11 +120,13 @@ def test_r1_bgp_version():
     "Wait for protocol convergence"
     tgen = get_topogen()
 
-    #tgen.mininet_cli()
+    # tgen.mininet_cli()
     r1 = tgen.net.get("r1")
     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__":