]> git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/bgp_gr_functionality_topo2/test_bgp_gr_functionality_topo2-4.py
tests: Fix spelling of daemons
[mirror_frr.git] / tests / topotests / bgp_gr_functionality_topo2 / test_bgp_gr_functionality_topo2-4.py
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 These tests have been broken up into 4 sub python scripts because
84 the totality of run time for this script was greater than 10 minutes
85 """
86
87 import os
88 import sys
89 import time
90 import pytest
91 from time import sleep
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.topogen import Topogen, get_topogen
101 from lib.topolog import logger
102
103 # Required to instantiate the topology builder class.
104
105 # Import topoJson from lib, to create topology and initial configuration
106 from lib.topojson import build_config_from_json
107 from lib.bgp import (
108 clear_bgp,
109 verify_bgp_rib,
110 verify_graceful_restart,
111 create_router_bgp,
112 verify_r_bit,
113 verify_eor,
114 verify_f_bit,
115 verify_bgp_convergence,
116 verify_gr_address_family,
117 modify_bgp_config_when_bgpd_down,
118 verify_graceful_restart_timers,
119 verify_bgp_convergence_from_running_config,
120 )
121
122 from lib.common_config import (
123 write_test_header,
124 reset_config_on_routers,
125 start_topology,
126 kill_router_daemons,
127 start_router_daemons,
128 verify_rib,
129 check_address_types,
130 write_test_footer,
131 check_router_status,
132 step,
133 get_frr_ipv6_linklocal,
134 required_linux_kernel_version,
135 )
136
137 pytestmark = [pytest.mark.bgpd]
138
139
140 # Global variables
141 BGP_CONVERGENCE = False
142 GR_RESTART_TIMER = 5
143 GR_SELECT_DEFER_TIMER = 5
144 GR_STALEPATH_TIMER = 5
145 PREFERRED_NEXT_HOP = "link_local"
146 NEXT_HOP_4 = ["192.168.1.1", "192.168.4.2"]
147 NEXT_HOP_6 = ["fd00:0:0:1::1", "fd00:0:0:4::2"]
148
149
150 def setup_module(mod):
151 """
152 Sets up the pytest environment
153
154 * `mod`: module name
155 """
156
157 # Required linux kernel version for this suite to run.
158 result = required_linux_kernel_version("4.16")
159 if result is not True:
160 pytest.skip("Kernel requirements are not met")
161
162 global ADDR_TYPES
163
164 testsuite_run_time = time.asctime(time.localtime(time.time()))
165 logger.info("Testsuite start time: {}".format(testsuite_run_time))
166 logger.info("=" * 40)
167
168 logger.info("Running setup_module to create topology")
169
170 # This function initiates the topology build with Topogen...
171 json_file = "{}/bgp_gr_topojson_topo2.json".format(CWD)
172 tgen = Topogen(json_file, mod.__name__)
173 global topo
174 topo = tgen.json_topo
175 # ... and here it calls Mininet initialization functions.
176
177 # Starting topology, create tmp files which are loaded to routers
178 # to start daemons and then start routers
179 start_topology(tgen)
180
181 # Creating configuration from JSON
182 build_config_from_json(tgen, topo)
183
184 # Api call verify whether BGP is converged
185 ADDR_TYPES = check_address_types()
186
187 for addr_type in ADDR_TYPES:
188 BGP_CONVERGENCE = verify_bgp_convergence(tgen, topo)
189 assert BGP_CONVERGENCE is True, "setup_module : Failed \n Error:" " {}".format(
190 BGP_CONVERGENCE
191 )
192
193 logger.info("Running setup_module() done")
194
195
196 def teardown_module(mod):
197 """
198 Teardown the pytest environment
199
200 * `mod`: module name
201 """
202
203 logger.info("Running teardown_module to delete topology")
204
205 tgen = get_topogen()
206
207 # Stop toplogy and Remove tmp files
208 tgen.stop_topology()
209
210 logger.info(
211 "Testsuite end time: {}".format(time.asctime(time.localtime(time.time())))
212 )
213 logger.info("=" * 40)
214
215
216 def configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut, peer):
217 """
218 This function groups the repetitive function calls into one function.
219 """
220
221 logger.info("configure_gr_followed_by_clear: dut %s peer %s", dut, peer)
222
223 result = create_router_bgp(tgen, topo, input_dict)
224 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
225
226 for addr_type in ADDR_TYPES:
227 neighbor = topo["routers"][peer]["links"][dut][addr_type].split("/")[0]
228 clear_bgp(tgen, addr_type, dut, neighbor=neighbor)
229
230 for addr_type in ADDR_TYPES:
231 neighbor = topo["routers"][dut]["links"][peer][addr_type].split("/")[0]
232 clear_bgp(tgen, addr_type, peer, neighbor=neighbor)
233
234 result = verify_bgp_convergence_from_running_config(tgen)
235 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
236
237 return True
238
239
240 def next_hop_per_address_family(tgen, dut, peer, addr_type, next_hop_dict):
241 """
242 This function returns link_local or global next_hop per address-family
243 """
244
245 intferface = topo["routers"][peer]["links"]["{}-link1".format(dut)]["interface"]
246 if addr_type == "ipv6" and "link_local" in PREFERRED_NEXT_HOP:
247 next_hop = get_frr_ipv6_linklocal(tgen, peer, intf=intferface)
248 else:
249 next_hop = next_hop_dict[addr_type]
250
251 return next_hop
252
253
254 def test_BGP_GR_TC_23_p1(request):
255 """
256 Verify that helper routers are deleting stale routes after stale route
257 timer's expiry. If all the routes are not received from restating node
258 after restart.
259 """
260
261 tgen = get_topogen()
262 tc_name = request.node.name
263 write_test_header(tc_name)
264
265 # Check router status
266 check_router_status(tgen)
267
268 # Don't run this test if we have any failure.
269 if tgen.routers_have_failure():
270 pytest.skip(tgen.errors)
271
272 # Creating configuration from JSON
273 reset_config_on_routers(tgen)
274
275 logger.info(
276 "Verify Stale Routes are deleted on helper: BGP_GR_TC_23 >> "
277 "BGP GR [Helper Mode]R1-----R2[Restart Mode] "
278 )
279
280 # Configure graceful-restart
281 input_dict = {
282 "r1": {
283 "bgp": {
284 "graceful-restart": {"timer": {"stalepath-time": GR_STALEPATH_TIMER}},
285 "address_family": {
286 "ipv4": {
287 "unicast": {
288 "neighbor": {
289 "r2": {
290 "dest_link": {
291 "r1": {"graceful-restart-helper": True}
292 }
293 }
294 }
295 }
296 },
297 "ipv6": {
298 "unicast": {
299 "neighbor": {
300 "r2": {
301 "dest_link": {
302 "r1": {"graceful-restart-helper": True}
303 }
304 }
305 }
306 }
307 },
308 },
309 }
310 },
311 "r2": {
312 "bgp": {
313 "graceful-restart": {
314 "graceful-restart": True,
315 "preserve-fw-state": True,
316 },
317 "address_family": {
318 "ipv4": {
319 "unicast": {
320 "neighbor": {
321 "r1": {"dest_link": {"r2": {"graceful-restart": True}}}
322 }
323 }
324 },
325 "ipv6": {
326 "unicast": {
327 "neighbor": {
328 "r1": {"dest_link": {"r2": {"graceful-restart": True}}}
329 }
330 }
331 },
332 },
333 }
334 },
335 }
336
337 configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2")
338
339 for addr_type in ADDR_TYPES:
340 result = verify_graceful_restart(
341 tgen, topo, addr_type, input_dict, dut="r1", peer="r2"
342 )
343 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
344
345 # Verifying BGP RIB routes received from router R1
346 dut = "r1"
347 input_dict_1 = {key: topo["routers"][key] for key in ["r2"]}
348 result = verify_bgp_rib(tgen, addr_type, dut, input_dict_1)
349 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
350
351 # Verifying RIB routes
352 result = verify_rib(tgen, addr_type, dut, input_dict_1)
353 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
354
355 logger.info("R2 goes for reload")
356 kill_router_daemons(tgen, "r2", ["bgpd"])
357
358 # Modify configuration to delete routes and include disable-eor
359 input_dict_3 = {"r2": {"bgp": {"graceful-restart": {"disable-eor": True}}}}
360
361 result = modify_bgp_config_when_bgpd_down(tgen, topo, input_dict_3)
362
363 # Modify configuration to delete routes and include disable-eor
364 network = {"ipv4": "102.0.20.1/32", "ipv6": "2::1/128"}
365 for addr_type in ADDR_TYPES:
366 input_dict_3 = {
367 "r2": {
368 "bgp": {
369 "address_family": {
370 addr_type: {
371 "unicast": {
372 "advertise_networks": [
373 {
374 "network": network[addr_type],
375 "no_of_network": 3,
376 "delete": True,
377 }
378 ]
379 }
380 }
381 }
382 }
383 }
384 }
385
386 result = modify_bgp_config_when_bgpd_down(tgen, topo, input_dict_3)
387 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
388
389 logger.info("BGPd comes up for r2")
390 start_router_daemons(tgen, "r2", ["bgpd"])
391
392 # Wait for stalepath timer
393 logger.info("Waiting for stalepath timer({} sec..)".format(GR_STALEPATH_TIMER))
394 sleep(GR_STALEPATH_TIMER)
395
396 for addr_type in ADDR_TYPES:
397 clear_bgp(tgen, addr_type, "r2")
398
399 # Verifying RIB routes
400 dut = "r1"
401 network = {"ipv4": "102.0.20.4/32", "ipv6": "2::4/128"}
402 for addr_type in ADDR_TYPES:
403 input_dict_1 = {
404 "r1": {
405 "bgp": {
406 "address_family": {
407 addr_type: {
408 "unicast": {
409 "advertise_networks": [
410 {"network": network[addr_type], "no_of_network": 2}
411 ]
412 }
413 }
414 }
415 }
416 }
417 }
418
419 # Verify EOR on helper router
420 result = verify_eor(
421 tgen, topo, addr_type, input_dict, dut="r1", peer="r2", expected=False
422 )
423 assert (
424 result is not True
425 ), "Testcase {} : Failed \n " "r1: EOR is set to True\n Error: {}".format(
426 tc_name, result
427 )
428
429 # Verifying BGP RIB routes received from router R1
430 dut = "r1"
431 result = verify_bgp_rib(tgen, addr_type, dut, input_dict_1)
432 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
433
434 write_test_footer(tc_name)
435
436
437 def test_BGP_GR_20_p1(request):
438 """
439 Test Objective : Verify that GR routers delete all the routes
440 received from a node if both the routers are configured as GR
441 helper node
442 """
443
444 tgen = get_topogen()
445 tc_name = request.node.name
446 write_test_header(tc_name)
447
448 # Check router status
449 check_router_status(tgen)
450
451 # Don't run this test if we have any failure.
452 if tgen.routers_have_failure():
453 pytest.skip(tgen.errors)
454
455 # Creating configuration from JSON
456 reset_config_on_routers(tgen)
457
458 logger.info(
459 "[Step 1] : Test Setup " "[Restart Mode]R3-----R1[Restart Mode] Initilized"
460 )
461
462 # Configure graceful-restart
463 input_dict = {
464 "r1": {
465 "bgp": {
466 "address_family": {
467 "ipv4": {
468 "unicast": {
469 "neighbor": {
470 "r3": {
471 "dest_link": {
472 "r1": {"graceful-restart-helper": True}
473 }
474 }
475 }
476 }
477 },
478 "ipv6": {
479 "unicast": {
480 "neighbor": {
481 "r3": {
482 "dest_link": {
483 "r1": {"graceful-restart-helper": True}
484 }
485 }
486 }
487 }
488 },
489 }
490 }
491 },
492 "r3": {
493 "bgp": {
494 "address_family": {
495 "ipv4": {
496 "unicast": {
497 "neighbor": {
498 "r1": {
499 "dest_link": {
500 "r3": {"graceful-restart-helper": True}
501 }
502 }
503 }
504 }
505 },
506 "ipv6": {
507 "unicast": {
508 "neighbor": {
509 "r1": {
510 "dest_link": {
511 "r3": {"graceful-restart-helper": True}
512 }
513 }
514 }
515 }
516 },
517 }
518 }
519 },
520 }
521
522 configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r3")
523
524 for addr_type in ADDR_TYPES:
525 result = verify_graceful_restart(
526 tgen, topo, addr_type, input_dict, dut="r1", peer="r3"
527 )
528 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
529
530 # Verifying BGP RIB routes
531 dut = "r3"
532 input_dict_1 = {key: topo["routers"][key] for key in ["r1"]}
533 result = verify_bgp_rib(tgen, addr_type, dut, input_dict_1)
534 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
535
536 # Verifying RIB routes before shutting down BGPd daemon
537 result = verify_rib(tgen, addr_type, dut, input_dict_1)
538 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
539
540 # Kill BGPd daemon on R1
541 kill_router_daemons(tgen, "r1", ["bgpd"])
542
543 for addr_type in ADDR_TYPES:
544 # Verifying BGP RIB routes
545 dut = "r3"
546 input_dict_1 = {key: topo["routers"][key] for key in ["r1"]}
547 result = verify_bgp_rib(tgen, addr_type, dut, input_dict_1, expected=False)
548 assert result is not True, (
549 "Testcase {} : Failed \n "
550 "r3: routes are still present in BGP RIB\n Error: {}".format(
551 tc_name, result
552 )
553 )
554 logger.info(" Expected behavior: {}".format(result))
555
556 # Verifying RIB routes before shutting down BGPd daemon
557 result = verify_rib(tgen, addr_type, dut, input_dict_1, expected=False)
558 assert result is not True, (
559 "Testcase {} : Failed \n "
560 "r3: routes are still present in ZEBRA\n Error: {}".format(tc_name, result)
561 )
562 logger.info(" Expected behavior: {}".format(result))
563
564 # Start BGPd daemon on R1
565 start_router_daemons(tgen, "r1", ["bgpd"])
566
567 for addr_type in ADDR_TYPES:
568 result = verify_bgp_convergence(tgen, topo)
569 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
570
571 # Verifying BGP RIB routes
572 dut = "r3"
573 input_dict_1 = {key: topo["routers"][key] for key in ["r1"]}
574 result = verify_bgp_rib(tgen, addr_type, dut, input_dict_1)
575 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
576
577 # Verifying RIB routes before shutting down BGPd daemon
578 result = verify_rib(tgen, addr_type, dut, input_dict_1)
579 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
580
581 write_test_footer(tc_name)
582
583
584 def test_BGP_GR_21_p2(request):
585 """
586 Test Objective : VVerify BGP-GR feature when helper node is
587 a transit router for it's eBGP peers.
588 """
589
590 tgen = get_topogen()
591 tc_name = request.node.name
592 write_test_header(tc_name)
593
594 # Check router status
595 check_router_status(tgen)
596
597 # Don't run this test if we have any failure.
598 if tgen.routers_have_failure():
599 pytest.skip(tgen.errors)
600
601 # Creating configuration from JSON
602 reset_config_on_routers(tgen)
603
604 logger.info(
605 "[Step 1] : Test Setup " "[Helper Mode]R6-----R1[Restart Mode] Initilized"
606 )
607
608 # Configure graceful-restart
609 input_dict = {
610 "r1": {
611 "bgp": {
612 "address_family": {
613 "ipv4": {
614 "unicast": {
615 "neighbor": {
616 "r6": {
617 "dest_link": {
618 "r1": {"graceful-restart-disable": True}
619 }
620 }
621 }
622 }
623 },
624 "ipv6": {
625 "unicast": {
626 "neighbor": {
627 "r6": {
628 "dest_link": {
629 "r1": {"graceful-restart-disable": True}
630 }
631 }
632 }
633 }
634 },
635 }
636 }
637 },
638 "r6": {
639 "bgp": {
640 "address_family": {
641 "ipv4": {
642 "unicast": {
643 "neighbor": {
644 "r1": {
645 "dest_link": {
646 "r6": {"graceful-restart-helper": True}
647 }
648 }
649 }
650 }
651 },
652 "ipv6": {
653 "unicast": {
654 "neighbor": {
655 "r1": {
656 "dest_link": {
657 "r6": {"graceful-restart-helper": True}
658 }
659 }
660 }
661 }
662 },
663 }
664 }
665 },
666 }
667
668 configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r6")
669
670 for addr_type in ADDR_TYPES:
671 result = verify_graceful_restart(
672 tgen, topo, addr_type, input_dict, dut="r1", peer="r6"
673 )
674 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
675
676 logger.info(
677 "[Step 2] : Test Setup "
678 "[Restart Mode]R2-----[Helper Mode]R1[Disable Mode]"
679 "--------R6[Helper Mode] Initilized"
680 )
681
682 # Configure graceful-restart
683 input_dict = {
684 "r1": {
685 "bgp": {
686 "address_family": {
687 "ipv4": {
688 "unicast": {
689 "neighbor": {
690 "r2": {
691 "dest_link": {
692 "r1": {"graceful-restart-helper": True}
693 }
694 }
695 }
696 }
697 },
698 "ipv6": {
699 "unicast": {
700 "neighbor": {
701 "r2": {
702 "dest_link": {
703 "r1": {"graceful-restart-helper": True}
704 }
705 }
706 }
707 }
708 },
709 }
710 }
711 },
712 "r2": {
713 "bgp": {
714 "graceful-restart": {
715 "graceful-restart": True,
716 }
717 }
718 },
719 }
720
721 configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2")
722
723 for addr_type in ADDR_TYPES:
724 result = verify_graceful_restart(
725 tgen, topo, addr_type, input_dict, dut="r1", peer="r2"
726 )
727 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
728
729 # Verifying BGP RIB routes
730 dut = "r6"
731 input_dict_1 = {key: topo["routers"][key] for key in ["r1"]}
732 result = verify_bgp_rib(tgen, addr_type, dut, input_dict_1)
733 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
734
735 # Verifying RIB routes before shutting down BGPd daemon
736 result = verify_rib(tgen, addr_type, dut, input_dict_1)
737 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
738
739 # Verifying BGP RIB routes
740 dut = "r6"
741 input_dict_2 = {key: topo["routers"][key] for key in ["r2"]}
742 result = verify_bgp_rib(tgen, addr_type, dut, input_dict_2)
743 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
744
745 # Verifying RIB routes before shutting down BGPd daemon
746 result = verify_rib(tgen, addr_type, dut, input_dict_2)
747 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
748
749 # Kill BGPd daemon on R1
750 kill_router_daemons(tgen, "r2", ["bgpd"])
751
752 for addr_type in ADDR_TYPES:
753 # Verifying BGP RIB routes
754 dut = "r6"
755 input_dict_1 = {key: topo["routers"][key] for key in ["r1"]}
756 result = verify_bgp_rib(tgen, addr_type, dut, input_dict_1)
757 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
758
759 # Verifying RIB routes before shutting down BGPd daemon
760 result = verify_rib(tgen, addr_type, dut, input_dict_1)
761 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
762
763 # Verifying BGP RIB routes
764 dut = "r6"
765 input_dict_2 = {key: topo["routers"][key] for key in ["r2"]}
766 result = verify_bgp_rib(tgen, addr_type, dut, input_dict_2)
767 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
768
769 # Verifying RIB routes before shutting down BGPd daemon
770 result = verify_rib(tgen, addr_type, dut, input_dict_2)
771 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
772
773 # Start BGPd daemon on R1
774 start_router_daemons(tgen, "r2", ["bgpd"])
775
776 for addr_type in ADDR_TYPES:
777 result = verify_bgp_convergence(tgen, topo)
778 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
779
780 # Verifying BGP RIB routes
781 dut = "r6"
782 input_dict_1 = {key: topo["routers"][key] for key in ["r1"]}
783 result = verify_bgp_rib(tgen, addr_type, dut, input_dict_1)
784 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
785
786 # Verifying RIB routes after bringing up BGPd daemon
787 result = verify_rib(tgen, addr_type, dut, input_dict_1)
788 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
789
790 # Verifying BGP RIB routes
791 dut = "r6"
792 input_dict_2 = {key: topo["routers"][key] for key in ["r2"]}
793 result = verify_bgp_rib(tgen, addr_type, dut, input_dict_2)
794 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
795
796 # Verifying RIB routes before shutting down BGPd daemon
797 result = verify_rib(tgen, addr_type, dut, input_dict_2)
798 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
799
800 write_test_footer(tc_name)
801
802
803 def test_BGP_GR_22_p2(request):
804 """
805 Test Objective : Verify BGP-GR feature when helper node
806 is a transit router for it's iBGP peers.
807 """
808
809 tgen = get_topogen()
810 tc_name = request.node.name
811 write_test_header(tc_name)
812
813 # Check router status
814 check_router_status(tgen)
815
816 # Don't run this test if we have any failure.
817 if tgen.routers_have_failure():
818 pytest.skip(tgen.errors)
819
820 # Creating configuration from JSON
821 reset_config_on_routers(tgen)
822
823 logger.info(
824 "[Step 1] : Test Setup " "[Helper Mode]R3-----R1[Restart Mode] Initilized"
825 )
826
827 # Configure graceful-restart
828 input_dict = {
829 "r1": {
830 "bgp": {
831 "address_family": {
832 "ipv4": {
833 "unicast": {
834 "neighbor": {
835 "r3": {
836 "dest_link": {
837 "r1": {
838 "graceful-restart-disable": True,
839 "next_hop_self": True,
840 }
841 }
842 }
843 }
844 }
845 },
846 "ipv6": {
847 "unicast": {
848 "neighbor": {
849 "r3": {
850 "dest_link": {
851 "r1": {
852 "graceful-restart-disable": True,
853 "next_hop_self": True,
854 }
855 }
856 }
857 }
858 }
859 },
860 }
861 }
862 },
863 "r3": {
864 "bgp": {
865 "address_family": {
866 "ipv4": {
867 "unicast": {
868 "neighbor": {
869 "r1": {
870 "dest_link": {
871 "r3": {"graceful-restart-helper": True}
872 }
873 }
874 }
875 }
876 },
877 "ipv6": {
878 "unicast": {
879 "neighbor": {
880 "r1": {
881 "dest_link": {
882 "r3": {"graceful-restart-helper": True}
883 }
884 }
885 }
886 }
887 },
888 }
889 }
890 },
891 }
892
893 configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r3")
894
895 for addr_type in ADDR_TYPES:
896 result = verify_graceful_restart(
897 tgen, topo, addr_type, input_dict, dut="r1", peer="r3"
898 )
899 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
900
901 logger.info(
902 "[Step 2] : Test Setup "
903 "[Restart Mode]R2-----[Helper Mode]R1[Disable Mode]"
904 "--------R3[Helper Mode] Initilized"
905 )
906
907 # Configure graceful-restart
908 input_dict = {
909 "r1": {
910 "bgp": {
911 "address_family": {
912 "ipv4": {
913 "unicast": {
914 "neighbor": {
915 "r2": {
916 "dest_link": {
917 "r1": {"graceful-restart-helper": True}
918 }
919 }
920 }
921 }
922 },
923 "ipv6": {
924 "unicast": {
925 "neighbor": {
926 "r2": {
927 "dest_link": {
928 "r1": {"graceful-restart-helper": True}
929 }
930 }
931 }
932 }
933 },
934 }
935 }
936 },
937 "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}},
938 }
939
940 configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2")
941
942 for addr_type in ADDR_TYPES:
943 result = verify_graceful_restart(
944 tgen, topo, addr_type, input_dict, dut="r1", peer="r2"
945 )
946 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
947
948 # Verifying BGP RIB routes
949 dut = "r3"
950 input_dict_1 = {key: topo["routers"][key] for key in ["r1"]}
951 result = verify_bgp_rib(tgen, addr_type, dut, input_dict_1)
952 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
953
954 # Verifying RIB routes before shutting down BGPd daemon
955 result = verify_rib(tgen, addr_type, dut, input_dict_1)
956 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
957
958 # Verifying BGP RIB routes
959 dut = "r3"
960 input_dict_2 = {key: topo["routers"][key] for key in ["r2"]}
961 result = verify_bgp_rib(tgen, addr_type, dut, input_dict_2)
962 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
963
964 # Verifying RIB routes before shutting down BGPd daemon
965 result = verify_rib(tgen, addr_type, dut, input_dict_2)
966 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
967
968 # Kill BGPd daemon on R1
969 kill_router_daemons(tgen, "r2", ["bgpd"])
970
971 for addr_type in ADDR_TYPES:
972 # Verifying BGP RIB routes
973 dut = "r3"
974 input_dict_1 = {key: topo["routers"][key] for key in ["r1"]}
975 result = verify_bgp_rib(tgen, addr_type, dut, input_dict_1)
976 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
977
978 # Verifying RIB routes before shutting down BGPd daemon
979 result = verify_rib(tgen, addr_type, dut, input_dict_1)
980 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
981
982 # Verifying BGP RIB routes
983 dut = "r3"
984 input_dict_2 = {key: topo["routers"][key] for key in ["r2"]}
985 result = verify_bgp_rib(tgen, addr_type, dut, input_dict_2)
986 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
987
988 # Verifying RIB routes before shutting down BGPd daemon
989 result = verify_rib(tgen, addr_type, dut, input_dict_2)
990 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
991
992 # Start BGPd daemon on R1
993 start_router_daemons(tgen, "r2", ["bgpd"])
994
995 for addr_type in ADDR_TYPES:
996 result = verify_bgp_convergence(tgen, topo)
997 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
998
999 # Verifying BGP RIB routes
1000 dut = "r3"
1001 input_dict_1 = {key: topo["routers"][key] for key in ["r1"]}
1002 result = verify_bgp_rib(tgen, addr_type, dut, input_dict_1)
1003 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
1004
1005 # Verifying RIB routes before shutting down BGPd daemon
1006 result = verify_rib(tgen, addr_type, dut, input_dict_1)
1007 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
1008
1009 # Verifying BGP RIB routes
1010 dut = "r3"
1011 input_dict_2 = {key: topo["routers"][key] for key in ["r2"]}
1012 result = verify_bgp_rib(tgen, addr_type, dut, input_dict_2)
1013 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
1014
1015 # Verifying RIB routes before shutting down BGPd daemon
1016 result = verify_rib(tgen, addr_type, dut, input_dict_2)
1017 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
1018
1019 write_test_footer(tc_name)
1020
1021
1022 if __name__ == "__main__":
1023 args = ["-s"] + sys.argv[1:]
1024 sys.exit(pytest.main(args))