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 7 routers topology
15 - Verify for bgp to converge
16 - Configure BGP Graceful Restart on both the routers.
19 Verify that EOR message is sent out only after initial convergence
20 Verify whether EOR message is received from all the peers after restart
22 Verify the selection deferral timer functionality when EOR is not sent
25 Verify that selection-deferral timer sets the maximum time to
26 avoid deadlock during which the best-path
28 Test Objective : Test GR scenarios on helper router by enabling
29 Graceful Restart for multiple address families.
31 Test Objective : Test GR scenarios by enabling Graceful Restart
32 for multiple address families..
34 Test Objective : Verify BGP-GR feature when restarting node
35 is a transit router for it's iBGP peers.
37 Test Objective : Verify that GR helper router deletes stale routes
38 received from restarting node, if GR capability is not present in
40 Test Objective : Verify that GR routers keeps all the routes
41 received from restarting node if both the routers are
43 Test Objective : Test GR scenarios on helper router by enabling
44 Graceful Restart for multiple address families.
46 Test Objective : Verify if helper node goes down before restarting
47 node comes up online, helper node sets the R-bit to avoid dead-lock
49 Test Objective : Change timers on the fly, and
50 verify if it takes immediate effect.
52 Test Objective : Helper router receives same prefixes from two
53 different routers (GR-restarting and GR-disabled). Keeps the
55 Test Objective : Restarting node doesn't preserve forwarding
56 state, helper router should not keep the stale entries.
58 Test Objective : Restarting node doesn't preserve the forwarding
59 state verify the behaviour on helper node, if it still keeps the
61 Test Objective : Restarting node is connected to multiple helper
62 nodes, one of them doesn't send EOR to restarting router. Verify
64 Test Objective : Verify if helper node restarts before sending the
65 EOR message, restarting node doesn't wait until stale path timer
67 Test Objective : Restarting node removes stale routes from Zebra
68 after receiving an EOR from helper router.
76 from time
import sleep
78 # Save the Current Working Directory to find configuration files.
79 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
80 sys
.path
.append(os
.path
.join("../"))
81 sys
.path
.append(os
.path
.join("../lib/"))
83 # pylint: disable=C0413
84 # Import topogen and topotest helpers
85 from lib
.topogen
import Topogen
, get_topogen
86 from lib
.topolog
import logger
88 # Required to instantiate the topology builder class.
90 # Import topoJson from lib, to create topology and initial configuration
91 from lib
.topojson
import build_config_from_json
95 verify_graceful_restart
,
100 verify_bgp_convergence
,
101 verify_gr_address_family
,
102 modify_bgp_config_when_bgpd_down
,
103 verify_graceful_restart_timers
,
104 verify_bgp_convergence_from_running_config
,
107 from lib
.common_config
import (
109 reset_config_on_routers
,
112 start_router_daemons
,
118 get_frr_ipv6_linklocal
,
119 required_linux_kernel_version
,
122 pytestmark
= [pytest
.mark
.bgpd
]
126 BGP_CONVERGENCE
= False
128 GR_SELECT_DEFER_TIMER
= 5
129 GR_STALEPATH_TIMER
= 5
130 PREFERRED_NEXT_HOP
= "link_local"
131 NEXT_HOP_4
= ["192.168.1.1", "192.168.4.2"]
132 NEXT_HOP_6
= ["fd00:0:0:1::1", "fd00:0:0:4::2"]
135 def setup_module(mod
):
137 Sets up the pytest environment
142 # Required linux kernel version for this suite to run.
143 result
= required_linux_kernel_version("4.16")
144 if result
is not True:
145 pytest
.skip("Kernel requirements are not met, kernel version should be >=4.16")
149 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
150 logger
.info("Testsuite start time: {}".format(testsuite_run_time
))
151 logger
.info("=" * 40)
153 logger
.info("Running setup_module to create topology")
155 # This function initiates the topology build with Topogen...
156 json_file
= "{}/bgp_gr_topojson_topo2.json".format(CWD
)
157 tgen
= Topogen(json_file
, mod
.__name
__)
159 topo
= tgen
.json_topo
160 # ... and here it calls Mininet initialization functions.
162 # Starting topology, create tmp files which are loaded to routers
163 # to start daemons and then start routers
166 # Creating configuration from JSON
167 build_config_from_json(tgen
, topo
)
169 # Api call verify whether BGP is converged
170 ADDR_TYPES
= check_address_types()
172 for addr_type
in ADDR_TYPES
:
173 BGP_CONVERGENCE
= verify_bgp_convergence(tgen
, topo
)
174 assert BGP_CONVERGENCE
is True, "setup_module : Failed \n Error:" " {}".format(
178 logger
.info("Running setup_module() done")
181 def teardown_module(mod
):
183 Teardown the pytest environment
188 logger
.info("Running teardown_module to delete topology")
192 # Stop toplogy and Remove tmp files
196 "Testsuite end time: {}".format(time
.asctime(time
.localtime(time
.time())))
198 logger
.info("=" * 40)
201 def configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
, peer
):
203 This function groups the repetitive function calls into one function.
206 logger
.info("configure_gr_followed_by_clear: dut %s peer %s", dut
, peer
)
208 result
= create_router_bgp(tgen
, topo
, input_dict
)
209 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
211 for addr_type
in ADDR_TYPES
:
212 neighbor
= topo
["routers"][peer
]["links"][dut
][addr_type
].split("/")[0]
213 clear_bgp(tgen
, addr_type
, dut
, neighbor
=neighbor
)
215 for addr_type
in ADDR_TYPES
:
216 neighbor
= topo
["routers"][dut
]["links"][peer
][addr_type
].split("/")[0]
217 clear_bgp(tgen
, addr_type
, peer
, neighbor
=neighbor
)
219 result
= verify_bgp_convergence_from_running_config(tgen
)
220 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
225 def next_hop_per_address_family(tgen
, dut
, peer
, addr_type
, next_hop_dict
):
227 This function returns link_local or global next_hop per address-family
230 intferface
= topo
["routers"][peer
]["links"]["{}-link1".format(dut
)]["interface"]
231 if addr_type
== "ipv6" and "link_local" in PREFERRED_NEXT_HOP
:
232 next_hop
= get_frr_ipv6_linklocal(tgen
, peer
, intf
=intferface
)
234 next_hop
= next_hop_dict
[addr_type
]
239 def test_BGP_GR_26_p2(request
):
241 Test Objective : Test GR scenarios on helper router by enabling
242 Graceful Restart for multiple address families.
246 tc_name
= request
.node
.name
247 write_test_header(tc_name
)
249 # Check router status
250 check_router_status(tgen
)
252 # Don't run this test if we have any failure.
253 if tgen
.routers_have_failure():
254 pytest
.skip(tgen
.errors
)
256 # Creating configuration from JSON
257 reset_config_on_routers(tgen
)
260 "[Step 1] : Test Setup " "[Helper Mode]R3-----R1[Restart Mode] initialized"
263 # Configure graceful-restart
274 "graceful-restart": True,
275 "next_hop_self": True,
289 "graceful-restart": True,
290 "next_hop_self": True,
310 "graceful-restart-helper": True,
324 "graceful-restart-helper": True,
337 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r3")
339 for addr_type
in ADDR_TYPES
:
340 result
= verify_graceful_restart(
341 tgen
, topo
, addr_type
, input_dict
, dut
="r3", peer
="r1"
343 assert result
is True, "Testcase {} : Failed \n Error {}".format(
347 # Verifying BGP RIB routes
349 input_topo
= {key
: topo
["routers"][key
] for key
in ["r1"]}
350 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
)
351 assert result
is True, "Testcase {} : Failed \n Error {}".format(
355 # Verifying RIB routes before shutting down BGPd daemon
356 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
)
357 assert result
is True, "Testcase {} : Failed \n Error {}".format(
361 # Kill BGPd daemon on R1
362 kill_router_daemons(tgen
, "r1", ["bgpd"])
364 for addr_type
in ADDR_TYPES
:
365 # Verifying BGP RIB routes
366 input_topo
= {key
: topo
["routers"][key
] for key
in ["r1"]}
367 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
)
368 assert result
is True, "Testcase {} : Failed \n Error {}".format(
372 # Verifying RIB routes before shutting down BGPd daemon
373 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
)
374 assert result
is True, "Testcase {} : Failed \n Error {}".format(
378 # Start BGPd daemon on R1
379 start_router_daemons(tgen
, "r1", ["bgpd"])
381 for addr_type
in ADDR_TYPES
:
382 # Verifying BGP RIB routes
383 input_topo
= {key
: topo
["routers"][key
] for key
in ["r1"]}
384 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_topo
)
385 assert result
is True, "Testcase {} : Failed \n Error {}".format(
389 # Verifying RIB routes before shutting down BGPd daemon
390 result
= verify_rib(tgen
, addr_type
, dut
, input_topo
)
391 assert result
is True, "Testcase {} : Failed \n Error {}".format(
395 # verify multi address family
396 result
= verify_gr_address_family(
404 assert result
is True, "Testcase {} : Failed \n Error {}".format(
408 # verify multi address family
409 result
= verify_gr_address_family(
417 assert result
is True, "Testcase {} : Failed \n Error {}".format(
421 # verify multi address family
422 result
= verify_gr_address_family(
430 assert result
is True, "Testcase {} : Failed \n Error {}".format(
434 # verify multi address family
435 result
= verify_gr_address_family(
443 assert result
is True, "Testcase {} : Failed \n Error {}".format(
447 write_test_footer(tc_name
)
450 def test_BGP_GR_chaos_28_p1(request
):
452 Test Objective : Verify if helper node goes down before restarting
453 node comes up online, helper node sets the R-bit to avoid dead-lock
458 tc_name
= request
.node
.name
459 write_test_header(tc_name
)
461 # Check router status
462 check_router_status(tgen
)
464 # Don't run this test if we have any failure.
465 if tgen
.routers_have_failure():
466 pytest
.skip(tgen
.errors
)
468 # Creating configuration from JSON
469 reset_config_on_routers(tgen
)
472 "Test Case: test_BGP_GR_chaos_28 :"
473 "[Helper Mode]R3-----R1[Restart Mode] initialized"
476 # Configure graceful-restart
484 "r3": {"dest_link": {"r1": {"graceful-restart": True}}}
491 "r3": {"dest_link": {"r1": {"graceful-restart": True}}}
506 "r3": {"graceful-restart-helper": True}
517 "r3": {"graceful-restart-helper": True}
528 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r3")
530 for addr_type
in ADDR_TYPES
:
531 result
= verify_graceful_restart(
532 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r3"
534 assert result
is True, "Testcase {} : Failed \n Error {}".format(
538 logger
.info("[Step 1] : Kill BGPd daemon on R1..")
540 # Kill BGPd daemon on R1
541 kill_router_daemons(tgen
, "r1", ["bgpd"])
543 logger
.info("[Step 2] : Kill BGPd daemon on R3..")
545 # Kill BGPd daemon on R3
546 kill_router_daemons(tgen
, "r3", ["bgpd"])
548 logger
.info("[Step 3] : Start BGPd daemon on R1..")
550 # Start BGPd daemon on R1
551 start_router_daemons(tgen
, "r1", ["bgpd"])
553 logger
.info("[Step 4] : Start BGPd daemon on R3..")
555 # Start BGPd daemon on R3
556 start_router_daemons(tgen
, "r3", ["bgpd"])
559 for addr_type
in ADDR_TYPES
:
560 result
= verify_r_bit(tgen
, topo
, addr_type
, input_dict
, dut
="r3", peer
="r1")
561 assert result
is True, "Testcase {} : Failed \n Error {}".format(
565 write_test_footer(tc_name
)
568 def test_BGP_GR_chaos_29_p1(request
):
570 Test Objective : Change timers on the fly, and
571 verify if it takes immediate effect.
575 tc_name
= request
.node
.name
576 write_test_header(tc_name
)
578 # Check router status
579 check_router_status(tgen
)
581 # Don't run this test if we have any failure.
582 if tgen
.routers_have_failure():
583 pytest
.skip(tgen
.errors
)
585 # Creating configuration from JSON
586 reset_config_on_routers(tgen
)
589 " Test Case : test_BGP_GR_chaos_29"
590 " BGP GR [Helper Mode]R3-----R1[Restart Mode]"
591 " and [restart-time 150]R1 initialized"
594 # Configure graceful-restart and timers
598 "graceful-restart": {"timer": {"restart-time": GR_RESTART_TIMER
}},
603 "r3": {"dest_link": {"r1": {"graceful-restart": True}}}
610 "r3": {"dest_link": {"r1": {"graceful-restart": True}}}
625 "r3": {"graceful-restart-helper": True}
636 "r3": {"graceful-restart-helper": True}
647 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r3")
649 for addr_type
in ADDR_TYPES
:
650 result
= verify_graceful_restart(
651 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r3"
653 assert result
is True, "Testcase {} : Failed \n Error {}".format(
657 # Verify graceful-restart timers
661 "graceful-restart": {"timer": {"restart-time": GR_RESTART_TIMER
+ 5}}
666 result
= create_router_bgp(tgen
, topo
, input_dict_2
)
667 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
669 for addr_type
in ADDR_TYPES
:
673 "graceful-restart": {"timer": {"restart-time": GR_RESTART_TIMER
}}
678 result
= verify_graceful_restart_timers(
679 tgen
, topo
, addr_type
, input_dict_2
, dut
="r3", peer
="r1"
681 assert result
is True, "Testcase {} : Failed \n Error {}".format(
685 for addr_type
in ADDR_TYPES
:
686 # Verifying BGP RIB routes before shutting down BGPd daemon
688 input_dict
= {key
: topo
["routers"][key
] for key
in ["r1"]}
689 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict
)
690 assert result
is True, "Testcase {} : Failed \n Error {}".format(
694 # Verifying RIB routes before shutting down BGPd daemon
695 result
= verify_rib(tgen
, addr_type
, dut
, input_dict
)
696 assert result
is True, "Testcase {} : Failed \n Error {}".format(
700 logger
.info("[Step 2] : Kill BGPd daemon on R1..")
702 # Kill BGPd daemon on R1
703 kill_router_daemons(tgen
, "r1", ["bgpd"])
705 logger
.info("[Step 3] : Wait for {} seconds..".format(GR_RESTART_TIMER
))
707 # Waiting for GR_RESTART_TIMER
708 sleep(GR_RESTART_TIMER
)
710 for addr_type
in ADDR_TYPES
:
711 # Verifying BGP RIB routes before shutting down BGPd daemon
712 input_dict
= {key
: topo
["routers"][key
] for key
in ["r1"]}
713 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict
, expected
=False)
714 assert result
is not True, (
715 "Testcase {} : Failed \n "
716 "Expected: Routes should not be present in {} BGP RIB \n "
717 "Found: {}".format(tc_name
, dut
, result
)
720 # Verifying RIB routes before shutting down BGPd daemon
721 result
= verify_rib(tgen
, addr_type
, dut
, input_dict
, expected
=False)
722 assert result
is not True, (
723 "Testcase {} : Failed \n "
724 "Expected: Routes should not be present in {} FIB \n "
725 "Found: {}".format(tc_name
, dut
, result
)
728 logger
.info("[Step 4] : Start BGPd daemon on R1..")
730 # Start BGPd daemon on R1
731 start_router_daemons(tgen
, "r1", ["bgpd"])
733 write_test_footer(tc_name
)
736 def test_BGP_GR_chaos_33_p1(request
):
738 Test Objective : Helper router receives same prefixes from two
739 different routers (GR-restarting and GR-disabled). Keeps the
740 stale entry only for GR-restarting node(next-hop is correct).
744 tc_name
= request
.node
.name
745 write_test_header(tc_name
)
747 # Check router status
748 check_router_status(tgen
)
750 # Don't run this test if we have any failure.
751 if tgen
.routers_have_failure():
752 pytest
.skip(tgen
.errors
)
754 # Creating configuration from JSON
755 reset_config_on_routers(tgen
)
758 " Test Case : test_BGP_GR_chaos_33 "
760 "[Restart Mode]R1--R3[Helper Mode]--R4[Disabled Mode]"
763 # Configure graceful-restart
771 "r3": {"dest_link": {"r1": {"graceful-restart": True}}}
778 "r3": {"dest_link": {"r1": {"graceful-restart": True}}}
793 "r3": {"graceful-restart-helper": True}
804 "r3": {"graceful-restart-helper": True}
821 "r4": {"graceful-restart-disable": True}
832 "r4": {"graceful-restart-disable": True}
843 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r3")
845 for addr_type
in ADDR_TYPES
:
846 result
= verify_graceful_restart(
847 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r3"
849 assert result
is True, "Testcase {} : Failed \n Error {}".format(
853 logger
.info("[Step 2] : Advertise same networks from R1 and R4..")
855 # Api call to delete advertised networks
862 "advertise_networks": [
864 "network": "200.0.20.1/32",
872 "advertise_networks": [
873 {"network": "2001::1/128", "no_of_network": 2}
885 "advertise_networks": [
886 {"network": "200.0.20.1/32", "no_of_network": 2}
892 "advertise_networks": [
893 {"network": "2001::1/128", "no_of_network": 2}
902 result
= create_router_bgp(tgen
, topo
, input_dict_2
)
903 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
905 for addr_type
in ADDR_TYPES
:
906 # Verifying RIB routes
910 intf1
= topo
["routers"][peer1
]["links"][dut
]["interface"]
911 intf2
= topo
["routers"][peer2
]["links"][dut
]["interface"]
913 if addr_type
== "ipv4":
914 next_hop_4
= NEXT_HOP_4
915 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
, next_hop_4
)
916 assert result
is True, "Testcase {} : Failed \n Error {}".format(
920 if addr_type
== "ipv6":
921 if "link_local" in PREFERRED_NEXT_HOP
:
922 next_hop1
= get_frr_ipv6_linklocal(tgen
, peer1
, intf
=intf1
)
923 next_hop2
= get_frr_ipv6_linklocal(tgen
, peer2
, intf
=intf2
)
925 next_hop_6
= [next_hop1
, next_hop2
]
927 next_hop_6
= NEXT_HOP_6
929 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
, next_hop_6
)
930 assert result
is True, "Testcase {} : Failed \n Error {}".format(
934 logger
.info("[Step 3] : Kill BGPd daemon on R1 and R4..")
936 # Kill BGPd daemon on R1
937 kill_router_daemons(tgen
, "r1", ["bgpd"])
939 # Kill BGPd daemon on R4
940 kill_router_daemons(tgen
, "r4", ["bgpd"])
942 for addr_type
in ADDR_TYPES
:
943 # Verifying RIB routes
944 next_hop_6
= ["fd00:0:0:1::1"]
945 if addr_type
== "ipv4":
946 next_hop_4
= NEXT_HOP_4
[0]
948 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
, next_hop_4
)
949 assert result
is True, "Testcase {} : Failed \n Error {}".format(
953 if addr_type
== "ipv6":
954 if "link_local" in PREFERRED_NEXT_HOP
:
955 next_hop_6
= get_frr_ipv6_linklocal(tgen
, peer1
, intf
=intf1
)
957 next_hop_6
= NEXT_HOP_6
[0]
959 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
, next_hop_6
)
961 # Verifying RIB routes
962 if addr_type
== "ipv4":
963 next_hop_4
= NEXT_HOP_4
[1]
965 tgen
, addr_type
, dut
, input_dict_2
, next_hop_4
, expected
=False
967 assert result
is not True, (
968 "Testcase {} : Failed \n "
969 "Expected: Routes should not be present in {} FIB \n "
970 "Found: {}".format(tc_name
, dut
, result
)
973 if addr_type
== "ipv6":
974 if "link_local" in PREFERRED_NEXT_HOP
:
975 next_hop_6
= get_frr_ipv6_linklocal(tgen
, peer2
, intf
=intf2
)
977 next_hop_6
= NEXT_HOP_6
[1]
980 tgen
, addr_type
, dut
, input_dict_2
, next_hop_6
, expected
=False
982 assert result
is not True, (
983 "Testcase {} : Failed \n "
984 "Expected: Routes should not be present in {} FIB \n "
985 "Found: {}".format(tc_name
, dut
, result
)
988 logger
.info("[Step 4] : Start BGPd daemon on R1 and R4..")
990 # Start BGPd daemon on R1
991 start_router_daemons(tgen
, "r1", ["bgpd"])
993 # Start BGPd daemon on R4
994 start_router_daemons(tgen
, "r4", ["bgpd"])
996 write_test_footer(tc_name
)
999 def test_BGP_GR_chaos_34_2_p1(request
):
1001 Test Objective : Restarting node doesn't preserve the forwarding
1002 state verify the behaviour on helper node, if it still keeps the
1006 tgen
= get_topogen()
1007 tc_name
= request
.node
.name
1008 write_test_header(tc_name
)
1010 # Check router status
1011 check_router_status(tgen
)
1013 # Don't run this test if we have any failure.
1014 if tgen
.routers_have_failure():
1015 pytest
.skip(tgen
.errors
)
1017 # Creating configuration from JSON
1018 reset_config_on_routers(tgen
)
1021 " Test Case : test_BGP_GR_chaos_34 "
1023 "[Restart Mode]R1---R3[Helper Mode]"
1026 logger
.info("[Step 1] : Configure restarting" " router R1 to prevent ")
1027 logger
.info("[Step 2] : Reset the session" " between R1 and R3..")
1029 # Configure graceful-restart
1033 "graceful-restart": {"preserve-fw-state": True, "disable-eor": True},
1038 "r3": {"dest_link": {"r1": {"graceful-restart": True}}}
1045 "r3": {"dest_link": {"r1": {"graceful-restart": True}}}
1060 "r3": {"graceful-restart-helper": True}
1071 "r3": {"graceful-restart-helper": True}
1082 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r3")
1084 for addr_type
in ADDR_TYPES
:
1085 result
= verify_graceful_restart(
1086 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r3"
1088 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1092 # Verify f-bit before killing BGPd daemon
1093 result
= verify_f_bit(tgen
, topo
, addr_type
, input_dict
, "r3", "r1")
1094 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1098 # Verifying BGP RIB routes after starting BGPd daemon
1100 input_dict_1
= {key
: topo
["routers"][key
] for key
in ["r1"]}
1101 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
)
1102 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1106 # Verifying RIB routes
1107 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
1108 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1112 logger
.info("[Step 3] : Kill BGPd daemon on R1..")
1114 # Kill BGPd daemon on R1
1115 kill_router_daemons(tgen
, "r1", ["bgpd"])
1117 logger
.info("[Step 4] : Withdraw/delete the prefixes " "originated from R1..")
1119 # Api call to delete advertised networks
1120 network
= {"ipv4": "101.0.20.1/32", "ipv6": "1::1/128"}
1121 for addr_type
in ADDR_TYPES
:
1128 "advertise_networks": [
1130 "network": network
[addr_type
],
1142 result
= modify_bgp_config_when_bgpd_down(tgen
, topo
, input_dict_2
)
1143 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1147 logger
.info("[Step 5] : Remove the CLI from R1's config to " "set the F-bit..")
1149 # Modify graceful-restart config not to set f-bit
1150 # and write to /etc/frr
1151 input_dict_2
= {"r1": {"bgp": {"graceful-restart": {"preserve-fw-state": False}}}}
1153 result
= modify_bgp_config_when_bgpd_down(tgen
, topo
, input_dict_2
)
1154 assert result
is True, "Testcase {} : Failed \n Error {}".format(tc_name
, result
)
1156 logger
.info("[Step 6] : Bring up the BGPd daemon on R1 again..")
1158 # Start BGPd daemon on R1
1159 start_router_daemons(tgen
, "r1", ["bgpd"])
1161 for addr_type
in ADDR_TYPES
:
1162 # Verify f-bit after starting BGPd daemon
1163 result
= verify_f_bit(
1164 tgen
, topo
, addr_type
, input_dict
, "r3", "r1", expected
=False
1166 assert result
is not True, (
1167 "Testcase {} : Failed \n "
1168 "Expected: F-bit should not be set to True in r3\n"
1169 "Found: {}".format(tc_name
, result
)
1172 # Verifying BGP RIB routes after starting BGPd daemon
1173 input_dict_1
= {key
: topo
["routers"][key
] for key
in ["r1"]}
1174 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
, expected
=False)
1175 assert result
is not True, (
1176 "Testcase {} : Failed \n "
1177 "Expected: Routes should not be present in {} BGP RIB \n "
1178 "Found: {}".format(tc_name
, dut
, result
)
1181 # Verifying RIB routes
1182 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
, expected
=False)
1183 assert result
is not True, (
1184 "Testcase {} : Failed \n "
1185 "Expected: Routes should not be present in {} FIB \n "
1186 "Found: {}".format(tc_name
, dut
, result
)
1189 write_test_footer(tc_name
)
1192 if __name__
== "__main__":
1193 args
= ["-s"] + sys
.argv
[1:]
1194 sys
.exit(pytest
.main(args
))