]> git.proxmox.com Git - mirror_frr.git/commitdiff
tests: pbr topotest flaps ifaces, maps, nh-groups
authorWesley Coakley <wcoakley@cumulusnetworks.com>
Fri, 5 Jun 2020 21:42:11 +0000 (17:42 -0400)
committerWesley Coakley <wcoakley@cumulusnetworks.com>
Mon, 8 Jun 2020 18:27:21 +0000 (14:27 -0400)
Signed-off-by: Wesley Coakley <wcoakley@cumulusnetworks.com>
tests/topotests/pbr-topo1/r1/pbr-map.json
tests/topotests/pbr-topo1/r1/pbrd.conf
tests/topotests/pbr-topo1/test_pbr_topo1.py

index 3d08b75993c59e05467617b166be4c3a9a02332e..c0a40afc7c52d2b2c86f7e4118de4ac2e92d511b 100644 (file)
@@ -1,14 +1,36 @@
 [
   {
     "name":"AKIHABARA",
-    "valid":true,
+    "valid":false,
     "policies":[
       {
         "sequenceNumber":5,
-        "vrfUnchanged":true,
-        "installed":false,
+        "vrfUnchanged":false,
+        "installed":true,
         "installedReason":"Valid",
+        "nexthopGroup": {
+          "name":"C",
+          "installed":true,
+          "installedInternally":1
+        },
         "matchDst":"192.168.4.0\/24"
+      },
+      {
+        "sequenceNumber":10,
+        "vrfUnchanged":false,
+        "installed":true,
+        "installedReason":"Invalid Src or Dst",
+        "nexthopGroup":{
+          "name":"C",
+          "installed":true,
+          "installedInternally":1
+        }
+      },
+      {
+        "sequenceNumber":15,
+        "vrfUnchanged":false,
+        "installed":false,
+        "installedReason":"No Nexthops"
       }
     ]
   },
     "policies":[
       {
         "sequenceNumber":5,
-        "vrfUnchanged":true,
-        "installed":false,
+        "vrfUnchanged":false,
+        "installed":true,
         "installedReason":"Valid",
-        "matchDst":"c0ff:ee::\/64"
+        "matchDst":"c0ff:ee::\/64",
+        "nexthopGroup":{
+          "name":"D",
+          "installed":true,
+          "installedInternally":1
+        }
       },
       {
         "sequenceNumber":10,
index f615a971c0fb642b8dd940d92f9b3a4c4ef1391a..b73d678e8eb8879638d8132420c4ed0d6e7ee749 100644 (file)
@@ -1,4 +1,11 @@
 debug pbr
+# Valid table range
+pbr table range 10000 50000
+# Try to set invalid bounds
+pbr table range 10000 10001
+pbr table range 50000 10000
+# Reset table range
+no pbr table range
 !
 nexthop-group A
   nexthop 192.168.1.2
@@ -36,12 +43,20 @@ pbr-map DONNA seq 5
 pbr-map AKIHABARA seq 5
   match dst-ip 192.168.4.0/24
   set nexthop-group C
-  set vrf unchanged
+!
+pbr-map AKIHABARA seq 10
+  match dst-ip 192.168.4.0/24
+  no match dst-ip 192.168.4.0/24
+  set nexthop-group C
+!
+pbr-map AKIHABARA seq 15
+  match dst-ip 192.168.4.0/24
+  set nexthop-group C
+  no set nexthop-group C
 !
 pbr-map ASAKUSA seq 5
   match dst-ip c0ff:ee::/64
   set nexthop-group D
-  set vrf unchanged
 !
 pbr-map ASAKUSA seq 10
   match dst-ip dead:beef::/64
index 9939aa7456ba6add811a690dab7296227bd4f1df..d0c3d3d8f4d8d10c2458ae7822637e19fd395da5 100755 (executable)
@@ -42,6 +42,7 @@ sys.path.append(os.path.join(CWD, "../"))
 from lib import topotest
 from lib.topogen import Topogen, TopoRouter, get_topogen
 from lib.topolog import logger
+from lib.common_config import shutdown_bringup_interface
 
 # Required to instantiate the topology builder class.
 from mininet.topo import Topo
@@ -163,6 +164,41 @@ def test_pbr_data():
         assert topotest.json_cmp(actual, expected) is None, assertmsg
 
 
+def test_pbr_flap():
+    "Test PBR interface flapping"
+
+    tgen = get_topogen()
+    # Don't run this test if we have any failure.
+    if tgen.routers_have_failure():
+        pytest.skip(tgen.errors)
+
+    # Verify PBR Status
+    logger.info("Flapping PBR Interfaces")
+
+    router_list = tgen.routers().values()
+    for router in router_list:
+        # Flap interface to see if route-map properties are intact
+        # Shutdown interface
+        dut = "r1"
+        for i in range(5):
+            intf = "r1-eth{}".format(i)
+
+            # Down and back again
+            shutdown_bringup_interface(tgen, dut, intf, False)
+            shutdown_bringup_interface(tgen, dut, intf, True)
+
+        intf_file = "{}/{}/pbr-interface.json".format(CWD, router.name)
+        logger.info(intf_file)
+
+        # Read expected result from file
+        expected = json.loads(open(intf_file).read())
+
+        # Actual output from router
+        actual = router.vtysh_cmd("show pbr interface json", isjson=True)
+        assertmsg = '"show pbr interface" mismatches on {}'.format(router.name)
+        assert topotest.json_cmp(actual, expected) is None, assertmsg
+
+
 if __name__ == "__main__":
     args = ["-s"] + sys.argv[1:]
     sys.exit(pytest.main(args))