@@ -143,6 +143,89 @@ def _bgp_peer_group_remoteas_add():
143
143
assert result is None , "Failed bgp convergence in r1"
144
144
145
145
146
+ def test_bgp_advertise_map_peer_group_config ():
147
+ """
148
+ Test that advertise-map configurations show correctly in running config
149
+ when a peer is part of a peer group. Tests both exist-map and non-exist-map.
150
+ """
151
+ tgen = get_topogen ()
152
+
153
+ if tgen .routers_have_failure ():
154
+ pytest .skip (tgen .errors )
155
+
156
+ r1 = tgen .gears ["r1" ]
157
+
158
+ # Create route-maps
159
+ r1 .vtysh_cmd (
160
+ """
161
+ configure terminal
162
+ route-map EXIST-MAP permit 10
163
+ route-map ADV-MAP permit 10
164
+ """
165
+ )
166
+
167
+ # First verify the peer is part of a peer group
168
+ output = r1 .vtysh_cmd ("show bgp neighbor 192.168.252.2 json" )
169
+ json_output = json .loads (output )
170
+ assert (
171
+ "peerGroup" in json_output ["192.168.252.2" ]
172
+ ), "Peer is not part of a peer group"
173
+
174
+ # Test 1: Configure advertise-map with exist-map
175
+ r1 .vtysh_cmd (
176
+ """
177
+ configure terminal
178
+ router bgp 65001
179
+ address-family ipv4 unicast
180
+ neighbor 192.168.252.2 advertise-map ADV-MAP exist-map EXIST-MAP
181
+ """
182
+ )
183
+
184
+ output = r1 .vtysh_cmd ("show running-config" )
185
+ exist_map_config = (
186
+ "neighbor 192.168.252.2 advertise-map ADV-MAP exist-map EXIST-MAP"
187
+ )
188
+
189
+ assert exist_map_config in output , (
190
+ f"Exist-map configuration not found or incorrect in running config. "
191
+ f"Expected: '{ exist_map_config } '"
192
+ )
193
+
194
+ # Test 2: Configure advertise-map with non-exist-map
195
+ r1 .vtysh_cmd (
196
+ """
197
+ configure terminal
198
+ router bgp 65001
199
+ address-family ipv4 unicast
200
+ neighbor 192.168.252.2 advertise-map ADV-MAP non-exist-map EXIST-MAP
201
+ """
202
+ )
203
+
204
+ output = r1 .vtysh_cmd ("show running-config" )
205
+ non_exist_map_config = (
206
+ "neighbor 192.168.252.2 advertise-map ADV-MAP non-exist-map EXIST-MAP"
207
+ )
208
+
209
+ assert non_exist_map_config in output , (
210
+ f"Non-exist-map configuration not found or incorrect in running config. "
211
+ f"Expected: '{ non_exist_map_config } '"
212
+ )
213
+
214
+ logger .info ("exist/non-exist-map configuration correctly shown in running config" )
215
+
216
+ # cleanup
217
+ r1 .vtysh_cmd (
218
+ """
219
+ configure terminal
220
+ router bgp 65001
221
+ address-family ipv4 unicast
222
+ no neighbor 192.168.252.2 advertise-map ADV-MAP non-exist-map EXIST-MAP
223
+ no route-map EXIST-MAP permit 10
224
+ no route-map ADV-MAP permit 10
225
+ """
226
+ )
227
+
228
+
146
229
if __name__ == "__main__" :
147
230
args = ["-s" ] + sys .argv [1 :]
148
231
sys .exit (pytest .main (args ))
0 commit comments