]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: Show BGP prefixes by community alias
authorDonatas Abraitis <donatas.abraitis@gmail.com>
Wed, 19 May 2021 14:47:23 +0000 (17:47 +0300)
committerDonatas Abraitis <donatas.abraitis@gmail.com>
Wed, 19 May 2021 15:11:39 +0000 (18:11 +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 2cf84d0b70a28ab3da695cff35617f5ba29c5e93..06113bdd2a34486713291158a174f30d785f9085 100644 (file)
@@ -1,7 +1,7 @@
 !
-bgp community alias 65002:1 community-r2-1
+bgp community alias 65001:1 community-r2-1
 bgp community alias 65002:2 community-r2-2
-bgp community alias 65002:1:1 large-community-r2-1
+bgp community alias 65001:1:1 large-community-r2-1
 !
 router bgp 65001
  no bgp ebgp-requires-policy
index 517ef70f2a0c807094df996a30368fdf6e72ef4d..fc67ff2ad2262a86b051ba6b4094118debe8f373 100644 (file)
@@ -6,7 +6,14 @@ router bgp 65002
   neighbor 192.168.1.1 route-map r1 out
  exit-address-family
 !
+ip prefix-list p1 permit 172.16.16.1/32
+ip prefix-list p2 permit 172.16.16.2/32
+!
 route-map r1 permit 10
+ match ip address prefix-list p1
+ set community 65001:1 65001:2
+ set large-community 65001:1:1 65001:1:2
+route-map r1 permit 20
+ match ip address prefix-list p2
  set community 65002:1 65002:2
- set large-community 65002:1:1 65002:2:1
 !
index cffe8273636d0aead83dee1e5a85ce1982f4602d..a806628a8e5f91f0f82a037f0edd95c2f49f46c1 100644 (file)
@@ -1,4 +1,8 @@
 !
+int lo
+ ip address 172.16.16.1/32
+ ip address 172.16.16.2/32
+!
 int r2-eth0
  ip address 192.168.1.2/24
 !
index a43e5f937e9effffe59d0deade5815ac9cf24542..90eeaaa7318f4331134366770a0006bbd330a5e0 100644 (file)
@@ -84,12 +84,14 @@ def test_bgp_community_alias():
     router = tgen.gears["r1"]
 
     def _bgp_converge(router):
-        output = json.loads(router.vtysh_cmd("show ip bgp 192.168.1.0/24 json"))
+        output = json.loads(
+            router.vtysh_cmd("show bgp ipv4 unicast 172.16.16.1/32 json")
+        )
         expected = {
             "paths": [
                 {
-                    "community": {"string": "community-r2-1 community-r2-2"},
-                    "largeCommunity": {"string": "large-community-r2-1 65002:2:1"},
+                    "community": {"string": "community-r2-1 65001:2"},
+                    "largeCommunity": {"string": "large-community-r2-1 65001:1:2"},
                 }
             ]
         }
@@ -97,9 +99,25 @@ def test_bgp_community_alias():
 
     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)
 
+    def _bgp_show_prefixes_by_alias(router):
+        output = json.loads(
+            router.vtysh_cmd("show bgp ipv4 unicast alias community-r2-2 json detail")
+        )
+        expected = {
+            "routes": {
+                "172.16.16.2/32": [{"community": {"string": "65002:1 community-r2-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
+    )
+
 
 if __name__ == "__main__":
     args = ["-s"] + sys.argv[1:]