2 # SPDX-License-Identifier: ISC
4 # Copyright (c) 2019 by VMware, Inc. ("VMware")
5 # Used Copyright (c) 2018 by Network Device Education Foundation, Inc. ("NetDEF")
10 Following tests are covered to test BGP Graceful Restart functionality.
11 Basic Common Test steps for all the test case below :
12 - Create topology (setup module)
13 Creating 2 routers topology, r1, r2 in IBGP
15 - Verify for bgp to converge
16 - Configure BGP Garceful Restart on both the routers.
18 1. Transition from Peer-level helper to Global Restarting
19 2. Transition from Peer-level helper to Global inherit helper
20 3. Transition from Peer-level restarting to Global inherit helper
21 4. Default GR functional mode is Helper.
22 5. Verify that the restarting node sets "R" bit while sending the
23 BGP open messages after the node restart, only if GR is enabled.
24 6. Verify if restarting node resets R bit in BGP open message
25 during normal BGP session flaps as well, even when GR restarting
26 mode is enabled. Here link flap happen due to interface UP/DOWN.
27 7. Verify if restarting node resets R bit in BGP
28 open message during normal BGP session flaps when GR is disabled.
29 8. Verify that restarting nodes set "F" bit while sending
30 the BGP open messages after it restarts, only when BGP GR is enabled.
31 9. Verify that only GR helper routers keep the stale
32 route entries, not any GR disabled router.
33 10. Verify that GR helper routers keeps all the routes received
34 from restarting node if both the routers are configured as
36 11. Verify that GR helper routers delete all the routes
37 received from a node if both the routers are configured as GR
39 12. After BGP neighborship is established and GR capability is exchanged,
40 transition restarting router to disabled state and vice versa.
41 13. After BGP neighborship is established and GR capability is exchanged,
42 transition restarting router to disabled state and vice versa.
43 14. Verify that restarting nodes reset "F" bit while sending
44 the BGP open messages after it's restarts, when BGP GR is **NOT** enabled.
45 15. Verify that only GR helper routers keep the stale
46 route entries, not any GR disabled router.
47 16. Transition from Global Restarting to Disable and then Global
48 Disable to Restarting.
49 17. Transition from Global Helper to Disable and then Global
51 18. Transition from Global Restart to Helper and then Global
52 Helper to Restart, Global Mode : GR Restarting
53 PerPeer Mode : GR Helper
54 GR Mode effective : GR Helper
55 19. Transition from Peer-level helper to Global Restarting,
56 Global Mode : GR Restarting
57 PerPeer Mode : GR Restarting
58 GR Mode effective : GR Restarting
59 20. Transition from Peer-level restart to Global Restart
60 Global Mode : GR Restarting
61 PerPeer Mode : GR Restarting
62 GR Mode effective : GR Restarting
63 21. Transition from Peer-level disabled to Global Restart
64 Global Mode : GR Restarting
65 PerPeer Mode : GR Disabled
66 GR Mode effective : GR Disabled
67 22. Peer-level inherit from Global Restarting
68 Global Mode : GR Restart
70 GR Mode effective : GR Restart
71 23. Transition from Peer-level disable to Global inherit helper
73 PerPeer Mode : GR Disable
74 GR Mode effective : GR Disable
76 These tests have been broken up into 4 sub python scripts because
77 the totality of this run was fairly significant.
85 # Save the Current Working Directory to find configuration files.
86 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
87 sys
.path
.append(os
.path
.join("../"))
88 sys
.path
.append(os
.path
.join("../lib/"))
90 # pylint: disable=C0413
91 # Import topogen and topotest helpers
92 from lib
.topogen
import Topogen
, get_topogen
93 from lib
.topolog
import logger
95 # Required to instantiate the topology builder class.
97 # Import topoJson from lib, to create topology and initial configuration
98 from lib
.topojson
import build_config_from_json
102 verify_graceful_restart
,
106 verify_bgp_convergence
,
107 verify_bgp_convergence_from_running_config
,
110 from lib
.common_config
import (
112 reset_config_on_routers
,
115 start_router_daemons
,
120 shutdown_bringup_interface
,
122 get_frr_ipv6_linklocal
,
123 required_linux_kernel_version
,
126 pytestmark
= [pytest
.mark
.bgpd
]
130 NEXT_HOP_IP
= {"ipv4": "192.168.1.10", "ipv6": "fd00:0:0:1::10"}
131 NEXT_HOP_IP_1
= {"ipv4": "192.168.0.1", "ipv6": "fd00::1"}
132 NEXT_HOP_IP_2
= {"ipv4": "192.168.0.2", "ipv6": "fd00::2"}
133 BGP_CONVERGENCE
= False
134 GR_RESTART_TIMER
= 20
135 PREFERRED_NEXT_HOP
= "link_local"
138 def setup_module(mod
):
140 Sets up the pytest environment
147 # Required linux kernel version for this suite to run.
148 result
= required_linux_kernel_version("4.16")
149 if result
is not True:
150 pytest
.skip("Kernel requirements are not met, kernel version should be >=4.16")
152 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
153 logger
.info("Testsuite start time: {}".format(testsuite_run_time
))
154 logger
.info("=" * 40)
156 logger
.info("Running setup_module to create topology")
158 # This function initiates the topology build with Topogen...
159 json_file
= "{}/bgp_gr_topojson_topo1.json".format(CWD
)
160 tgen
= Topogen(json_file
, mod
.__name
__)
162 topo
= tgen
.json_topo
163 # ... and here it calls Mininet initialization functions.
165 # Starting topology, create tmp files which are loaded to routers
166 # to start daemons and then start routers
169 # Creating configuration from JSON
170 build_config_from_json(tgen
, topo
)
172 # Don't run this test if we have any failure.
173 if tgen
.routers_have_failure():
174 pytest
.skip(tgen
.errors
)
176 # Api call verify whether BGP is converged
177 ADDR_TYPES
= check_address_types()
179 BGP_CONVERGENCE
= verify_bgp_convergence(tgen
, topo
)
180 assert BGP_CONVERGENCE
is True, "setup_module : Failed \n Error:" " {}".format(
184 logger
.info("Running setup_module() done")
187 def teardown_module(mod
):
189 Teardown the pytest environment
194 logger
.info("Running teardown_module to delete topology")
198 # Stop toplogy and Remove tmp files
202 "Testsuite end time: {}".format(time
.asctime(time
.localtime(time
.time())))
204 logger
.info("=" * 40)
207 def configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
, peer
):
209 This function groups the repetitive function calls into one function.
212 result
= create_router_bgp(tgen
, topo
, input_dict
)
213 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
215 for addr_type
in ADDR_TYPES
:
216 neighbor
= topo
["routers"][peer
]["links"]["r1-link1"][addr_type
].split("/")[0]
217 clear_bgp(tgen
, addr_type
, dut
, neighbor
=neighbor
)
219 for addr_type
in ADDR_TYPES
:
220 neighbor
= topo
["routers"][dut
]["links"]["r2-link1"][addr_type
].split("/")[0]
221 clear_bgp(tgen
, addr_type
, peer
, neighbor
=neighbor
)
223 result
= verify_bgp_convergence_from_running_config(tgen
)
224 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
229 def next_hop_per_address_family(
230 tgen
, dut
, peer
, addr_type
, next_hop_dict
, preferred_next_hop
=PREFERRED_NEXT_HOP
233 This function returns link_local or global next_hop per address-family
236 intferface
= topo
["routers"][peer
]["links"]["{}-link1".format(dut
)]["interface"]
237 if addr_type
== "ipv6" and "link_local" in preferred_next_hop
:
238 next_hop
= get_frr_ipv6_linklocal(tgen
, peer
, intf
=intferface
)
240 next_hop
= next_hop_dict
[addr_type
]
245 def BGP_GR_TC_50_p1(request
):
247 Test Objective : Transition from Peer-level helper to Global inherit helper
249 PerPeer Mode : Helper
250 GR Mode effective : GR Helper
255 tc_name
= request
.node
.name
256 write_test_header(tc_name
)
258 # Check router status
259 check_router_status(tgen
)
261 # Don't run this test if we have any failure.
262 if tgen
.routers_have_failure():
263 pytest
.skip(tgen
.errors
)
265 # Creating configuration from JSON
266 reset_config_on_routers(tgen
)
269 "Configure R1 as GR helper node at per Peer-level for R2"
270 " and configure R2 as global restarting node."
282 "r1-link1": {"graceful-restart-helper": True}
293 "r1-link1": {"graceful-restart-helper": True}
302 "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}},
305 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r2")
307 step("Verify on R2 that R1 advertises GR capabilities as a helper node")
309 for addr_type
in ADDR_TYPES
:
310 result
= verify_graceful_restart(
311 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
313 assert result
is True, "Testcase {} : Failed \n Error {}".format(
317 for addr_type
in ADDR_TYPES
:
319 next_hop
= next_hop_per_address_family(
320 tgen
, "r2", "r1", addr_type
, NEXT_HOP_IP_1
322 input_topo
= {"r1": topo
["routers"]["r1"]}
323 result
= verify_rib(tgen
, addr_type
, "r2", input_topo
, next_hop
, protocol
)
324 assert result
is True, "Testcase {} : Failed \n Error {}".format(
328 for addr_type
in ADDR_TYPES
:
329 next_hop
= next_hop_per_address_family(
330 tgen
, "r1", "r2", addr_type
, NEXT_HOP_IP_2
332 input_topo
= {"r2": topo
["routers"]["r2"]}
333 result
= verify_bgp_rib(tgen
, addr_type
, "r1", input_topo
, next_hop
)
334 assert result
is True, "Testcase {} : Failed \n Error {}".format(
338 result
= verify_rib(tgen
, addr_type
, "r1", input_topo
, next_hop
, protocol
)
339 assert result
is True, "Testcase {} : Failed \n Error {}".format(
343 step("Kill BGP on R2")
345 kill_router_daemons(tgen
, "r2", ["bgpd"])
348 "Verify that R2 keeps the stale entries in FIB & R1 keeps stale entries in RIB & FIB"
351 for addr_type
in ADDR_TYPES
:
353 next_hop
= next_hop_per_address_family(
354 tgen
, "r2", "r1", addr_type
, NEXT_HOP_IP_1
356 input_topo
= {"r1": topo
["routers"]["r1"]}
357 result
= verify_rib(tgen
, addr_type
, "r2", input_topo
, next_hop
, protocol
)
358 assert result
is True, "Testcase {} : Failed \n Error {}".format(
362 for addr_type
in ADDR_TYPES
:
363 next_hop
= next_hop_per_address_family(
364 tgen
, "r1", "r2", addr_type
, NEXT_HOP_IP_2
366 input_topo
= {"r2": topo
["routers"]["r2"]}
367 result
= verify_bgp_rib(tgen
, addr_type
, "r1", input_topo
, next_hop
)
368 assert result
is True, "Testcase {} : Failed \n Error {}".format(
372 result
= verify_rib(tgen
, addr_type
, "r1", input_topo
, next_hop
, protocol
)
373 assert result
is True, "Testcase {} : Failed \n Error {}".format(
377 step("Bring up BGP on R2 and remove Peer-level GR config from R1 ")
379 start_router_daemons(tgen
, "r2", ["bgpd"])
390 "r1-link1": {"graceful-restart-helper": False}
401 "r1-link1": {"graceful-restart-helper": False}
412 result
= create_router_bgp(tgen
, topo
, input_dict
)
413 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
415 for addr_type
in ADDR_TYPES
:
416 neighbor
= topo
["routers"]["r2"]["links"]["r1-link1"][addr_type
].split("/")[0]
417 clear_bgp(tgen
, addr_type
, "r1", neighbor
=neighbor
)
419 result
= verify_bgp_convergence_from_running_config(tgen
)
420 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
422 step("Verify on R2 that R1 still advertises GR capabilities as a helper node")
425 "r1": {"bgp": {"graceful-restart": {"graceful-restart-helper": True}}},
426 "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}},
429 for addr_type
in ADDR_TYPES
:
430 result
= verify_graceful_restart(
431 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
433 assert result
is True, "Testcase {} : Failed \n Error {}".format(
437 for addr_type
in ADDR_TYPES
:
439 next_hop
= next_hop_per_address_family(
440 tgen
, "r2", "r1", addr_type
, NEXT_HOP_IP_1
442 input_topo
= {"r1": topo
["routers"]["r1"]}
443 result
= verify_rib(tgen
, addr_type
, "r2", input_topo
, next_hop
, protocol
)
446 ), "Testcase {} : Failed \n Routes are still present \n Error {}".format(
450 for addr_type
in ADDR_TYPES
:
451 next_hop
= next_hop_per_address_family(
452 tgen
, "r1", "r2", addr_type
, NEXT_HOP_IP_2
454 input_topo
= {"r2": topo
["routers"]["r2"]}
455 result
= verify_bgp_rib(tgen
, addr_type
, "r1", input_topo
, next_hop
)
456 assert result
is True, "Testcase {} : Failed \n Error {}".format(
460 result
= verify_rib(tgen
, addr_type
, "r1", input_topo
, next_hop
, protocol
)
463 ), "Testcase {} : Failed \n Routes are still present \n Error {}".format(
467 step("Kill BGP on R2")
469 kill_router_daemons(tgen
, "r2", ["bgpd"])
472 "Verify that R2 keeps the stale entries in FIB & R1 keeps stale entries in RIB & FIB"
475 for addr_type
in ADDR_TYPES
:
477 next_hop
= next_hop_per_address_family(
478 tgen
, "r2", "r1", addr_type
, NEXT_HOP_IP_1
480 input_topo
= {"r1": topo
["routers"]["r1"]}
481 result
= verify_rib(tgen
, addr_type
, "r2", input_topo
, next_hop
, protocol
)
484 ), "Testcase {} : Failed \n Routes are still present \n Error {}".format(
488 for addr_type
in ADDR_TYPES
:
489 next_hop
= next_hop_per_address_family(
490 tgen
, "r1", "r2", addr_type
, NEXT_HOP_IP_2
492 input_topo
= {"r2": topo
["routers"]["r2"]}
493 result
= verify_bgp_rib(tgen
, addr_type
, "r1", input_topo
, next_hop
)
494 assert result
is True, "Testcase {} : Failed \n Error {}".format(
498 result
= verify_rib(tgen
, addr_type
, "r1", input_topo
, next_hop
, protocol
)
501 ), "Testcase {} : Failed \n Routes are still present \n Error {}".format(
505 step("Start BGP on R2")
507 start_router_daemons(tgen
, "r2", ["bgpd"])
509 write_test_footer(tc_name
)
512 def test_BGP_GR_TC_19_p1(request
):
514 Test Objective : Verify that GR helper routers keeps all the routes received
515 from restarting node if both the routers are configured as GR restarting node.
519 tc_name
= request
.node
.name
520 write_test_header(tc_name
)
522 # Check router status
523 check_router_status(tgen
)
525 # Don't run this test if we have any failure.
526 if tgen
.routers_have_failure():
527 pytest
.skip(tgen
.errors
)
529 # Creating configuration from JSON
530 reset_config_on_routers(tgen
)
532 logger
.info("[Phase 1] : Test Setup [Helper]R1-----R2[Restart] initialized ")
534 # Configure graceful-restart
538 "graceful-restart": {
539 "graceful-restart": True,
540 "preserve-fw-state": True,
548 "r1-link1": {"graceful-restart-helper": True}
559 "r1-link1": {"graceful-restart-helper": True}
576 "r2-link1": {"graceful-restart": True}
587 "r2-link1": {"graceful-restart": True}
598 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r2")
600 for addr_type
in ADDR_TYPES
:
601 result
= verify_graceful_restart(
602 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
604 assert result
is True, "Testcase {} : Failed \n Error {}".format(
608 # Verifying BGP RIB routes
611 next_hop
= next_hop_per_address_family(
612 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
614 input_topo
= {key
: topo
["routers"][key
] for key
in ["r2"]}
615 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
)
616 assert result
is True, "Testcase {} : Failed \n Error {}".format(
620 # Verifying RIB routes
622 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
623 assert result
is True, "Testcase {} : Failed \n Error {}".format(
628 "[Phase 2] : R1's Gr state cahnge to Graceful"
629 " Restart without resetting the session "
632 # Configure graceful-restart
642 "r1-link1": {"graceful-restart": True}
653 "r1-link1": {"graceful-restart": True}
664 result
= create_router_bgp(tgen
, topo
, input_dict
)
665 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
668 "[Phase 3] : R2 is still down, restart time 120 sec."
669 " So time verify the routes are present in BGP RIB and ZEBRA "
672 for addr_type
in ADDR_TYPES
:
673 # Verifying BGP RIB routes
674 next_hop
= next_hop_per_address_family(
675 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
677 input_topo
= {key
: topo
["routers"][key
] for key
in ["r2"]}
678 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
)
679 assert result
is True, "Testcase {} : Failed \n Error {}".format(
683 # Verifying RIB routes
684 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
685 assert result
is True, "Testcase {} : Failed \n Error {}".format(
689 write_test_footer(tc_name
)
692 def test_BGP_GR_TC_20_p1(request
):
694 Test Objective : Verify that GR helper routers delete all the routes
695 received from a node if both the routers are configured as GR helper node.
698 tc_name
= request
.node
.name
699 write_test_header(tc_name
)
701 # Check router status
702 check_router_status(tgen
)
704 # Don't run this test if we have any failure.
705 if tgen
.routers_have_failure():
706 pytest
.skip(tgen
.errors
)
708 # Creating configuration from JSON
709 reset_config_on_routers(tgen
)
711 logger
.info("[Phase 1] : Test Setup [Helper]R1-----R2[Helper] initialized ")
713 # Configure graceful-restart
717 "graceful-restart": {
718 "graceful-restart": True,
719 "preserve-fw-state": True,
727 "r1-link1": {"graceful-restart-helper": True}
738 "r1-link1": {"graceful-restart-helper": True}
755 "r2-link1": {"graceful-restart-helper": True}
766 "r2-link1": {"graceful-restart-helper": True}
777 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r2")
779 for addr_type
in ADDR_TYPES
:
780 result
= verify_graceful_restart(
781 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
783 assert result
is True, "Testcase {} : Failed \n Error {}".format(
787 # Verifying BGP RIB routes
790 next_hop
= next_hop_per_address_family(
791 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
793 input_topo
= {key
: topo
["routers"][key
] for key
in ["r2"]}
794 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
)
795 assert result
is True, "Testcase {} : Failed \n Error {}".format(
799 # Verifying RIB routes
801 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
802 assert result
is True, "Testcase {} : Failed \n Error {}".format(
806 kill_router_daemons(tgen
, "r2", ["bgpd"])
808 for addr_type
in ADDR_TYPES
:
809 # Verifying BGP RIB routes
810 next_hop
= next_hop_per_address_family(
811 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
813 input_topo
= {key
: topo
["routers"][key
] for key
in ["r2"]}
814 result
= verify_bgp_rib(
815 tgen
, addr_type
, dut
, input_topo
, next_hop
, expected
=False
817 assert result
is not True, (
818 "Testcase {} : Failed \n "
819 "Expected: Routes should not be present in {} BGP RIB \n "
820 "Found: {}".format(tc_name
, dut
, result
)
823 # Verifying RIB routes
825 tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
, expected
=False
827 assert result
is not True, (
828 "Testcase {} : Failed \n "
829 "Expected: Routes should not be present in {} FIB \n "
830 "Found: {}".format(tc_name
, dut
, result
)
833 logger
.info("[Phase 5] : R2 is about to come up now ")
835 start_router_daemons(tgen
, "r2", ["bgpd"])
837 logger
.info("[Phase 4] : R2 is UP now, so time to collect GR stats ")
839 for addr_type
in ADDR_TYPES
:
840 # Verifying BGP RIB routes
841 next_hop
= next_hop_per_address_family(
842 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
844 input_topo
= {key
: topo
["routers"][key
] for key
in ["r2"]}
845 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
)
846 assert result
is True, "Testcase {} : Failed \n Error {}".format(
850 # Verifying RIB routes
851 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
852 assert result
is True, "Testcase {} : Failed \n Error {}".format(
856 write_test_footer(tc_name
)
859 def test_BGP_GR_TC_31_1_p1(request
):
861 After BGP neighborship is established and GR capability is exchanged,
862 transition restarting router to disabled state and vice versa.
866 tc_name
= request
.node
.name
867 write_test_header(tc_name
)
869 # Check router status
870 check_router_status(tgen
)
872 # Don't run this test if we have any failure.
873 if tgen
.routers_have_failure():
874 pytest
.skip(tgen
.errors
)
876 # Creating configuration from JSON
877 reset_config_on_routers(tgen
)
880 "[Phase 1] : Test Setup" " [Helper Mode]R2-----R1[Restart Mode] initialized "
883 # Configure graceful-restart
893 "r2-link1": {"graceful-restart-helper": True}
904 "r2-link1": {"graceful-restart-helper": True}
915 "graceful-restart": {"preserve-fw-state": True},
922 "r1-link1": {"graceful-restart": True}
933 "r1-link1": {"graceful-restart": True}
944 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r2")
946 for addr_type
in ADDR_TYPES
:
947 result
= verify_graceful_restart(
948 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
950 assert result
is True, "Testcase {} : Failed \n Error {}".format(
954 # Verifying BGP RIB routes
958 next_hop
= next_hop_per_address_family(
959 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
961 input_topo
= {key
: topo
["routers"][key
] for key
in ["r2"]}
962 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
)
963 assert result
is True, "Testcase {} : Failed \n Error {}".format(
967 # Verifying RIB routes
968 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
969 assert result
is True, "Testcase {} : Failed \n Error {}".format(
973 logger
.info("[Phase 2] : R1 Goes from Restart to Disable Mode ")
975 # Configure graceful-restart
985 "r1-link1": {"graceful-restart-disable": True}
996 "r1-link1": {"graceful-restart-disable": True}
1007 result
= create_router_bgp(tgen
, topo
, input_dict
)
1008 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1010 for addr_type
in ADDR_TYPES
:
1011 neighbor
= topo
["routers"]["r2"]["links"]["r1-link1"][addr_type
].split("/")[0]
1012 clear_bgp(tgen
, addr_type
, "r1", neighbor
=neighbor
)
1014 result
= verify_bgp_convergence_from_running_config(tgen
)
1015 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1027 "r1-link1": {"graceful-restart-disable": True}
1038 "r1-link1": {"graceful-restart-disable": True}
1055 "r2-link1": {"graceful-restart-helper": True}
1066 "r2-link1": {"graceful-restart-helper": True}
1077 for addr_type
in ADDR_TYPES
:
1078 result
= verify_graceful_restart(
1079 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
1081 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1085 logger
.info("[Phase 2] : R1 goes for reload ")
1087 kill_router_daemons(tgen
, "r1", ["bgpd"])
1090 "[Phase 3] : R1 is still down, restart time 120 sec."
1091 " So time verify the routes are not present in BGP RIB and ZEBRA"
1094 for addr_type
in ADDR_TYPES
:
1095 # Verifying RIB routes
1096 next_hop
= next_hop_per_address_family(
1097 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
1099 input_topo
= {key
: topo
["routers"][key
] for key
in ["r2"]}
1100 result
= verify_rib(
1101 tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
, expected
=False
1103 assert result
is not True, (
1104 "Testcase {} : Failed \n "
1105 "Expected: Routes should not be present in {} FIB \n "
1106 "Found: {}".format(tc_name
, dut
, result
)
1109 logger
.info("[Phase 4] : R1 is about to come up now ")
1110 start_router_daemons(tgen
, "r1", ["bgpd"])
1112 logger
.info("[Phase 5] : R1 is UP now, so time to collect GR stats ")
1114 for addr_type
in ADDR_TYPES
:
1115 result
= verify_graceful_restart(
1116 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
1118 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1122 # Verifying BGP RIB routes
1123 next_hop
= next_hop_per_address_family(
1124 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
1126 input_topo
= {key
: topo
["routers"][key
] for key
in ["r2"]}
1127 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
)
1128 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1132 # Verifying RIB routes
1133 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
1134 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1138 write_test_footer(tc_name
)
1141 def test_BGP_GR_TC_31_2_p1(request
):
1143 After BGP neighborship is established and GR capability is exchanged,
1144 transition restarting router to disabled state and vice versa.
1147 tgen
= get_topogen()
1148 tc_name
= request
.node
.name
1149 write_test_header(tc_name
)
1151 # Check router status
1152 check_router_status(tgen
)
1154 # Don't run this test if we have any failure.
1155 if tgen
.routers_have_failure():
1156 pytest
.skip(tgen
.errors
)
1158 # Creating configuration from JSON
1159 reset_config_on_routers(tgen
)
1162 "[Phase 1] : Test Setup " "[Disable Mode]R1-----R2[Restart Mode] initialized "
1165 # Configure graceful-restart
1175 "r2-link1": {"graceful-restart-helper": True}
1186 "r2-link1": {"graceful-restart-helper": True}
1203 "r1-link1": {"graceful-restart-disable": True}
1214 "r1-link1": {"graceful-restart-disable": True}
1225 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r2")
1227 for addr_type
in ADDR_TYPES
:
1228 result
= verify_graceful_restart(
1229 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
1231 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1235 # Verifying BGP RIB routes
1238 next_hop
= next_hop_per_address_family(
1239 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
1241 input_topo
= {key
: topo
["routers"][key
] for key
in ["r2"]}
1242 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
)
1243 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1247 # Verifying RIB routes
1249 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
1250 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1254 logger
.info("[Phase 2] : R2 Goes from Disable to Restart Mode ")
1256 # Configure graceful-restart
1260 "graceful-restart": {"preserve-fw-state": True},
1267 "r1-link1": {"graceful-restart": True}
1278 "r1-link1": {"graceful-restart": True}
1289 result
= create_router_bgp(tgen
, topo
, input_dict
)
1290 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1292 for addr_type
in ADDR_TYPES
:
1293 neighbor
= topo
["routers"]["r2"]["links"]["r1-link1"][addr_type
].split("/")[0]
1294 clear_bgp(tgen
, addr_type
, "r1", neighbor
=neighbor
)
1296 result
= verify_bgp_convergence_from_running_config(tgen
)
1297 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1309 "r2-link1": {"graceful-restart-helper": True}
1320 "r2-link1": {"graceful-restart-helper": True}
1337 "r1-link1": {"graceful-restart": True}
1348 "r1-link1": {"graceful-restart": True}
1359 # here the verify_graceful_restart fro the neighbor would be
1360 # "NotReceived" as the latest GR config is not yet applied.
1361 for addr_type
in ADDR_TYPES
:
1362 result
= verify_graceful_restart(
1363 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
1365 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1369 for addr_type
in ADDR_TYPES
:
1370 # Verifying RIB routes
1371 next_hop
= next_hop_per_address_family(
1372 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
1374 input_topo
= {key
: topo
["routers"][key
] for key
in ["r2"]}
1375 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
1376 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1380 logger
.info("[Phase 6] : R1 is about to come up now ")
1381 start_router_daemons(tgen
, "r1", ["bgpd"])
1383 logger
.info("[Phase 4] : R1 is UP now, so time to collect GR stats ")
1385 for addr_type
in ADDR_TYPES
:
1386 result
= verify_graceful_restart(
1387 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
1389 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1393 # Verifying BGP RIB routes
1394 next_hop
= next_hop_per_address_family(
1395 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
1397 input_topo
= {key
: topo
["routers"][key
] for key
in ["r2"]}
1398 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
)
1399 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1403 # Verifying RIB routes
1404 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
1405 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1409 logger
.info("[Phase 3] : R1 goes for reload ")
1411 kill_router_daemons(tgen
, "r1", ["bgpd"])
1414 "[Phase 4] : R1 is still down, restart time 120 sec."
1415 " So time verify the routes are present in BGP RIB and ZEBRA "
1418 for addr_type
in ADDR_TYPES
:
1419 # Verifying RIB routes
1420 next_hop
= next_hop_per_address_family(
1421 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
1423 input_topo
= {key
: topo
["routers"][key
] for key
in ["r2"]}
1424 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
1425 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1429 logger
.info("[Phase 6] : R1 is about to come up now ")
1430 start_router_daemons(tgen
, "r1", ["bgpd"])
1432 logger
.info("[Phase 4] : R1 is UP now, so time to collect GR stats ")
1434 for addr_type
in ADDR_TYPES
:
1435 result
= verify_graceful_restart(
1436 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
1438 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1442 # Verifying BGP RIB routes
1443 next_hop
= next_hop_per_address_family(
1444 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
1446 input_topo
= {key
: topo
["routers"][key
] for key
in ["r2"]}
1447 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
)
1448 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1452 # Verifying RIB routes
1453 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
1454 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1458 write_test_footer(tc_name
)
1461 def test_BGP_GR_TC_9_p1(request
):
1463 Test Objective : Verify that restarting nodes reset "F" bit while sending
1464 the BGP open messages after it's restarts, when BGP GR is **NOT** enabled.
1467 tgen
= get_topogen()
1468 tc_name
= request
.node
.name
1469 write_test_header(tc_name
)
1471 # Check router status
1472 check_router_status(tgen
)
1474 # Don't run this test if we have any failure.
1475 if tgen
.routers_have_failure():
1476 pytest
.skip(tgen
.errors
)
1478 # Creating configuration from JSON
1479 reset_config_on_routers(tgen
)
1482 "[Phase 1] : Test Setup" " [Restart Mode]R1-----R2[Helper Mode] Initiliazed "
1485 # Configure graceful-restart
1495 "r1-link1": {"graceful-restart": True}
1506 "r1-link1": {"graceful-restart": True}
1517 "graceful-restart": {"preserve-fw-state": True},
1524 "r2-link1": {"graceful-restart-helper": True}
1535 "r2-link1": {"graceful-restart-helper": True}
1546 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r2")
1548 for addr_type
in ADDR_TYPES
:
1549 result
= verify_graceful_restart(
1550 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
1552 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1554 # Verifying BGP RIB routes
1557 next_hop
= next_hop_per_address_family(
1558 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
1560 input_topo
= {key
: topo
["routers"][key
] for key
in ["r2"]}
1561 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
)
1562 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1564 # Verifying RIB routes
1566 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
1567 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1569 logger
.info("[Phase 2] : R2 goes for reload ")
1570 kill_router_daemons(tgen
, "r2", ["bgpd"])
1573 "[Phase 3] : R2 is still down, restart time 120 sec."
1574 "So time verify the routes are present in BGP RIB and ZEBRA "
1577 for addr_type
in ADDR_TYPES
:
1578 # Verifying BGP RIB routes
1579 next_hop
= next_hop_per_address_family(
1580 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
1582 input_topo
= {key
: topo
["routers"][key
] for key
in ["r2"]}
1583 result
= verify_bgp_rib(
1584 tgen
, addr_type
, dut
, input_topo
, next_hop
, expected
=False
1586 assert result
is not True, (
1587 "Testcase {} : Failed \n "
1588 "Expected: Routes should not be present in {} BGP RIB \n "
1589 "Found: {}".format(tc_name
, dut
, result
)
1592 # Verifying RIB routes
1594 result
= verify_rib(
1595 tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
, expected
=False
1597 assert result
is not True, (
1598 "Testcase {} : Failed \n "
1599 "Expected: Routes should not be present in {} FIB \n "
1600 "Found: {}".format(tc_name
, dut
, result
)
1603 logger
.info("[Phase 5] : R2 is about to come up now ")
1604 start_router_daemons(tgen
, "r2", ["bgpd"])
1606 logger
.info("[Phase 4] : R2 is UP now, so time to collect GR stats ")
1608 for addr_type
in ADDR_TYPES
:
1609 result
= verify_bgp_convergence(tgen
, topo
)
1612 ), "BGP Convergence after BGPd restart" " :Failed \n Error:{}".format(result
)
1614 result
= verify_graceful_restart(
1615 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
1617 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1619 result
= verify_graceful_restart(
1620 tgen
, topo
, addr_type
, input_dict
, dut
="r2", peer
="r1"
1622 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1624 result
= verify_r_bit(tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2")
1625 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1627 result
= verify_f_bit(
1628 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2", expected
=False
1630 assert result
is not True, (
1631 "Testcase {} : Failed \n "
1632 "Expected: F-bit should not be set to True in r1\n"
1633 "Found: {}".format(tc_name
, result
)
1636 write_test_footer(tc_name
)
1639 def test_BGP_GR_TC_17_p1(request
):
1641 Test Objective : Verify that only GR helper routers keep the stale
1642 route entries, not any GR disabled router.
1645 tgen
= get_topogen()
1646 tc_name
= request
.node
.name
1647 write_test_header(tc_name
)
1649 # Check router status
1650 check_router_status(tgen
)
1652 # Don't run this test if we have any failure.
1653 if tgen
.routers_have_failure():
1654 pytest
.skip(tgen
.errors
)
1656 # Creating configuration from JSON
1657 reset_config_on_routers(tgen
)
1659 logger
.info("[Phase 1] : Test Setup [Disable]R1-----R2[Restart] " "Initiliazed ")
1661 # Configure graceful-restart
1665 "graceful-restart": {
1666 "graceful-restart": True,
1667 "preserve-fw-state": True,
1675 "r1-link1": {"graceful-restart-disable": True}
1686 "r1-link1": {"graceful-restart-disable": True}
1703 "r2-link1": {"graceful-restart": True}
1714 "r2-link1": {"graceful-restart": True}
1725 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r2")
1727 for addr_type
in ADDR_TYPES
:
1728 result
= verify_graceful_restart(
1729 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
1731 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1733 # Verifying BGP RIB routes
1736 next_hop
= next_hop_per_address_family(
1737 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
1739 input_topo
= {key
: topo
["routers"][key
] for key
in ["r2"]}
1740 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
)
1741 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1743 # Verifying RIB routes
1745 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
1746 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1748 logger
.info("[Phase 2] : R2 goes for reload ")
1750 kill_router_daemons(tgen
, "r2", ["bgpd"])
1753 "[Phase 3] : R2 is still down, restart time 120 sec."
1754 " So time verify the routes are present in BGP RIB and ZEBRA "
1757 for addr_type
in ADDR_TYPES
:
1758 # Verifying BGP RIB routes
1759 next_hop
= next_hop_per_address_family(
1760 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
1762 input_topo
= {key
: topo
["routers"][key
] for key
in ["r2"]}
1763 result
= verify_bgp_rib(
1764 tgen
, addr_type
, dut
, input_topo
, next_hop
, expected
=False
1766 assert result
is not True, (
1767 "Testcase {} : Failed \n "
1768 "Expected: Routes should not be present in {} BGP RIB \n "
1769 "Found: {}".format(tc_name
, dut
, result
)
1772 # Verifying RIB routes
1774 result
= verify_rib(
1775 tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
, expected
=False
1777 assert result
is not True, (
1778 "Testcase {} : Failed \n "
1779 "Expected: Routes should not be present in {} FIB \n "
1780 "Found: {}".format(tc_name
, dut
, result
)
1783 logger
.info("[Phase 5] : R2 is about to come up now ")
1784 start_router_daemons(tgen
, "r2", ["bgpd"])
1786 logger
.info("[Phase 4] : R2 is UP now, so time to collect GR stats ")
1788 for addr_type
in ADDR_TYPES
:
1789 result
= verify_bgp_convergence(tgen
, topo
)
1792 ), "BGP Convergence after BGPd restart" " :Failed \n Error:{}".format(result
)
1794 result
= verify_graceful_restart(
1795 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
1797 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1799 result
= verify_r_bit(
1800 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2", expected
=False
1802 assert result
is not True, (
1803 "Testcase {} : Failed \n "
1804 "Expected: R-bit should not be set to True in r1\n"
1805 "Found: {}".format(tc_name
, result
)
1808 # Verifying BGP RIB routes
1809 next_hop
= next_hop_per_address_family(
1810 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
1812 input_topo
= {key
: topo
["routers"][key
] for key
in ["r2"]}
1813 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
)
1814 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1816 # Verifying RIB routes
1818 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
1819 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1821 write_test_footer(tc_name
)
1824 def test_BGP_GR_TC_43_p1(request
):
1826 Test Objective : Transition from Global Restarting to Disable
1827 and then Global Disable to Restarting.
1831 tgen
= get_topogen()
1832 tc_name
= request
.node
.name
1833 write_test_header(tc_name
)
1835 # Check router status
1836 check_router_status(tgen
)
1838 # Don't run this test if we have any failure.
1839 if tgen
.routers_have_failure():
1840 pytest
.skip(tgen
.errors
)
1842 # Creating configuration from JSON
1843 reset_config_on_routers(tgen
)
1845 step("Configure R1 and R2 as GR restarting node in global level")
1850 "graceful-restart": {
1851 "graceful-restart": True,
1855 "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}},
1858 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r2")
1860 step("Verify on R2 that R1 advertises GR capabilities as a restarting node")
1862 for addr_type
in ADDR_TYPES
:
1863 result
= verify_graceful_restart(
1864 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
1866 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1867 result
= verify_graceful_restart(
1868 tgen
, topo
, addr_type
, input_dict
, dut
="r2", peer
="r1"
1870 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1872 for addr_type
in ADDR_TYPES
:
1876 next_hop
= next_hop_per_address_family(
1877 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
1879 input_topo
= {"r2": topo
["routers"]["r2"]}
1880 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
1881 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1885 next_hop
= next_hop_per_address_family(
1886 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_1
1888 input_topo
= {"r1": topo
["routers"]["r1"]}
1889 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
)
1890 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1892 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
1893 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1895 step("Kill BGP on R1")
1897 kill_router_daemons(tgen
, "r1", ["bgpd"])
1900 "Verify that R1 keeps BGP routes in zebra and R2 retains"
1901 " the stale entry for received routes from R1"
1904 for addr_type
in ADDR_TYPES
:
1908 next_hop
= next_hop_per_address_family(
1909 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
1911 input_topo
= {"r2": topo
["routers"]["r2"]}
1912 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
1913 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1917 next_hop
= next_hop_per_address_family(
1918 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_1
1920 input_topo
= {"r1": topo
["routers"]["r1"]}
1921 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
)
1922 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1924 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
1925 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1927 step("Bring up BGPd on R1 and configure it as GR disabled node in global level")
1929 start_router_daemons(tgen
, "r1", ["bgpd"])
1934 "graceful-restart": {
1935 "graceful-restart": False,
1936 "graceful-restart-disable": True,
1942 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r2")
1944 step("Verify on R2 that R1 doesn't advertise any GR capabilities")
1949 "graceful-restart": {
1950 "graceful-restart-disable": True,
1954 "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}},
1957 for addr_type
in ADDR_TYPES
:
1958 result
= verify_graceful_restart(
1959 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
1961 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1963 result
= verify_graceful_restart(
1964 tgen
, topo
, addr_type
, input_dict
, dut
="r2", peer
="r1"
1966 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1968 for addr_type
in ADDR_TYPES
:
1972 next_hop
= next_hop_per_address_family(
1973 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
1975 input_topo
= {"r2": topo
["routers"]["r2"]}
1976 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
1977 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1981 next_hop
= next_hop_per_address_family(
1982 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_1
1984 input_topo
= {"r1": topo
["routers"]["r1"]}
1985 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
)
1986 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1988 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
1989 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1991 step("Kill BGP on R1")
1993 kill_router_daemons(tgen
, "r1", ["bgpd"])
1996 "Verify that R1 flush all BGP routes from RIB & FIB and FIB and R2"
1997 " does not retain stale entry for received routes from R1"
2000 for addr_type
in ADDR_TYPES
:
2004 next_hop
= next_hop_per_address_family(
2005 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
2007 input_topo
= {"r2": topo
["routers"]["r2"]}
2008 result
= verify_rib(
2009 tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
, expected
=False
2011 assert result
is not True, (
2012 "Testcase {} : Failed \n "
2013 "Expected: Routes should not be present in {} FIB \n "
2014 "Found: {}".format(tc_name
, dut
, result
)
2019 next_hop
= next_hop_per_address_family(
2020 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_1
2022 input_topo
= {"r1": topo
["routers"]["r1"]}
2023 result
= verify_bgp_rib(
2024 tgen
, addr_type
, dut
, input_topo
, next_hop
, expected
=False
2026 assert result
is not True, (
2027 "Testcase {} : Failed \n "
2028 "Expected: Routes should not be present in {} BGP RIB \n "
2029 "Found: {}".format(tc_name
, dut
, result
)
2033 result
= verify_rib(
2034 tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
, expected
=False
2036 assert result
is not True, (
2037 "Testcase {} : Failed \n "
2038 "Expected: Routes should not be present in {} FIB \n "
2039 "Found: {}".format(tc_name
, dut
, result
)
2043 "Bring up BGPd on R1 and configure it as GR" " restarting node in global level"
2046 start_router_daemons(tgen
, "r1", ["bgpd"])
2048 input_dict
= {"r1": {"bgp": {"graceful-restart": {"graceful-restart": True}}}}
2050 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r2")
2052 step("Verify on R2 that R1 advertises GR capabilities as a restarting node")
2057 "graceful-restart": {
2058 "graceful-restart": True,
2062 "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}},
2065 for addr_type
in ADDR_TYPES
:
2066 result
= verify_graceful_restart(
2067 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
2069 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2071 result
= verify_graceful_restart(
2072 tgen
, topo
, addr_type
, input_dict
, dut
="r2", peer
="r1"
2074 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2076 for addr_type
in ADDR_TYPES
:
2080 next_hop
= next_hop_per_address_family(
2081 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
2083 input_topo
= {"r2": topo
["routers"]["r2"]}
2084 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
2087 ), "Testcase {} :Failed \n Routes are still present \n Error {}".format(
2093 next_hop
= next_hop_per_address_family(
2094 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_1
2096 input_topo
= {"r1": topo
["routers"]["r1"]}
2097 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
)
2098 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2099 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
2102 ), "Testcase {} :Failed \n Routes are still present \n Error {}".format(
2106 step("Kill BGP on R1")
2108 kill_router_daemons(tgen
, "r1", ["bgpd"])
2111 "Verify that R1 keeps BGP routes in zebra and R2"
2112 " retains the stale entry for received routes from R1"
2115 for addr_type
in ADDR_TYPES
:
2119 next_hop
= next_hop_per_address_family(
2120 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
2122 input_topo
= {"r2": topo
["routers"]["r2"]}
2123 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
2126 ), "Testcase {} :Failed \n Routes are still present \n Error {}".format(
2132 next_hop
= next_hop_per_address_family(
2133 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_1
2135 input_topo
= {"r1": topo
["routers"]["r1"]}
2136 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
)
2137 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2138 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
2141 ), "Testcase {} :Failed \n Routes are still present \n Error {}".format(
2145 write_test_footer(tc_name
)
2148 def test_BGP_GR_TC_44_p1(request
):
2150 Test Objective : Transition from Global Helper to Disable
2151 and then Global Disable to Helper.
2155 tgen
= get_topogen()
2156 tc_name
= request
.node
.name
2157 write_test_header(tc_name
)
2159 # Check router status
2160 check_router_status(tgen
)
2162 # Don't run this test if we have any failure.
2163 if tgen
.routers_have_failure():
2164 pytest
.skip(tgen
.errors
)
2166 # Creating configuration from JSON
2167 reset_config_on_routers(tgen
)
2170 "Configure R2 as GR restating node in global level and"
2171 " leave R1 without any GR related config"
2174 input_dict
= {"r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}}}
2176 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r2")
2178 step("Verify on R2 that R1 advertises GR capabilities as a helper node")
2183 "graceful-restart": {
2184 "graceful-restart-helper": True,
2188 "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}},
2191 for addr_type
in ADDR_TYPES
:
2192 result
= verify_graceful_restart(
2193 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
2195 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2197 result
= verify_graceful_restart(
2198 tgen
, topo
, addr_type
, input_dict
, dut
="r2", peer
="r1"
2200 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2202 for addr_type
in ADDR_TYPES
:
2206 next_hop
= next_hop_per_address_family(
2207 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_1
2209 input_topo
= {"r1": topo
["routers"]["r1"]}
2210 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
2211 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2215 next_hop
= next_hop_per_address_family(
2216 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
2218 input_topo
= {"r2": topo
["routers"]["r2"]}
2219 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
)
2220 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2221 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
2222 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2224 step("Kill BGP on R2")
2226 kill_router_daemons(tgen
, "r2", ["bgpd"])
2228 step("Verify that R1 keeps stale entry for BGP routes when BGPd on R2 is down")
2230 for addr_type
in ADDR_TYPES
:
2234 next_hop
= next_hop_per_address_family(
2235 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_1
2237 input_topo
= {"r1": topo
["routers"]["r1"]}
2238 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
2239 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2243 next_hop
= next_hop_per_address_family(
2244 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
2246 input_topo
= {"r2": topo
["routers"]["r2"]}
2247 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
)
2248 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2249 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
2250 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2252 step("Bring up BGPd on R2 and configure R1 as GR disabled node in global level")
2254 start_router_daemons(tgen
, "r2", ["bgpd"])
2259 "graceful-restart": {
2260 "graceful-restart-disable": True,
2266 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r2")
2268 step("Verify on R2 that R1 doesn't advertise any GR capabilities")
2273 "graceful-restart": {
2274 "graceful-restart-disable": True,
2278 "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}},
2281 for addr_type
in ADDR_TYPES
:
2282 result
= verify_graceful_restart(
2283 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
2285 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2286 result
= verify_graceful_restart(
2287 tgen
, topo
, addr_type
, input_dict
, dut
="r2", peer
="r1"
2289 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2291 for addr_type
in ADDR_TYPES
:
2295 next_hop
= next_hop_per_address_family(
2296 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_1
2298 input_topo
= {"r1": topo
["routers"]["r1"]}
2299 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
2302 ), "Testcase {} :Failed \n Routes are still present \n Error {}".format(
2306 step("Kill BGP on R2")
2308 kill_router_daemons(tgen
, "r2", ["bgpd"])
2310 step("Verify that R1 does not retain stale entry for received routes from R2")
2312 for addr_type
in ADDR_TYPES
:
2316 next_hop
= next_hop_per_address_family(
2317 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_1
2319 input_topo
= {"r1": topo
["routers"]["r1"]}
2320 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
2323 ), "Testcase {} :Failed \n Routes are still present \n Error {}".format(
2329 next_hop
= next_hop_per_address_family(
2330 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
2332 next_hop
= NEXT_HOP_IP_2
[addr_type
]
2333 result
= verify_bgp_rib(
2334 tgen
, addr_type
, dut
, input_topo
, next_hop
, expected
=False
2336 assert result
is not True, (
2337 "Testcase {} : Failed \n "
2338 "Expected: Routes should not be present in {} BGP RIB \n "
2339 "Found: {}".format(tc_name
, dut
, result
)
2342 result
= verify_rib(
2343 tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
, expected
=False
2345 assert result
is not True, (
2346 "Testcase {} : Failed \n "
2347 "Expected: Routes should not be present in {} FIB \n "
2348 "Found: {}".format(tc_name
, dut
, result
)
2351 step("Bring up BGPd on R2 and remove GR related config from R1 in global level")
2353 start_router_daemons(tgen
, "r2", ["bgpd"])
2356 "r1": {"bgp": {"graceful-restart": {"graceful-restart-disable": False}}}
2359 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r2")
2361 step("Verify on R2 that R1 advertises GR capabilities as a helper node")
2366 "graceful-restart": {
2367 "graceful-restart-helper": True,
2371 "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}},
2374 for addr_type
in ADDR_TYPES
:
2375 result
= verify_graceful_restart(
2376 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
2378 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2380 result
= verify_graceful_restart(
2381 tgen
, topo
, addr_type
, input_dict
, dut
="r2", peer
="r1"
2383 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2385 for addr_type
in ADDR_TYPES
:
2389 next_hop
= next_hop_per_address_family(
2390 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_1
2392 input_topo
= {"r1": topo
["routers"]["r1"]}
2393 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
2394 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2398 next_hop
= next_hop_per_address_family(
2399 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
2401 input_topo
= {"r2": topo
["routers"]["r2"]}
2402 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
)
2403 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2404 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
2405 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2407 step("Kill BGP on R2")
2409 kill_router_daemons(tgen
, "r2", ["bgpd"])
2411 step("Verify that R1 keeps stale entry for BGP routes when BGPd on R2 is down")
2413 for addr_type
in ADDR_TYPES
:
2417 next_hop
= next_hop_per_address_family(
2418 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_1
2420 input_topo
= {"r1": topo
["routers"]["r1"]}
2421 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
2422 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2426 next_hop
= next_hop_per_address_family(
2427 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
2429 input_topo
= {"r2": topo
["routers"]["r2"]}
2430 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
)
2431 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2432 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
2433 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2435 write_test_footer(tc_name
)
2438 def test_BGP_GR_TC_45_p1(request
):
2440 Test Objective : Transition from Global Restart to Helper
2441 and then Global Helper to Restart.
2445 tgen
= get_topogen()
2446 tc_name
= request
.node
.name
2447 write_test_header(tc_name
)
2449 # Check router status
2450 check_router_status(tgen
)
2452 # Don't run this test if we have any failure.
2453 if tgen
.routers_have_failure():
2454 pytest
.skip(tgen
.errors
)
2456 # Creating configuration from JSON
2457 reset_config_on_routers(tgen
)
2459 step("Configure R1 and R2 as GR restarting node in global level")
2462 "r1": {"bgp": {"graceful-restart": {"graceful-restart": True}}},
2463 "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}},
2466 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r2")
2468 step("Verify on R2 that R1 advertises GR capabilities as a restarting node")
2470 for addr_type
in ADDR_TYPES
:
2471 result
= verify_graceful_restart(
2472 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
2474 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2475 result
= verify_graceful_restart(
2476 tgen
, topo
, addr_type
, input_dict
, dut
="r2", peer
="r1"
2478 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2480 for addr_type
in ADDR_TYPES
:
2484 next_hop
= next_hop_per_address_family(
2485 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
2487 input_topo
= {"r2": topo
["routers"]["r2"]}
2488 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
2489 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2493 next_hop
= next_hop_per_address_family(
2494 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_1
2496 input_topo
= {"r1": topo
["routers"]["r1"]}
2497 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
)
2498 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2499 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
2500 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2502 step("Kill BGP on R1")
2504 kill_router_daemons(tgen
, "r1", ["bgpd"])
2507 "Verify that R1 keeps BGP routes in zebra and R2"
2508 " retains the stale entry for received routes from R1"
2511 for addr_type
in ADDR_TYPES
:
2515 next_hop
= next_hop_per_address_family(
2516 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
2518 input_topo
= {"r2": topo
["routers"]["r2"]}
2519 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
2520 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2524 next_hop
= next_hop_per_address_family(
2525 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_1
2527 input_topo
= {"r1": topo
["routers"]["r1"]}
2528 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
)
2529 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2530 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
2531 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2533 step("Bring up BGPd on R1 and remove GR related config in global level")
2535 start_router_daemons(tgen
, "r1", ["bgpd"])
2540 "graceful-restart": {
2541 "graceful-restart": False,
2547 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r2")
2549 step("Verify on R2 that R1 advertises GR capabilities as a helper node")
2554 "graceful-restart": {
2555 "graceful-restart-helper": True,
2559 "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}},
2562 for addr_type
in ADDR_TYPES
:
2563 result
= verify_graceful_restart(
2564 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
2566 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2567 result
= verify_graceful_restart(
2568 tgen
, topo
, addr_type
, input_dict
, dut
="r2", peer
="r1"
2570 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2572 for addr_type
in ADDR_TYPES
:
2576 next_hop
= next_hop_per_address_family(
2577 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_1
2579 input_topo
= {"r1": topo
["routers"]["r1"]}
2580 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
2583 ), "Testcase {} :Failed \n Routes are still present \n Error {}".format(
2589 next_hop
= next_hop_per_address_family(
2590 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
2592 input_topo
= {"r2": topo
["routers"]["r2"]}
2593 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
)
2594 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2595 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
2598 ), "Testcase {} :Failed \n Routes are still present \n Error {}".format(
2602 step("Kill BGP on R2")
2604 kill_router_daemons(tgen
, "r2", ["bgpd"])
2606 step("Verify that R1 keeps stale entry for BGP routes when BGPd on R2 is down")
2608 for addr_type
in ADDR_TYPES
:
2612 next_hop
= next_hop_per_address_family(
2613 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_1
2615 input_topo
= {"r1": topo
["routers"]["r1"]}
2616 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
2619 ), "Testcase {} :Failed \n Routes are still present \n Error {}".format(
2625 next_hop
= next_hop_per_address_family(
2626 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
2628 input_topo
= {"r2": topo
["routers"]["r2"]}
2629 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
)
2630 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2631 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
2634 ), "Testcase {} :Failed \n Routes are still present \n Error {}".format(
2638 step("Bring up BGPd on R2 and configure R1 as GR restarting node in global level")
2640 start_router_daemons(tgen
, "r2", ["bgpd"])
2645 "graceful-restart": {
2646 "graceful-restart": True,
2652 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r2")
2654 step("Verify on R2 that R1 advertises GR capabilities as a restarting node")
2659 "graceful-restart": {
2660 "graceful-restart": True,
2664 "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}},
2667 for addr_type
in ADDR_TYPES
:
2668 result
= verify_graceful_restart(
2669 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
2671 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2672 result
= verify_graceful_restart(
2673 tgen
, topo
, addr_type
, input_dict
, dut
="r2", peer
="r1"
2675 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2677 for addr_type
in ADDR_TYPES
:
2681 next_hop
= next_hop_per_address_family(
2682 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
2684 input_topo
= {"r2": topo
["routers"]["r2"]}
2685 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
2686 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2690 next_hop
= next_hop_per_address_family(
2691 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_1
2693 input_topo
= {"r1": topo
["routers"]["r1"]}
2694 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
)
2695 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2696 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
2697 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2699 step("Kill BGP on R1")
2701 kill_router_daemons(tgen
, "r1", ["bgpd"])
2704 "Verify that R1 keeps BGP routes in zebra and R2"
2705 " retains the stale entry for received routes from R1"
2708 for addr_type
in ADDR_TYPES
:
2712 next_hop
= next_hop_per_address_family(
2713 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_2
2715 input_topo
= {"r2": topo
["routers"]["r2"]}
2716 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
2717 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2721 next_hop
= next_hop_per_address_family(
2722 tgen
, dut
, peer
, addr_type
, NEXT_HOP_IP_1
2724 input_topo
= {"r1": topo
["routers"]["r1"]}
2725 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
)
2726 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2727 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
, next_hop
, protocol
)
2728 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2730 write_test_footer(tc_name
)
2733 if __name__
== "__main__":
2734 args
= ["-s"] + sys
.argv
[1:]
2735 sys
.exit(pytest
.main(args
))