]> git.proxmox.com Git - mirror_frr.git/commitdiff
eigrp-topo1: Change Route verification to use json
authorMartin Winter <mwinter@opensourcerouting.org>
Tue, 12 Sep 2017 23:36:38 +0000 (16:36 -0700)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 28 Nov 2018 01:22:12 +0000 (20:22 -0500)
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
tests/topotests/eigrp-topo1/r1/show_ip_route.json_ref [new file with mode: 0644]
tests/topotests/eigrp-topo1/r1/show_ip_route.ref [deleted file]
tests/topotests/eigrp-topo1/r2/show_ip_route.json_ref [new file with mode: 0644]
tests/topotests/eigrp-topo1/r2/show_ip_route.ref [deleted file]
tests/topotests/eigrp-topo1/r3/show_ip_route.json_ref [new file with mode: 0644]
tests/topotests/eigrp-topo1/r3/show_ip_route.ref [deleted file]
tests/topotests/eigrp-topo1/test_eigrp_topo1.py

diff --git a/tests/topotests/eigrp-topo1/r1/show_ip_route.json_ref b/tests/topotests/eigrp-topo1/r1/show_ip_route.json_ref
new file mode 100644 (file)
index 0000000..d1216d7
--- /dev/null
@@ -0,0 +1,94 @@
+{
+  "192.168.1.0/24":[
+    {
+      "prefix":"192.168.1.0/24",
+      "protocol":"eigrp",
+      "distance":0,
+      "metric":0,
+      "nexthops":[
+        {
+          "directlyConnected":true,
+          "interfaceName":"r1-eth0",
+          "active":true
+        }
+      ]
+    },
+    {
+      "prefix":"192.168.1.0/24",
+      "protocol":"connected",
+      "selected":true,
+      "nexthops":[
+        {
+          "fib":true,
+          "directlyConnected":true,
+          "interfaceName":"r1-eth0",
+          "active":true
+        }
+      ]
+    }
+  ],
+  "192.168.3.0/24":[
+    {
+      "prefix":"192.168.3.0/24",
+      "protocol":"eigrp",
+      "selected":true,
+      "distance":0,
+      "metric":0,
+      "nexthops":[
+        {
+          "fib":true,
+          "ip":"193.1.1.2",
+          "afi":"ipv4",
+          "interfaceName":"r1-eth1",
+          "active":true
+        }
+      ]
+    }
+  ],
+  "193.1.1.0/26":[
+    {
+      "prefix":"193.1.1.0/26",
+      "protocol":"eigrp",
+      "distance":0,
+      "metric":0,
+      "nexthops":[
+        {
+          "directlyConnected":true,
+          "interfaceName":"r1-eth1",
+          "active":true
+        }
+      ]
+    },
+    {
+      "prefix":"193.1.1.0/26",
+      "protocol":"connected",
+      "selected":true,
+      "nexthops":[
+        {
+          "fib":true,
+          "directlyConnected":true,
+          "interfaceName":"r1-eth1",
+          "active":true
+        }
+      ]
+    }
+  ],
+  "193.1.2.0/24":[
+    {
+      "prefix":"193.1.2.0/24",
+      "protocol":"eigrp",
+      "selected":true,
+      "distance":0,
+      "metric":0,
+      "nexthops":[
+        {
+          "fib":true,
+          "ip":"193.1.1.2",
+          "afi":"ipv4",
+          "interfaceName":"r1-eth1",
+          "active":true
+        }
+      ]
+    }
+  ]
+}
diff --git a/tests/topotests/eigrp-topo1/r1/show_ip_route.ref b/tests/topotests/eigrp-topo1/r1/show_ip_route.ref
deleted file mode 100644 (file)
index 7f7a2ff..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-Codes: K - kernel route, C - connected, S - static, R - RIP,
-       O - OSPF, I - IS-IS, B - BGP, P - PIM, E - EIGRP, N - NHRP,
-       T - Table, v - VNC, V - VNC-Direct, A - Babel,
-       > - selected route, * - FIB route
-
-E   192.168.1.0/24 [0/0] is directly connected, r1-eth0
-C>* 192.168.1.0/24 is directly connected, r1-eth0
-E>* 192.168.3.0/24 [0/0] via 193.1.1.2, r1-eth1
-E   193.1.1.0/26 [0/0] is directly connected, r1-eth1
-C>* 193.1.1.0/26 is directly connected, r1-eth1
-E>* 193.1.2.0/24 [0/0] via 193.1.1.2, r1-eth1
diff --git a/tests/topotests/eigrp-topo1/r2/show_ip_route.json_ref b/tests/topotests/eigrp-topo1/r2/show_ip_route.json_ref
new file mode 100644 (file)
index 0000000..ea1d86b
--- /dev/null
@@ -0,0 +1,94 @@
+{
+  "192.168.1.0/24":[
+    {
+      "prefix":"192.168.1.0/24",
+      "protocol":"eigrp",
+      "selected":true,
+      "distance":0,
+      "metric":0,
+      "nexthops":[
+        {
+          "fib":true,
+          "ip":"193.1.1.1",
+          "afi":"ipv4",
+          "interfaceName":"r2-eth0",
+          "active":true
+        }
+      ]
+    }
+  ],
+  "192.168.3.0/24":[
+    {
+      "prefix":"192.168.3.0/24",
+      "protocol":"eigrp",
+      "selected":true,
+      "distance":0,
+      "metric":0,
+      "nexthops":[
+        {
+          "fib":true,
+          "ip":"193.1.2.2",
+          "afi":"ipv4",
+          "interfaceName":"r2-eth1",
+          "active":true
+        }
+      ]
+    }
+  ],
+  "193.1.1.0/26":[
+    {
+      "prefix":"193.1.1.0/26",
+      "protocol":"eigrp",
+      "distance":0,
+      "metric":0,
+      "nexthops":[
+        {
+          "directlyConnected":true,
+          "interfaceName":"r2-eth0",
+          "active":true
+        }
+      ]
+    },
+    {
+      "prefix":"193.1.1.0/26",
+      "protocol":"connected",
+      "selected":true,
+      "nexthops":[
+        {
+          "fib":true,
+          "directlyConnected":true,
+          "interfaceName":"r2-eth0",
+          "active":true
+        }
+      ]
+    }
+  ],
+  "193.1.2.0/24":[
+    {
+      "prefix":"193.1.2.0/24",
+      "protocol":"eigrp",
+      "distance":0,
+      "metric":0,
+      "nexthops":[
+        {
+          "directlyConnected":true,
+          "interfaceName":"r2-eth1",
+          "active":true
+        }
+      ]
+    },
+    {
+      "prefix":"193.1.2.0/24",
+      "protocol":"connected",
+      "selected":true,
+      "nexthops":[
+        {
+          "fib":true,
+          "directlyConnected":true,
+          "interfaceName":"r2-eth1",
+          "active":true
+        }
+      ]
+    }
+  ]
+}
diff --git a/tests/topotests/eigrp-topo1/r2/show_ip_route.ref b/tests/topotests/eigrp-topo1/r2/show_ip_route.ref
deleted file mode 100644 (file)
index 13ef7c6..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-Codes: K - kernel route, C - connected, S - static, R - RIP,
-       O - OSPF, I - IS-IS, B - BGP, P - PIM, E - EIGRP, N - NHRP,
-       T - Table, v - VNC, V - VNC-Direct, A - Babel,
-       > - selected route, * - FIB route
-
-E>* 192.168.1.0/24 [0/0] via 193.1.1.1, r2-eth0
-E>* 192.168.3.0/24 [0/0] via 193.1.2.2, r2-eth1
-E   193.1.1.0/26 [0/0] is directly connected, r2-eth0
-C>* 193.1.1.0/26 is directly connected, r2-eth0
-E   193.1.2.0/24 [0/0] is directly connected, r2-eth1
-C>* 193.1.2.0/24 is directly connected, r2-eth1
diff --git a/tests/topotests/eigrp-topo1/r3/show_ip_route.json_ref b/tests/topotests/eigrp-topo1/r3/show_ip_route.json_ref
new file mode 100644 (file)
index 0000000..076e4b0
--- /dev/null
@@ -0,0 +1,112 @@
+{
+  "192.168.1.0/24":[
+    {
+      "prefix":"192.168.1.0/24",
+      "protocol":"eigrp",
+      "selected":true,
+      "distance":0,
+      "metric":0,
+      "nexthops":[
+        {
+          "fib":true,
+          "ip":"193.1.2.1",
+          "afi":"ipv4",
+          "interfaceName":"r3-eth1",
+          "active":true
+        }
+      ]
+    }
+  ],
+  "192.168.2.0/24":[
+    {
+      "prefix":"192.168.2.0/24",
+      "protocol":"static",
+      "selected":true,
+      "distance":1,
+      "metric":0,
+      "nexthops":[
+        {
+          "fib":true,
+          "ip":"192.168.3.10",
+          "afi":"ipv4",
+          "interfaceName":"r3-eth0",
+          "active":true
+        }
+      ]
+    }
+  ],
+  "192.168.3.0/24":[
+    {
+      "prefix":"192.168.3.0/24",
+      "protocol":"eigrp",
+      "distance":0,
+      "metric":0,
+      "nexthops":[
+        {
+          "directlyConnected":true,
+          "interfaceName":"r3-eth0",
+          "active":true
+        }
+      ]
+    },
+    {
+      "prefix":"192.168.3.0/24",
+      "protocol":"connected",
+      "selected":true,
+      "nexthops":[
+        {
+          "fib":true,
+          "directlyConnected":true,
+          "interfaceName":"r3-eth0",
+          "active":true
+        }
+      ]
+    }
+  ],
+  "193.1.1.0/26":[
+    {
+      "prefix":"193.1.1.0/26",
+      "protocol":"eigrp",
+      "selected":true,
+      "distance":0,
+      "metric":0,
+      "nexthops":[
+        {
+          "fib":true,
+          "ip":"193.1.2.1",
+          "afi":"ipv4",
+          "interfaceName":"r3-eth1",
+          "active":true
+        }
+      ]
+    }
+  ],
+  "193.1.2.0/24":[
+    {
+      "prefix":"193.1.2.0/24",
+      "protocol":"eigrp",
+      "distance":0,
+      "metric":0,
+      "nexthops":[
+        {
+          "directlyConnected":true,
+          "interfaceName":"r3-eth1",
+          "active":true
+        }
+      ]
+    },
+    {
+      "prefix":"193.1.2.0/24",
+      "protocol":"connected",
+      "selected":true,
+      "nexthops":[
+        {
+          "fib":true,
+          "directlyConnected":true,
+          "interfaceName":"r3-eth1",
+          "active":true
+        }
+      ]
+    }
+  ]
+}
diff --git a/tests/topotests/eigrp-topo1/r3/show_ip_route.ref b/tests/topotests/eigrp-topo1/r3/show_ip_route.ref
deleted file mode 100644 (file)
index c12965c..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-Codes: K - kernel route, C - connected, S - static, R - RIP,
-       O - OSPF, I - IS-IS, B - BGP, P - PIM, E - EIGRP, N - NHRP,
-       T - Table, v - VNC, V - VNC-Direct, A - Babel,
-       > - selected route, * - FIB route
-
-E>* 192.168.1.0/24 [0/0] via 193.1.2.1, r3-eth1
-S>* 192.168.2.0/24 [1/0] via 192.168.3.10, r3-eth0
-E   192.168.3.0/24 [0/0] is directly connected, r3-eth0
-C>* 192.168.3.0/24 is directly connected, r3-eth0
-E>* 193.1.1.0/26 [0/0] via 193.1.2.1, r3-eth1
-E   193.1.2.0/24 [0/0] is directly connected, r3-eth1
-C>* 193.1.2.0/24 is directly connected, r3-eth1
index e50261b070b1a92a1b21212826fc1301cc197c6e..aff28b1232bb58956e3ea073cc680363f88ce3df 100755 (executable)
@@ -31,6 +31,7 @@ import os
 import re
 import sys
 import pytest
+import json
 
 # Save the Current Working Directory to find configuration files.
 CWD = os.path.dirname(os.path.realpath(__file__))
@@ -166,6 +167,42 @@ def test_eigrp_routes():
         assert failures == 0, 'SHOW IP EIGRP failed for router {}:\n{}'.format(router.name, diff)
 
 
+# def test_zebra_ipv4_routingTable():
+#     "Test 'show ip route'"
+
+#     tgen = get_topogen()
+#     # Don't run this test if we have any failure.
+#     if tgen.routers_have_failure():
+#         pytest.skip(tgen.errors)
+
+#     # Verify OSPFv2 Routing Table
+#     logger.info("Verifying Zebra IPv4 Routing Table")
+
+#     failures = 0
+#     router_list = tgen.routers().values()
+#     for router in router_list:
+#         refTableFile = '{}/{}/show_ip_route.ref'.format(CWD, router.name)
+
+#         # Read expected result from file
+#         expected = open(refTableFile).read().rstrip()
+
+#         # Actual output from router
+#         actual = router.vtysh_cmd('show ip route').rstrip()
+
+#         # Generate Diff
+#         diff = topotest.difflines(actual, expected,
+#                                   title1="actual Zebra IPv4 routing table",
+#                                   title2="expected Zebra IPv4 routing table")
+
+#         # Empty string if it matches, otherwise diff contains unified diff
+#         if diff:
+#             failures += 1
+#         else:
+#             logger.info('{} ok'.format(router.name))
+
+#         assert failures == 0, 'Zebra IPv4 Routing Table verification failed for router {}:\n{}'.format(router.name, diff)
+
+
 def test_zebra_ipv4_routingTable():
     "Test 'show ip route'"
 
@@ -174,32 +211,27 @@ def test_zebra_ipv4_routingTable():
     if tgen.routers_have_failure():
         pytest.skip(tgen.errors)
 
-    # Verify OSPFv3 Routing Table
-    logger.info("Verifying Zebra IPv4 Routing Table")
-
     failures = 0
     router_list = tgen.routers().values()
     for router in router_list:
-        refTableFile = '{}/{}/show_ip_route.ref'.format(CWD, router.name)
+        output = router.vtysh_cmd('show ip route json', isjson=True)
+        refTableFile = '{}/{}/show_ip_route.json_ref'.format(CWD, router.name)
+        expected = json.loads(open(refTableFile).read())
 
-        # Read expected result from file
-        expected = open(refTableFile).read().rstrip()
-
-        # Actual output from router
-        actual = router.vtysh_cmd('show ip route').rstrip()
+        # diff = topotest.json_cmp(output, expected)
 
-        # Generate Diff
-        diff = topotest.difflines(actual, expected,
-                                  title1="actual Zebra IPv4 routing table",
-                                  title2="expected Zebra IPv4 routing table")
+        assertmsg = 'Zebra IPv4 Routing Table verification failed for router {}'.format(router.name)
+        assert topotest.json_cmp(output, expected) is None, assertmsg
 
-        # Empty string if it matches, otherwise diff contains unified diff
-        if diff:
-            failures += 1
-        else:
-            logger.info('{} ok'.format(router.name))
+        # # Empty string if it matches, otherwise diff contains unified diff
+        # if diff:
+        #     logger.info('{} NOT ok'.format(router.name))
+        #     print("diff = %s" % str(diff))
+        #     failures += 1
+        # else:
+        #     logger.info('{} ok'.format(router.name))
 
-        assert failures == 0, 'Zebra IPv4 Routing Table verification failed for router {}:\n{}'.format(router.name, diff)
+        assert failures == 0, 'Zebra IPv4 Routing Table verification failed for router {}:\n{}'.format(router.name, diff)
 
 
 def test_shutdown_check_stderr():