Commit b0dac90b94 for frr
commit b0dac90b94d6c088b54a93b8a713f45a8e41060f
Author: Enke Chen <enchen@paloaltonetworks.com>
Date: Wed Nov 18 14:13:14 2026 -0800
tests: bgp: verify community attrs in advertised-routes match received-routes JSON
Add a topotest that checks community, extended community, and large
community attributes in the non-detail 'show bgp neighbor X
advertised-routes json' output are compatible with the received-routes
JSON format. The test fetches advertised-routes from r2 and
received-routes from r3 for the same prefix and asserts that the
community, extendedCommunity, and largeCommunity fields are identical.
The test reuses the existing bgp_show_advertised_routes_detail topology,
which already sets all three community types via route-map on the
r2->r3 session.
Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
diff --git a/tests/topotests/bgp_show_advertised_routes_detail/r3/frr.conf b/tests/topotests/bgp_show_advertised_routes_detail/r3/frr.conf
index 11333d481f..0e0c2f5343 100644
--- a/tests/topotests/bgp_show_advertised_routes_detail/r3/frr.conf
+++ b/tests/topotests/bgp_show_advertised_routes_detail/r3/frr.conf
@@ -7,5 +7,8 @@ router bgp 65003
neighbor 192.168.2.2 remote-as auto
neighbor 192.168.2.2 timers 1 3
neighbor 192.168.2.2 timers connect 1
+ address-family ipv4 unicast
+ neighbor 192.168.2.2 soft-reconfiguration inbound
+ exit-address-family
!
!
diff --git a/tests/topotests/bgp_show_advertised_routes_detail/test_bgp_show_advertised_routes_detail.py b/tests/topotests/bgp_show_advertised_routes_detail/test_bgp_show_advertised_routes_detail.py
index c1c09dd5df..d96f73f501 100644
--- a/tests/topotests/bgp_show_advertised_routes_detail/test_bgp_show_advertised_routes_detail.py
+++ b/tests/topotests/bgp_show_advertised_routes_detail/test_bgp_show_advertised_routes_detail.py
@@ -83,6 +83,61 @@ def test_bgp_show_advertised_routes_detail():
assert result is None, "Can't converge"
+def test_bgp_show_advertised_routes_community_json():
+ """Verify community attrs in advertised-routes JSON match received-routes JSON.
+
+ r2 advertises 10.10.10.1/32 to r3 with community, extended community, and
+ large community set via route-map. Fetch advertised-routes from r2 and
+ received-routes from r3 for the same prefix and assert that the community,
+ extendedCommunity, and largeCommunity fields are identical, confirming that
+ the non-detail advertised-routes JSON output is compatible with the
+ received-routes JSON format.
+ """
+ tgen = get_topogen()
+
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
+
+ r2 = tgen.gears["r2"]
+ r3 = tgen.gears["r3"]
+
+ def _bgp_community_json():
+ advertised = json.loads(
+ r2.vtysh_cmd(
+ "show bgp ipv4 unicast neighbor 192.168.2.3 advertised-routes json"
+ )
+ )
+ received = json.loads(
+ r3.vtysh_cmd(
+ "show bgp ipv4 unicast neighbor 192.168.2.2 received-routes json"
+ )
+ )
+
+ adv_route = advertised.get("advertisedRoutes", {}).get("10.10.10.1/32")
+ rcv_route = received.get("receivedRoutes", {}).get("10.10.10.1/32")
+
+ if not adv_route or not rcv_route:
+ return "Route 10.10.10.1/32 not found in advertised or received output"
+
+ for attr in ("community", "extendedCommunity", "largeCommunity"):
+ if adv_route.get(attr) != rcv_route.get(attr):
+ return "Mismatch in {}: advertised={} received={}".format(
+ attr, adv_route.get(attr), rcv_route.get(attr)
+ )
+
+ return None
+
+ test_func = functools.partial(
+ _bgp_community_json,
+ )
+ _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
+ assert (
+ result is None
+ ), "Community attrs in advertised-routes JSON do not match received-routes: {}".format(
+ result
+ )
+
+
if __name__ == "__main__":
args = ["-s"] + sys.argv[1:]
sys.exit(pytest.main(args))