]>
Commit | Line | Data |
---|---|---|
35ba1e3d KK |
1 | #!/usr/bin/env python |
2 | # | |
3 | # Copyright (c) 2019 by VMware, Inc. ("VMware") | |
4 | # Used Copyright (c) 2018 by Network Device Education Foundation, Inc. ("NetDEF") | |
5 | # in this file. | |
6 | # | |
7 | # Permission to use, copy, modify, and/or distribute this software | |
8 | # for any purpose with or without fee is hereby granted, provided | |
9 | # that the above copyright notice and this permission notice appear | |
10 | # in all copies. | |
11 | # | |
12 | # THE SOFTWARE IS PROVIDED "AS IS" AND VMWARE DISCLAIMS ALL WARRANTIES | |
13 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
14 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL VMWARE BE LIABLE FOR | |
15 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY | |
16 | # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, | |
17 | # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS | |
18 | # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE | |
19 | # OF THIS SOFTWARE. | |
20 | # | |
21 | ||
22 | """ | |
23 | Following tests are covered to test BGP Gracefull Restart functionality. | |
24 | Basic Common Test steps for all the test case below : | |
25 | - Create topology (setup module) | |
26 | Creating 2 routers topology, r1, r2 in IBGP | |
27 | - Bring up topology | |
28 | - Verify for bgp to converge | |
29 | - Configure BGP Garceful Restart on both the routers. | |
30 | ||
17022899 KK |
31 | 1. Transition from Peer-level helper to Global Restarting |
32 | 2. Transition from Peer-level helper to Global inherit helper | |
33 | 3. Transition from Peer-level restarting to Global inherit helper | |
34 | 4. Default GR functional mode is Helper. | |
35 | 5. Verify that the restarting node sets "R" bit while sending the | |
35ba1e3d | 36 | BGP open messages after the node restart, only if GR is enabled. |
35ba1e3d | 37 | 6. Verify if restarting node resets R bit in BGP open message |
17022899 KK |
38 | during normal BGP session flaps as well, even when GR restarting |
39 | mode is enabled. Here link flap happen due to interface UP/DOWN. | |
40 | 7. Verify if restarting node resets R bit in BGP | |
41 | open message during normal BGP session flaps when GR is disabled. | |
42 | 8. Verify that restarting nodes set "F" bit while sending | |
35ba1e3d | 43 | the BGP open messages after it restarts, only when BGP GR is enabled. |
17022899 | 44 | 9. Verify that only GR helper routers keep the stale |
35ba1e3d | 45 | route entries, not any GR disabled router. |
17022899 KK |
46 | 10. Verify that GR helper routers keeps all the routes received |
47 | from restarting node if both the routers are configured as | |
48 | GR restarting node. | |
49 | 11. Verify that GR helper routers delete all the routes | |
50 | received from a node if both the routers are configured as GR | |
51 | helper node. | |
52 | 12. After BGP neighborship is established and GR capability is exchanged, | |
53 | transition restarting router to disabled state and vice versa. | |
54 | 13. After BGP neighborship is established and GR capability is exchanged, | |
55 | transition restarting router to disabled state and vice versa. | |
56 | 14. Verify that restarting nodes reset "F" bit while sending | |
57 | the BGP open messages after it's restarts, when BGP GR is **NOT** enabled. | |
58 | 15. Verify that only GR helper routers keep the stale | |
59 | route entries, not any GR disabled router. | |
60 | 16. Transition from Global Restarting to Disable and then Global | |
61 | Disable to Restarting. | |
62 | 17. Transition from Global Helper to Disable and then Global | |
35ba1e3d | 63 | Disable to Helper. |
17022899 KK |
64 | 18. Transition from Global Restart to Helper and then Global |
65 | Helper to Restart, Global Mode : GR Restarting | |
66 | PerPeer Mode : GR Helper | |
67 | GR Mode effective : GR Helper | |
68 | 19. Transition from Peer-level helper to Global Restarting, | |
69 | Global Mode : GR Restarting | |
70 | PerPeer Mode : GR Restarting | |
71 | GR Mode effective : GR Restarting | |
72 | 20. Transition from Peer-level restart to Global Restart | |
73 | Global Mode : GR Restarting | |
74 | PerPeer Mode : GR Restarting | |
75 | GR Mode effective : GR Restarting | |
76 | 21. Transition from Peer-level disabled to Global Restart | |
77 | Global Mode : GR Restarting | |
78 | PerPeer Mode : GR Disabled | |
79 | GR Mode effective : GR Disabled | |
80 | 22. Peer-level inherit from Global Restarting | |
81 | Global Mode : GR Restart | |
82 | PerPeer Mode : None | |
83 | GR Mode effective : GR Restart | |
84 | 23. Transition from Peer-level disbale to Global inherit helper | |
85 | Global Mode : None | |
86 | PerPeer Mode : GR Disable | |
87 | GR Mode effective : GR Disable | |
35ba1e3d KK |
88 | """ |
89 | ||
90 | import os | |
91 | import sys | |
92 | import json | |
93 | import time | |
94 | import inspect | |
95 | import pytest | |
35ba1e3d KK |
96 | |
97 | # Save the Current Working Directory to find configuration files. | |
98 | CWD = os.path.dirname(os.path.realpath(__file__)) | |
99 | sys.path.append(os.path.join("../")) | |
100 | sys.path.append(os.path.join("../lib/")) | |
101 | ||
102 | # pylint: disable=C0413 | |
103 | # Import topogen and topotest helpers | |
104 | from lib import topotest | |
105 | from lib.topogen import Topogen, TopoRouter, get_topogen | |
106 | from lib.topolog import logger | |
3dfd384e | 107 | |
35ba1e3d | 108 | # Required to instantiate the topology builder class. |
8db751b8 | 109 | from lib.micronet_compat import Topo |
35ba1e3d KK |
110 | |
111 | # Import topoJson from lib, to create topology and initial configuration | |
112 | from lib.topojson import build_topo_from_json, build_config_from_json | |
113 | from lib.bgp import ( | |
114 | clear_bgp, | |
115 | verify_bgp_rib, | |
116 | verify_graceful_restart, | |
117 | create_router_bgp, | |
118 | verify_r_bit, | |
119 | verify_f_bit, | |
35ba1e3d | 120 | verify_graceful_restart_timers, |
17022899 KK |
121 | verify_bgp_convergence, |
122 | verify_bgp_convergence_from_running_config, | |
35ba1e3d KK |
123 | ) |
124 | ||
125 | from lib.common_config import ( | |
126 | write_test_header, | |
127 | reset_config_on_routers, | |
128 | start_topology, | |
129 | kill_router_daemons, | |
130 | start_router_daemons, | |
131 | verify_rib, | |
132 | check_address_types, | |
133 | write_test_footer, | |
134 | check_router_status, | |
135 | shutdown_bringup_interface, | |
136 | step, | |
35ba1e3d KK |
137 | get_frr_ipv6_linklocal, |
138 | create_route_maps, | |
0b25370e | 139 | required_linux_kernel_version, |
35ba1e3d KK |
140 | ) |
141 | ||
bf3a0a9a DS |
142 | pytestmark = [pytest.mark.bgpd] |
143 | ||
144 | ||
35ba1e3d KK |
145 | # Reading the data from JSON File for topology and configuration creation |
146 | jsonFile = "{}/bgp_gr_topojson_topo1.json".format(CWD) | |
147 | try: | |
148 | with open(jsonFile, "r") as topoJson: | |
149 | topo = json.load(topoJson) | |
150 | except IOError: | |
151 | logger.info("Could not read file:", jsonFile) | |
152 | ||
153 | ||
154 | # Global variables | |
155 | NEXT_HOP_IP = {"ipv4": "192.168.1.10", "ipv6": "fd00:0:0:1::10"} | |
156 | NEXT_HOP_IP_1 = {"ipv4": "192.168.0.1", "ipv6": "fd00::1"} | |
157 | NEXT_HOP_IP_2 = {"ipv4": "192.168.0.2", "ipv6": "fd00::2"} | |
158 | BGP_CONVERGENCE = False | |
159 | GR_RESTART_TIMER = 20 | |
160 | PREFERRED_NEXT_HOP = "link_local" | |
161 | ||
162 | ||
163 | class GenerateTopo(Topo): | |
164 | """ | |
165 | Test topology builder | |
166 | ||
167 | * `Topo`: Topology object | |
168 | """ | |
169 | ||
170 | def build(self, *_args, **_opts): | |
171 | "Build function" | |
172 | tgen = get_topogen(self) | |
173 | ||
174 | # This function only purpose is to create topology | |
175 | # as defined in input json file. | |
176 | # | |
177 | # Create topology (setup module) | |
178 | # Creating 2 routers topology, r1, r2in IBGP | |
179 | # Bring up topology | |
180 | ||
181 | # Building topology from json file | |
182 | build_topo_from_json(tgen, topo) | |
183 | ||
184 | ||
185 | def setup_module(mod): | |
186 | """ | |
187 | Sets up the pytest environment | |
188 | ||
189 | * `mod`: module name | |
190 | """ | |
191 | ||
192 | global ADDR_TYPES | |
193 | ||
3dfd384e | 194 | # Required linux kernel version for this suite to run. |
17022899 | 195 | result = required_linux_kernel_version("4.16") |
955212d9 | 196 | if result is not True: |
197 | pytest.skip("Kernel requirements are not met") | |
3dfd384e | 198 | |
35ba1e3d KK |
199 | testsuite_run_time = time.asctime(time.localtime(time.time())) |
200 | logger.info("Testsuite start time: {}".format(testsuite_run_time)) | |
201 | logger.info("=" * 40) | |
202 | ||
203 | logger.info("Running setup_module to create topology") | |
204 | ||
205 | # This function initiates the topology build with Topogen... | |
206 | tgen = Topogen(GenerateTopo, mod.__name__) | |
207 | # ... and here it calls Mininet initialization functions. | |
208 | ||
35ba1e3d KK |
209 | # Starting topology, create tmp files which are loaded to routers |
210 | # to start deamons and then start routers | |
211 | start_topology(tgen) | |
212 | ||
213 | # Creating configuration from JSON | |
214 | build_config_from_json(tgen, topo) | |
215 | ||
216 | # Don't run this test if we have any failure. | |
217 | if tgen.routers_have_failure(): | |
218 | pytest.skip(tgen.errors) | |
219 | ||
220 | # Api call verify whether BGP is converged | |
221 | ADDR_TYPES = check_address_types() | |
222 | ||
17022899 KK |
223 | BGP_CONVERGENCE = verify_bgp_convergence(tgen, topo) |
224 | assert BGP_CONVERGENCE is True, "setup_module : Failed \n Error:" " {}".format( | |
225 | BGP_CONVERGENCE | |
226 | ) | |
35ba1e3d KK |
227 | |
228 | logger.info("Running setup_module() done") | |
229 | ||
230 | ||
231 | def teardown_module(mod): | |
232 | """ | |
233 | Teardown the pytest environment | |
234 | ||
235 | * `mod`: module name | |
236 | """ | |
237 | ||
238 | logger.info("Running teardown_module to delete topology") | |
239 | ||
240 | tgen = get_topogen() | |
241 | ||
242 | # Stop toplogy and Remove tmp files | |
243 | tgen.stop_topology() | |
244 | ||
245 | logger.info( | |
246 | "Testsuite end time: {}".format(time.asctime(time.localtime(time.time()))) | |
247 | ) | |
248 | logger.info("=" * 40) | |
249 | ||
250 | ||
251 | def configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut, peer): | |
252 | """ | |
253 | This function groups the repetitive function calls into one function. | |
254 | """ | |
255 | ||
256 | result = create_router_bgp(tgen, topo, input_dict) | |
257 | assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) | |
258 | ||
259 | for addr_type in ADDR_TYPES: | |
2268cf50 KK |
260 | neighbor = topo["routers"][peer]["links"]["r1-link1"][addr_type].split("/")[0] |
261 | clear_bgp(tgen, addr_type, dut, neighbor=neighbor) | |
35ba1e3d | 262 | |
17022899 | 263 | for addr_type in ADDR_TYPES: |
2268cf50 KK |
264 | neighbor = topo["routers"][dut]["links"]["r2-link1"][addr_type].split("/")[0] |
265 | clear_bgp(tgen, addr_type, peer, neighbor=neighbor) | |
17022899 KK |
266 | |
267 | result = verify_bgp_convergence_from_running_config(tgen) | |
268 | assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) | |
269 | ||
35ba1e3d KK |
270 | return True |
271 | ||
272 | ||
273 | def next_hop_per_address_family( | |
274 | tgen, dut, peer, addr_type, next_hop_dict, preferred_next_hop=PREFERRED_NEXT_HOP | |
275 | ): | |
276 | """ | |
277 | This function returns link_local or global next_hop per address-family | |
278 | """ | |
279 | ||
280 | intferface = topo["routers"][peer]["links"]["{}-link1".format(dut)]["interface"] | |
281 | if addr_type == "ipv6" and "link_local" in preferred_next_hop: | |
282 | next_hop = get_frr_ipv6_linklocal(tgen, peer, intf=intferface) | |
283 | else: | |
284 | next_hop = next_hop_dict[addr_type] | |
285 | ||
286 | return next_hop | |
287 | ||
288 | ||
2268cf50 | 289 | def BGP_GR_TC_50_p1(request): |
35ba1e3d KK |
290 | """ |
291 | Test Objective : Transition from Peer-level helper to Global inherit helper | |
292 | Global Mode : None | |
293 | PerPeer Mode : Helper | |
294 | GR Mode effective : GR Helper | |
295 | ||
296 | """ | |
297 | ||
298 | tgen = get_topogen() | |
299 | tc_name = request.node.name | |
300 | write_test_header(tc_name) | |
301 | ||
302 | # Check router status | |
303 | check_router_status(tgen) | |
304 | ||
305 | # Don't run this test if we have any failure. | |
306 | if tgen.routers_have_failure(): | |
307 | pytest.skip(tgen.errors) | |
308 | ||
309 | # Creating configuration from JSON | |
310 | reset_config_on_routers(tgen) | |
311 | ||
312 | step( | |
313 | "Configure R1 as GR helper node at per Peer-level for R2" | |
314 | " and configure R2 as global restarting node." | |
315 | ) | |
316 | ||
317 | input_dict = { | |
318 | "r1": { | |
319 | "bgp": { | |
320 | "address_family": { | |
321 | "ipv4": { | |
322 | "unicast": { | |
323 | "neighbor": { | |
324 | "r2": { | |
325 | "dest_link": { | |
326 | "r1-link1": {"graceful-restart-helper": True} | |
327 | } | |
328 | } | |
329 | } | |
330 | } | |
331 | }, | |
332 | "ipv6": { | |
333 | "unicast": { | |
334 | "neighbor": { | |
335 | "r2": { | |
336 | "dest_link": { | |
337 | "r1-link1": {"graceful-restart-helper": True} | |
338 | } | |
339 | } | |
340 | } | |
341 | } | |
342 | }, | |
343 | } | |
344 | } | |
345 | }, | |
346 | "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}}, | |
347 | } | |
348 | ||
349 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
350 | ||
351 | step("Verify on R2 that R1 advertises GR capabilities as a helper node") | |
352 | ||
353 | for addr_type in ADDR_TYPES: | |
354 | result = verify_graceful_restart( | |
355 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
356 | ) | |
357 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
358 | tc_name, result | |
359 | ) | |
360 | ||
17022899 KK |
361 | for addr_type in ADDR_TYPES: |
362 | protocol = "bgp" | |
363 | next_hop = next_hop_per_address_family( | |
364 | tgen, "r2", "r1", addr_type, NEXT_HOP_IP_1 | |
365 | ) | |
366 | input_topo = {"r1": topo["routers"]["r1"]} | |
367 | result = verify_rib(tgen, addr_type, "r2", input_topo, next_hop, protocol) | |
368 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
369 | tc_name, result | |
370 | ) | |
371 | ||
372 | for addr_type in ADDR_TYPES: | |
373 | next_hop = next_hop_per_address_family( | |
374 | tgen, "r1", "r2", addr_type, NEXT_HOP_IP_2 | |
375 | ) | |
376 | input_topo = {"r2": topo["routers"]["r2"]} | |
377 | result = verify_bgp_rib(tgen, addr_type, "r1", input_topo, next_hop) | |
378 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
379 | tc_name, result | |
380 | ) | |
381 | ||
382 | result = verify_rib(tgen, addr_type, "r1", input_topo, next_hop, protocol) | |
383 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
384 | tc_name, result | |
385 | ) | |
386 | ||
35ba1e3d KK |
387 | step("Kill BGP on R2") |
388 | ||
389 | kill_router_daemons(tgen, "r2", ["bgpd"]) | |
390 | ||
391 | step( | |
392 | "Verify that R2 keeps the stale entries in FIB & R1 keeps stale entries in RIB & FIB" | |
393 | ) | |
394 | ||
395 | for addr_type in ADDR_TYPES: | |
396 | protocol = "bgp" | |
397 | next_hop = next_hop_per_address_family( | |
398 | tgen, "r2", "r1", addr_type, NEXT_HOP_IP_1 | |
399 | ) | |
400 | input_topo = {"r1": topo["routers"]["r1"]} | |
401 | result = verify_rib(tgen, addr_type, "r2", input_topo, next_hop, protocol) | |
402 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
403 | tc_name, result | |
404 | ) | |
405 | ||
406 | for addr_type in ADDR_TYPES: | |
407 | next_hop = next_hop_per_address_family( | |
408 | tgen, "r1", "r2", addr_type, NEXT_HOP_IP_2 | |
409 | ) | |
410 | input_topo = {"r2": topo["routers"]["r2"]} | |
411 | result = verify_bgp_rib(tgen, addr_type, "r1", input_topo, next_hop) | |
412 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
413 | tc_name, result | |
414 | ) | |
415 | ||
416 | result = verify_rib(tgen, addr_type, "r1", input_topo, next_hop, protocol) | |
417 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
418 | tc_name, result | |
419 | ) | |
420 | ||
421 | step("Bring up BGP on R2 and remove Peer-level GR config from R1 ") | |
422 | ||
423 | start_router_daemons(tgen, "r2", ["bgpd"]) | |
424 | ||
425 | input_dict = { | |
426 | "r1": { | |
427 | "bgp": { | |
428 | "address_family": { | |
429 | "ipv4": { | |
430 | "unicast": { | |
431 | "neighbor": { | |
432 | "r2": { | |
433 | "dest_link": { | |
434 | "r1-link1": {"graceful-restart-helper": False} | |
435 | } | |
436 | } | |
437 | } | |
438 | } | |
439 | }, | |
440 | "ipv6": { | |
441 | "unicast": { | |
442 | "neighbor": { | |
443 | "r2": { | |
444 | "dest_link": { | |
445 | "r1-link1": {"graceful-restart-helper": False} | |
446 | } | |
447 | } | |
448 | } | |
449 | } | |
450 | }, | |
451 | } | |
452 | } | |
453 | } | |
454 | } | |
455 | ||
2268cf50 KK |
456 | result = create_router_bgp(tgen, topo, input_dict) |
457 | assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) | |
458 | ||
459 | for addr_type in ADDR_TYPES: | |
460 | neighbor = topo["routers"]["r2"]["links"]["r1-link1"][addr_type].split("/")[0] | |
461 | clear_bgp(tgen, addr_type, "r1", neighbor=neighbor) | |
35ba1e3d | 462 | |
17022899 KK |
463 | result = verify_bgp_convergence_from_running_config(tgen) |
464 | assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) | |
465 | ||
35ba1e3d KK |
466 | step("Verify on R2 that R1 still advertises GR capabilities as a helper node") |
467 | ||
468 | input_dict = { | |
469 | "r1": {"bgp": {"graceful-restart": {"graceful-restart-helper": True}}}, | |
470 | "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}}, | |
471 | } | |
472 | ||
473 | for addr_type in ADDR_TYPES: | |
474 | result = verify_graceful_restart( | |
475 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
476 | ) | |
477 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
478 | tc_name, result | |
479 | ) | |
480 | ||
17022899 KK |
481 | for addr_type in ADDR_TYPES: |
482 | protocol = "bgp" | |
483 | next_hop = next_hop_per_address_family( | |
484 | tgen, "r2", "r1", addr_type, NEXT_HOP_IP_1 | |
485 | ) | |
486 | input_topo = {"r1": topo["routers"]["r1"]} | |
487 | result = verify_rib(tgen, addr_type, "r2", input_topo, next_hop, protocol) | |
488 | assert ( | |
489 | result is True | |
490 | ), "Testcase {} : Failed \n Routes are still present \n Error {}".format( | |
491 | tc_name, result | |
492 | ) | |
493 | ||
494 | for addr_type in ADDR_TYPES: | |
495 | next_hop = next_hop_per_address_family( | |
496 | tgen, "r1", "r2", addr_type, NEXT_HOP_IP_2 | |
497 | ) | |
498 | input_topo = {"r2": topo["routers"]["r2"]} | |
499 | result = verify_bgp_rib(tgen, addr_type, "r1", input_topo, next_hop) | |
500 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
501 | tc_name, result | |
502 | ) | |
503 | ||
504 | result = verify_rib(tgen, addr_type, "r1", input_topo, next_hop, protocol) | |
505 | assert ( | |
506 | result is True | |
507 | ), "Testcase {} : Failed \n Routes are still present \n Error {}".format( | |
508 | tc_name, result | |
509 | ) | |
510 | ||
35ba1e3d KK |
511 | step("Kill BGP on R2") |
512 | ||
513 | kill_router_daemons(tgen, "r2", ["bgpd"]) | |
514 | ||
515 | step( | |
516 | "Verify that R2 keeps the stale entries in FIB & R1 keeps stale entries in RIB & FIB" | |
517 | ) | |
518 | ||
519 | for addr_type in ADDR_TYPES: | |
520 | protocol = "bgp" | |
521 | next_hop = next_hop_per_address_family( | |
522 | tgen, "r2", "r1", addr_type, NEXT_HOP_IP_1 | |
523 | ) | |
524 | input_topo = {"r1": topo["routers"]["r1"]} | |
525 | result = verify_rib(tgen, addr_type, "r2", input_topo, next_hop, protocol) | |
526 | assert ( | |
527 | result is True | |
528 | ), "Testcase {} : Failed \n Routes are still present \n Error {}".format( | |
529 | tc_name, result | |
530 | ) | |
531 | ||
532 | for addr_type in ADDR_TYPES: | |
533 | next_hop = next_hop_per_address_family( | |
534 | tgen, "r1", "r2", addr_type, NEXT_HOP_IP_2 | |
535 | ) | |
536 | input_topo = {"r2": topo["routers"]["r2"]} | |
537 | result = verify_bgp_rib(tgen, addr_type, "r1", input_topo, next_hop) | |
538 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
539 | tc_name, result | |
540 | ) | |
541 | ||
542 | result = verify_rib(tgen, addr_type, "r1", input_topo, next_hop, protocol) | |
543 | assert ( | |
544 | result is True | |
545 | ), "Testcase {} : Failed \n Routes are still present \n Error {}".format( | |
546 | tc_name, result | |
547 | ) | |
548 | ||
549 | step("Start BGP on R2") | |
550 | ||
551 | start_router_daemons(tgen, "r2", ["bgpd"]) | |
552 | ||
553 | write_test_footer(tc_name) | |
554 | ||
555 | ||
556 | def test_BGP_GR_TC_51_p1(request): | |
557 | """ | |
558 | Test Objective : Transition from Peer-level restarting to Global inherit helper | |
559 | Global Mode : None | |
560 | PerPeer Mode : GR Restart | |
561 | GR Mode effective : GR Restart | |
562 | ||
563 | """ | |
564 | ||
565 | tgen = get_topogen() | |
566 | tc_name = request.node.name | |
567 | write_test_header(tc_name) | |
568 | ||
569 | # Check router status | |
570 | check_router_status(tgen) | |
571 | ||
572 | # Don't run this test if we have any failure. | |
573 | if tgen.routers_have_failure(): | |
574 | pytest.skip(tgen.errors) | |
575 | ||
576 | # Creating configuration from JSON | |
577 | reset_config_on_routers(tgen) | |
578 | ||
579 | step("Configure R1 as GR restarting node at per Peer-level for R2") | |
580 | ||
581 | input_dict = { | |
582 | "r1": { | |
583 | "bgp": { | |
584 | "address_family": { | |
585 | "ipv4": { | |
586 | "unicast": { | |
587 | "neighbor": { | |
588 | "r2": { | |
589 | "dest_link": { | |
590 | "r1-link1": {"graceful-restart": True} | |
591 | } | |
592 | } | |
593 | } | |
594 | } | |
595 | }, | |
596 | "ipv6": { | |
597 | "unicast": { | |
598 | "neighbor": { | |
599 | "r2": { | |
600 | "dest_link": { | |
601 | "r1-link1": {"graceful-restart": True} | |
602 | } | |
603 | } | |
604 | } | |
605 | } | |
606 | }, | |
607 | } | |
608 | } | |
609 | }, | |
610 | "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}}, | |
611 | } | |
612 | ||
613 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
614 | step("Verify on R2 that R1 advertises GR capabilities as a restarting node") | |
615 | ||
616 | for addr_type in ADDR_TYPES: | |
617 | result = verify_graceful_restart( | |
618 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
619 | ) | |
620 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
621 | tc_name, result | |
622 | ) | |
623 | ||
17022899 KK |
624 | for addr_type in ADDR_TYPES: |
625 | protocol = "bgp" | |
626 | next_hop = next_hop_per_address_family( | |
627 | tgen, "r1", "r2", addr_type, NEXT_HOP_IP_2 | |
628 | ) | |
629 | input_topo = {"r2": topo["routers"]["r2"]} | |
630 | result = verify_rib(tgen, addr_type, "r1", input_topo, next_hop, protocol) | |
631 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
632 | tc_name, result | |
633 | ) | |
634 | ||
635 | for addr_type in ADDR_TYPES: | |
636 | next_hop = next_hop_per_address_family( | |
637 | tgen, "r2", "r1", addr_type, NEXT_HOP_IP_1 | |
638 | ) | |
639 | input_topo = {"r1": topo["routers"]["r1"]} | |
640 | result = verify_bgp_rib(tgen, addr_type, "r2", input_topo, next_hop) | |
641 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
642 | tc_name, result | |
643 | ) | |
644 | ||
645 | result = verify_rib(tgen, addr_type, "r2", input_topo, next_hop, protocol) | |
646 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
647 | tc_name, result | |
648 | ) | |
649 | ||
35ba1e3d KK |
650 | step("Kill BGP on R1") |
651 | ||
652 | kill_router_daemons(tgen, "r1", ["bgpd"]) | |
653 | ||
654 | step( | |
655 | "Verify that R1 keeps the stale entries in FIB & R2 keeps stale entries in RIB & FIB" | |
656 | ) | |
657 | ||
658 | for addr_type in ADDR_TYPES: | |
659 | protocol = "bgp" | |
660 | next_hop = next_hop_per_address_family( | |
661 | tgen, "r1", "r2", addr_type, NEXT_HOP_IP_2 | |
662 | ) | |
663 | input_topo = {"r2": topo["routers"]["r2"]} | |
664 | result = verify_rib(tgen, addr_type, "r1", input_topo, next_hop, protocol) | |
665 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
666 | tc_name, result | |
667 | ) | |
668 | ||
669 | for addr_type in ADDR_TYPES: | |
670 | next_hop = next_hop_per_address_family( | |
671 | tgen, "r2", "r1", addr_type, NEXT_HOP_IP_1 | |
672 | ) | |
673 | input_topo = {"r1": topo["routers"]["r1"]} | |
674 | result = verify_bgp_rib(tgen, addr_type, "r2", input_topo, next_hop) | |
675 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
676 | tc_name, result | |
677 | ) | |
678 | ||
679 | result = verify_rib(tgen, addr_type, "r2", input_topo, next_hop, protocol) | |
680 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
681 | tc_name, result | |
682 | ) | |
683 | ||
684 | step("Bring up BGP on R1 and remove Peer-level GR config") | |
685 | ||
686 | start_router_daemons(tgen, "r1", ["bgpd"]) | |
687 | ||
688 | input_dict = { | |
689 | "r1": { | |
690 | "bgp": { | |
691 | "address_family": { | |
692 | "ipv4": { | |
693 | "unicast": { | |
694 | "neighbor": { | |
695 | "r2": { | |
696 | "dest_link": { | |
697 | "r1-link1": {"graceful-restart": False} | |
698 | } | |
699 | } | |
700 | } | |
701 | } | |
702 | }, | |
703 | "ipv6": { | |
704 | "unicast": { | |
705 | "neighbor": { | |
706 | "r2": { | |
707 | "dest_link": { | |
708 | "r1-link1": {"graceful-restart": False} | |
709 | } | |
710 | } | |
711 | } | |
712 | } | |
713 | }, | |
714 | } | |
715 | } | |
716 | } | |
717 | } | |
718 | ||
2268cf50 KK |
719 | result = create_router_bgp(tgen, topo, input_dict) |
720 | assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) | |
721 | ||
722 | for addr_type in ADDR_TYPES: | |
723 | neighbor = topo["routers"]["r2"]["links"]["r1-link1"][addr_type].split("/")[0] | |
724 | clear_bgp(tgen, addr_type, "r1", neighbor=neighbor) | |
725 | ||
726 | result = verify_bgp_convergence_from_running_config(tgen) | |
727 | assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) | |
35ba1e3d KK |
728 | |
729 | step("Verify on R2 that R1 advertises GR capabilities as a helper node") | |
730 | ||
731 | input_dict = { | |
732 | "r1": {"bgp": {"graceful-restart": {"graceful-restart-helper": True}}}, | |
733 | "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}}, | |
734 | } | |
735 | ||
736 | for addr_type in ADDR_TYPES: | |
737 | result = verify_graceful_restart( | |
738 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
739 | ) | |
740 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
741 | tc_name, result | |
742 | ) | |
743 | ||
17022899 KK |
744 | for addr_type in ADDR_TYPES: |
745 | protocol = "bgp" | |
746 | next_hop = next_hop_per_address_family( | |
747 | tgen, "r2", "r1", addr_type, NEXT_HOP_IP_1 | |
748 | ) | |
749 | input_topo = {"r1": topo["routers"]["r1"]} | |
750 | result = verify_rib(tgen, addr_type, "r2", input_topo, next_hop, protocol) | |
751 | assert ( | |
752 | result is True | |
753 | ), "Testcase {} : Failed \n Routes are still present \n Error {}".format( | |
754 | tc_name, result | |
755 | ) | |
756 | ||
757 | for addr_type in ADDR_TYPES: | |
758 | next_hop = next_hop_per_address_family( | |
759 | tgen, "r1", "r2", addr_type, NEXT_HOP_IP_2 | |
760 | ) | |
761 | input_topo = {"r2": topo["routers"]["r2"]} | |
762 | result = verify_bgp_rib(tgen, addr_type, "r1", input_topo, next_hop) | |
763 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
764 | tc_name, result | |
765 | ) | |
766 | ||
767 | result = verify_rib(tgen, addr_type, "r1", input_topo, next_hop, protocol) | |
768 | assert ( | |
769 | result is True | |
770 | ), "Testcase {} : Failed \n Routes are still present \n Error {}".format( | |
771 | tc_name, result | |
772 | ) | |
773 | ||
35ba1e3d KK |
774 | step("Kill BGPd on R2") |
775 | ||
776 | kill_router_daemons(tgen, "r2", ["bgpd"]) | |
777 | ||
778 | step( | |
779 | "Verify that R2 keeps the stale entries in FIB & R1 keeps stale entries in RIB & FIB" | |
780 | ) | |
781 | ||
782 | for addr_type in ADDR_TYPES: | |
783 | protocol = "bgp" | |
784 | next_hop = next_hop_per_address_family( | |
785 | tgen, "r2", "r1", addr_type, NEXT_HOP_IP_1 | |
786 | ) | |
787 | input_topo = {"r1": topo["routers"]["r1"]} | |
788 | result = verify_rib(tgen, addr_type, "r2", input_topo, next_hop, protocol) | |
789 | assert ( | |
790 | result is True | |
791 | ), "Testcase {} : Failed \n Routes are still present \n Error {}".format( | |
792 | tc_name, result | |
793 | ) | |
794 | ||
795 | for addr_type in ADDR_TYPES: | |
796 | next_hop = next_hop_per_address_family( | |
797 | tgen, "r1", "r2", addr_type, NEXT_HOP_IP_2 | |
798 | ) | |
799 | input_topo = {"r2": topo["routers"]["r2"]} | |
800 | result = verify_bgp_rib(tgen, addr_type, "r1", input_topo, next_hop) | |
801 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
802 | tc_name, result | |
803 | ) | |
804 | ||
805 | result = verify_rib(tgen, addr_type, "r1", input_topo, next_hop, protocol) | |
806 | assert ( | |
807 | result is True | |
808 | ), "Testcase {} : Failed \n Routes are still present \n Error {}".format( | |
809 | tc_name, result | |
810 | ) | |
811 | ||
812 | step("Start BGP on R2") | |
813 | ||
814 | start_router_daemons(tgen, "r2", ["bgpd"]) | |
815 | ||
816 | write_test_footer(tc_name) | |
817 | ||
818 | ||
819 | def test_BGP_GR_TC_53_p1(request): | |
820 | """ | |
821 | Test Objective : Default GR functional mode is Helper. | |
822 | Global Mode : None | |
823 | PerPeer Mode : None | |
824 | GR Mode effective : GR Helper | |
825 | ||
826 | """ | |
827 | ||
828 | tgen = get_topogen() | |
829 | tc_name = request.node.name | |
830 | write_test_header(tc_name) | |
831 | ||
832 | # Check router status | |
833 | check_router_status(tgen) | |
834 | ||
835 | # Don't run this test if we have any failure. | |
836 | if tgen.routers_have_failure(): | |
837 | pytest.skip(tgen.errors) | |
838 | ||
839 | # Creating configuration from JSON | |
840 | reset_config_on_routers(tgen) | |
841 | ||
842 | step("configure R2 as global restarting node") | |
843 | ||
844 | input_dict = {"r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}}} | |
845 | ||
846 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
847 | ||
848 | step( | |
849 | "Verify on R2 that R1 advertises GR capabilities as a helper node based on inherit" | |
850 | ) | |
851 | ||
852 | input_dict = { | |
853 | "r1": {"bgp": {"graceful-restart": {"graceful-restart-helper": True}}}, | |
854 | "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}}, | |
855 | } | |
856 | ||
857 | for addr_type in ADDR_TYPES: | |
858 | result = verify_graceful_restart( | |
859 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
860 | ) | |
861 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
862 | tc_name, result | |
863 | ) | |
864 | ||
17022899 KK |
865 | for addr_type in ADDR_TYPES: |
866 | protocol = "bgp" | |
867 | next_hop = next_hop_per_address_family( | |
868 | tgen, "r2", "r1", addr_type, NEXT_HOP_IP_1 | |
869 | ) | |
870 | input_topo = {"r1": topo["routers"]["r1"]} | |
871 | result = verify_rib(tgen, addr_type, "r2", input_topo, next_hop, protocol) | |
872 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
873 | tc_name, result | |
874 | ) | |
875 | ||
876 | for addr_type in ADDR_TYPES: | |
877 | next_hop = next_hop_per_address_family( | |
878 | tgen, "r1", "r2", addr_type, NEXT_HOP_IP_2 | |
879 | ) | |
880 | input_topo = {"r2": topo["routers"]["r2"]} | |
881 | result = verify_bgp_rib(tgen, addr_type, "r1", input_topo, next_hop) | |
882 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
883 | tc_name, result | |
884 | ) | |
885 | ||
886 | result = verify_rib(tgen, addr_type, "r1", input_topo, next_hop, protocol) | |
887 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
888 | tc_name, result | |
889 | ) | |
890 | ||
35ba1e3d KK |
891 | step("Kill BGPd on R2") |
892 | ||
893 | kill_router_daemons(tgen, "r2", ["bgpd"]) | |
894 | ||
895 | step( | |
896 | "Verify that R2 keeps the stale entries in FIB & R1 keeps stale entries in RIB & FIB" | |
897 | ) | |
898 | ||
899 | for addr_type in ADDR_TYPES: | |
900 | protocol = "bgp" | |
901 | next_hop = next_hop_per_address_family( | |
902 | tgen, "r2", "r1", addr_type, NEXT_HOP_IP_1 | |
903 | ) | |
904 | input_topo = {"r1": topo["routers"]["r1"]} | |
905 | result = verify_rib(tgen, addr_type, "r2", input_topo, next_hop, protocol) | |
906 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
907 | tc_name, result | |
908 | ) | |
909 | ||
910 | for addr_type in ADDR_TYPES: | |
911 | next_hop = next_hop_per_address_family( | |
912 | tgen, "r1", "r2", addr_type, NEXT_HOP_IP_2 | |
913 | ) | |
914 | input_topo = {"r2": topo["routers"]["r2"]} | |
915 | result = verify_bgp_rib(tgen, addr_type, "r1", input_topo, next_hop) | |
916 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
917 | tc_name, result | |
918 | ) | |
919 | ||
920 | result = verify_rib(tgen, addr_type, "r1", input_topo, next_hop, protocol) | |
921 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
922 | tc_name, result | |
923 | ) | |
924 | ||
925 | step("Start BGP on R2") | |
926 | ||
927 | start_router_daemons(tgen, "r2", ["bgpd"]) | |
928 | ||
929 | write_test_footer(tc_name) | |
930 | ||
931 | ||
17022899 | 932 | def test_BGP_GR_TC_4_p0(request): |
35ba1e3d | 933 | """ |
9fa6ec14 | 934 | Test Objective : Verify that the restarting node sets "R" bit while sending the |
935 | BGP open messages after the node restart, only if GR is enabled. | |
35ba1e3d KK |
936 | """ |
937 | ||
938 | tgen = get_topogen() | |
939 | tc_name = request.node.name | |
940 | write_test_header(tc_name) | |
941 | ||
17022899 KK |
942 | # Check router status |
943 | check_router_status(tgen) | |
944 | ||
35ba1e3d KK |
945 | # Don't run this test if we have any failure. |
946 | if tgen.routers_have_failure(): | |
947 | pytest.skip(tgen.errors) | |
948 | ||
17022899 KK |
949 | # Creating configuration from JSON |
950 | reset_config_on_routers(tgen) | |
35ba1e3d | 951 | |
17022899 KK |
952 | logger.info( |
953 | "[Phase 1] : Test Setup" " [Restart Mode]R1-----R2[Helper Mode] initialized " | |
954 | ) | |
955 | ||
956 | # Configure graceful-restart | |
957 | input_dict = { | |
35ba1e3d KK |
958 | "r1": { |
959 | "bgp": { | |
960 | "address_family": { | |
17022899 | 961 | "ipv4": { |
35ba1e3d KK |
962 | "unicast": { |
963 | "neighbor": { | |
964 | "r2": { | |
965 | "dest_link": { | |
17022899 | 966 | "r1-link1": {"graceful-restart": True} |
35ba1e3d KK |
967 | } |
968 | } | |
969 | } | |
970 | } | |
17022899 | 971 | }, |
35ba1e3d KK |
972 | "ipv6": { |
973 | "unicast": { | |
974 | "neighbor": { | |
975 | "r2": { | |
976 | "dest_link": { | |
17022899 | 977 | "r1-link1": {"graceful-restart": True} |
35ba1e3d KK |
978 | } |
979 | } | |
980 | } | |
981 | } | |
982 | }, | |
983 | } | |
984 | } | |
985 | }, | |
986 | "r2": { | |
987 | "bgp": { | |
35ba1e3d KK |
988 | "address_family": { |
989 | "ipv4": { | |
990 | "unicast": { | |
991 | "neighbor": { | |
992 | "r1": { | |
993 | "dest_link": { | |
17022899 | 994 | "r2-link1": {"graceful-restart-helper": True} |
35ba1e3d KK |
995 | } |
996 | } | |
997 | } | |
998 | } | |
999 | }, | |
1000 | "ipv6": { | |
1001 | "unicast": { | |
1002 | "neighbor": { | |
1003 | "r1": { | |
1004 | "dest_link": { | |
17022899 | 1005 | "r2-link1": {"graceful-restart-helper": True} |
35ba1e3d KK |
1006 | } |
1007 | } | |
1008 | } | |
1009 | } | |
1010 | }, | |
17022899 | 1011 | } |
35ba1e3d KK |
1012 | } |
1013 | }, | |
1014 | } | |
1015 | ||
17022899 | 1016 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") |
35ba1e3d KK |
1017 | |
1018 | for addr_type in ADDR_TYPES: | |
1019 | result = verify_graceful_restart( | |
17022899 | 1020 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" |
35ba1e3d KK |
1021 | ) |
1022 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
1023 | tc_name, result | |
1024 | ) | |
1025 | ||
1026 | # Verifying BGP RIB routes | |
1027 | dut = "r1" | |
1028 | peer = "r2" | |
1029 | next_hop = next_hop_per_address_family( | |
17022899 | 1030 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 |
35ba1e3d KK |
1031 | ) |
1032 | input_topo = {key: topo["routers"][key] for key in ["r2"]} | |
17022899 | 1033 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) |
35ba1e3d KK |
1034 | assert result is True, "Testcase {} : Failed \n Error {}".format( |
1035 | tc_name, result | |
1036 | ) | |
1037 | ||
1038 | # Verifying RIB routes | |
17022899 KK |
1039 | protocol = "bgp" |
1040 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
35ba1e3d KK |
1041 | assert result is True, "Testcase {} : Failed \n Error {}".format( |
1042 | tc_name, result | |
1043 | ) | |
1044 | ||
1045 | logger.info("[Phase 2] : R2 goes for reload ") | |
1046 | ||
1047 | kill_router_daemons(tgen, "r2", ["bgpd"]) | |
1048 | ||
1049 | logger.info( | |
17022899 KK |
1050 | "[Phase 3] : R2 is still down, restart time {} sec." |
1051 | "So time verify the routes are present in BGP RIB and ZEBRA ".format( | |
1052 | GR_RESTART_TIMER | |
1053 | ) | |
35ba1e3d KK |
1054 | ) |
1055 | ||
1056 | for addr_type in ADDR_TYPES: | |
1057 | # Verifying BGP RIB routes | |
1058 | next_hop = next_hop_per_address_family( | |
17022899 | 1059 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 |
35ba1e3d | 1060 | ) |
35ba1e3d | 1061 | input_topo = {key: topo["routers"][key] for key in ["r2"]} |
17022899 KK |
1062 | result = verify_bgp_rib( |
1063 | tgen, addr_type, dut, input_topo, next_hop, expected=False | |
1064 | ) | |
0b25370e DS |
1065 | assert result is not True, ( |
1066 | "Testcase {} : Failed \n " | |
5cbb02eb | 1067 | "r1: routes are still present in BGP RIB\n Error: {}".format( |
0b25370e DS |
1068 | tc_name, result |
1069 | ) | |
1070 | ) | |
35ba1e3d KK |
1071 | logger.info(" Expected behavior: {}".format(result)) |
1072 | ||
1073 | # Verifying RIB routes | |
1074 | result = verify_rib( | |
17022899 | 1075 | tgen, addr_type, dut, input_topo, next_hop, protocol, expected=False |
35ba1e3d | 1076 | ) |
0b25370e DS |
1077 | assert result is not True, ( |
1078 | "Testcase {} : Failed \n " | |
1079 | "r1: routes are still present in ZEBRA\n Error: {}".format(tc_name, result) | |
1080 | ) | |
35ba1e3d KK |
1081 | logger.info(" Expected behavior: {}".format(result)) |
1082 | ||
1083 | logger.info("[Phase 5] : R2 is about to come up now ") | |
1084 | start_router_daemons(tgen, "r2", ["bgpd"]) | |
1085 | ||
17022899 | 1086 | logger.info("[Phase 4] : R2 is UP now, so time to collect GR stats ") |
35ba1e3d KK |
1087 | |
1088 | for addr_type in ADDR_TYPES: | |
35ba1e3d | 1089 | result = verify_graceful_restart( |
17022899 | 1090 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" |
35ba1e3d KK |
1091 | ) |
1092 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
1093 | tc_name, result | |
1094 | ) | |
1095 | ||
1096 | result = verify_r_bit(tgen, topo, addr_type, input_dict, dut="r1", peer="r2") | |
1097 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
1098 | tc_name, result | |
1099 | ) | |
1100 | ||
1101 | # Verifying BGP RIB routes | |
1102 | next_hop = next_hop_per_address_family( | |
17022899 | 1103 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 |
35ba1e3d | 1104 | ) |
17022899 | 1105 | input_topo = {key: topo["routers"][key] for key in ["r2"]} |
35ba1e3d KK |
1106 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) |
1107 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
1108 | tc_name, result | |
1109 | ) | |
1110 | ||
1111 | # Verifying RIB routes | |
1112 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
1113 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
1114 | tc_name, result | |
1115 | ) | |
1116 | ||
1117 | write_test_footer(tc_name) | |
1118 | ||
1119 | ||
17022899 | 1120 | def test_BGP_GR_TC_5_1_2_p1(request): |
35ba1e3d | 1121 | """ |
9fa6ec14 | 1122 | Test Objective : Verify if restarting node resets R bit in BGP open message |
1123 | during normal BGP session flaps as well, even when GR restarting mode is enabled. | |
1124 | Here link flap happen due to interface UP/DOWN. | |
35ba1e3d | 1125 | |
35ba1e3d | 1126 | """ |
35ba1e3d KK |
1127 | tgen = get_topogen() |
1128 | tc_name = request.node.name | |
1129 | write_test_header(tc_name) | |
1130 | ||
17022899 | 1131 | # Check router status |
35ba1e3d KK |
1132 | check_router_status(tgen) |
1133 | ||
1134 | # Don't run this test if we have any failure. | |
1135 | if tgen.routers_have_failure(): | |
1136 | pytest.skip(tgen.errors) | |
1137 | ||
1138 | # Creating configuration from JSON | |
17022899 | 1139 | reset_config_on_routers(tgen) |
35ba1e3d KK |
1140 | |
1141 | logger.info( | |
17022899 | 1142 | "[Phase 1] : Test Setup" " [Restart Mode]R1-----R2[Restart Mode] initialized " |
35ba1e3d KK |
1143 | ) |
1144 | ||
1145 | # Configure graceful-restart | |
1146 | input_dict = { | |
1147 | "r1": { | |
1148 | "bgp": { | |
1149 | "address_family": { | |
1150 | "ipv4": { | |
1151 | "unicast": { | |
1152 | "neighbor": { | |
1153 | "r2": { | |
1154 | "dest_link": { | |
1155 | "r1-link1": {"graceful-restart": True} | |
1156 | } | |
1157 | } | |
1158 | } | |
1159 | } | |
1160 | }, | |
1161 | "ipv6": { | |
1162 | "unicast": { | |
1163 | "neighbor": { | |
1164 | "r2": { | |
1165 | "dest_link": { | |
1166 | "r1-link1": {"graceful-restart": True} | |
1167 | } | |
1168 | } | |
1169 | } | |
1170 | } | |
1171 | }, | |
1172 | } | |
1173 | } | |
1174 | }, | |
1175 | "r2": { | |
1176 | "bgp": { | |
1177 | "address_family": { | |
1178 | "ipv4": { | |
1179 | "unicast": { | |
1180 | "neighbor": { | |
1181 | "r1": { | |
1182 | "dest_link": { | |
17022899 | 1183 | "r2-link1": {"graceful-restart": True} |
35ba1e3d KK |
1184 | } |
1185 | } | |
1186 | } | |
1187 | } | |
1188 | }, | |
1189 | "ipv6": { | |
1190 | "unicast": { | |
1191 | "neighbor": { | |
1192 | "r1": { | |
1193 | "dest_link": { | |
17022899 | 1194 | "r2-link1": {"graceful-restart": True} |
35ba1e3d KK |
1195 | } |
1196 | } | |
1197 | } | |
1198 | } | |
1199 | }, | |
1200 | } | |
1201 | } | |
1202 | }, | |
1203 | } | |
1204 | ||
1205 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
1206 | ||
1207 | for addr_type in ADDR_TYPES: | |
1208 | result = verify_graceful_restart( | |
1209 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
1210 | ) | |
1211 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
1212 | tc_name, result | |
1213 | ) | |
1214 | ||
1215 | # Verifying BGP RIB routes | |
1216 | dut = "r1" | |
1217 | peer = "r2" | |
1218 | next_hop = next_hop_per_address_family( | |
17022899 | 1219 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 |
35ba1e3d KK |
1220 | ) |
1221 | input_topo = {key: topo["routers"][key] for key in ["r2"]} | |
1222 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
1223 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
1224 | tc_name, result | |
1225 | ) | |
1226 | ||
1227 | # Verifying RIB routes | |
1228 | protocol = "bgp" | |
1229 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
1230 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
1231 | tc_name, result | |
1232 | ) | |
1233 | ||
17022899 KK |
1234 | logger.info("[Phase 2] : Now flap the link running the BGP session ") |
1235 | # Shutdown interface | |
1236 | intf = "r2-r1-eth0" | |
1237 | shutdown_bringup_interface(tgen, "r2", intf) | |
35ba1e3d | 1238 | |
17022899 | 1239 | # Bring up Interface |
662aa246 | 1240 | shutdown_bringup_interface(tgen, "r2", intf, ifaceaction=True) |
35ba1e3d KK |
1241 | |
1242 | for addr_type in ADDR_TYPES: | |
35ba1e3d KK |
1243 | result = verify_graceful_restart( |
1244 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
1245 | ) | |
1246 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
1247 | tc_name, result | |
1248 | ) | |
1249 | ||
17022899 | 1250 | result = verify_r_bit(tgen, topo, addr_type, input_dict, dut="r1", peer="r2") |
35ba1e3d KK |
1251 | assert result is True, "Testcase {} : Failed \n Error {}".format( |
1252 | tc_name, result | |
1253 | ) | |
1254 | ||
17022899 KK |
1255 | logger.info("[Phase 2] : Restart BGPd on router R2. ") |
1256 | kill_router_daemons(tgen, "r2", ["bgpd"]) | |
1257 | ||
1258 | start_router_daemons(tgen, "r2", ["bgpd"]) | |
1259 | ||
1260 | logger.info("[Phase 4] : R2 is UP now, so time to collect GR stats ") | |
1261 | ||
1262 | for addr_type in ADDR_TYPES: | |
1263 | result = verify_graceful_restart( | |
1264 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
35ba1e3d | 1265 | ) |
35ba1e3d KK |
1266 | assert result is True, "Testcase {} : Failed \n Error {}".format( |
1267 | tc_name, result | |
1268 | ) | |
1269 | ||
17022899 | 1270 | result = verify_r_bit(tgen, topo, addr_type, input_dict, dut="r1", peer="r2") |
35ba1e3d KK |
1271 | assert result is True, "Testcase {} : Failed \n Error {}".format( |
1272 | tc_name, result | |
1273 | ) | |
1274 | ||
17022899 KK |
1275 | # Verifying BGP RIB routes |
1276 | next_hop = next_hop_per_address_family( | |
1277 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
1278 | ) | |
1279 | input_topo = {key: topo["routers"][key] for key in ["r2"]} | |
1280 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
35ba1e3d KK |
1281 | assert result is True, "Testcase {} : Failed \n Error {}".format( |
1282 | tc_name, result | |
1283 | ) | |
1284 | ||
17022899 KK |
1285 | # Verifying RIB routes |
1286 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
1287 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
35ba1e3d KK |
1288 | tc_name, result |
1289 | ) | |
1290 | ||
1291 | write_test_footer(tc_name) | |
1292 | ||
1293 | ||
17022899 | 1294 | def test_BGP_GR_TC_6_1_2_p1(request): |
35ba1e3d | 1295 | """ |
17022899 KK |
1296 | Test Objective : Verify if restarting node resets R bit in BGP |
1297 | open message during normal BGP session flaps when GR is disabled. | |
35ba1e3d KK |
1298 | """ |
1299 | ||
1300 | tgen = get_topogen() | |
1301 | tc_name = request.node.name | |
1302 | write_test_header(tc_name) | |
1303 | ||
1304 | # Check router status | |
1305 | check_router_status(tgen) | |
1306 | ||
1307 | # Don't run this test if we have any failure. | |
1308 | if tgen.routers_have_failure(): | |
1309 | pytest.skip(tgen.errors) | |
1310 | ||
1311 | # Creating configuration from JSON | |
1312 | reset_config_on_routers(tgen) | |
1313 | ||
1314 | logger.info( | |
17022899 | 1315 | "[Phase 1] : Test Setup" "[Restart Mode]R1-----R2[Helper Mode] initialized " |
35ba1e3d KK |
1316 | ) |
1317 | ||
1318 | # Configure graceful-restart | |
1319 | input_dict = { | |
1320 | "r1": { | |
1321 | "bgp": { | |
1322 | "address_family": { | |
1323 | "ipv4": { | |
1324 | "unicast": { | |
1325 | "neighbor": { | |
1326 | "r2": { | |
1327 | "dest_link": { | |
17022899 | 1328 | "r1-link1": {"graceful-restart": True} |
35ba1e3d KK |
1329 | } |
1330 | } | |
1331 | } | |
1332 | } | |
1333 | }, | |
1334 | "ipv6": { | |
1335 | "unicast": { | |
1336 | "neighbor": { | |
1337 | "r2": { | |
1338 | "dest_link": { | |
17022899 | 1339 | "r1-link1": {"graceful-restart": True} |
35ba1e3d KK |
1340 | } |
1341 | } | |
1342 | } | |
1343 | } | |
1344 | }, | |
1345 | } | |
1346 | } | |
1347 | }, | |
1348 | "r2": { | |
1349 | "bgp": { | |
1350 | "address_family": { | |
1351 | "ipv4": { | |
1352 | "unicast": { | |
1353 | "neighbor": { | |
1354 | "r1": { | |
1355 | "dest_link": { | |
17022899 | 1356 | "r2-link1": {"graceful-restart-helper": True} |
35ba1e3d KK |
1357 | } |
1358 | } | |
1359 | } | |
1360 | } | |
1361 | }, | |
1362 | "ipv6": { | |
1363 | "unicast": { | |
1364 | "neighbor": { | |
1365 | "r1": { | |
1366 | "dest_link": { | |
17022899 | 1367 | "r2-link1": {"graceful-restart-helper": True} |
35ba1e3d KK |
1368 | } |
1369 | } | |
1370 | } | |
1371 | } | |
1372 | }, | |
1373 | } | |
1374 | } | |
1375 | }, | |
1376 | } | |
1377 | ||
1378 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
1379 | ||
1380 | for addr_type in ADDR_TYPES: | |
1381 | result = verify_graceful_restart( | |
1382 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
1383 | ) | |
1384 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
1385 | tc_name, result | |
1386 | ) | |
1387 | ||
1388 | # Verifying BGP RIB routes | |
1389 | dut = "r1" | |
1390 | peer = "r2" | |
1391 | next_hop = next_hop_per_address_family( | |
1392 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
1393 | ) | |
1394 | input_topo = {key: topo["routers"][key] for key in ["r2"]} | |
1395 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
1396 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
1397 | tc_name, result | |
1398 | ) | |
1399 | ||
1400 | # Verifying RIB routes | |
1401 | protocol = "bgp" | |
1402 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
1403 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
1404 | tc_name, result | |
1405 | ) | |
1406 | ||
17022899 | 1407 | logger.info("[Phase 1] : Changing mode" "[Disable Mode]R1-----R2[Helper Mode]") |
35ba1e3d KK |
1408 | |
1409 | # Configure graceful-restart | |
1410 | input_dict = { | |
1411 | "r1": { | |
1412 | "bgp": { | |
1413 | "address_family": { | |
1414 | "ipv4": { | |
1415 | "unicast": { | |
1416 | "neighbor": { | |
1417 | "r2": { | |
1418 | "dest_link": { | |
17022899 | 1419 | "r1-link1": {"graceful-restart-disable": True} |
35ba1e3d KK |
1420 | } |
1421 | } | |
1422 | } | |
1423 | } | |
1424 | }, | |
1425 | "ipv6": { | |
1426 | "unicast": { | |
1427 | "neighbor": { | |
1428 | "r2": { | |
1429 | "dest_link": { | |
17022899 | 1430 | "r1-link1": {"graceful-restart-disable": True} |
35ba1e3d KK |
1431 | } |
1432 | } | |
1433 | } | |
1434 | } | |
1435 | }, | |
1436 | } | |
1437 | } | |
17022899 KK |
1438 | } |
1439 | } | |
1440 | ||
1441 | result = create_router_bgp(tgen, topo, input_dict) | |
1442 | assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) | |
1443 | ||
1444 | for addr_type in ADDR_TYPES: | |
2268cf50 KK |
1445 | neighbor = topo["routers"]["r2"]["links"]["r1-link1"][addr_type].split("/")[0] |
1446 | clear_bgp(tgen, addr_type, "r1", neighbor=neighbor) | |
17022899 | 1447 | |
2268cf50 | 1448 | result = verify_bgp_convergence_from_running_config(tgen) |
17022899 KK |
1449 | assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) |
1450 | ||
1451 | # Verify GR stats | |
1452 | input_dict = { | |
35ba1e3d KK |
1453 | "r2": { |
1454 | "bgp": { | |
1455 | "address_family": { | |
1456 | "ipv4": { | |
1457 | "unicast": { | |
1458 | "neighbor": { | |
1459 | "r1": { | |
1460 | "dest_link": { | |
1461 | "r2-link1": {"graceful-restart-helper": True} | |
1462 | } | |
1463 | } | |
1464 | } | |
1465 | } | |
1466 | }, | |
1467 | "ipv6": { | |
1468 | "unicast": { | |
1469 | "neighbor": { | |
1470 | "r1": { | |
1471 | "dest_link": { | |
1472 | "r2-link1": {"graceful-restart-helper": True} | |
1473 | } | |
1474 | } | |
1475 | } | |
1476 | } | |
1477 | }, | |
1478 | } | |
1479 | } | |
1480 | }, | |
17022899 KK |
1481 | "r1": { |
1482 | "bgp": { | |
1483 | "address_family": { | |
1484 | "ipv4": { | |
1485 | "unicast": { | |
1486 | "neighbor": { | |
1487 | "r2": { | |
1488 | "dest_link": { | |
1489 | "r1-link1": {"graceful-restart-disable": True} | |
1490 | } | |
1491 | } | |
1492 | } | |
1493 | } | |
1494 | }, | |
1495 | "ipv6": { | |
1496 | "unicast": { | |
1497 | "neighbor": { | |
1498 | "r2": { | |
1499 | "dest_link": { | |
1500 | "r1-link1": {"graceful-restart-disable": True} | |
1501 | } | |
1502 | } | |
1503 | } | |
1504 | } | |
1505 | }, | |
1506 | } | |
1507 | } | |
1508 | }, | |
35ba1e3d KK |
1509 | } |
1510 | ||
17022899 KK |
1511 | # here the verify_graceful_restart fro the neighbor would be |
1512 | # "NotReceived" as the latest GR config is not yet applied. | |
35ba1e3d KK |
1513 | for addr_type in ADDR_TYPES: |
1514 | result = verify_graceful_restart( | |
1515 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
1516 | ) | |
1517 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
1518 | tc_name, result | |
1519 | ) | |
1520 | ||
17022899 KK |
1521 | logger.info("[Phase 2] : Now flap the link running the BGP session ") |
1522 | # Shutdown interface | |
1523 | intf = "r2-r1-eth0" | |
1524 | shutdown_bringup_interface(tgen, "r2", intf) | |
35ba1e3d | 1525 | |
17022899 | 1526 | # Bring up Interface |
662aa246 | 1527 | shutdown_bringup_interface(tgen, "r2", intf, ifaceaction=True) |
35ba1e3d KK |
1528 | |
1529 | for addr_type in ADDR_TYPES: | |
17022899 KK |
1530 | result = verify_graceful_restart( |
1531 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
35ba1e3d | 1532 | ) |
17022899 | 1533 | assert result is True, "Testcase {} : Failed \n Error {}".format( |
35ba1e3d KK |
1534 | tc_name, result |
1535 | ) | |
35ba1e3d | 1536 | |
17022899 KK |
1537 | result = verify_r_bit( |
1538 | tgen, topo, addr_type, input_dict, dut="r2", peer="r1", expected=False | |
35ba1e3d | 1539 | ) |
0b25370e DS |
1540 | assert ( |
1541 | result is not True | |
1542 | ), "Testcase {} : Failed \n " "r2: R-bit is set to True\n Error: {}".format( | |
35ba1e3d | 1543 | tc_name, result |
0b25370e | 1544 | ) |
35ba1e3d | 1545 | |
17022899 KK |
1546 | logger.info("Restart BGPd on R2 ") |
1547 | kill_router_daemons(tgen, "r2", ["bgpd"]) | |
35ba1e3d | 1548 | |
17022899 | 1549 | start_router_daemons(tgen, "r2", ["bgpd"]) |
35ba1e3d KK |
1550 | |
1551 | for addr_type in ADDR_TYPES: | |
1552 | result = verify_graceful_restart( | |
1553 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
1554 | ) | |
1555 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
1556 | tc_name, result | |
1557 | ) | |
1558 | ||
17022899 KK |
1559 | result = verify_r_bit( |
1560 | tgen, topo, addr_type, input_dict, dut="r2", peer="r1", expected=False | |
35ba1e3d | 1561 | ) |
0b25370e DS |
1562 | assert ( |
1563 | result is not True | |
1564 | ), "Testcase {} : Failed \n " "r2: R-bit is set to True\n Error: {}".format( | |
35ba1e3d | 1565 | tc_name, result |
0b25370e | 1566 | ) |
35ba1e3d KK |
1567 | |
1568 | write_test_footer(tc_name) | |
1569 | ||
1570 | ||
17022899 | 1571 | def test_BGP_GR_TC_8_p1(request): |
35ba1e3d | 1572 | """ |
9fa6ec14 | 1573 | Test Objective : Verify that restarting nodes set "F" bit while sending |
1574 | the BGP open messages after it restarts, only when BGP GR is enabled. | |
35ba1e3d | 1575 | """ |
17022899 | 1576 | |
35ba1e3d KK |
1577 | tgen = get_topogen() |
1578 | tc_name = request.node.name | |
1579 | write_test_header(tc_name) | |
1580 | ||
1581 | # Check router status | |
1582 | check_router_status(tgen) | |
1583 | ||
1584 | # Don't run this test if we have any failure. | |
1585 | if tgen.routers_have_failure(): | |
1586 | pytest.skip(tgen.errors) | |
1587 | ||
1588 | # Creating configuration from JSON | |
1589 | reset_config_on_routers(tgen) | |
1590 | ||
1591 | logger.info( | |
1592 | "[Phase 1] : Test Setup" " [Restart Mode]R1-----R2[Restart Mode] initialized " | |
1593 | ) | |
1594 | ||
1595 | # Configure graceful-restart | |
1596 | input_dict = { | |
1597 | "r1": { | |
1598 | "bgp": { | |
17022899 | 1599 | "graceful-restart": {"preserve-fw-state": True}, |
35ba1e3d KK |
1600 | "address_family": { |
1601 | "ipv4": { | |
1602 | "unicast": { | |
1603 | "neighbor": { | |
1604 | "r2": { | |
1605 | "dest_link": { | |
1606 | "r1-link1": {"graceful-restart": True} | |
1607 | } | |
1608 | } | |
1609 | } | |
1610 | } | |
1611 | }, | |
1612 | "ipv6": { | |
1613 | "unicast": { | |
1614 | "neighbor": { | |
1615 | "r2": { | |
1616 | "dest_link": { | |
1617 | "r1-link1": {"graceful-restart": True} | |
1618 | } | |
1619 | } | |
1620 | } | |
1621 | } | |
1622 | }, | |
17022899 | 1623 | }, |
35ba1e3d KK |
1624 | } |
1625 | }, | |
1626 | "r2": { | |
1627 | "bgp": { | |
1628 | "address_family": { | |
1629 | "ipv4": { | |
1630 | "unicast": { | |
1631 | "neighbor": { | |
1632 | "r1": { | |
1633 | "dest_link": { | |
1634 | "r2-link1": {"graceful-restart": True} | |
1635 | } | |
1636 | } | |
1637 | } | |
1638 | } | |
1639 | }, | |
1640 | "ipv6": { | |
1641 | "unicast": { | |
1642 | "neighbor": { | |
1643 | "r1": { | |
1644 | "dest_link": { | |
1645 | "r2-link1": {"graceful-restart": True} | |
1646 | } | |
1647 | } | |
1648 | } | |
1649 | } | |
1650 | }, | |
1651 | } | |
1652 | } | |
1653 | }, | |
1654 | } | |
1655 | ||
1656 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
1657 | ||
1658 | for addr_type in ADDR_TYPES: | |
1659 | result = verify_graceful_restart( | |
1660 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
1661 | ) | |
1662 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
1663 | tc_name, result | |
1664 | ) | |
1665 | ||
1666 | # Verifying BGP RIB routes | |
1667 | dut = "r1" | |
1668 | peer = "r2" | |
1669 | next_hop = next_hop_per_address_family( | |
1670 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
1671 | ) | |
1672 | input_topo = {key: topo["routers"][key] for key in ["r2"]} | |
1673 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
1674 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
1675 | tc_name, result | |
1676 | ) | |
1677 | ||
1678 | # Verifying RIB routes | |
1679 | protocol = "bgp" | |
1680 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
1681 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
1682 | tc_name, result | |
1683 | ) | |
1684 | ||
17022899 | 1685 | logger.info("[Phase 2] : R1 goes for reload ") |
35ba1e3d | 1686 | |
17022899 | 1687 | kill_router_daemons(tgen, "r1", ["bgpd"]) |
35ba1e3d | 1688 | |
17022899 KK |
1689 | logger.info("[Phase 3] : R1 is about to come up now ") |
1690 | start_router_daemons(tgen, "r1", ["bgpd"]) | |
35ba1e3d KK |
1691 | |
1692 | logger.info("[Phase 4] : R2 is UP now, so time to collect GR stats ") | |
1693 | ||
1694 | for addr_type in ADDR_TYPES: | |
1695 | result = verify_graceful_restart( | |
1696 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
1697 | ) | |
1698 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
1699 | tc_name, result | |
1700 | ) | |
1701 | ||
17022899 | 1702 | result = verify_r_bit(tgen, topo, addr_type, input_dict, dut="r2", peer="r1") |
35ba1e3d KK |
1703 | assert result is True, "Testcase {} : Failed \n Error {}".format( |
1704 | tc_name, result | |
1705 | ) | |
1706 | ||
17022899 | 1707 | result = verify_f_bit(tgen, topo, addr_type, input_dict, dut="r2", peer="r1") |
35ba1e3d KK |
1708 | assert result is True, "Testcase {} : Failed \n Error {}".format( |
1709 | tc_name, result | |
1710 | ) | |
1711 | ||
1712 | write_test_footer(tc_name) | |
1713 | ||
1714 | ||
17022899 | 1715 | def test_BGP_GR_TC_19_p1(request): |
35ba1e3d | 1716 | """ |
9fa6ec14 | 1717 | Test Objective : Verify that GR helper routers keeps all the routes received |
1718 | from restarting node if both the routers are configured as GR restarting node. | |
35ba1e3d KK |
1719 | """ |
1720 | ||
1721 | tgen = get_topogen() | |
1722 | tc_name = request.node.name | |
1723 | write_test_header(tc_name) | |
1724 | ||
1725 | # Check router status | |
1726 | check_router_status(tgen) | |
1727 | ||
1728 | # Don't run this test if we have any failure. | |
1729 | if tgen.routers_have_failure(): | |
1730 | pytest.skip(tgen.errors) | |
1731 | ||
1732 | # Creating configuration from JSON | |
1733 | reset_config_on_routers(tgen) | |
1734 | ||
17022899 | 1735 | logger.info("[Phase 1] : Test Setup [Helper]R1-----R2[Restart] initialized ") |
35ba1e3d KK |
1736 | |
1737 | # Configure graceful-restart | |
1738 | input_dict = { | |
1739 | "r1": { | |
1740 | "bgp": { | |
17022899 KK |
1741 | "graceful-restart": { |
1742 | "graceful-restart": True, | |
1743 | "preserve-fw-state": True, | |
1744 | }, | |
35ba1e3d KK |
1745 | "address_family": { |
1746 | "ipv4": { | |
1747 | "unicast": { | |
1748 | "neighbor": { | |
1749 | "r2": { | |
1750 | "dest_link": { | |
17022899 | 1751 | "r1-link1": {"graceful-restart-helper": True} |
35ba1e3d KK |
1752 | } |
1753 | } | |
1754 | } | |
1755 | } | |
1756 | }, | |
1757 | "ipv6": { | |
1758 | "unicast": { | |
1759 | "neighbor": { | |
1760 | "r2": { | |
1761 | "dest_link": { | |
17022899 | 1762 | "r1-link1": {"graceful-restart-helper": True} |
35ba1e3d KK |
1763 | } |
1764 | } | |
1765 | } | |
1766 | } | |
1767 | }, | |
1768 | }, | |
1769 | } | |
1770 | }, | |
1771 | "r2": { | |
1772 | "bgp": { | |
1773 | "address_family": { | |
1774 | "ipv4": { | |
1775 | "unicast": { | |
1776 | "neighbor": { | |
1777 | "r1": { | |
1778 | "dest_link": { | |
1779 | "r2-link1": {"graceful-restart": True} | |
1780 | } | |
1781 | } | |
1782 | } | |
1783 | } | |
1784 | }, | |
1785 | "ipv6": { | |
1786 | "unicast": { | |
1787 | "neighbor": { | |
1788 | "r1": { | |
1789 | "dest_link": { | |
1790 | "r2-link1": {"graceful-restart": True} | |
1791 | } | |
1792 | } | |
1793 | } | |
1794 | } | |
1795 | }, | |
1796 | } | |
1797 | } | |
1798 | }, | |
1799 | } | |
1800 | ||
1801 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
1802 | ||
1803 | for addr_type in ADDR_TYPES: | |
1804 | result = verify_graceful_restart( | |
1805 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
1806 | ) | |
1807 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
1808 | tc_name, result | |
1809 | ) | |
1810 | ||
1811 | # Verifying BGP RIB routes | |
1812 | dut = "r1" | |
1813 | peer = "r2" | |
1814 | next_hop = next_hop_per_address_family( | |
1815 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
1816 | ) | |
1817 | input_topo = {key: topo["routers"][key] for key in ["r2"]} | |
1818 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
1819 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
1820 | tc_name, result | |
1821 | ) | |
1822 | ||
1823 | # Verifying RIB routes | |
1824 | protocol = "bgp" | |
1825 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
1826 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
1827 | tc_name, result | |
1828 | ) | |
1829 | ||
17022899 KK |
1830 | logger.info( |
1831 | "[Phase 2] : R1's Gr state cahnge to Graceful" | |
1832 | " Restart without resetting the session " | |
1833 | ) | |
35ba1e3d | 1834 | |
17022899 KK |
1835 | # Configure graceful-restart |
1836 | input_dict = { | |
1837 | "r1": { | |
1838 | "bgp": { | |
1839 | "address_family": { | |
1840 | "ipv4": { | |
1841 | "unicast": { | |
1842 | "neighbor": { | |
1843 | "r2": { | |
1844 | "dest_link": { | |
1845 | "r1-link1": {"graceful-restart": True} | |
1846 | } | |
1847 | } | |
1848 | } | |
1849 | } | |
1850 | }, | |
1851 | "ipv6": { | |
1852 | "unicast": { | |
1853 | "neighbor": { | |
1854 | "r2": { | |
1855 | "dest_link": { | |
1856 | "r1-link1": {"graceful-restart": True} | |
1857 | } | |
1858 | } | |
1859 | } | |
1860 | } | |
1861 | }, | |
1862 | } | |
1863 | } | |
1864 | } | |
1865 | } | |
35ba1e3d | 1866 | |
17022899 KK |
1867 | result = create_router_bgp(tgen, topo, input_dict) |
1868 | assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) | |
35ba1e3d | 1869 | |
17022899 KK |
1870 | logger.info( |
1871 | "[Phase 3] : R2 is still down, restart time 120 sec." | |
1872 | " So time verify the routes are present in BGP RIB and ZEBRA " | |
1873 | ) | |
35ba1e3d KK |
1874 | |
1875 | for addr_type in ADDR_TYPES: | |
17022899 KK |
1876 | # Verifying BGP RIB routes |
1877 | next_hop = next_hop_per_address_family( | |
1878 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
35ba1e3d | 1879 | ) |
17022899 KK |
1880 | input_topo = {key: topo["routers"][key] for key in ["r2"]} |
1881 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
35ba1e3d KK |
1882 | assert result is True, "Testcase {} : Failed \n Error {}".format( |
1883 | tc_name, result | |
1884 | ) | |
1885 | ||
17022899 KK |
1886 | # Verifying RIB routes |
1887 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
35ba1e3d KK |
1888 | assert result is True, "Testcase {} : Failed \n Error {}".format( |
1889 | tc_name, result | |
1890 | ) | |
1891 | ||
1892 | write_test_footer(tc_name) | |
1893 | ||
1894 | ||
17022899 | 1895 | def test_BGP_GR_TC_20_p1(request): |
35ba1e3d | 1896 | """ |
9fa6ec14 | 1897 | Test Objective : Verify that GR helper routers delete all the routes |
1898 | received from a node if both the routers are configured as GR helper node. | |
35ba1e3d | 1899 | """ |
35ba1e3d KK |
1900 | tgen = get_topogen() |
1901 | tc_name = request.node.name | |
1902 | write_test_header(tc_name) | |
1903 | ||
1904 | # Check router status | |
1905 | check_router_status(tgen) | |
1906 | ||
1907 | # Don't run this test if we have any failure. | |
1908 | if tgen.routers_have_failure(): | |
1909 | pytest.skip(tgen.errors) | |
1910 | ||
1911 | # Creating configuration from JSON | |
1912 | reset_config_on_routers(tgen) | |
1913 | ||
17022899 | 1914 | logger.info("[Phase 1] : Test Setup [Helper]R1-----R2[Helper] initialized ") |
35ba1e3d KK |
1915 | |
1916 | # Configure graceful-restart | |
1917 | input_dict = { | |
1918 | "r1": { | |
1919 | "bgp": { | |
1920 | "graceful-restart": { | |
1921 | "graceful-restart": True, | |
1922 | "preserve-fw-state": True, | |
1923 | }, | |
1924 | "address_family": { | |
1925 | "ipv4": { | |
1926 | "unicast": { | |
1927 | "neighbor": { | |
1928 | "r2": { | |
1929 | "dest_link": { | |
17022899 | 1930 | "r1-link1": {"graceful-restart-helper": True} |
35ba1e3d KK |
1931 | } |
1932 | } | |
1933 | } | |
1934 | } | |
1935 | }, | |
1936 | "ipv6": { | |
1937 | "unicast": { | |
1938 | "neighbor": { | |
1939 | "r2": { | |
1940 | "dest_link": { | |
17022899 | 1941 | "r1-link1": {"graceful-restart-helper": True} |
35ba1e3d KK |
1942 | } |
1943 | } | |
1944 | } | |
1945 | } | |
1946 | }, | |
1947 | }, | |
1948 | } | |
1949 | }, | |
1950 | "r2": { | |
1951 | "bgp": { | |
1952 | "address_family": { | |
1953 | "ipv4": { | |
1954 | "unicast": { | |
1955 | "neighbor": { | |
1956 | "r1": { | |
1957 | "dest_link": { | |
17022899 | 1958 | "r2-link1": {"graceful-restart-helper": True} |
35ba1e3d KK |
1959 | } |
1960 | } | |
1961 | } | |
1962 | } | |
1963 | }, | |
1964 | "ipv6": { | |
1965 | "unicast": { | |
1966 | "neighbor": { | |
1967 | "r1": { | |
1968 | "dest_link": { | |
17022899 | 1969 | "r2-link1": {"graceful-restart-helper": True} |
35ba1e3d KK |
1970 | } |
1971 | } | |
1972 | } | |
1973 | } | |
1974 | }, | |
1975 | } | |
1976 | } | |
1977 | }, | |
1978 | } | |
1979 | ||
1980 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
1981 | ||
1982 | for addr_type in ADDR_TYPES: | |
1983 | result = verify_graceful_restart( | |
1984 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
1985 | ) | |
1986 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
1987 | tc_name, result | |
1988 | ) | |
1989 | ||
1990 | # Verifying BGP RIB routes | |
1991 | dut = "r1" | |
1992 | peer = "r2" | |
1993 | next_hop = next_hop_per_address_family( | |
1994 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
1995 | ) | |
1996 | input_topo = {key: topo["routers"][key] for key in ["r2"]} | |
1997 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
1998 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
1999 | tc_name, result | |
2000 | ) | |
2001 | ||
2002 | # Verifying RIB routes | |
2003 | protocol = "bgp" | |
2004 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
2005 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
2006 | tc_name, result | |
2007 | ) | |
2008 | ||
35ba1e3d KK |
2009 | kill_router_daemons(tgen, "r2", ["bgpd"]) |
2010 | ||
35ba1e3d KK |
2011 | for addr_type in ADDR_TYPES: |
2012 | # Verifying BGP RIB routes | |
2013 | next_hop = next_hop_per_address_family( | |
2014 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
2015 | ) | |
2016 | input_topo = {key: topo["routers"][key] for key in ["r2"]} | |
2017 | result = verify_bgp_rib( | |
2018 | tgen, addr_type, dut, input_topo, next_hop, expected=False | |
2019 | ) | |
0b25370e DS |
2020 | assert result is not True, ( |
2021 | "Testcase {} : Failed \n " | |
5cbb02eb | 2022 | "r1: routes are still present in BGP RIB\n Error: {}".format( |
0b25370e DS |
2023 | tc_name, result |
2024 | ) | |
2025 | ) | |
35ba1e3d KK |
2026 | logger.info(" Expected behavior: {}".format(result)) |
2027 | ||
2028 | # Verifying RIB routes | |
2029 | result = verify_rib( | |
2030 | tgen, addr_type, dut, input_topo, next_hop, protocol, expected=False | |
2031 | ) | |
0b25370e DS |
2032 | assert result is not True, ( |
2033 | "Testcase {} : Failed \n " | |
2034 | "r1: routes are still present in ZEBRA\n Error: {}".format(tc_name, result) | |
2035 | ) | |
35ba1e3d KK |
2036 | logger.info(" Expected behavior: {}".format(result)) |
2037 | ||
2038 | logger.info("[Phase 5] : R2 is about to come up now ") | |
17022899 | 2039 | |
35ba1e3d KK |
2040 | start_router_daemons(tgen, "r2", ["bgpd"]) |
2041 | ||
2042 | logger.info("[Phase 4] : R2 is UP now, so time to collect GR stats ") | |
2043 | ||
2044 | for addr_type in ADDR_TYPES: | |
35ba1e3d KK |
2045 | # Verifying BGP RIB routes |
2046 | next_hop = next_hop_per_address_family( | |
2047 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
2048 | ) | |
2049 | input_topo = {key: topo["routers"][key] for key in ["r2"]} | |
2050 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
2051 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
2052 | tc_name, result | |
2053 | ) | |
2054 | ||
2055 | # Verifying RIB routes | |
2056 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
2057 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
2058 | tc_name, result | |
2059 | ) | |
2060 | ||
2061 | write_test_footer(tc_name) | |
2062 | ||
2063 | ||
17022899 | 2064 | def test_BGP_GR_TC_31_1_p1(request): |
35ba1e3d | 2065 | """ |
17022899 KK |
2066 | After BGP neighborship is established and GR capability is exchanged, |
2067 | transition restarting router to disabled state and vice versa. | |
35ba1e3d KK |
2068 | """ |
2069 | ||
2070 | tgen = get_topogen() | |
2071 | tc_name = request.node.name | |
2072 | write_test_header(tc_name) | |
2073 | ||
2074 | # Check router status | |
2075 | check_router_status(tgen) | |
2076 | ||
2077 | # Don't run this test if we have any failure. | |
2078 | if tgen.routers_have_failure(): | |
2079 | pytest.skip(tgen.errors) | |
2080 | ||
2081 | # Creating configuration from JSON | |
2082 | reset_config_on_routers(tgen) | |
2083 | ||
17022899 KK |
2084 | logger.info( |
2085 | "[Phase 1] : Test Setup" " [Helper Mode]R2-----R1[Restart Mode] initialized " | |
2086 | ) | |
35ba1e3d KK |
2087 | |
2088 | # Configure graceful-restart | |
2089 | input_dict = { | |
17022899 | 2090 | "r2": { |
35ba1e3d | 2091 | "bgp": { |
35ba1e3d KK |
2092 | "address_family": { |
2093 | "ipv4": { | |
2094 | "unicast": { | |
2095 | "neighbor": { | |
17022899 | 2096 | "r1": { |
35ba1e3d | 2097 | "dest_link": { |
17022899 | 2098 | "r2-link1": {"graceful-restart-helper": True} |
35ba1e3d KK |
2099 | } |
2100 | } | |
2101 | } | |
2102 | } | |
2103 | }, | |
2104 | "ipv6": { | |
2105 | "unicast": { | |
2106 | "neighbor": { | |
17022899 | 2107 | "r1": { |
35ba1e3d | 2108 | "dest_link": { |
17022899 | 2109 | "r2-link1": {"graceful-restart-helper": True} |
35ba1e3d KK |
2110 | } |
2111 | } | |
2112 | } | |
2113 | } | |
2114 | }, | |
17022899 | 2115 | } |
35ba1e3d KK |
2116 | } |
2117 | }, | |
17022899 | 2118 | "r1": { |
35ba1e3d | 2119 | "bgp": { |
17022899 | 2120 | "graceful-restart": {"preserve-fw-state": True}, |
35ba1e3d KK |
2121 | "address_family": { |
2122 | "ipv4": { | |
2123 | "unicast": { | |
2124 | "neighbor": { | |
17022899 | 2125 | "r2": { |
35ba1e3d | 2126 | "dest_link": { |
17022899 | 2127 | "r1-link1": {"graceful-restart": True} |
35ba1e3d KK |
2128 | } |
2129 | } | |
2130 | } | |
2131 | } | |
2132 | }, | |
2133 | "ipv6": { | |
2134 | "unicast": { | |
2135 | "neighbor": { | |
17022899 | 2136 | "r2": { |
35ba1e3d | 2137 | "dest_link": { |
17022899 | 2138 | "r1-link1": {"graceful-restart": True} |
35ba1e3d KK |
2139 | } |
2140 | } | |
2141 | } | |
2142 | } | |
2143 | }, | |
17022899 | 2144 | }, |
35ba1e3d KK |
2145 | } |
2146 | }, | |
2147 | } | |
2148 | ||
2149 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
2150 | ||
2151 | for addr_type in ADDR_TYPES: | |
2152 | result = verify_graceful_restart( | |
2153 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
2154 | ) | |
2155 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
2156 | tc_name, result | |
2157 | ) | |
2158 | ||
2159 | # Verifying BGP RIB routes | |
2160 | dut = "r1" | |
2161 | peer = "r2" | |
17022899 | 2162 | protocol = "bgp" |
35ba1e3d KK |
2163 | next_hop = next_hop_per_address_family( |
2164 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
2165 | ) | |
2166 | input_topo = {key: topo["routers"][key] for key in ["r2"]} | |
2167 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
2168 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
2169 | tc_name, result | |
2170 | ) | |
2171 | ||
2172 | # Verifying RIB routes | |
35ba1e3d KK |
2173 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) |
2174 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
2175 | tc_name, result | |
2176 | ) | |
2177 | ||
17022899 | 2178 | logger.info("[Phase 2] : R1 Goes from Restart to Disable Mode ") |
35ba1e3d KK |
2179 | |
2180 | # Configure graceful-restart | |
2181 | input_dict = { | |
2182 | "r1": { | |
2183 | "bgp": { | |
2184 | "address_family": { | |
2185 | "ipv4": { | |
2186 | "unicast": { | |
2187 | "neighbor": { | |
2188 | "r2": { | |
2189 | "dest_link": { | |
17022899 | 2190 | "r1-link1": {"graceful-restart-disable": True} |
35ba1e3d KK |
2191 | } |
2192 | } | |
2193 | } | |
2194 | } | |
2195 | }, | |
2196 | "ipv6": { | |
2197 | "unicast": { | |
2198 | "neighbor": { | |
2199 | "r2": { | |
2200 | "dest_link": { | |
17022899 | 2201 | "r1-link1": {"graceful-restart-disable": True} |
35ba1e3d KK |
2202 | } |
2203 | } | |
2204 | } | |
2205 | } | |
2206 | }, | |
2207 | } | |
2208 | } | |
2209 | } | |
2210 | } | |
2211 | ||
2212 | result = create_router_bgp(tgen, topo, input_dict) | |
2213 | assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) | |
2214 | ||
35ba1e3d | 2215 | for addr_type in ADDR_TYPES: |
2268cf50 KK |
2216 | neighbor = topo["routers"]["r2"]["links"]["r1-link1"][addr_type].split("/")[0] |
2217 | clear_bgp(tgen, addr_type, "r1", neighbor=neighbor) | |
35ba1e3d | 2218 | |
2268cf50 | 2219 | result = verify_bgp_convergence_from_running_config(tgen) |
17022899 | 2220 | assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) |
35ba1e3d | 2221 | |
17022899 | 2222 | # Verify GR stats |
35ba1e3d KK |
2223 | input_dict = { |
2224 | "r1": { | |
2225 | "bgp": { | |
35ba1e3d KK |
2226 | "address_family": { |
2227 | "ipv4": { | |
2228 | "unicast": { | |
2229 | "neighbor": { | |
2230 | "r2": { | |
2231 | "dest_link": { | |
17022899 | 2232 | "r1-link1": {"graceful-restart-disable": True} |
35ba1e3d KK |
2233 | } |
2234 | } | |
2235 | } | |
2236 | } | |
2237 | }, | |
2238 | "ipv6": { | |
2239 | "unicast": { | |
2240 | "neighbor": { | |
2241 | "r2": { | |
2242 | "dest_link": { | |
17022899 | 2243 | "r1-link1": {"graceful-restart-disable": True} |
35ba1e3d KK |
2244 | } |
2245 | } | |
2246 | } | |
2247 | } | |
2248 | }, | |
17022899 | 2249 | } |
35ba1e3d KK |
2250 | } |
2251 | }, | |
2252 | "r2": { | |
2253 | "bgp": { | |
2254 | "address_family": { | |
2255 | "ipv4": { | |
2256 | "unicast": { | |
2257 | "neighbor": { | |
2258 | "r1": { | |
2259 | "dest_link": { | |
2260 | "r2-link1": {"graceful-restart-helper": True} | |
2261 | } | |
2262 | } | |
2263 | } | |
2264 | } | |
2265 | }, | |
2266 | "ipv6": { | |
2267 | "unicast": { | |
2268 | "neighbor": { | |
2269 | "r1": { | |
2270 | "dest_link": { | |
2271 | "r2-link1": {"graceful-restart-helper": True} | |
2272 | } | |
2273 | } | |
2274 | } | |
2275 | } | |
2276 | }, | |
2277 | } | |
2278 | } | |
2279 | }, | |
2280 | } | |
2281 | ||
35ba1e3d KK |
2282 | for addr_type in ADDR_TYPES: |
2283 | result = verify_graceful_restart( | |
2284 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
2285 | ) | |
2286 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
2287 | tc_name, result | |
2288 | ) | |
2289 | ||
17022899 | 2290 | logger.info("[Phase 2] : R1 goes for reload ") |
35ba1e3d | 2291 | |
17022899 | 2292 | kill_router_daemons(tgen, "r1", ["bgpd"]) |
35ba1e3d | 2293 | |
17022899 KK |
2294 | logger.info( |
2295 | "[Phase 3] : R1 is still down, restart time 120 sec." | |
2296 | " So time verify the routes are not present in BGP RIB and ZEBRA" | |
2297 | ) | |
35ba1e3d KK |
2298 | |
2299 | for addr_type in ADDR_TYPES: | |
17022899 | 2300 | # Verifying RIB routes |
35ba1e3d KK |
2301 | next_hop = next_hop_per_address_family( |
2302 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
2303 | ) | |
2304 | input_topo = {key: topo["routers"][key] for key in ["r2"]} | |
35ba1e3d KK |
2305 | result = verify_rib( |
2306 | tgen, addr_type, dut, input_topo, next_hop, protocol, expected=False | |
2307 | ) | |
0b25370e DS |
2308 | assert result is not True, ( |
2309 | "Testcase {} : Failed \n " | |
2310 | "r1: routes are still present in ZEBRA\n Error: {}".format(tc_name, result) | |
2311 | ) | |
35ba1e3d | 2312 | |
17022899 KK |
2313 | logger.info("[Phase 4] : R1 is about to come up now ") |
2314 | start_router_daemons(tgen, "r1", ["bgpd"]) | |
35ba1e3d | 2315 | |
17022899 | 2316 | logger.info("[Phase 5] : R1 is UP now, so time to collect GR stats ") |
35ba1e3d KK |
2317 | |
2318 | for addr_type in ADDR_TYPES: | |
17022899 KK |
2319 | result = verify_graceful_restart( |
2320 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
2321 | ) | |
2322 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
2323 | tc_name, result | |
2324 | ) | |
2325 | ||
35ba1e3d KK |
2326 | # Verifying BGP RIB routes |
2327 | next_hop = next_hop_per_address_family( | |
2328 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
2329 | ) | |
2330 | input_topo = {key: topo["routers"][key] for key in ["r2"]} | |
2331 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
2332 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
2333 | tc_name, result | |
2334 | ) | |
2335 | ||
2336 | # Verifying RIB routes | |
2337 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
2338 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
2339 | tc_name, result | |
2340 | ) | |
2341 | ||
2342 | write_test_footer(tc_name) | |
2343 | ||
2344 | ||
17022899 | 2345 | def test_BGP_GR_TC_31_2_p1(request): |
35ba1e3d KK |
2346 | """ |
2347 | After BGP neighborship is established and GR capability is exchanged, | |
2348 | transition restarting router to disabled state and vice versa. | |
2349 | """ | |
2350 | ||
2351 | tgen = get_topogen() | |
2352 | tc_name = request.node.name | |
2353 | write_test_header(tc_name) | |
2354 | ||
2355 | # Check router status | |
2356 | check_router_status(tgen) | |
2357 | ||
2358 | # Don't run this test if we have any failure. | |
2359 | if tgen.routers_have_failure(): | |
2360 | pytest.skip(tgen.errors) | |
2361 | ||
2362 | # Creating configuration from JSON | |
2363 | reset_config_on_routers(tgen) | |
2364 | ||
2365 | logger.info( | |
17022899 | 2366 | "[Phase 1] : Test Setup " "[Disable Mode]R1-----R2[Restart Mode] initialized " |
35ba1e3d KK |
2367 | ) |
2368 | ||
2369 | # Configure graceful-restart | |
2370 | input_dict = { | |
2371 | "r2": { | |
2372 | "bgp": { | |
2373 | "address_family": { | |
2374 | "ipv4": { | |
2375 | "unicast": { | |
2376 | "neighbor": { | |
2377 | "r1": { | |
2378 | "dest_link": { | |
2379 | "r2-link1": {"graceful-restart-helper": True} | |
2380 | } | |
2381 | } | |
2382 | } | |
2383 | } | |
2384 | }, | |
2385 | "ipv6": { | |
2386 | "unicast": { | |
2387 | "neighbor": { | |
2388 | "r1": { | |
2389 | "dest_link": { | |
2390 | "r2-link1": {"graceful-restart-helper": True} | |
2391 | } | |
2392 | } | |
2393 | } | |
2394 | } | |
2395 | }, | |
2396 | } | |
2397 | } | |
2398 | }, | |
2399 | "r1": { | |
2400 | "bgp": { | |
35ba1e3d KK |
2401 | "address_family": { |
2402 | "ipv4": { | |
2403 | "unicast": { | |
2404 | "neighbor": { | |
2405 | "r2": { | |
2406 | "dest_link": { | |
17022899 | 2407 | "r1-link1": {"graceful-restart-disable": True} |
35ba1e3d KK |
2408 | } |
2409 | } | |
2410 | } | |
2411 | } | |
2412 | }, | |
2413 | "ipv6": { | |
2414 | "unicast": { | |
2415 | "neighbor": { | |
2416 | "r2": { | |
2417 | "dest_link": { | |
17022899 | 2418 | "r1-link1": {"graceful-restart-disable": True} |
35ba1e3d KK |
2419 | } |
2420 | } | |
2421 | } | |
2422 | } | |
2423 | }, | |
17022899 | 2424 | } |
35ba1e3d KK |
2425 | } |
2426 | }, | |
2427 | } | |
2428 | ||
2429 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
2430 | ||
2431 | for addr_type in ADDR_TYPES: | |
2432 | result = verify_graceful_restart( | |
2433 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
2434 | ) | |
2435 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
2436 | tc_name, result | |
2437 | ) | |
2438 | ||
2439 | # Verifying BGP RIB routes | |
2440 | dut = "r1" | |
2441 | peer = "r2" | |
35ba1e3d KK |
2442 | next_hop = next_hop_per_address_family( |
2443 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
2444 | ) | |
2445 | input_topo = {key: topo["routers"][key] for key in ["r2"]} | |
2446 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
2447 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
2448 | tc_name, result | |
2449 | ) | |
2450 | ||
2451 | # Verifying RIB routes | |
17022899 | 2452 | protocol = "bgp" |
35ba1e3d KK |
2453 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) |
2454 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
2455 | tc_name, result | |
2456 | ) | |
2457 | ||
17022899 | 2458 | logger.info("[Phase 2] : R2 Goes from Disable to Restart Mode ") |
35ba1e3d KK |
2459 | |
2460 | # Configure graceful-restart | |
2461 | input_dict = { | |
2462 | "r1": { | |
2463 | "bgp": { | |
17022899 | 2464 | "graceful-restart": {"preserve-fw-state": True}, |
35ba1e3d KK |
2465 | "address_family": { |
2466 | "ipv4": { | |
2467 | "unicast": { | |
2468 | "neighbor": { | |
2469 | "r2": { | |
2470 | "dest_link": { | |
17022899 | 2471 | "r1-link1": {"graceful-restart": True} |
35ba1e3d KK |
2472 | } |
2473 | } | |
2474 | } | |
2475 | } | |
2476 | }, | |
2477 | "ipv6": { | |
2478 | "unicast": { | |
2479 | "neighbor": { | |
2480 | "r2": { | |
2481 | "dest_link": { | |
17022899 | 2482 | "r1-link1": {"graceful-restart": True} |
35ba1e3d KK |
2483 | } |
2484 | } | |
2485 | } | |
2486 | } | |
2487 | }, | |
17022899 | 2488 | }, |
35ba1e3d KK |
2489 | } |
2490 | } | |
2491 | } | |
2492 | ||
2493 | result = create_router_bgp(tgen, topo, input_dict) | |
2494 | assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) | |
2495 | ||
2496 | for addr_type in ADDR_TYPES: | |
2268cf50 KK |
2497 | neighbor = topo["routers"]["r2"]["links"]["r1-link1"][addr_type].split("/")[0] |
2498 | clear_bgp(tgen, addr_type, "r1", neighbor=neighbor) | |
35ba1e3d | 2499 | |
2268cf50 | 2500 | result = verify_bgp_convergence_from_running_config(tgen) |
17022899 KK |
2501 | assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) |
2502 | ||
35ba1e3d KK |
2503 | # Verify GR stats |
2504 | input_dict = { | |
17022899 | 2505 | "r2": { |
35ba1e3d KK |
2506 | "bgp": { |
2507 | "address_family": { | |
2508 | "ipv4": { | |
2509 | "unicast": { | |
2510 | "neighbor": { | |
17022899 | 2511 | "r1": { |
35ba1e3d | 2512 | "dest_link": { |
17022899 | 2513 | "r2-link1": {"graceful-restart-helper": True} |
35ba1e3d KK |
2514 | } |
2515 | } | |
2516 | } | |
2517 | } | |
2518 | }, | |
2519 | "ipv6": { | |
2520 | "unicast": { | |
2521 | "neighbor": { | |
17022899 | 2522 | "r1": { |
35ba1e3d | 2523 | "dest_link": { |
17022899 | 2524 | "r2-link1": {"graceful-restart-helper": True} |
35ba1e3d KK |
2525 | } |
2526 | } | |
2527 | } | |
2528 | } | |
2529 | }, | |
2530 | } | |
2531 | } | |
2532 | }, | |
17022899 | 2533 | "r1": { |
35ba1e3d KK |
2534 | "bgp": { |
2535 | "address_family": { | |
2536 | "ipv4": { | |
2537 | "unicast": { | |
2538 | "neighbor": { | |
17022899 | 2539 | "r2": { |
35ba1e3d | 2540 | "dest_link": { |
17022899 | 2541 | "r1-link1": {"graceful-restart": True} |
35ba1e3d KK |
2542 | } |
2543 | } | |
2544 | } | |
2545 | } | |
2546 | }, | |
2547 | "ipv6": { | |
2548 | "unicast": { | |
2549 | "neighbor": { | |
17022899 | 2550 | "r2": { |
35ba1e3d | 2551 | "dest_link": { |
17022899 | 2552 | "r1-link1": {"graceful-restart": True} |
35ba1e3d KK |
2553 | } |
2554 | } | |
2555 | } | |
2556 | } | |
2557 | }, | |
2558 | } | |
2559 | } | |
2560 | }, | |
2561 | } | |
2562 | ||
17022899 KK |
2563 | # here the verify_graceful_restart fro the neighbor would be |
2564 | # "NotReceived" as the latest GR config is not yet applied. | |
35ba1e3d KK |
2565 | for addr_type in ADDR_TYPES: |
2566 | result = verify_graceful_restart( | |
2567 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
2568 | ) | |
2569 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
2570 | tc_name, result | |
2571 | ) | |
2572 | ||
17022899 KK |
2573 | for addr_type in ADDR_TYPES: |
2574 | # Verifying RIB routes | |
2575 | next_hop = next_hop_per_address_family( | |
2576 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
2577 | ) | |
2578 | input_topo = {key: topo["routers"][key] for key in ["r2"]} | |
2579 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
2580 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
2581 | tc_name, result | |
2582 | ) | |
2583 | ||
2584 | logger.info("[Phase 6] : R1 is about to come up now ") | |
2585 | start_router_daemons(tgen, "r1", ["bgpd"]) | |
2586 | ||
2587 | logger.info("[Phase 4] : R1 is UP now, so time to collect GR stats ") | |
2588 | ||
2589 | for addr_type in ADDR_TYPES: | |
2590 | result = verify_graceful_restart( | |
2591 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
2592 | ) | |
2593 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
2594 | tc_name, result | |
2595 | ) | |
2596 | ||
2597 | # Verifying BGP RIB routes | |
2598 | next_hop = next_hop_per_address_family( | |
2599 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
2600 | ) | |
2601 | input_topo = {key: topo["routers"][key] for key in ["r2"]} | |
2602 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
2603 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
2604 | tc_name, result | |
2605 | ) | |
2606 | ||
2607 | # Verifying RIB routes | |
2608 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
2609 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
2610 | tc_name, result | |
2611 | ) | |
2612 | ||
2613 | logger.info("[Phase 3] : R1 goes for reload ") | |
35ba1e3d KK |
2614 | |
2615 | kill_router_daemons(tgen, "r1", ["bgpd"]) | |
2616 | ||
2617 | logger.info( | |
17022899 KK |
2618 | "[Phase 4] : R1 is still down, restart time 120 sec." |
2619 | " So time verify the routes are present in BGP RIB and ZEBRA " | |
35ba1e3d KK |
2620 | ) |
2621 | ||
2622 | for addr_type in ADDR_TYPES: | |
2623 | # Verifying RIB routes | |
2624 | next_hop = next_hop_per_address_family( | |
2625 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
2626 | ) | |
2627 | input_topo = {key: topo["routers"][key] for key in ["r2"]} | |
17022899 KK |
2628 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) |
2629 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
35ba1e3d KK |
2630 | tc_name, result |
2631 | ) | |
2632 | ||
17022899 | 2633 | logger.info("[Phase 6] : R1 is about to come up now ") |
35ba1e3d KK |
2634 | start_router_daemons(tgen, "r1", ["bgpd"]) |
2635 | ||
17022899 | 2636 | logger.info("[Phase 4] : R1 is UP now, so time to collect GR stats ") |
35ba1e3d KK |
2637 | |
2638 | for addr_type in ADDR_TYPES: | |
2639 | result = verify_graceful_restart( | |
2640 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
2641 | ) | |
2642 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
2643 | tc_name, result | |
2644 | ) | |
2645 | ||
2646 | # Verifying BGP RIB routes | |
2647 | next_hop = next_hop_per_address_family( | |
2648 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
2649 | ) | |
2650 | input_topo = {key: topo["routers"][key] for key in ["r2"]} | |
2651 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
2652 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
2653 | tc_name, result | |
2654 | ) | |
2655 | ||
2656 | # Verifying RIB routes | |
2657 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
2658 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
2659 | tc_name, result | |
2660 | ) | |
2661 | ||
2662 | write_test_footer(tc_name) | |
2663 | ||
2664 | ||
17022899 | 2665 | def test_BGP_GR_TC_9_p1(request): |
35ba1e3d | 2666 | """ |
9fa6ec14 | 2667 | Test Objective : Verify that restarting nodes reset "F" bit while sending |
2668 | the BGP open messages after it's restarts, when BGP GR is **NOT** enabled. | |
35ba1e3d KK |
2669 | """ |
2670 | ||
2671 | tgen = get_topogen() | |
2672 | tc_name = request.node.name | |
2673 | write_test_header(tc_name) | |
2674 | ||
2675 | # Check router status | |
2676 | check_router_status(tgen) | |
2677 | ||
2678 | # Don't run this test if we have any failure. | |
2679 | if tgen.routers_have_failure(): | |
2680 | pytest.skip(tgen.errors) | |
2681 | ||
2682 | # Creating configuration from JSON | |
2683 | reset_config_on_routers(tgen) | |
2684 | ||
2685 | logger.info( | |
17022899 | 2686 | "[Phase 1] : Test Setup" " [Restart Mode]R1-----R2[Helper Mode] Initiliazed " |
35ba1e3d KK |
2687 | ) |
2688 | ||
2689 | # Configure graceful-restart | |
2690 | input_dict = { | |
17022899 | 2691 | "r1": { |
35ba1e3d KK |
2692 | "bgp": { |
2693 | "address_family": { | |
2694 | "ipv4": { | |
2695 | "unicast": { | |
2696 | "neighbor": { | |
17022899 | 2697 | "r2": { |
35ba1e3d | 2698 | "dest_link": { |
17022899 | 2699 | "r1-link1": {"graceful-restart": True} |
35ba1e3d KK |
2700 | } |
2701 | } | |
2702 | } | |
2703 | } | |
2704 | }, | |
2705 | "ipv6": { | |
2706 | "unicast": { | |
2707 | "neighbor": { | |
17022899 | 2708 | "r2": { |
35ba1e3d | 2709 | "dest_link": { |
17022899 | 2710 | "r1-link1": {"graceful-restart": True} |
35ba1e3d KK |
2711 | } |
2712 | } | |
2713 | } | |
2714 | } | |
2715 | }, | |
2716 | } | |
2717 | } | |
2718 | }, | |
17022899 | 2719 | "r2": { |
35ba1e3d | 2720 | "bgp": { |
17022899 | 2721 | "graceful-restart": {"preserve-fw-state": True}, |
35ba1e3d KK |
2722 | "address_family": { |
2723 | "ipv4": { | |
2724 | "unicast": { | |
2725 | "neighbor": { | |
17022899 | 2726 | "r1": { |
35ba1e3d | 2727 | "dest_link": { |
17022899 | 2728 | "r2-link1": {"graceful-restart-helper": True} |
35ba1e3d KK |
2729 | } |
2730 | } | |
2731 | } | |
2732 | } | |
2733 | }, | |
2734 | "ipv6": { | |
2735 | "unicast": { | |
2736 | "neighbor": { | |
17022899 | 2737 | "r1": { |
35ba1e3d | 2738 | "dest_link": { |
17022899 | 2739 | "r2-link1": {"graceful-restart-helper": True} |
35ba1e3d KK |
2740 | } |
2741 | } | |
2742 | } | |
2743 | } | |
2744 | }, | |
17022899 | 2745 | }, |
35ba1e3d KK |
2746 | } |
2747 | }, | |
2748 | } | |
2749 | ||
2750 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
2751 | ||
2752 | for addr_type in ADDR_TYPES: | |
2753 | result = verify_graceful_restart( | |
2754 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
2755 | ) | |
17022899 | 2756 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) |
35ba1e3d KK |
2757 | |
2758 | # Verifying BGP RIB routes | |
2759 | dut = "r1" | |
2760 | peer = "r2" | |
2761 | next_hop = next_hop_per_address_family( | |
2762 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
2763 | ) | |
2764 | input_topo = {key: topo["routers"][key] for key in ["r2"]} | |
2765 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
17022899 KK |
2766 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) |
2767 | ||
2768 | # Verifying RIB routes | |
2769 | protocol = "bgp" | |
2770 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
2771 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
2772 | ||
2773 | logger.info("[Phase 2] : R2 goes for reload ") | |
2774 | kill_router_daemons(tgen, "r2", ["bgpd"]) | |
2775 | ||
2776 | logger.info( | |
2777 | "[Phase 3] : R2 is still down, restart time 120 sec." | |
2778 | "So time verify the routes are present in BGP RIB and ZEBRA " | |
2779 | ) | |
2780 | ||
2781 | for addr_type in ADDR_TYPES: | |
2782 | # Verifying BGP RIB routes | |
2783 | next_hop = next_hop_per_address_family( | |
2784 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
2785 | ) | |
2786 | input_topo = {key: topo["routers"][key] for key in ["r2"]} | |
2787 | result = verify_bgp_rib( | |
2788 | tgen, addr_type, dut, input_topo, next_hop, expected=False | |
2789 | ) | |
0b25370e DS |
2790 | assert result is not True, ( |
2791 | "Testcase {} : Failed \n " | |
5cbb02eb | 2792 | "r1: routes are still present in BGP RIB\n Error: {}".format( |
0b25370e DS |
2793 | tc_name, result |
2794 | ) | |
2795 | ) | |
17022899 | 2796 | logger.info(" Expected behavior: {}".format(result)) |
35ba1e3d KK |
2797 | |
2798 | # Verifying RIB routes | |
2799 | protocol = "bgp" | |
17022899 KK |
2800 | result = verify_rib( |
2801 | tgen, addr_type, dut, input_topo, next_hop, protocol, expected=False | |
2802 | ) | |
0b25370e DS |
2803 | assert result is not True, ( |
2804 | "Testcase {} : Failed \n " | |
2805 | "r1: routes are still present in ZEBRA\n Error: {}".format(tc_name, result) | |
2806 | ) | |
17022899 | 2807 | logger.info(" Expected behavior: {}".format(result)) |
35ba1e3d | 2808 | |
17022899 KK |
2809 | logger.info("[Phase 5] : R2 is about to come up now ") |
2810 | start_router_daemons(tgen, "r2", ["bgpd"]) | |
2811 | ||
2812 | logger.info("[Phase 4] : R2 is UP now, so time to collect GR stats ") | |
2813 | ||
2814 | for addr_type in ADDR_TYPES: | |
2815 | result = verify_bgp_convergence(tgen, topo) | |
2816 | assert ( | |
2817 | result is True | |
2818 | ), "BGP Convergence after BGPd restart" " :Failed \n Error:{}".format(result) | |
2819 | ||
2820 | result = verify_graceful_restart( | |
2821 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
2822 | ) | |
2823 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
2824 | ||
2825 | result = verify_graceful_restart( | |
2826 | tgen, topo, addr_type, input_dict, dut="r2", peer="r1" | |
2827 | ) | |
2828 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
2829 | ||
2830 | result = verify_r_bit(tgen, topo, addr_type, input_dict, dut="r1", peer="r2") | |
2831 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
2832 | ||
2833 | result = verify_f_bit( | |
2834 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2", expected=False | |
2835 | ) | |
0b25370e DS |
2836 | assert ( |
2837 | result is not True | |
2838 | ), "Testcase {} : Failed \n " "r1: F-bit is set to True\n Error: {}".format( | |
17022899 | 2839 | tc_name, result |
0b25370e | 2840 | ) |
17022899 KK |
2841 | |
2842 | write_test_footer(tc_name) | |
2843 | ||
2844 | ||
2845 | def test_BGP_GR_TC_17_p1(request): | |
2846 | """ | |
9fa6ec14 | 2847 | Test Objective : Verify that only GR helper routers keep the stale |
2848 | route entries, not any GR disabled router. | |
17022899 KK |
2849 | """ |
2850 | ||
2851 | tgen = get_topogen() | |
2852 | tc_name = request.node.name | |
2853 | write_test_header(tc_name) | |
2854 | ||
2855 | # Check router status | |
2856 | check_router_status(tgen) | |
2857 | ||
2858 | # Don't run this test if we have any failure. | |
2859 | if tgen.routers_have_failure(): | |
2860 | pytest.skip(tgen.errors) | |
2861 | ||
2862 | # Creating configuration from JSON | |
2863 | reset_config_on_routers(tgen) | |
2864 | ||
2865 | logger.info("[Phase 1] : Test Setup [Disable]R1-----R2[Restart] " "Initiliazed ") | |
35ba1e3d KK |
2866 | |
2867 | # Configure graceful-restart | |
2868 | input_dict = { | |
2869 | "r1": { | |
2870 | "bgp": { | |
17022899 KK |
2871 | "graceful-restart": { |
2872 | "graceful-restart": True, | |
2873 | "preserve-fw-state": True, | |
2874 | }, | |
35ba1e3d KK |
2875 | "address_family": { |
2876 | "ipv4": { | |
2877 | "unicast": { | |
2878 | "neighbor": { | |
2879 | "r2": { | |
2880 | "dest_link": { | |
17022899 | 2881 | "r1-link1": {"graceful-restart-disable": True} |
35ba1e3d KK |
2882 | } |
2883 | } | |
2884 | } | |
2885 | } | |
2886 | }, | |
2887 | "ipv6": { | |
2888 | "unicast": { | |
2889 | "neighbor": { | |
2890 | "r2": { | |
2891 | "dest_link": { | |
17022899 | 2892 | "r1-link1": {"graceful-restart-disable": True} |
35ba1e3d KK |
2893 | } |
2894 | } | |
2895 | } | |
2896 | } | |
2897 | }, | |
2898 | }, | |
2899 | } | |
17022899 | 2900 | }, |
35ba1e3d KK |
2901 | "r2": { |
2902 | "bgp": { | |
2903 | "address_family": { | |
2904 | "ipv4": { | |
2905 | "unicast": { | |
2906 | "neighbor": { | |
2907 | "r1": { | |
2908 | "dest_link": { | |
17022899 | 2909 | "r2-link1": {"graceful-restart": True} |
35ba1e3d KK |
2910 | } |
2911 | } | |
2912 | } | |
2913 | } | |
2914 | }, | |
2915 | "ipv6": { | |
2916 | "unicast": { | |
2917 | "neighbor": { | |
2918 | "r1": { | |
2919 | "dest_link": { | |
17022899 | 2920 | "r2-link1": {"graceful-restart": True} |
35ba1e3d KK |
2921 | } |
2922 | } | |
2923 | } | |
2924 | } | |
2925 | }, | |
2926 | } | |
2927 | } | |
2928 | }, | |
2929 | } | |
2930 | ||
17022899 KK |
2931 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") |
2932 | ||
35ba1e3d KK |
2933 | for addr_type in ADDR_TYPES: |
2934 | result = verify_graceful_restart( | |
2935 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
2936 | ) | |
17022899 KK |
2937 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) |
2938 | ||
2939 | # Verifying BGP RIB routes | |
2940 | dut = "r1" | |
2941 | peer = "r2" | |
2942 | next_hop = next_hop_per_address_family( | |
2943 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
35ba1e3d | 2944 | ) |
17022899 KK |
2945 | input_topo = {key: topo["routers"][key] for key in ["r2"]} |
2946 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
2947 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
35ba1e3d | 2948 | |
17022899 KK |
2949 | # Verifying RIB routes |
2950 | protocol = "bgp" | |
2951 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
2952 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
35ba1e3d | 2953 | |
17022899 KK |
2954 | logger.info("[Phase 2] : R2 goes for reload ") |
2955 | ||
2956 | kill_router_daemons(tgen, "r2", ["bgpd"]) | |
35ba1e3d KK |
2957 | |
2958 | logger.info( | |
17022899 | 2959 | "[Phase 3] : R2 is still down, restart time 120 sec." |
35ba1e3d KK |
2960 | " So time verify the routes are present in BGP RIB and ZEBRA " |
2961 | ) | |
2962 | ||
2963 | for addr_type in ADDR_TYPES: | |
17022899 | 2964 | # Verifying BGP RIB routes |
35ba1e3d KK |
2965 | next_hop = next_hop_per_address_family( |
2966 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
2967 | ) | |
2968 | input_topo = {key: topo["routers"][key] for key in ["r2"]} | |
17022899 KK |
2969 | result = verify_bgp_rib( |
2970 | tgen, addr_type, dut, input_topo, next_hop, expected=False | |
2971 | ) | |
0b25370e DS |
2972 | assert result is not True, ( |
2973 | "Testcase {} : Failed \n " | |
5cbb02eb | 2974 | "r1: routes are still present in BGP RIB\n Error: {}".format( |
0b25370e DS |
2975 | tc_name, result |
2976 | ) | |
2977 | ) | |
17022899 | 2978 | logger.info(" Expected behavior: {}".format(result)) |
35ba1e3d | 2979 | |
17022899 KK |
2980 | # Verifying RIB routes |
2981 | protocol = "bgp" | |
2982 | result = verify_rib( | |
2983 | tgen, addr_type, dut, input_topo, next_hop, protocol, expected=False | |
2984 | ) | |
0b25370e DS |
2985 | assert result is not True, ( |
2986 | "Testcase {} : Failed \n " | |
2987 | "r1: routes are still present in ZEBRA\n Error: {}".format(tc_name, result) | |
2988 | ) | |
17022899 | 2989 | logger.info(" Expected behavior: {}".format(result)) |
35ba1e3d | 2990 | |
17022899 KK |
2991 | logger.info("[Phase 5] : R2 is about to come up now ") |
2992 | start_router_daemons(tgen, "r2", ["bgpd"]) | |
2993 | ||
2994 | logger.info("[Phase 4] : R2 is UP now, so time to collect GR stats ") | |
35ba1e3d KK |
2995 | |
2996 | for addr_type in ADDR_TYPES: | |
17022899 KK |
2997 | result = verify_bgp_convergence(tgen, topo) |
2998 | assert ( | |
2999 | result is True | |
3000 | ), "BGP Convergence after BGPd restart" " :Failed \n Error:{}".format(result) | |
3001 | ||
35ba1e3d KK |
3002 | result = verify_graceful_restart( |
3003 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
3004 | ) | |
17022899 KK |
3005 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) |
3006 | ||
3007 | result = verify_r_bit( | |
3008 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2", expected=False | |
3009 | ) | |
0b25370e DS |
3010 | assert ( |
3011 | result is not True | |
3012 | ), "Testcase {} : Failed \n " "r1: R-bit is set to True\n Error: {}".format( | |
35ba1e3d | 3013 | tc_name, result |
0b25370e | 3014 | ) |
35ba1e3d KK |
3015 | |
3016 | # Verifying BGP RIB routes | |
3017 | next_hop = next_hop_per_address_family( | |
3018 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
3019 | ) | |
3020 | input_topo = {key: topo["routers"][key] for key in ["r2"]} | |
3021 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
17022899 | 3022 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) |
35ba1e3d KK |
3023 | |
3024 | # Verifying RIB routes | |
17022899 | 3025 | protocol = "bgp" |
35ba1e3d | 3026 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) |
17022899 KK |
3027 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) |
3028 | ||
3029 | write_test_footer(tc_name) | |
3030 | ||
3031 | ||
3032 | def test_BGP_GR_TC_43_p1(request): | |
3033 | """ | |
3034 | Test Objective : Transition from Global Restarting to Disable | |
3035 | and then Global Disable to Restarting. | |
3036 | ||
3037 | """ | |
3038 | ||
3039 | tgen = get_topogen() | |
3040 | tc_name = request.node.name | |
3041 | write_test_header(tc_name) | |
3042 | ||
3043 | # Check router status | |
3044 | check_router_status(tgen) | |
3045 | ||
3046 | # Don't run this test if we have any failure. | |
3047 | if tgen.routers_have_failure(): | |
3048 | pytest.skip(tgen.errors) | |
3049 | ||
3050 | # Creating configuration from JSON | |
3051 | reset_config_on_routers(tgen) | |
3052 | ||
3053 | step("Configure R1 and R2 as GR restarting node in global level") | |
3054 | ||
3055 | input_dict = { | |
9fa6ec14 | 3056 | "r1": { |
3057 | "bgp": { | |
3058 | "graceful-restart": { | |
3059 | "graceful-restart": True, | |
3060 | } | |
3061 | } | |
3062 | }, | |
17022899 KK |
3063 | "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}}, |
3064 | } | |
3065 | ||
3066 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
3067 | ||
3068 | step("Verify on R2 that R1 advertises GR capabilities as a restarting node") | |
3069 | ||
3070 | for addr_type in ADDR_TYPES: | |
3071 | result = verify_graceful_restart( | |
3072 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
3073 | ) | |
3074 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3075 | result = verify_graceful_restart( | |
3076 | tgen, topo, addr_type, input_dict, dut="r2", peer="r1" | |
3077 | ) | |
3078 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3079 | ||
3080 | for addr_type in ADDR_TYPES: | |
3081 | dut = "r1" | |
3082 | peer = "r2" | |
3083 | protocol = "bgp" | |
3084 | next_hop = next_hop_per_address_family( | |
3085 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
3086 | ) | |
3087 | input_topo = {"r2": topo["routers"]["r2"]} | |
3088 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3089 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3090 | ||
3091 | dut = "r2" | |
3092 | peer = "r1" | |
3093 | next_hop = next_hop_per_address_family( | |
3094 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
3095 | ) | |
3096 | input_topo = {"r1": topo["routers"]["r1"]} | |
3097 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
3098 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3099 | protocol = "bgp" | |
3100 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3101 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3102 | ||
3103 | step("Kill BGP on R1") | |
3104 | ||
3105 | kill_router_daemons(tgen, "r1", ["bgpd"]) | |
3106 | ||
3107 | step( | |
3108 | "Verify that R1 keeps BGP routes in zebra and R2 retains" | |
3109 | " the stale entry for received routes from R1" | |
3110 | ) | |
3111 | ||
3112 | for addr_type in ADDR_TYPES: | |
3113 | dut = "r1" | |
3114 | peer = "r2" | |
3115 | protocol = "bgp" | |
3116 | next_hop = next_hop_per_address_family( | |
3117 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
3118 | ) | |
3119 | input_topo = {"r2": topo["routers"]["r2"]} | |
3120 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3121 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3122 | ||
3123 | dut = "r2" | |
3124 | peer = "r1" | |
3125 | next_hop = next_hop_per_address_family( | |
3126 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
3127 | ) | |
3128 | input_topo = {"r1": topo["routers"]["r1"]} | |
3129 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
3130 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3131 | protocol = "bgp" | |
3132 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3133 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3134 | ||
3135 | step("Bring up BGPd on R1 and configure it as GR disabled node in global level") | |
3136 | ||
3137 | start_router_daemons(tgen, "r1", ["bgpd"]) | |
3138 | ||
3139 | input_dict = { | |
3140 | "r1": { | |
3141 | "bgp": { | |
3142 | "graceful-restart": { | |
3143 | "graceful-restart": False, | |
3144 | "graceful-restart-disable": True, | |
3145 | } | |
3146 | } | |
3147 | } | |
3148 | } | |
3149 | ||
3150 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
3151 | ||
3152 | step("Verify on R2 that R1 doesn't advertise any GR capabilities") | |
3153 | ||
3154 | input_dict = { | |
9fa6ec14 | 3155 | "r1": { |
3156 | "bgp": { | |
3157 | "graceful-restart": { | |
3158 | "graceful-restart-disable": True, | |
3159 | } | |
3160 | } | |
3161 | }, | |
17022899 KK |
3162 | "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}}, |
3163 | } | |
3164 | ||
3165 | for addr_type in ADDR_TYPES: | |
3166 | result = verify_graceful_restart( | |
3167 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
3168 | ) | |
3169 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3170 | ||
3171 | result = verify_graceful_restart( | |
3172 | tgen, topo, addr_type, input_dict, dut="r2", peer="r1" | |
3173 | ) | |
3174 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3175 | ||
3176 | for addr_type in ADDR_TYPES: | |
3177 | dut = "r1" | |
3178 | peer = "r2" | |
3179 | protocol = "bgp" | |
3180 | next_hop = next_hop_per_address_family( | |
3181 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
3182 | ) | |
3183 | input_topo = {"r2": topo["routers"]["r2"]} | |
3184 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3185 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3186 | ||
3187 | dut = "r2" | |
3188 | peer = "r1" | |
3189 | next_hop = next_hop_per_address_family( | |
3190 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
3191 | ) | |
3192 | input_topo = {"r1": topo["routers"]["r1"]} | |
3193 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
3194 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3195 | protocol = "bgp" | |
3196 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3197 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3198 | ||
3199 | step("Kill BGP on R1") | |
3200 | ||
3201 | kill_router_daemons(tgen, "r1", ["bgpd"]) | |
3202 | ||
3203 | step( | |
3204 | "Verify that R1 flush all BGP routes from RIB & FIB and FIB and R2" | |
3205 | " does not retain stale entry for received routes from R1" | |
3206 | ) | |
3207 | ||
3208 | for addr_type in ADDR_TYPES: | |
3209 | dut = "r1" | |
3210 | peer = "r2" | |
3211 | protocol = "bgp" | |
3212 | next_hop = next_hop_per_address_family( | |
3213 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
3214 | ) | |
3215 | input_topo = {"r2": topo["routers"]["r2"]} | |
3216 | result = verify_rib( | |
3217 | tgen, addr_type, dut, input_topo, next_hop, protocol, expected=False | |
3218 | ) | |
3219 | assert ( | |
3220 | result is not True | |
3221 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
3222 | tc_name, result | |
3223 | ) | |
3224 | ||
3225 | dut = "r2" | |
3226 | peer = "r1" | |
3227 | next_hop = next_hop_per_address_family( | |
3228 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
3229 | ) | |
3230 | input_topo = {"r1": topo["routers"]["r1"]} | |
3231 | result = verify_bgp_rib( | |
3232 | tgen, addr_type, dut, input_topo, next_hop, expected=False | |
3233 | ) | |
0b25370e DS |
3234 | assert result is not True, ( |
3235 | "Testcase {} : Failed \n " | |
5cbb02eb | 3236 | "r2: routes are still present in BGP RIB\n Error: {}".format( |
0b25370e DS |
3237 | tc_name, result |
3238 | ) | |
3239 | ) | |
17022899 KK |
3240 | protocol = "bgp" |
3241 | result = verify_rib( | |
3242 | tgen, addr_type, dut, input_topo, next_hop, protocol, expected=False | |
3243 | ) | |
3244 | assert ( | |
3245 | result is not True | |
3246 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
3247 | tc_name, result | |
3248 | ) | |
3249 | ||
3250 | step( | |
3251 | "Bring up BGPd on R1 and configure it as GR" " restarting node in global level" | |
3252 | ) | |
3253 | ||
3254 | start_router_daemons(tgen, "r1", ["bgpd"]) | |
3255 | ||
3256 | input_dict = {"r1": {"bgp": {"graceful-restart": {"graceful-restart": True}}}} | |
3257 | ||
3258 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
3259 | ||
3260 | step("Verify on R2 that R1 advertises GR capabilities as a restarting node") | |
3261 | ||
3262 | input_dict = { | |
9fa6ec14 | 3263 | "r1": { |
3264 | "bgp": { | |
3265 | "graceful-restart": { | |
3266 | "graceful-restart": True, | |
3267 | } | |
3268 | } | |
3269 | }, | |
17022899 KK |
3270 | "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}}, |
3271 | } | |
3272 | ||
3273 | for addr_type in ADDR_TYPES: | |
3274 | result = verify_graceful_restart( | |
3275 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
3276 | ) | |
3277 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3278 | ||
3279 | result = verify_graceful_restart( | |
3280 | tgen, topo, addr_type, input_dict, dut="r2", peer="r1" | |
3281 | ) | |
3282 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3283 | ||
3284 | for addr_type in ADDR_TYPES: | |
3285 | dut = "r1" | |
3286 | peer = "r2" | |
3287 | protocol = "bgp" | |
3288 | next_hop = next_hop_per_address_family( | |
3289 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
3290 | ) | |
3291 | input_topo = {"r2": topo["routers"]["r2"]} | |
3292 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3293 | assert ( | |
3294 | result is True | |
3295 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
3296 | tc_name, result | |
3297 | ) | |
3298 | ||
3299 | dut = "r2" | |
3300 | peer = "r1" | |
3301 | next_hop = next_hop_per_address_family( | |
3302 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
3303 | ) | |
3304 | input_topo = {"r1": topo["routers"]["r1"]} | |
3305 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
3306 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3307 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3308 | assert ( | |
3309 | result is True | |
3310 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
3311 | tc_name, result | |
3312 | ) | |
3313 | ||
3314 | step("Kill BGP on R1") | |
3315 | ||
3316 | kill_router_daemons(tgen, "r1", ["bgpd"]) | |
3317 | ||
3318 | step( | |
3319 | "Verify that R1 keeps BGP routes in zebra and R2" | |
3320 | " retains the stale entry for received routes from R1" | |
3321 | ) | |
3322 | ||
3323 | for addr_type in ADDR_TYPES: | |
3324 | dut = "r1" | |
3325 | peer = "r2" | |
3326 | protocol = "bgp" | |
3327 | next_hop = next_hop_per_address_family( | |
3328 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
3329 | ) | |
3330 | input_topo = {"r2": topo["routers"]["r2"]} | |
3331 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3332 | assert ( | |
3333 | result is True | |
3334 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
3335 | tc_name, result | |
3336 | ) | |
3337 | ||
3338 | dut = "r2" | |
3339 | peer = "r1" | |
3340 | next_hop = next_hop_per_address_family( | |
3341 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
3342 | ) | |
3343 | input_topo = {"r1": topo["routers"]["r1"]} | |
3344 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
3345 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3346 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3347 | assert ( | |
3348 | result is True | |
3349 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
3350 | tc_name, result | |
3351 | ) | |
3352 | ||
3353 | write_test_footer(tc_name) | |
3354 | ||
3355 | ||
3356 | def test_BGP_GR_TC_44_p1(request): | |
3357 | """ | |
3358 | Test Objective : Transition from Global Helper to Disable | |
3359 | and then Global Disable to Helper. | |
3360 | ||
3361 | """ | |
3362 | ||
3363 | tgen = get_topogen() | |
3364 | tc_name = request.node.name | |
3365 | write_test_header(tc_name) | |
3366 | ||
3367 | # Check router status | |
3368 | check_router_status(tgen) | |
3369 | ||
3370 | # Don't run this test if we have any failure. | |
3371 | if tgen.routers_have_failure(): | |
3372 | pytest.skip(tgen.errors) | |
3373 | ||
3374 | # Creating configuration from JSON | |
3375 | reset_config_on_routers(tgen) | |
3376 | ||
3377 | step( | |
3378 | "Configure R2 as GR restating node in global level and" | |
3379 | " leave R1 without any GR related config" | |
3380 | ) | |
3381 | ||
3382 | input_dict = {"r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}}} | |
3383 | ||
3384 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
3385 | ||
3386 | step("Verify on R2 that R1 advertises GR capabilities as a helper node") | |
3387 | ||
3388 | input_dict = { | |
9fa6ec14 | 3389 | "r1": { |
3390 | "bgp": { | |
3391 | "graceful-restart": { | |
3392 | "graceful-restart-helper": True, | |
3393 | } | |
3394 | } | |
3395 | }, | |
17022899 KK |
3396 | "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}}, |
3397 | } | |
3398 | ||
3399 | for addr_type in ADDR_TYPES: | |
3400 | result = verify_graceful_restart( | |
3401 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
3402 | ) | |
3403 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3404 | ||
3405 | result = verify_graceful_restart( | |
3406 | tgen, topo, addr_type, input_dict, dut="r2", peer="r1" | |
3407 | ) | |
3408 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3409 | ||
3410 | for addr_type in ADDR_TYPES: | |
3411 | dut = "r2" | |
3412 | peer = "r1" | |
3413 | protocol = "bgp" | |
3414 | next_hop = next_hop_per_address_family( | |
3415 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
3416 | ) | |
3417 | input_topo = {"r1": topo["routers"]["r1"]} | |
3418 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3419 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3420 | ||
3421 | dut = "r1" | |
3422 | peer = "r2" | |
3423 | next_hop = next_hop_per_address_family( | |
3424 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
3425 | ) | |
3426 | input_topo = {"r2": topo["routers"]["r2"]} | |
3427 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
3428 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3429 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3430 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3431 | ||
3432 | step("Kill BGP on R2") | |
3433 | ||
3434 | kill_router_daemons(tgen, "r2", ["bgpd"]) | |
3435 | ||
3436 | step("Verify that R1 keeps stale entry for BGP routes when BGPd on R2 is down") | |
3437 | ||
3438 | for addr_type in ADDR_TYPES: | |
3439 | dut = "r2" | |
3440 | peer = "r1" | |
3441 | protocol = "bgp" | |
3442 | next_hop = next_hop_per_address_family( | |
3443 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
3444 | ) | |
3445 | input_topo = {"r1": topo["routers"]["r1"]} | |
3446 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3447 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3448 | ||
3449 | dut = "r1" | |
3450 | peer = "r2" | |
3451 | next_hop = next_hop_per_address_family( | |
3452 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
3453 | ) | |
3454 | input_topo = {"r2": topo["routers"]["r2"]} | |
3455 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
3456 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3457 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3458 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3459 | ||
3460 | step("Bring up BGPd on R2 and configure R1 as GR disabled node in global level") | |
3461 | ||
3462 | start_router_daemons(tgen, "r2", ["bgpd"]) | |
3463 | ||
3464 | input_dict = { | |
9fa6ec14 | 3465 | "r1": { |
3466 | "bgp": { | |
3467 | "graceful-restart": { | |
3468 | "graceful-restart-disable": True, | |
3469 | } | |
3470 | } | |
3471 | } | |
17022899 KK |
3472 | } |
3473 | ||
3474 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
3475 | ||
3476 | step("Verify on R2 that R1 doesn't advertise any GR capabilities") | |
3477 | ||
3478 | input_dict = { | |
9fa6ec14 | 3479 | "r1": { |
3480 | "bgp": { | |
3481 | "graceful-restart": { | |
3482 | "graceful-restart-disable": True, | |
3483 | } | |
3484 | } | |
3485 | }, | |
17022899 KK |
3486 | "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}}, |
3487 | } | |
3488 | ||
3489 | for addr_type in ADDR_TYPES: | |
3490 | result = verify_graceful_restart( | |
3491 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
3492 | ) | |
3493 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3494 | result = verify_graceful_restart( | |
3495 | tgen, topo, addr_type, input_dict, dut="r2", peer="r1" | |
3496 | ) | |
3497 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3498 | ||
3499 | for addr_type in ADDR_TYPES: | |
3500 | dut = "r2" | |
3501 | peer = "r1" | |
3502 | protocol = "bgp" | |
3503 | next_hop = next_hop_per_address_family( | |
3504 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
3505 | ) | |
3506 | input_topo = {"r1": topo["routers"]["r1"]} | |
3507 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3508 | assert ( | |
3509 | result is True | |
3510 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
3511 | tc_name, result | |
3512 | ) | |
3513 | ||
3514 | step("Kill BGP on R2") | |
3515 | ||
3516 | kill_router_daemons(tgen, "r2", ["bgpd"]) | |
3517 | ||
3518 | step("Verify that R1 does not retain stale entry for received routes from R2") | |
3519 | ||
3520 | for addr_type in ADDR_TYPES: | |
3521 | dut = "r2" | |
3522 | peer = "r1" | |
3523 | protocol = "bgp" | |
3524 | next_hop = next_hop_per_address_family( | |
3525 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
3526 | ) | |
3527 | input_topo = {"r1": topo["routers"]["r1"]} | |
3528 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3529 | assert ( | |
3530 | result is True | |
3531 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
3532 | tc_name, result | |
3533 | ) | |
3534 | ||
3535 | dut = "r1" | |
3536 | peer = "r2" | |
3537 | next_hop = next_hop_per_address_family( | |
3538 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
3539 | ) | |
3540 | next_hop = NEXT_HOP_IP_2[addr_type] | |
3541 | result = verify_bgp_rib( | |
3542 | tgen, addr_type, dut, input_topo, next_hop, expected=False | |
3543 | ) | |
0b25370e DS |
3544 | assert result is not True, ( |
3545 | "Testcase {} : Failed \n " | |
5cbb02eb | 3546 | "r1: routes are still present in BGP RIB\n Error: {}".format( |
0b25370e DS |
3547 | tc_name, result |
3548 | ) | |
3549 | ) | |
17022899 KK |
3550 | result = verify_rib( |
3551 | tgen, addr_type, dut, input_topo, next_hop, protocol, expected=False | |
3552 | ) | |
3553 | assert ( | |
3554 | result is not True | |
3555 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
3556 | tc_name, result | |
3557 | ) | |
3558 | ||
3559 | step("Bring up BGPd on R2 and remove GR related config from R1 in global level") | |
3560 | ||
3561 | start_router_daemons(tgen, "r2", ["bgpd"]) | |
3562 | ||
3563 | input_dict = { | |
3564 | "r1": {"bgp": {"graceful-restart": {"graceful-restart-disable": False}}} | |
3565 | } | |
3566 | ||
3567 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
3568 | ||
3569 | step("Verify on R2 that R1 advertises GR capabilities as a helper node") | |
3570 | ||
3571 | input_dict = { | |
9fa6ec14 | 3572 | "r1": { |
3573 | "bgp": { | |
3574 | "graceful-restart": { | |
3575 | "graceful-restart-helper": True, | |
3576 | } | |
3577 | } | |
3578 | }, | |
17022899 KK |
3579 | "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}}, |
3580 | } | |
3581 | ||
3582 | for addr_type in ADDR_TYPES: | |
3583 | result = verify_graceful_restart( | |
3584 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
3585 | ) | |
3586 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3587 | ||
3588 | result = verify_graceful_restart( | |
3589 | tgen, topo, addr_type, input_dict, dut="r2", peer="r1" | |
3590 | ) | |
3591 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3592 | ||
3593 | for addr_type in ADDR_TYPES: | |
3594 | dut = "r2" | |
3595 | peer = "r1" | |
3596 | protocol = "bgp" | |
3597 | next_hop = next_hop_per_address_family( | |
3598 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
3599 | ) | |
3600 | input_topo = {"r1": topo["routers"]["r1"]} | |
3601 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3602 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3603 | ||
3604 | dut = "r1" | |
3605 | peer = "r2" | |
3606 | next_hop = next_hop_per_address_family( | |
3607 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
3608 | ) | |
3609 | input_topo = {"r2": topo["routers"]["r2"]} | |
3610 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
3611 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3612 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3613 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3614 | ||
3615 | step("Kill BGP on R2") | |
3616 | ||
3617 | kill_router_daemons(tgen, "r2", ["bgpd"]) | |
3618 | ||
3619 | step("Verify that R1 keeps stale entry for BGP routes when BGPd on R2 is down") | |
3620 | ||
3621 | for addr_type in ADDR_TYPES: | |
3622 | dut = "r2" | |
3623 | peer = "r1" | |
3624 | protocol = "bgp" | |
3625 | next_hop = next_hop_per_address_family( | |
3626 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
3627 | ) | |
3628 | input_topo = {"r1": topo["routers"]["r1"]} | |
3629 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3630 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3631 | ||
3632 | dut = "r1" | |
3633 | peer = "r2" | |
3634 | next_hop = next_hop_per_address_family( | |
3635 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
3636 | ) | |
3637 | input_topo = {"r2": topo["routers"]["r2"]} | |
3638 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
3639 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3640 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3641 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3642 | ||
3643 | write_test_footer(tc_name) | |
3644 | ||
3645 | ||
3646 | def test_BGP_GR_TC_45_p1(request): | |
3647 | """ | |
3648 | Test Objective : Transition from Global Restart to Helper | |
3649 | and then Global Helper to Restart. | |
3650 | ||
3651 | """ | |
3652 | ||
3653 | tgen = get_topogen() | |
3654 | tc_name = request.node.name | |
3655 | write_test_header(tc_name) | |
3656 | ||
3657 | # Check router status | |
3658 | check_router_status(tgen) | |
3659 | ||
3660 | # Don't run this test if we have any failure. | |
3661 | if tgen.routers_have_failure(): | |
3662 | pytest.skip(tgen.errors) | |
3663 | ||
3664 | # Creating configuration from JSON | |
3665 | reset_config_on_routers(tgen) | |
3666 | ||
3667 | step("Configure R1 and R2 as GR restarting node in global level") | |
3668 | ||
3669 | input_dict = { | |
3670 | "r1": {"bgp": {"graceful-restart": {"graceful-restart": True}}}, | |
3671 | "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}}, | |
3672 | } | |
3673 | ||
3674 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
3675 | ||
3676 | step("Verify on R2 that R1 advertises GR capabilities as a restarting node") | |
3677 | ||
3678 | for addr_type in ADDR_TYPES: | |
3679 | result = verify_graceful_restart( | |
3680 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
3681 | ) | |
3682 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3683 | result = verify_graceful_restart( | |
3684 | tgen, topo, addr_type, input_dict, dut="r2", peer="r1" | |
3685 | ) | |
3686 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3687 | ||
3688 | for addr_type in ADDR_TYPES: | |
3689 | dut = "r1" | |
3690 | peer = "r2" | |
3691 | protocol = "bgp" | |
3692 | next_hop = next_hop_per_address_family( | |
3693 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
3694 | ) | |
3695 | input_topo = {"r2": topo["routers"]["r2"]} | |
3696 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3697 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3698 | ||
3699 | dut = "r2" | |
3700 | peer = "r1" | |
3701 | next_hop = next_hop_per_address_family( | |
3702 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
3703 | ) | |
3704 | input_topo = {"r1": topo["routers"]["r1"]} | |
3705 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
3706 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3707 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3708 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3709 | ||
3710 | step("Kill BGP on R1") | |
3711 | ||
3712 | kill_router_daemons(tgen, "r1", ["bgpd"]) | |
3713 | ||
3714 | step( | |
3715 | "Verify that R1 keeps BGP routes in zebra and R2" | |
3716 | " retains the stale entry for received routes from R1" | |
3717 | ) | |
3718 | ||
3719 | for addr_type in ADDR_TYPES: | |
3720 | dut = "r1" | |
3721 | peer = "r2" | |
3722 | protocol = "bgp" | |
3723 | next_hop = next_hop_per_address_family( | |
3724 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
3725 | ) | |
3726 | input_topo = {"r2": topo["routers"]["r2"]} | |
3727 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3728 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3729 | ||
3730 | dut = "r2" | |
3731 | peer = "r1" | |
3732 | next_hop = next_hop_per_address_family( | |
3733 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
3734 | ) | |
3735 | input_topo = {"r1": topo["routers"]["r1"]} | |
3736 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
3737 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3738 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3739 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3740 | ||
3741 | step("Bring up BGPd on R1 and remove GR related config in global level") | |
3742 | ||
3743 | start_router_daemons(tgen, "r1", ["bgpd"]) | |
3744 | ||
9fa6ec14 | 3745 | input_dict = { |
3746 | "r1": { | |
3747 | "bgp": { | |
3748 | "graceful-restart": { | |
3749 | "graceful-restart": False, | |
3750 | } | |
3751 | } | |
3752 | } | |
3753 | } | |
17022899 KK |
3754 | |
3755 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
3756 | ||
3757 | step("Verify on R2 that R1 advertises GR capabilities as a helper node") | |
3758 | ||
3759 | input_dict = { | |
9fa6ec14 | 3760 | "r1": { |
3761 | "bgp": { | |
3762 | "graceful-restart": { | |
3763 | "graceful-restart-helper": True, | |
3764 | } | |
3765 | } | |
3766 | }, | |
17022899 KK |
3767 | "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}}, |
3768 | } | |
3769 | ||
3770 | for addr_type in ADDR_TYPES: | |
3771 | result = verify_graceful_restart( | |
3772 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
3773 | ) | |
3774 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3775 | result = verify_graceful_restart( | |
3776 | tgen, topo, addr_type, input_dict, dut="r2", peer="r1" | |
3777 | ) | |
3778 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3779 | ||
3780 | for addr_type in ADDR_TYPES: | |
3781 | dut = "r2" | |
3782 | peer = "r1" | |
3783 | protocol = "bgp" | |
3784 | next_hop = next_hop_per_address_family( | |
3785 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
3786 | ) | |
3787 | input_topo = {"r1": topo["routers"]["r1"]} | |
3788 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3789 | assert ( | |
3790 | result is True | |
3791 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
3792 | tc_name, result | |
3793 | ) | |
3794 | ||
3795 | dut = "r1" | |
3796 | peer = "r2" | |
3797 | next_hop = next_hop_per_address_family( | |
3798 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
3799 | ) | |
3800 | input_topo = {"r2": topo["routers"]["r2"]} | |
3801 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
3802 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3803 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3804 | assert ( | |
3805 | result is True | |
3806 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
3807 | tc_name, result | |
3808 | ) | |
3809 | ||
3810 | step("Kill BGP on R2") | |
3811 | ||
3812 | kill_router_daemons(tgen, "r2", ["bgpd"]) | |
3813 | ||
3814 | step("Verify that R1 keeps stale entry for BGP routes when BGPd on R2 is down") | |
3815 | ||
3816 | for addr_type in ADDR_TYPES: | |
3817 | dut = "r2" | |
3818 | peer = "r1" | |
3819 | protocol = "bgp" | |
3820 | next_hop = next_hop_per_address_family( | |
3821 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
3822 | ) | |
3823 | input_topo = {"r1": topo["routers"]["r1"]} | |
3824 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3825 | assert ( | |
3826 | result is True | |
3827 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
3828 | tc_name, result | |
3829 | ) | |
3830 | ||
3831 | dut = "r1" | |
3832 | peer = "r2" | |
3833 | next_hop = next_hop_per_address_family( | |
3834 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
3835 | ) | |
3836 | input_topo = {"r2": topo["routers"]["r2"]} | |
3837 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
3838 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3839 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3840 | assert ( | |
3841 | result is True | |
3842 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
3843 | tc_name, result | |
3844 | ) | |
3845 | ||
3846 | step("Bring up BGPd on R2 and configure R1 as GR restarting node in global level") | |
3847 | ||
3848 | start_router_daemons(tgen, "r2", ["bgpd"]) | |
3849 | ||
9fa6ec14 | 3850 | input_dict = { |
3851 | "r1": { | |
3852 | "bgp": { | |
3853 | "graceful-restart": { | |
3854 | "graceful-restart": True, | |
3855 | } | |
3856 | } | |
3857 | } | |
3858 | } | |
17022899 KK |
3859 | |
3860 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
3861 | ||
3862 | step("Verify on R2 that R1 advertises GR capabilities as a restarting node") | |
3863 | ||
3864 | input_dict = { | |
9fa6ec14 | 3865 | "r1": { |
3866 | "bgp": { | |
3867 | "graceful-restart": { | |
3868 | "graceful-restart": True, | |
3869 | } | |
3870 | } | |
3871 | }, | |
17022899 KK |
3872 | "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}}, |
3873 | } | |
3874 | ||
3875 | for addr_type in ADDR_TYPES: | |
3876 | result = verify_graceful_restart( | |
3877 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
3878 | ) | |
3879 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3880 | result = verify_graceful_restart( | |
3881 | tgen, topo, addr_type, input_dict, dut="r2", peer="r1" | |
3882 | ) | |
3883 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3884 | ||
3885 | for addr_type in ADDR_TYPES: | |
3886 | dut = "r1" | |
3887 | peer = "r2" | |
3888 | protocol = "bgp" | |
3889 | next_hop = next_hop_per_address_family( | |
3890 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
3891 | ) | |
3892 | input_topo = {"r2": topo["routers"]["r2"]} | |
3893 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3894 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3895 | ||
3896 | dut = "r2" | |
3897 | peer = "r1" | |
3898 | next_hop = next_hop_per_address_family( | |
3899 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
3900 | ) | |
3901 | input_topo = {"r1": topo["routers"]["r1"]} | |
3902 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
3903 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3904 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3905 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3906 | ||
3907 | step("Kill BGP on R1") | |
3908 | ||
3909 | kill_router_daemons(tgen, "r1", ["bgpd"]) | |
3910 | ||
3911 | step( | |
3912 | "Verify that R1 keeps BGP routes in zebra and R2" | |
3913 | " retains the stale entry for received routes from R1" | |
3914 | ) | |
3915 | ||
3916 | for addr_type in ADDR_TYPES: | |
3917 | dut = "r1" | |
3918 | peer = "r2" | |
3919 | protocol = "bgp" | |
3920 | next_hop = next_hop_per_address_family( | |
3921 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
3922 | ) | |
3923 | input_topo = {"r2": topo["routers"]["r2"]} | |
3924 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3925 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3926 | ||
3927 | dut = "r2" | |
3928 | peer = "r1" | |
3929 | next_hop = next_hop_per_address_family( | |
3930 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
3931 | ) | |
3932 | input_topo = {"r1": topo["routers"]["r1"]} | |
3933 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
3934 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3935 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
3936 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
3937 | ||
3938 | write_test_footer(tc_name) | |
3939 | ||
3940 | ||
3941 | def test_BGP_GR_TC_46_p1(request): | |
3942 | """ | |
3943 | Test Objective : transition from Peer-level helper to Global Restarting | |
3944 | Global Mode : GR Restarting | |
3945 | PerPeer Mode : GR Helper | |
3946 | GR Mode effective : GR Helper | |
3947 | ||
3948 | """ | |
3949 | ||
3950 | tgen = get_topogen() | |
3951 | tc_name = request.node.name | |
3952 | write_test_header(tc_name) | |
3953 | ||
3954 | # Check router status | |
3955 | check_router_status(tgen) | |
3956 | ||
3957 | # Don't run this test if we have any failure. | |
3958 | if tgen.routers_have_failure(): | |
3959 | pytest.skip(tgen.errors) | |
3960 | ||
3961 | # Creating configuration from JSON | |
3962 | reset_config_on_routers(tgen) | |
3963 | ||
3964 | step( | |
3965 | "Configure R1 and R2 as GR restarting node in global" | |
3966 | " and helper in per-Peer-level" | |
3967 | ) | |
3968 | ||
3969 | input_dict = { | |
3970 | "r1": { | |
3971 | "bgp": { | |
9fa6ec14 | 3972 | "graceful-restart": { |
3973 | "graceful-restart": True, | |
3974 | }, | |
17022899 KK |
3975 | "address_family": { |
3976 | "ipv4": { | |
3977 | "unicast": { | |
3978 | "neighbor": { | |
3979 | "r2": { | |
3980 | "dest_link": { | |
3981 | "r1-link1": {"graceful-restart-helper": True} | |
3982 | } | |
3983 | } | |
3984 | } | |
3985 | } | |
3986 | }, | |
3987 | "ipv6": { | |
3988 | "unicast": { | |
3989 | "neighbor": { | |
3990 | "r2": { | |
3991 | "dest_link": { | |
3992 | "r1-link1": {"graceful-restart-helper": True} | |
3993 | } | |
3994 | } | |
3995 | } | |
3996 | } | |
3997 | }, | |
3998 | }, | |
3999 | } | |
4000 | }, | |
4001 | "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}}, | |
4002 | } | |
4003 | ||
4004 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
4005 | ||
4006 | step("Verify on R2 that R1 advertises GR capabilities as a restarting node") | |
4007 | ||
4008 | for addr_type in ADDR_TYPES: | |
4009 | result = verify_graceful_restart( | |
4010 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
4011 | ) | |
4012 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4013 | result = verify_graceful_restart( | |
4014 | tgen, topo, addr_type, input_dict, dut="r2", peer="r1" | |
4015 | ) | |
4016 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4017 | ||
4018 | for addr_type in ADDR_TYPES: | |
4019 | dut = "r2" | |
4020 | peer = "r1" | |
4021 | protocol = "bgp" | |
4022 | next_hop = next_hop_per_address_family( | |
4023 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
4024 | ) | |
4025 | input_topo = {"r1": topo["routers"]["r1"]} | |
4026 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4027 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4028 | ||
4029 | dut = "r1" | |
4030 | peer = "r2" | |
4031 | next_hop = next_hop_per_address_family( | |
4032 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
4033 | ) | |
4034 | input_topo = {"r2": topo["routers"]["r2"]} | |
4035 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
4036 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4037 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4038 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4039 | ||
4040 | step("Kill BGP on R2") | |
4041 | ||
4042 | kill_router_daemons(tgen, "r2", ["bgpd"]) | |
4043 | ||
4044 | step( | |
4045 | "Verify that R1 keeps the stale entries in RIB & FIB and R2 keeps stale entries in FIB using" | |
4046 | ) | |
4047 | ||
4048 | for addr_type in ADDR_TYPES: | |
4049 | dut = "r2" | |
4050 | peer = "r1" | |
4051 | protocol = "bgp" | |
4052 | next_hop = next_hop_per_address_family( | |
4053 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
4054 | ) | |
4055 | input_topo = {"r1": topo["routers"]["r1"]} | |
4056 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4057 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4058 | ||
4059 | dut = "r1" | |
4060 | peer = "r2" | |
4061 | next_hop = next_hop_per_address_family( | |
4062 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
4063 | ) | |
4064 | input_topo = {"r2": topo["routers"]["r2"]} | |
4065 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
4066 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4067 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4068 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4069 | ||
4070 | step( | |
4071 | "Bring up BGP on R1 and remove Peer-level GR config" | |
4072 | " from R1 following by a session reset" | |
4073 | ) | |
4074 | ||
4075 | start_router_daemons(tgen, "r2", ["bgpd"]) | |
4076 | ||
4077 | input_dict = { | |
4078 | "r1": { | |
4079 | "bgp": { | |
4080 | "address_family": { | |
4081 | "ipv4": { | |
4082 | "unicast": { | |
4083 | "neighbor": { | |
4084 | "r2": { | |
4085 | "dest_link": { | |
4086 | "r1-link1": {"graceful-restart-helper": False} | |
4087 | } | |
4088 | } | |
4089 | } | |
4090 | } | |
4091 | }, | |
4092 | "ipv6": { | |
4093 | "unicast": { | |
4094 | "neighbor": { | |
4095 | "r2": { | |
4096 | "dest_link": { | |
4097 | "r1-link1": {"graceful-restart-helper": False} | |
4098 | } | |
4099 | } | |
4100 | } | |
4101 | } | |
4102 | }, | |
4103 | } | |
4104 | } | |
4105 | } | |
4106 | } | |
4107 | ||
4108 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
4109 | ||
4110 | step("Verify on R2 that R1 advertises GR capabilities as a restarting node") | |
4111 | ||
4112 | input_dict = { | |
4113 | "r1": {"bgp": {"graceful-restart": {"graceful-restart": True}}}, | |
4114 | "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}}, | |
4115 | } | |
4116 | ||
4117 | for addr_type in ADDR_TYPES: | |
4118 | result = verify_graceful_restart( | |
4119 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
4120 | ) | |
4121 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4122 | result = verify_graceful_restart( | |
4123 | tgen, topo, addr_type, input_dict, dut="r2", peer="r1" | |
4124 | ) | |
4125 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4126 | ||
4127 | for addr_type in ADDR_TYPES: | |
4128 | dut = "r1" | |
4129 | peer = "r2" | |
4130 | protocol = "bgp" | |
4131 | next_hop = next_hop_per_address_family( | |
4132 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
4133 | ) | |
4134 | input_topo = {"r2": topo["routers"]["r2"]} | |
4135 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4136 | assert ( | |
4137 | result is True | |
4138 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
4139 | tc_name, result | |
4140 | ) | |
4141 | ||
4142 | dut = "r2" | |
4143 | peer = "r1" | |
4144 | next_hop = next_hop_per_address_family( | |
4145 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
4146 | ) | |
4147 | input_topo = {"r1": topo["routers"]["r1"]} | |
4148 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
4149 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4150 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4151 | assert ( | |
4152 | result is True | |
4153 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
4154 | tc_name, result | |
4155 | ) | |
4156 | ||
4157 | step("Kill BGP on R1") | |
4158 | ||
4159 | kill_router_daemons(tgen, "r1", ["bgpd"]) | |
4160 | ||
4161 | step( | |
4162 | "Verify that R1 keeps the stale entries in FIB command and R2 keeps stale entries in RIB & FIB" | |
4163 | ) | |
4164 | ||
4165 | for addr_type in ADDR_TYPES: | |
4166 | dut = "r1" | |
4167 | peer = "r2" | |
4168 | protocol = "bgp" | |
4169 | next_hop = next_hop_per_address_family( | |
4170 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
4171 | ) | |
4172 | input_topo = {"r2": topo["routers"]["r2"]} | |
4173 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4174 | assert ( | |
4175 | result is True | |
4176 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
4177 | tc_name, result | |
4178 | ) | |
4179 | ||
4180 | dut = "r2" | |
4181 | peer = "r1" | |
4182 | next_hop = next_hop_per_address_family( | |
4183 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
4184 | ) | |
4185 | input_topo = {"r1": topo["routers"]["r1"]} | |
4186 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
4187 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4188 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4189 | assert ( | |
4190 | result is True | |
4191 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
4192 | tc_name, result | |
4193 | ) | |
4194 | ||
4195 | write_test_footer(tc_name) | |
4196 | ||
4197 | ||
4198 | def test_BGP_GR_TC_47_p1(request): | |
4199 | """ | |
4200 | Test Objective : transition from Peer-level restart to Global Restart | |
4201 | Global Mode : GR Restarting | |
4202 | PerPeer Mode : GR Restarting | |
4203 | GR Mode effective : GR Restarting | |
4204 | ||
4205 | """ | |
4206 | ||
4207 | tgen = get_topogen() | |
4208 | tc_name = request.node.name | |
4209 | write_test_header(tc_name) | |
4210 | ||
4211 | # Check router status | |
4212 | check_router_status(tgen) | |
4213 | ||
4214 | # Don't run this test if we have any failure. | |
4215 | if tgen.routers_have_failure(): | |
4216 | pytest.skip(tgen.errors) | |
4217 | ||
4218 | # Creating configuration from JSON | |
4219 | reset_config_on_routers(tgen) | |
4220 | ||
4221 | step("Configure R1 and R2 as GR restarting node in global and per-Peer-level") | |
4222 | ||
4223 | input_dict = { | |
4224 | "r1": { | |
4225 | "bgp": { | |
9fa6ec14 | 4226 | "graceful-restart": { |
4227 | "graceful-restart": True, | |
4228 | }, | |
17022899 KK |
4229 | "address_family": { |
4230 | "ipv4": { | |
4231 | "unicast": { | |
4232 | "neighbor": { | |
4233 | "r2": { | |
4234 | "dest_link": { | |
4235 | "r1-link1": {"graceful-restart": True} | |
4236 | } | |
4237 | } | |
4238 | } | |
4239 | } | |
4240 | }, | |
4241 | "ipv6": { | |
4242 | "unicast": { | |
4243 | "neighbor": { | |
4244 | "r2": { | |
4245 | "dest_link": { | |
4246 | "r1-link1": {"graceful-restart": True} | |
4247 | } | |
4248 | } | |
4249 | } | |
4250 | } | |
4251 | }, | |
4252 | }, | |
4253 | } | |
4254 | }, | |
4255 | "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}}, | |
4256 | } | |
4257 | ||
4258 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
4259 | ||
4260 | step("Verify on R2 that R1 advertises GR capabilities as a restarting node") | |
4261 | ||
4262 | for addr_type in ADDR_TYPES: | |
4263 | result = verify_graceful_restart( | |
4264 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
4265 | ) | |
4266 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4267 | result = verify_graceful_restart( | |
4268 | tgen, topo, addr_type, input_dict, dut="r2", peer="r1" | |
4269 | ) | |
4270 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4271 | ||
4272 | for addr_type in ADDR_TYPES: | |
4273 | dut = "r1" | |
4274 | peer = "r2" | |
4275 | protocol = "bgp" | |
4276 | next_hop = next_hop_per_address_family( | |
4277 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
4278 | ) | |
4279 | input_topo = {"r2": topo["routers"]["r2"]} | |
4280 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4281 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4282 | ||
4283 | dut = "r2" | |
4284 | peer = "r1" | |
4285 | next_hop = next_hop_per_address_family( | |
4286 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
4287 | ) | |
4288 | input_topo = {"r1": topo["routers"]["r1"]} | |
4289 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
4290 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4291 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4292 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4293 | ||
4294 | step("Kill BGP on R1") | |
4295 | ||
4296 | kill_router_daemons(tgen, "r1", ["bgpd"]) | |
4297 | ||
4298 | step( | |
4299 | "Verify that R1 keeps the stale entries in FIB and R2 keeps stale entries in RIB & FIB" | |
4300 | ) | |
4301 | ||
4302 | for addr_type in ADDR_TYPES: | |
4303 | dut = "r1" | |
4304 | peer = "r2" | |
4305 | protocol = "bgp" | |
4306 | next_hop = next_hop_per_address_family( | |
4307 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
4308 | ) | |
4309 | input_topo = {"r2": topo["routers"]["r2"]} | |
4310 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4311 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4312 | ||
4313 | dut = "r2" | |
4314 | peer = "r1" | |
4315 | next_hop = next_hop_per_address_family( | |
4316 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
4317 | ) | |
4318 | input_topo = {"r1": topo["routers"]["r1"]} | |
4319 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
4320 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4321 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4322 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4323 | ||
4324 | step( | |
4325 | "Bring up BGP on R1 and remove Peer-level GR" | |
4326 | " config from R1 following by a session reset" | |
4327 | ) | |
4328 | ||
4329 | start_router_daemons(tgen, "r1", ["bgpd"]) | |
4330 | ||
4331 | input_dict = { | |
4332 | "r1": { | |
4333 | "bgp": { | |
4334 | "address_family": { | |
4335 | "ipv4": { | |
4336 | "unicast": { | |
4337 | "neighbor": { | |
4338 | "r2": { | |
4339 | "dest_link": { | |
4340 | "r1-link1": {"graceful-restart": False} | |
4341 | } | |
4342 | } | |
4343 | } | |
4344 | } | |
4345 | }, | |
4346 | "ipv6": { | |
4347 | "unicast": { | |
4348 | "neighbor": { | |
4349 | "r2": { | |
4350 | "dest_link": { | |
4351 | "r1-link1": {"graceful-restart": False} | |
4352 | } | |
4353 | } | |
4354 | } | |
4355 | } | |
4356 | }, | |
4357 | } | |
4358 | } | |
4359 | } | |
4360 | } | |
4361 | ||
4362 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
4363 | ||
4364 | step("Verify on R2 that R1 still advertises GR capabilities as a restarting node") | |
4365 | ||
4366 | input_dict = { | |
9fa6ec14 | 4367 | "r1": { |
4368 | "bgp": { | |
4369 | "graceful-restart": { | |
4370 | "graceful-restart": True, | |
4371 | } | |
4372 | } | |
4373 | }, | |
17022899 KK |
4374 | "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}}, |
4375 | } | |
4376 | ||
4377 | for addr_type in ADDR_TYPES: | |
4378 | result = verify_graceful_restart( | |
4379 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
4380 | ) | |
4381 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4382 | result = verify_graceful_restart( | |
4383 | tgen, topo, addr_type, input_dict, dut="r2", peer="r1" | |
4384 | ) | |
4385 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4386 | ||
4387 | for addr_type in ADDR_TYPES: | |
4388 | dut = "r1" | |
4389 | peer = "r2" | |
4390 | protocol = "bgp" | |
4391 | next_hop = next_hop_per_address_family( | |
4392 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
4393 | ) | |
4394 | input_topo = {"r2": topo["routers"]["r2"]} | |
4395 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4396 | assert ( | |
4397 | result is True | |
4398 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
4399 | tc_name, result | |
4400 | ) | |
4401 | ||
4402 | dut = "r2" | |
4403 | peer = "r1" | |
4404 | next_hop = next_hop_per_address_family( | |
4405 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
4406 | ) | |
4407 | input_topo = {"r1": topo["routers"]["r1"]} | |
4408 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
4409 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4410 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4411 | assert ( | |
4412 | result is True | |
4413 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
4414 | tc_name, result | |
4415 | ) | |
4416 | ||
4417 | step("Kill BGP on R1") | |
4418 | ||
4419 | kill_router_daemons(tgen, "r1", ["bgpd"]) | |
4420 | ||
4421 | step( | |
4422 | "Verify that R1 keeps the stale entries in FIB and R2 keeps stale entries in RIB & FIB" | |
4423 | ) | |
4424 | ||
4425 | for addr_type in ADDR_TYPES: | |
4426 | dut = "r1" | |
4427 | peer = "r2" | |
4428 | protocol = "bgp" | |
4429 | next_hop = next_hop_per_address_family( | |
4430 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
4431 | ) | |
4432 | input_topo = {"r2": topo["routers"]["r2"]} | |
4433 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4434 | assert ( | |
4435 | result is True | |
4436 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
4437 | tc_name, result | |
4438 | ) | |
4439 | ||
4440 | dut = "r2" | |
4441 | peer = "r1" | |
4442 | next_hop = next_hop_per_address_family( | |
4443 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
4444 | ) | |
4445 | input_topo = {"r1": topo["routers"]["r1"]} | |
4446 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
4447 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4448 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4449 | assert ( | |
4450 | result is True | |
4451 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
4452 | tc_name, result | |
4453 | ) | |
4454 | ||
4455 | write_test_footer(tc_name) | |
4456 | ||
4457 | ||
4458 | def test_BGP_GR_TC_48_p1(request): | |
4459 | """ | |
4460 | Test Objective : transition from Peer-level disabled to Global Restart | |
4461 | Global Mode : GR Restarting | |
4462 | PerPeer Mode : GR Disabled | |
4463 | GR Mode effective : GR Disabled | |
4464 | ||
4465 | """ | |
4466 | ||
4467 | tgen = get_topogen() | |
4468 | tc_name = request.node.name | |
4469 | write_test_header(tc_name) | |
4470 | ||
4471 | # Check router status | |
4472 | check_router_status(tgen) | |
4473 | ||
4474 | # Don't run this test if we have any failure. | |
4475 | if tgen.routers_have_failure(): | |
4476 | pytest.skip(tgen.errors) | |
4477 | ||
4478 | # Creating configuration from JSON | |
4479 | reset_config_on_routers(tgen) | |
4480 | ||
4481 | step( | |
4482 | "Configure R1 as GR restarting node in global level and" | |
4483 | " GR Disabled in per-Peer-level" | |
4484 | ) | |
4485 | ||
4486 | input_dict = { | |
4487 | "r1": { | |
4488 | "bgp": { | |
9fa6ec14 | 4489 | "graceful-restart": { |
4490 | "graceful-restart": True, | |
4491 | }, | |
17022899 KK |
4492 | "address_family": { |
4493 | "ipv4": { | |
4494 | "unicast": { | |
4495 | "neighbor": { | |
4496 | "r2": { | |
4497 | "dest_link": { | |
4498 | "r1-link1": {"graceful-restart-disable": True} | |
4499 | } | |
4500 | } | |
4501 | } | |
4502 | } | |
4503 | }, | |
4504 | "ipv6": { | |
4505 | "unicast": { | |
4506 | "neighbor": { | |
4507 | "r2": { | |
4508 | "dest_link": { | |
4509 | "r1-link1": {"graceful-restart-disable": True} | |
4510 | } | |
4511 | } | |
4512 | } | |
4513 | } | |
4514 | }, | |
4515 | }, | |
4516 | } | |
4517 | }, | |
4518 | "r2": {"bgp": {"graceful-restart": {"graceful-restart-helper": True}}}, | |
4519 | } | |
4520 | ||
4521 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
4522 | ||
4523 | step("Verify on R2 that R1 does't advertise any GR capabilities") | |
4524 | ||
4525 | for addr_type in ADDR_TYPES: | |
4526 | result = verify_graceful_restart( | |
4527 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
4528 | ) | |
4529 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4530 | result = verify_graceful_restart( | |
4531 | tgen, topo, addr_type, input_dict, dut="r2", peer="r1" | |
4532 | ) | |
4533 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4534 | ||
4535 | for addr_type in ADDR_TYPES: | |
4536 | dut = "r1" | |
4537 | peer = "r2" | |
4538 | protocol = "bgp" | |
4539 | next_hop = next_hop_per_address_family( | |
4540 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
4541 | ) | |
4542 | input_topo = {"r2": topo["routers"]["r2"]} | |
4543 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4544 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4545 | ||
4546 | dut = "r2" | |
4547 | peer = "r1" | |
4548 | next_hop = next_hop_per_address_family( | |
4549 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
4550 | ) | |
4551 | input_topo = {"r1": topo["routers"]["r1"]} | |
4552 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
4553 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4554 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4555 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4556 | ||
4557 | step("Kill BGP on R1") | |
4558 | ||
4559 | kill_router_daemons(tgen, "r1", ["bgpd"]) | |
4560 | ||
4561 | step("Verify on R2 and R1 that none of the routers keep stale entries") | |
4562 | ||
4563 | for addr_type in ADDR_TYPES: | |
4564 | dut = "r1" | |
4565 | peer = "r2" | |
4566 | protocol = "bgp" | |
4567 | next_hop = next_hop_per_address_family( | |
4568 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
4569 | ) | |
4570 | input_topo = {"r2": topo["routers"]["r2"]} | |
4571 | result = verify_rib( | |
4572 | tgen, addr_type, dut, input_topo, next_hop, protocol, expected=False | |
4573 | ) | |
0b25370e DS |
4574 | assert result is not True, ( |
4575 | "Testcase {} : Failed \n " | |
4576 | "r1: routes are still present in ZEBRA\n Error: {}".format(tc_name, result) | |
4577 | ) | |
17022899 KK |
4578 | |
4579 | dut = "r2" | |
4580 | peer = "r1" | |
4581 | next_hop = next_hop_per_address_family( | |
4582 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
4583 | ) | |
4584 | input_topo = {"r1": topo["routers"]["r1"]} | |
4585 | result = verify_bgp_rib( | |
4586 | tgen, addr_type, dut, input_topo, next_hop, expected=False | |
4587 | ) | |
0b25370e DS |
4588 | assert result is not True, ( |
4589 | "Testcase {} : Failed \n " | |
5cbb02eb | 4590 | "r2: routes are still present in BGP RIB\n Error: {}".format( |
0b25370e DS |
4591 | tc_name, result |
4592 | ) | |
4593 | ) | |
17022899 KK |
4594 | result = verify_rib( |
4595 | tgen, addr_type, dut, input_topo, next_hop, protocol, expected=False | |
4596 | ) | |
0b25370e DS |
4597 | assert result is not True, ( |
4598 | "Testcase {} : Failed \n " | |
4599 | "r2: routes are still present in ZEBRA\n Error: {}".format(tc_name, result) | |
4600 | ) | |
17022899 KK |
4601 | |
4602 | step("Bring up BGP on R1 and remove Peer-level GR config from R1") | |
4603 | ||
4604 | start_router_daemons(tgen, "r1", ["bgpd"]) | |
4605 | ||
4606 | input_dict = { | |
4607 | "r1": { | |
4608 | "bgp": { | |
4609 | "address_family": { | |
4610 | "ipv4": { | |
4611 | "unicast": { | |
4612 | "neighbor": { | |
4613 | "r2": { | |
4614 | "dest_link": { | |
4615 | "r1-link1": {"graceful-restart-disable": False} | |
4616 | } | |
4617 | } | |
4618 | } | |
4619 | } | |
4620 | }, | |
4621 | "ipv6": { | |
4622 | "unicast": { | |
4623 | "neighbor": { | |
4624 | "r2": { | |
4625 | "dest_link": { | |
4626 | "r1-link1": {"graceful-restart-disable": False} | |
4627 | } | |
4628 | } | |
4629 | } | |
4630 | } | |
4631 | }, | |
4632 | } | |
4633 | } | |
4634 | } | |
4635 | } | |
4636 | ||
4637 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
4638 | ||
4639 | step("Verify on R2 that R1 advertises GR capabilities as a restarting node") | |
4640 | ||
4641 | input_dict = { | |
9fa6ec14 | 4642 | "r1": { |
4643 | "bgp": { | |
4644 | "graceful-restart": { | |
4645 | "graceful-restart": True, | |
4646 | } | |
4647 | } | |
4648 | }, | |
17022899 KK |
4649 | "r2": {"bgp": {"graceful-restart": {"graceful-restart-helper": True}}}, |
4650 | } | |
4651 | ||
4652 | for addr_type in ADDR_TYPES: | |
4653 | result = verify_graceful_restart( | |
4654 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
4655 | ) | |
4656 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4657 | result = verify_graceful_restart( | |
4658 | tgen, topo, addr_type, input_dict, dut="r2", peer="r1" | |
4659 | ) | |
4660 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4661 | ||
4662 | for addr_type in ADDR_TYPES: | |
4663 | dut = "r1" | |
4664 | peer = "r2" | |
4665 | protocol = "bgp" | |
4666 | next_hop = next_hop_per_address_family( | |
4667 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
4668 | ) | |
4669 | input_topo = {"r2": topo["routers"]["r2"]} | |
4670 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4671 | assert ( | |
4672 | result is True | |
4673 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
4674 | tc_name, result | |
4675 | ) | |
4676 | ||
4677 | dut = "r2" | |
4678 | peer = "r1" | |
4679 | next_hop = next_hop_per_address_family( | |
4680 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
4681 | ) | |
4682 | input_topo = {"r1": topo["routers"]["r1"]} | |
4683 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
4684 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4685 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4686 | assert ( | |
4687 | result is True | |
4688 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
4689 | tc_name, result | |
4690 | ) | |
4691 | ||
4692 | step("Kill BGP on R1") | |
4693 | ||
4694 | kill_router_daemons(tgen, "r1", ["bgpd"]) | |
4695 | ||
4696 | step( | |
4697 | "Verify that R1 keeps the stale entries in FIB and R2 keeps stale entries in RIB & FIB" | |
4698 | ) | |
4699 | ||
4700 | for addr_type in ADDR_TYPES: | |
4701 | dut = "r1" | |
4702 | peer = "r2" | |
4703 | protocol = "bgp" | |
4704 | next_hop = next_hop_per_address_family( | |
4705 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
4706 | ) | |
4707 | input_topo = {"r2": topo["routers"]["r2"]} | |
4708 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4709 | assert ( | |
4710 | result is True | |
4711 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
4712 | tc_name, result | |
4713 | ) | |
4714 | ||
4715 | dut = "r2" | |
4716 | peer = "r1" | |
4717 | next_hop = next_hop_per_address_family( | |
4718 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
4719 | ) | |
4720 | input_topo = {"r1": topo["routers"]["r1"]} | |
4721 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
4722 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4723 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4724 | assert ( | |
4725 | result is True | |
4726 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
4727 | tc_name, result | |
4728 | ) | |
4729 | ||
4730 | write_test_footer(tc_name) | |
4731 | ||
4732 | ||
4733 | def test_BGP_GR_TC_49_p1(request): | |
4734 | """ | |
4735 | Test Objective : Peer-level inherit from Global Restarting | |
4736 | Global Mode : GR Restart | |
4737 | PerPeer Mode : None | |
4738 | GR Mode effective : GR Restart | |
4739 | ||
4740 | """ | |
4741 | ||
4742 | tgen = get_topogen() | |
4743 | tc_name = request.node.name | |
4744 | write_test_header(tc_name) | |
4745 | ||
4746 | # Check router status | |
4747 | check_router_status(tgen) | |
4748 | ||
4749 | # Don't run this test if we have any failure. | |
4750 | if tgen.routers_have_failure(): | |
4751 | pytest.skip(tgen.errors) | |
4752 | ||
4753 | # Creating configuration from JSON | |
4754 | reset_config_on_routers(tgen) | |
4755 | ||
4756 | step("Configure R1 as GR restarting node in global level") | |
4757 | ||
4758 | input_dict = { | |
4759 | "r1": {"bgp": {"graceful-restart": {"graceful-restart": True}}}, | |
4760 | "r2": {"bgp": {"graceful-restart": {"graceful-restart-helper": True}}}, | |
4761 | } | |
4762 | ||
4763 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
4764 | ||
4765 | step( | |
4766 | "Verify that R2 receives GR restarting capabilities" | |
4767 | " from R1 based on inheritence" | |
4768 | ) | |
4769 | ||
4770 | for addr_type in ADDR_TYPES: | |
4771 | result = verify_graceful_restart( | |
4772 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
4773 | ) | |
4774 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4775 | result = verify_graceful_restart( | |
4776 | tgen, topo, addr_type, input_dict, dut="r2", peer="r1" | |
4777 | ) | |
4778 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4779 | ||
4780 | for addr_type in ADDR_TYPES: | |
4781 | dut = "r1" | |
4782 | peer = "r2" | |
4783 | protocol = "bgp" | |
4784 | next_hop = next_hop_per_address_family( | |
4785 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
4786 | ) | |
4787 | input_topo = {"r2": topo["routers"]["r2"]} | |
4788 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4789 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4790 | ||
4791 | dut = "r2" | |
4792 | peer = "r1" | |
4793 | next_hop = next_hop_per_address_family( | |
4794 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
4795 | ) | |
4796 | input_topo = {"r1": topo["routers"]["r1"]} | |
4797 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
4798 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4799 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4800 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4801 | ||
4802 | step("Kill BGPd on router R1") | |
4803 | ||
4804 | kill_router_daemons(tgen, "r1", ["bgpd"]) | |
4805 | ||
4806 | step( | |
4807 | "Verify that R1 keeps the stale entries in FIB and R2 keeps stale entries in RIB & FIB" | |
4808 | ) | |
4809 | ||
4810 | for addr_type in ADDR_TYPES: | |
4811 | dut = "r1" | |
4812 | peer = "r2" | |
4813 | protocol = "bgp" | |
4814 | next_hop = next_hop_per_address_family( | |
4815 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
4816 | ) | |
4817 | input_topo = {"r2": topo["routers"]["r2"]} | |
4818 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4819 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4820 | ||
4821 | dut = "r2" | |
4822 | peer = "r1" | |
4823 | next_hop = next_hop_per_address_family( | |
4824 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
4825 | ) | |
4826 | input_topo = {"r1": topo["routers"]["r1"]} | |
4827 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
4828 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4829 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4830 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4831 | ||
4832 | write_test_footer(tc_name) | |
4833 | ||
4834 | ||
2268cf50 | 4835 | def BGP_GR_TC_52_p1(request): |
17022899 KK |
4836 | """ |
4837 | Test Objective : Transition from Peer-level disbale to Global inherit helper | |
4838 | Global Mode : None | |
4839 | PerPeer Mode : GR Disable | |
4840 | GR Mode effective : GR Disable | |
4841 | ||
4842 | """ | |
4843 | ||
4844 | tgen = get_topogen() | |
4845 | tc_name = request.node.name | |
4846 | write_test_header(tc_name) | |
4847 | ||
4848 | # Check router status | |
4849 | check_router_status(tgen) | |
4850 | ||
4851 | # Don't run this test if we have any failure. | |
4852 | if tgen.routers_have_failure(): | |
4853 | pytest.skip(tgen.errors) | |
4854 | ||
4855 | # Creating configuration from JSON | |
4856 | reset_config_on_routers(tgen) | |
4857 | ||
4858 | step( | |
4859 | "Configure R1 as GR disabled node at per Peer-level for R2" | |
4860 | " & R2 as GR restarting node" | |
4861 | ) | |
4862 | ||
4863 | input_dict = { | |
4864 | "r1": { | |
4865 | "bgp": { | |
4866 | "address_family": { | |
4867 | "ipv4": { | |
4868 | "unicast": { | |
4869 | "neighbor": { | |
4870 | "r2": { | |
4871 | "dest_link": { | |
4872 | "r1-link1": {"graceful-restart-disable": True} | |
4873 | } | |
4874 | } | |
4875 | } | |
4876 | } | |
4877 | }, | |
4878 | "ipv6": { | |
4879 | "unicast": { | |
4880 | "neighbor": { | |
4881 | "r2": { | |
4882 | "dest_link": { | |
4883 | "r1-link1": {"graceful-restart-disable": True} | |
4884 | } | |
4885 | } | |
4886 | } | |
4887 | } | |
4888 | }, | |
4889 | } | |
4890 | } | |
4891 | }, | |
4892 | "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}}, | |
4893 | } | |
4894 | ||
4895 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
4896 | ||
4897 | step("Verify on R2 that R1 does't advertise any GR capabilities") | |
4898 | ||
4899 | for addr_type in ADDR_TYPES: | |
4900 | result = verify_graceful_restart( | |
4901 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
4902 | ) | |
4903 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4904 | result = verify_graceful_restart( | |
4905 | tgen, topo, addr_type, input_dict, dut="r2", peer="r1" | |
4906 | ) | |
4907 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4908 | ||
4909 | for addr_type in ADDR_TYPES: | |
4910 | dut = "r2" | |
4911 | peer = "r1" | |
4912 | protocol = "bgp" | |
4913 | next_hop = next_hop_per_address_family( | |
4914 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
4915 | ) | |
4916 | input_topo = {"r1": topo["routers"]["r1"]} | |
4917 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4918 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4919 | ||
4920 | dut = "r1" | |
4921 | peer = "r2" | |
4922 | next_hop = next_hop_per_address_family( | |
4923 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
4924 | ) | |
4925 | input_topo = {"r2": topo["routers"]["r2"]} | |
4926 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
4927 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4928 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4929 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4930 | ||
4931 | step("Kill BGP on R2") | |
4932 | ||
4933 | kill_router_daemons(tgen, "r2", ["bgpd"]) | |
4934 | ||
4935 | step( | |
4936 | "Verify that R2 keeps the stale entries in FIB & R1 doesn't keep RIB & FIB entries." | |
4937 | ) | |
4938 | ||
4939 | for addr_type in ADDR_TYPES: | |
4940 | dut = "r2" | |
4941 | peer = "r1" | |
4942 | protocol = "bgp" | |
4943 | next_hop = next_hop_per_address_family( | |
4944 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
4945 | ) | |
4946 | input_topo = {"r1": topo["routers"]["r1"]} | |
4947 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
4948 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
4949 | ||
4950 | dut = "r1" | |
4951 | peer = "r2" | |
4952 | next_hop = next_hop_per_address_family( | |
4953 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
4954 | ) | |
4955 | input_topo = {"r2": topo["routers"]["r2"]} | |
4956 | result = verify_bgp_rib( | |
4957 | tgen, addr_type, dut, input_topo, next_hop, expected=False | |
4958 | ) | |
0b25370e DS |
4959 | assert result is not True, ( |
4960 | "Testcase {} : Failed \n " | |
5cbb02eb | 4961 | "r1: routes are still present in BGP RIB\n Error: {}".format( |
0b25370e DS |
4962 | tc_name, result |
4963 | ) | |
4964 | ) | |
17022899 KK |
4965 | result = verify_rib( |
4966 | tgen, addr_type, dut, input_topo, next_hop, protocol, expected=False | |
4967 | ) | |
0b25370e DS |
4968 | assert result is not True, ( |
4969 | "Testcase {} : Failed \n " | |
4970 | "r1: routes are still present in ZEBRA\n Error: {}".format(tc_name, result) | |
4971 | ) | |
17022899 KK |
4972 | |
4973 | step("Bring up BGP on R2 and remove Peer-level GR config from R1") | |
4974 | ||
4975 | start_router_daemons(tgen, "r2", ["bgpd"]) | |
4976 | ||
4977 | input_dict = { | |
4978 | "r1": { | |
4979 | "bgp": { | |
4980 | "address_family": { | |
4981 | "ipv4": { | |
4982 | "unicast": { | |
4983 | "neighbor": { | |
4984 | "r2": { | |
4985 | "dest_link": { | |
4986 | "r1-link1": {"graceful-restart-disable": False} | |
4987 | } | |
4988 | } | |
4989 | } | |
4990 | } | |
4991 | }, | |
4992 | "ipv6": { | |
4993 | "unicast": { | |
4994 | "neighbor": { | |
4995 | "r2": { | |
4996 | "dest_link": { | |
4997 | "r1-link1": {"graceful-restart-disable": False} | |
4998 | } | |
4999 | } | |
5000 | } | |
5001 | } | |
5002 | }, | |
5003 | } | |
5004 | } | |
5005 | } | |
5006 | } | |
5007 | ||
5008 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
5009 | ||
5010 | step( | |
5011 | "Verify on R2 that R1 advertises GR capabilities as a helper node from global inherit" | |
5012 | ) | |
5013 | ||
5014 | input_dict = { | |
5015 | "r1": {"bgp": {"graceful-restart": {"graceful-restart-helper": True}}}, | |
5016 | "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}}, | |
5017 | } | |
5018 | ||
5019 | for addr_type in ADDR_TYPES: | |
5020 | result = verify_graceful_restart( | |
5021 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
5022 | ) | |
5023 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
5024 | result = verify_graceful_restart( | |
5025 | tgen, topo, addr_type, input_dict, dut="r2", peer="r1" | |
5026 | ) | |
5027 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
5028 | ||
5029 | for addr_type in ADDR_TYPES: | |
5030 | dut = "r2" | |
5031 | peer = "r1" | |
5032 | protocol = "bgp" | |
5033 | next_hop = next_hop_per_address_family( | |
5034 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
5035 | ) | |
5036 | input_topo = {"r1": topo["routers"]["r1"]} | |
5037 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
5038 | assert ( | |
5039 | result is True | |
5040 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
5041 | tc_name, result | |
5042 | ) | |
5043 | ||
5044 | dut = "r1" | |
5045 | peer = "r2" | |
5046 | next_hop = next_hop_per_address_family( | |
5047 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
5048 | ) | |
5049 | input_topo = {"r2": topo["routers"]["r2"]} | |
5050 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
5051 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
5052 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
5053 | assert ( | |
5054 | result is True | |
5055 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
5056 | tc_name, result | |
5057 | ) | |
5058 | ||
5059 | step("Kill BGP on R2") | |
5060 | ||
5061 | kill_router_daemons(tgen, "r2", ["bgpd"]) | |
5062 | ||
5063 | step( | |
5064 | "Verify that R2 keeps the stale entries in FIB & R1 keeps stale entries in RIB & FIB" | |
5065 | ) | |
5066 | ||
5067 | for addr_type in ADDR_TYPES: | |
5068 | dut = "r2" | |
5069 | peer = "r1" | |
5070 | protocol = "bgp" | |
5071 | next_hop = next_hop_per_address_family( | |
5072 | tgen, dut, peer, addr_type, NEXT_HOP_IP_1 | |
5073 | ) | |
5074 | input_topo = {"r1": topo["routers"]["r1"]} | |
5075 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
5076 | assert ( | |
5077 | result is True | |
5078 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
5079 | tc_name, result | |
5080 | ) | |
5081 | ||
5082 | dut = "r1" | |
5083 | peer = "r2" | |
5084 | next_hop = next_hop_per_address_family( | |
5085 | tgen, dut, peer, addr_type, NEXT_HOP_IP_2 | |
5086 | ) | |
5087 | input_topo = {"r2": topo["routers"]["r2"]} | |
5088 | result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop) | |
5089 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
5090 | result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol) | |
5091 | assert ( | |
5092 | result is True | |
5093 | ), "Testcase {} :Failed \n Routes are still present \n Error {}".format( | |
35ba1e3d KK |
5094 | tc_name, result |
5095 | ) | |
5096 | ||
5097 | write_test_footer(tc_name) | |
5098 | ||
5099 | ||
5100 | if __name__ == "__main__": | |
5101 | args = ["-s"] + sys.argv[1:] | |
5102 | sys.exit(pytest.main(args)) |