@@ -286,6 +286,89 @@ def _check_route_advertisement():
286286 )
287287
288288
289+ def test_bgp_advertise_map_peer_group_config ():
290+ """
291+ Test that advertise-map configurations show correctly in running config
292+ when a peer is part of a peer group. Tests both exist-map and non-exist-map.
293+ """
294+ tgen = get_topogen ()
295+
296+ if tgen .routers_have_failure ():
297+ pytest .skip (tgen .errors )
298+
299+ r1 = tgen .gears ["r1" ]
300+
301+ # Create route-maps
302+ r1 .vtysh_cmd (
303+ """
304+ configure terminal
305+ route-map EXIST-MAP permit 10
306+ route-map ADV-MAP permit 10
307+ """
308+ )
309+
310+ # First verify the peer is part of a peer group
311+ output = r1 .vtysh_cmd ("show bgp neighbor 192.168.252.2 json" )
312+ json_output = json .loads (output )
313+ assert (
314+ "peerGroup" in json_output ["192.168.252.2" ]
315+ ), "Peer is not part of a peer group"
316+
317+ # Test 1: Configure advertise-map with exist-map
318+ r1 .vtysh_cmd (
319+ """
320+ configure terminal
321+ router bgp 65001
322+ address-family ipv4 unicast
323+ neighbor 192.168.252.2 advertise-map ADV-MAP exist-map EXIST-MAP
324+ """
325+ )
326+
327+ output = r1 .vtysh_cmd ("show running-config" )
328+ exist_map_config = (
329+ "neighbor 192.168.252.2 advertise-map ADV-MAP exist-map EXIST-MAP"
330+ )
331+
332+ assert exist_map_config in output , (
333+ f"Exist-map configuration not found or incorrect in running config. "
334+ f"Expected: '{ exist_map_config } '"
335+ )
336+
337+ # Test 2: Configure advertise-map with non-exist-map
338+ r1 .vtysh_cmd (
339+ """
340+ configure terminal
341+ router bgp 65001
342+ address-family ipv4 unicast
343+ neighbor 192.168.252.2 advertise-map ADV-MAP non-exist-map EXIST-MAP
344+ """
345+ )
346+
347+ output = r1 .vtysh_cmd ("show running-config" )
348+ non_exist_map_config = (
349+ "neighbor 192.168.252.2 advertise-map ADV-MAP non-exist-map EXIST-MAP"
350+ )
351+
352+ assert non_exist_map_config in output , (
353+ f"Non-exist-map configuration not found or incorrect in running config. "
354+ f"Expected: '{ non_exist_map_config } '"
355+ )
356+
357+ logger .info ("exist/non-exist-map configuration correctly shown in running config" )
358+
359+ # cleanup
360+ r1 .vtysh_cmd (
361+ """
362+ configure terminal
363+ router bgp 65001
364+ address-family ipv4 unicast
365+ no neighbor 192.168.252.2 advertise-map ADV-MAP non-exist-map EXIST-MAP
366+ no route-map EXIST-MAP permit 10
367+ no route-map ADV-MAP permit 10
368+ """
369+ )
370+
371+
289372if __name__ == "__main__" :
290373 args = ["-s" ] + sys .argv [1 :]
291374 sys .exit (pytest .main (args ))
0 commit comments