diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2021-05-21 07:23:10 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-21 07:23:10 -0400 |
| commit | 2db528e3844c79232d32b6197a6c3b6233b561db (patch) | |
| tree | 572f7959eefcb00704021b9ac4cd0ec5bb28de7a /tests | |
| parent | 53e00a69d29b255e19fcf4ce68628fc57937f192 (diff) | |
| parent | d95a84e0a515c9d04efe0aae0da4f8f9c0d8defd (diff) | |
Merge pull request #8701 from ton31337/feature/show_ip_bgp_alias
bgpd: Show BGP prefixes by community alias
Diffstat (limited to 'tests')
4 files changed, 36 insertions, 7 deletions
diff --git a/tests/topotests/bgp_community_alias/r1/bgpd.conf b/tests/topotests/bgp_community_alias/r1/bgpd.conf index 2cf84d0b70..06113bdd2a 100644 --- a/tests/topotests/bgp_community_alias/r1/bgpd.conf +++ b/tests/topotests/bgp_community_alias/r1/bgpd.conf @@ -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 diff --git a/tests/topotests/bgp_community_alias/r2/bgpd.conf b/tests/topotests/bgp_community_alias/r2/bgpd.conf index 517ef70f2a..fc67ff2ad2 100644 --- a/tests/topotests/bgp_community_alias/r2/bgpd.conf +++ b/tests/topotests/bgp_community_alias/r2/bgpd.conf @@ -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 ! diff --git a/tests/topotests/bgp_community_alias/r2/zebra.conf b/tests/topotests/bgp_community_alias/r2/zebra.conf index cffe827363..a806628a8e 100644 --- a/tests/topotests/bgp_community_alias/r2/zebra.conf +++ b/tests/topotests/bgp_community_alias/r2/zebra.conf @@ -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 ! diff --git a/tests/topotests/bgp_community_alias/test_bgp-community-alias.py b/tests/topotests/bgp_community_alias/test_bgp-community-alias.py index a43e5f937e..90eeaaa731 100644 --- a/tests/topotests/bgp_community_alias/test_bgp-community-alias.py +++ b/tests/topotests/bgp_community_alias/test_bgp-community-alias.py @@ -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:] |
