!
-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
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
!
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"},
}
]
}
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:]