3 # Copyright (c) 2019 by VMware, Inc. ("VMware")
4 # Used Copyright (c) 2018 by Network Device Education Foundation, Inc. ("NetDEF")
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
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
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
28 - Verify for bgp to converge
29 - Configure BGP Graceful Restart on both the routers.
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
35 Verify the selection deferral timer functionality when EOR is not sent
38 Verify that selection-deferral timer sets the maximum time to
39 avoid deadlock during which the best-path
41 Test Objective : Test GR scenarios on helper router by enabling
42 Graceful Restart for multiple address families.
44 Test Objective : Test GR scenarios by enabling Graceful Restart
45 for multiple address families..
47 Test Objective : Verify BGP-GR feature when restarting node
48 is a transit router for it's iBGP peers.
50 Test Objective : Verify that GR helper router deletes stale routes
51 received from restarting node, if GR capability is not present in
53 Test Objective : Verify that GR routers keeps all the routes
54 received from restarting node if both the routers are
56 Test Objective : Test GR scenarios on helper router by enabling
57 Graceful Restart for multiple address families.
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
62 Test Objective : Change timers on the fly, and
63 verify if it takes immediate effect.
65 Test Objective : Helper router receives same prefixes from two
66 different routers (GR-restarting and GR-disabled). Keeps the
68 Test Objective : Restarting node doesn't preserve forwarding
69 state, helper router should not keep the stale entries.
71 Test Objective : Restarting node doesn't preserve the forwarding
72 state verify the behaviour on helper node, if it still keeps the
74 Test Objective : Restarting node is connected to multiple helper
75 nodes, one of them doesn't send EOR to restarting router. Verify
77 Test Objective : Verify if helper node restarts before sending the
78 EOR message, restarting node doesn't wait until stale path timer
80 Test Objective : Restarting node removes stale routes from Zebra
81 after receiving an EOR from helper router.
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
91 from time
import sleep
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/"))
98 # pylint: disable=C0413
99 # Import topogen and topotest helpers
100 from lib
.topogen
import Topogen
, get_topogen
101 from lib
.topolog
import logger
103 # Required to instantiate the topology builder class.
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 (
110 verify_graceful_restart
,
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
,
122 from lib
.common_config
import (
124 reset_config_on_routers
,
127 start_router_daemons
,
133 get_frr_ipv6_linklocal
,
134 required_linux_kernel_version
,
137 pytestmark
= [pytest
.mark
.bgpd
]
141 BGP_CONVERGENCE
= False
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"]
150 def setup_module(mod
):
152 Sets up the pytest environment
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, kernel version should be >=4.16")
164 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
165 logger
.info("Testsuite start time: {}".format(testsuite_run_time
))
166 logger
.info("=" * 40)
168 logger
.info("Running setup_module to create topology")
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
__)
174 topo
= tgen
.json_topo
175 # ... and here it calls Mininet initialization functions.
177 # Starting topology, create tmp files which are loaded to routers
178 # to start daemons and then start routers
181 # Creating configuration from JSON
182 build_config_from_json(tgen
, topo
)
184 # Api call verify whether BGP is converged
185 ADDR_TYPES
= check_address_types()
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(
193 logger
.info("Running setup_module() done")
196 def teardown_module(mod
):
198 Teardown the pytest environment
203 logger
.info("Running teardown_module to delete topology")
207 # Stop toplogy and Remove tmp files
211 "Testsuite end time: {}".format(time
.asctime(time
.localtime(time
.time())))
213 logger
.info("=" * 40)
216 def configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
, peer
):
218 This function groups the repetitive function calls into one function.
221 logger
.info("configure_gr_followed_by_clear: dut %s peer %s", dut
, peer
)
223 result
= create_router_bgp(tgen
, topo
, input_dict
)
224 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
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
)
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
)
234 result
= verify_bgp_convergence_from_running_config(tgen
)
235 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
240 def next_hop_per_address_family(tgen
, dut
, peer
, addr_type
, next_hop_dict
):
242 This function returns link_local or global next_hop per address-family
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
)
249 next_hop
= next_hop_dict
[addr_type
]
254 def test_BGP_GR_TC_23_p1(request
):
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
262 tc_name
= request
.node
.name
263 write_test_header(tc_name
)
265 # Check router status
266 check_router_status(tgen
)
268 # Don't run this test if we have any failure.
269 if tgen
.routers_have_failure():
270 pytest
.skip(tgen
.errors
)
272 # Creating configuration from JSON
273 reset_config_on_routers(tgen
)
276 "Verify Stale Routes are deleted on helper: BGP_GR_TC_23 >> "
277 "BGP GR [Helper Mode]R1-----R2[Restart Mode] "
280 # Configure graceful-restart
284 "graceful-restart": {"timer": {"stalepath-time": GR_STALEPATH_TIMER
}},
291 "r1": {"graceful-restart-helper": True}
302 "r1": {"graceful-restart-helper": True}
313 "graceful-restart": {
314 "graceful-restart": True,
315 "preserve-fw-state": True,
321 "r1": {"dest_link": {"r2": {"graceful-restart": True}}}
328 "r1": {"dest_link": {"r2": {"graceful-restart": True}}}
337 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r2")
339 for addr_type
in ADDR_TYPES
:
340 result
= verify_graceful_restart(
341 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
343 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
345 # Verifying BGP RIB routes received from router 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
)
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
)
355 logger
.info("R2 goes for reload")
356 kill_router_daemons(tgen
, "r2", ["bgpd"])
358 # Modify configuration to delete routes and include disable-eor
359 input_dict_3
= {"r2": {"bgp": {"graceful-restart": {"disable-eor": True}}}}
361 result
= modify_bgp_config_when_bgpd_down(tgen
, topo
, input_dict_3
)
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
:
372 "advertise_networks": [
374 "network": network
[addr_type
],
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
)
389 logger
.info("BGPd comes up for r2")
390 start_router_daemons(tgen
, "r2", ["bgpd"])
392 # Wait for stalepath timer
393 logger
.info("Waiting for stalepath timer({} sec..)".format(GR_STALEPATH_TIMER
))
394 sleep(GR_STALEPATH_TIMER
)
396 for addr_type
in ADDR_TYPES
:
397 clear_bgp(tgen
, addr_type
, "r2")
399 # Verifying RIB routes
401 network
= {"ipv4": "102.0.20.4/32", "ipv6": "2::4/128"}
402 for addr_type
in ADDR_TYPES
:
409 "advertise_networks": [
410 {"network": network
[addr_type
], "no_of_network": 2}
419 # Verify EOR on helper router
421 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2", expected
=False
423 assert result
is not True, (
424 "Testcase {} : Failed \n "
425 "Expected: EOR should not be set to True in r2\n"
426 "Found: {}".format(tc_name
, result
)
429 # Verifying BGP RIB routes received from router 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
)
434 write_test_footer(tc_name
)
437 def test_BGP_GR_20_p1(request
):
439 Test Objective : Verify that GR routers delete all the routes
440 received from a node if both the routers are configured as GR
445 tc_name
= request
.node
.name
446 write_test_header(tc_name
)
448 # Check router status
449 check_router_status(tgen
)
451 # Don't run this test if we have any failure.
452 if tgen
.routers_have_failure():
453 pytest
.skip(tgen
.errors
)
455 # Creating configuration from JSON
456 reset_config_on_routers(tgen
)
459 "[Step 1] : Test Setup " "[Restart Mode]R3-----R1[Restart Mode] Initialized"
462 # Configure graceful-restart
472 "r1": {"graceful-restart-helper": True}
483 "r1": {"graceful-restart-helper": True}
500 "r3": {"graceful-restart-helper": True}
511 "r3": {"graceful-restart-helper": True}
522 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r3")
524 for addr_type
in ADDR_TYPES
:
525 result
= verify_graceful_restart(
526 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r3"
528 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
530 # Verifying BGP RIB routes
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
)
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
)
540 # Kill BGPd daemon on R1
541 kill_router_daemons(tgen
, "r1", ["bgpd"])
543 for addr_type
in ADDR_TYPES
:
544 # Verifying BGP RIB routes
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 "Expected: Routes should not be present in {} BGP RIB \n "
551 "Found: {}".format(tc_name
, dut
, result
)
554 # Verifying RIB routes before shutting down BGPd daemon
555 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
, expected
=False)
556 assert result
is not True, (
557 "Testcase {} : Failed \n "
558 "Expected: Routes should not be present in {} FIB \n "
559 "Found: {}".format(tc_name
, dut
, result
)
562 # Start BGPd daemon on R1
563 start_router_daemons(tgen
, "r1", ["bgpd"])
565 for addr_type
in ADDR_TYPES
:
566 result
= verify_bgp_convergence(tgen
, topo
)
567 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
569 # Verifying BGP RIB routes
571 input_dict_1
= {key
: topo
["routers"][key
] for key
in ["r1"]}
572 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
)
573 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
575 # Verifying RIB routes before shutting down BGPd daemon
576 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
577 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
579 write_test_footer(tc_name
)
582 def test_BGP_GR_21_p2(request
):
584 Test Objective : VVerify BGP-GR feature when helper node is
585 a transit router for it's eBGP peers.
589 tc_name
= request
.node
.name
590 write_test_header(tc_name
)
592 # Check router status
593 check_router_status(tgen
)
595 # Don't run this test if we have any failure.
596 if tgen
.routers_have_failure():
597 pytest
.skip(tgen
.errors
)
599 # Creating configuration from JSON
600 reset_config_on_routers(tgen
)
603 "[Step 1] : Test Setup " "[Helper Mode]R6-----R1[Restart Mode] Initialized"
606 # Configure graceful-restart
616 "r1": {"graceful-restart-disable": True}
627 "r1": {"graceful-restart-disable": True}
644 "r6": {"graceful-restart-helper": True}
655 "r6": {"graceful-restart-helper": True}
666 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r6")
668 for addr_type
in ADDR_TYPES
:
669 result
= verify_graceful_restart(
670 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r6"
672 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
675 "[Step 2] : Test Setup "
676 "[Restart Mode]R2-----[Helper Mode]R1[Disable Mode]"
677 "--------R6[Helper Mode] Initialized"
680 # Configure graceful-restart
690 "r1": {"graceful-restart-helper": True}
701 "r1": {"graceful-restart-helper": True}
712 "graceful-restart": {
713 "graceful-restart": True,
719 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r2")
721 for addr_type
in ADDR_TYPES
:
722 result
= verify_graceful_restart(
723 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
725 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
727 # Verifying BGP RIB routes
729 input_dict_1
= {key
: topo
["routers"][key
] for key
in ["r1"]}
730 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
)
731 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
733 # Verifying RIB routes before shutting down BGPd daemon
734 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
735 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
737 # Verifying BGP RIB routes
739 input_dict_2
= {key
: topo
["routers"][key
] for key
in ["r2"]}
740 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_2
)
741 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
743 # Verifying RIB routes before shutting down BGPd daemon
744 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
745 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
747 # Kill BGPd daemon on R1
748 kill_router_daemons(tgen
, "r2", ["bgpd"])
750 for addr_type
in ADDR_TYPES
:
751 # Verifying BGP RIB routes
753 input_dict_1
= {key
: topo
["routers"][key
] for key
in ["r1"]}
754 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
)
755 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
757 # Verifying RIB routes before shutting down BGPd daemon
758 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
759 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
761 # Verifying BGP RIB routes
763 input_dict_2
= {key
: topo
["routers"][key
] for key
in ["r2"]}
764 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_2
)
765 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
767 # Verifying RIB routes before shutting down BGPd daemon
768 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
769 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
771 # Start BGPd daemon on R1
772 start_router_daemons(tgen
, "r2", ["bgpd"])
774 for addr_type
in ADDR_TYPES
:
775 result
= verify_bgp_convergence(tgen
, topo
)
776 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
778 # Verifying BGP RIB routes
780 input_dict_1
= {key
: topo
["routers"][key
] for key
in ["r1"]}
781 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
)
782 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
784 # Verifying RIB routes after bringing up BGPd daemon
785 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
786 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
788 # Verifying BGP RIB routes
790 input_dict_2
= {key
: topo
["routers"][key
] for key
in ["r2"]}
791 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_2
)
792 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
794 # Verifying RIB routes before shutting down BGPd daemon
795 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
796 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
798 write_test_footer(tc_name
)
801 def test_BGP_GR_22_p2(request
):
803 Test Objective : Verify BGP-GR feature when helper node
804 is a transit router for it's iBGP peers.
808 tc_name
= request
.node
.name
809 write_test_header(tc_name
)
811 # Check router status
812 check_router_status(tgen
)
814 # Don't run this test if we have any failure.
815 if tgen
.routers_have_failure():
816 pytest
.skip(tgen
.errors
)
818 # Creating configuration from JSON
819 reset_config_on_routers(tgen
)
822 "[Step 1] : Test Setup " "[Helper Mode]R3-----R1[Restart Mode] Initialized"
825 # Configure graceful-restart
836 "graceful-restart-disable": True,
837 "next_hop_self": True,
850 "graceful-restart-disable": True,
851 "next_hop_self": True,
869 "r3": {"graceful-restart-helper": True}
880 "r3": {"graceful-restart-helper": True}
891 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r3")
893 for addr_type
in ADDR_TYPES
:
894 result
= verify_graceful_restart(
895 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r3"
897 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
900 "[Step 2] : Test Setup "
901 "[Restart Mode]R2-----[Helper Mode]R1[Disable Mode]"
902 "--------R3[Helper Mode] Initialized"
905 # Configure graceful-restart
915 "r1": {"graceful-restart-helper": True}
926 "r1": {"graceful-restart-helper": True}
935 "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}},
938 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r2")
940 for addr_type
in ADDR_TYPES
:
941 result
= verify_graceful_restart(
942 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
944 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
946 # Verifying BGP RIB routes
948 input_dict_1
= {key
: topo
["routers"][key
] for key
in ["r1"]}
949 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
)
950 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
952 # Verifying RIB routes before shutting down BGPd daemon
953 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
954 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
956 # Verifying BGP RIB routes
958 input_dict_2
= {key
: topo
["routers"][key
] for key
in ["r2"]}
959 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_2
)
960 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
962 # Verifying RIB routes before shutting down BGPd daemon
963 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
964 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
966 # Kill BGPd daemon on R1
967 kill_router_daemons(tgen
, "r2", ["bgpd"])
969 for addr_type
in ADDR_TYPES
:
970 # Verifying BGP RIB routes
972 input_dict_1
= {key
: topo
["routers"][key
] for key
in ["r1"]}
973 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
)
974 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
976 # Verifying RIB routes before shutting down BGPd daemon
977 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
978 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
980 # Verifying BGP RIB routes
982 input_dict_2
= {key
: topo
["routers"][key
] for key
in ["r2"]}
983 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_2
)
984 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
986 # Verifying RIB routes before shutting down BGPd daemon
987 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
988 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
990 # Start BGPd daemon on R1
991 start_router_daemons(tgen
, "r2", ["bgpd"])
993 for addr_type
in ADDR_TYPES
:
994 result
= verify_bgp_convergence(tgen
, topo
)
995 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
997 # Verifying BGP RIB routes
999 input_dict_1
= {key
: topo
["routers"][key
] for key
in ["r1"]}
1000 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
)
1001 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1003 # Verifying RIB routes before shutting down BGPd daemon
1004 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
1005 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1007 # Verifying BGP RIB routes
1009 input_dict_2
= {key
: topo
["routers"][key
] for key
in ["r2"]}
1010 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_2
)
1011 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1013 # Verifying RIB routes before shutting down BGPd daemon
1014 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
1015 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1017 write_test_footer(tc_name
)
1020 if __name__
== "__main__":
1021 args
= ["-s"] + sys
.argv
[1:]
1022 sys
.exit(pytest
.main(args
))