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