]> git.puffer.fish Git - matthieu/frr.git/commitdiff
tests: Check if `match alias` works for route-maps
authorDonatas Abraitis <donatas.abraitis@gmail.com>
Sun, 18 Jul 2021 11:36:53 +0000 (14:36 +0300)
committerDonatas Abraitis <donatas.abraitis@gmail.com>
Wed, 21 Jul 2021 06:26:15 +0000 (09:26 +0300)
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
tests/topotests/bgp_community_alias/r1/bgpd.conf
tests/topotests/bgp_community_alias/r2/bgpd.conf
tests/topotests/bgp_community_alias/r2/zebra.conf
tests/topotests/bgp_community_alias/test_bgp-community-alias.py

index 06113bdd2a34486713291158a174f30d785f9085..a6366204e8aeacb08d90c89f72690ff262b2d3a5 100644 (file)
@@ -6,4 +6,17 @@ bgp community alias 65001:1:1 large-community-r2-1
 router bgp 65001
  no bgp ebgp-requires-policy
  neighbor 192.168.1.2 remote-as external
+ address-family ipv4 unicast
+  redistribute connected
+  neighbor 192.168.1.2 route-map r2 in
+ exit-address-family
+!
+route-map r2 permit 10
+ match alias community-r2-1
+ set tag 10
+route-map r2 permit 20
+ match alias community-r2-2
+ set tag 20
+route-map r2 permit 30
+ set tag 100
 !
index fc67ff2ad2262a86b051ba6b4094118debe8f373..9276fe592dda9341bcdca0924fe56d7d5d9a24e4 100644 (file)
@@ -8,6 +8,7 @@ router bgp 65002
 !
 ip prefix-list p1 permit 172.16.16.1/32
 ip prefix-list p2 permit 172.16.16.2/32
+ip prefix-list p3 permit 172.16.16.3/32
 !
 route-map r1 permit 10
  match ip address prefix-list p1
@@ -16,4 +17,6 @@ route-map r1 permit 10
 route-map r1 permit 20
  match ip address prefix-list p2
  set community 65002:1 65002:2
+route-map r1 permit 30
+ match ip address prefix-list p3
 !
index a806628a8e5f91f0f82a037f0edd95c2f49f46c1..b8cb9baf3c3a21c3e33efa4d7ef110929c810b12 100644 (file)
@@ -2,6 +2,7 @@
 int lo
  ip address 172.16.16.1/32
  ip address 172.16.16.2/32
+ ip address 172.16.16.3/32
 !
 int r2-eth0
  ip address 192.168.1.2/24
index 90eeaaa7318f4331134366770a0006bbd330a5e0..c41ba810f18e956b1a0391b9e4d00529dfcebb28 100644 (file)
@@ -84,39 +84,57 @@ def test_bgp_community_alias():
     router = tgen.gears["r1"]
 
     def _bgp_converge(router):
-        output = json.loads(
-            router.vtysh_cmd("show bgp ipv4 unicast 172.16.16.1/32 json")
-        )
+        output = json.loads(router.vtysh_cmd("show ip route json"))
         expected = {
-            "paths": [
+            "172.16.16.1/32": [
+                {
+                    "tag": 10,
+                    "communities": "community-r2-1 65001:2",
+                    "largeCommunities": "large-community-r2-1 65001:1:2",
+                }
+            ],
+            "172.16.16.2/32": [
+                {
+                    "tag": 20,
+                    "communities": "65002:1 community-r2-2",
+                    "largeCommunities": "",
+                }
+            ],
+            "172.16.16.3/32": [
                 {
-                    "community": {"string": "community-r2-1 65001:2"},
-                    "largeCommunity": {"string": "large-community-r2-1 65001:1:2"},
+                    "tag": 100,
+                    "communities": "",
+                    "largeCommunities": "",
                 }
-            ]
+            ],
         }
         return topotest.json_cmp(output, expected)
 
     test_func = functools.partial(_bgp_converge, router)
     success, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
-    assert result is None, 'Cannot see BGP community aliases "{}"'.format(router)
+    assert result is None, "Cannot see BGP community aliases at r1"
 
     def _bgp_show_prefixes_by_alias(router):
         output = json.loads(
-            router.vtysh_cmd("show bgp ipv4 unicast alias community-r2-2 json detail")
+            router.vtysh_cmd(
+                "show bgp ipv4 unicast alias large-community-r2-1 json detail"
+            )
         )
         expected = {
             "routes": {
-                "172.16.16.2/32": [{"community": {"string": "65002:1 community-r2-2"}}]
+                "172.16.16.1/32": [
+                    {
+                        "community": {"string": "community-r2-1 65001:2"},
+                        "largeCommunity": {"string": "large-community-r2-1 65001:1:2"},
+                    }
+                ]
             }
         }
         return topotest.json_cmp(output, expected)
 
     test_func = functools.partial(_bgp_show_prefixes_by_alias, router)
     success, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
-    assert result is None, 'Cannot see BGP prefixes by community alias "{}"'.format(
-        router
-    )
+    assert result is None, "Cannot see BGP prefixes by community alias at r1"
 
 
 if __name__ == "__main__":