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")
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 deamons 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
425 ), "Testcase {} : Failed \n " "r1: EOR is set to True\n Error: {}".format(
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] Initilized"
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 "r3: routes are still present in BGP RIB\n Error: {}".format(
554 logger
.info(" Expected behavior: {}".format(result
))
556 # Verifying RIB routes before shutting down BGPd daemon
557 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
, expected
=False)
558 assert result
is not True, (
559 "Testcase {} : Failed \n "
560 "r3: routes are still present in ZEBRA\n Error: {}".format(tc_name
, result
)
562 logger
.info(" Expected behavior: {}".format(result
))
564 # Start BGPd daemon on R1
565 start_router_daemons(tgen
, "r1", ["bgpd"])
567 for addr_type
in ADDR_TYPES
:
568 result
= verify_bgp_convergence(tgen
, topo
)
569 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
571 # Verifying BGP RIB routes
573 input_dict_1
= {key
: topo
["routers"][key
] for key
in ["r1"]}
574 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
)
575 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
577 # Verifying RIB routes before shutting down BGPd daemon
578 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
579 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
581 write_test_footer(tc_name
)
584 def test_BGP_GR_21_p2(request
):
586 Test Objective : VVerify BGP-GR feature when helper node is
587 a transit router for it's eBGP peers.
591 tc_name
= request
.node
.name
592 write_test_header(tc_name
)
594 # Check router status
595 check_router_status(tgen
)
597 # Don't run this test if we have any failure.
598 if tgen
.routers_have_failure():
599 pytest
.skip(tgen
.errors
)
601 # Creating configuration from JSON
602 reset_config_on_routers(tgen
)
605 "[Step 1] : Test Setup " "[Helper Mode]R6-----R1[Restart Mode] Initilized"
608 # Configure graceful-restart
618 "r1": {"graceful-restart-disable": True}
629 "r1": {"graceful-restart-disable": True}
646 "r6": {"graceful-restart-helper": True}
657 "r6": {"graceful-restart-helper": True}
668 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r6")
670 for addr_type
in ADDR_TYPES
:
671 result
= verify_graceful_restart(
672 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r6"
674 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
677 "[Step 2] : Test Setup "
678 "[Restart Mode]R2-----[Helper Mode]R1[Disable Mode]"
679 "--------R6[Helper Mode] Initilized"
682 # Configure graceful-restart
692 "r1": {"graceful-restart-helper": True}
703 "r1": {"graceful-restart-helper": True}
714 "graceful-restart": {
715 "graceful-restart": True,
721 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r2")
723 for addr_type
in ADDR_TYPES
:
724 result
= verify_graceful_restart(
725 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
727 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
729 # Verifying BGP RIB routes
731 input_dict_1
= {key
: topo
["routers"][key
] for key
in ["r1"]}
732 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
)
733 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
735 # Verifying RIB routes before shutting down BGPd daemon
736 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
737 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
739 # Verifying BGP RIB routes
741 input_dict_2
= {key
: topo
["routers"][key
] for key
in ["r2"]}
742 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_2
)
743 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
745 # Verifying RIB routes before shutting down BGPd daemon
746 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
747 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
749 # Kill BGPd daemon on R1
750 kill_router_daemons(tgen
, "r2", ["bgpd"])
752 for addr_type
in ADDR_TYPES
:
753 # Verifying BGP RIB routes
755 input_dict_1
= {key
: topo
["routers"][key
] for key
in ["r1"]}
756 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
)
757 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
759 # Verifying RIB routes before shutting down BGPd daemon
760 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
761 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
763 # Verifying BGP RIB routes
765 input_dict_2
= {key
: topo
["routers"][key
] for key
in ["r2"]}
766 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_2
)
767 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
769 # Verifying RIB routes before shutting down BGPd daemon
770 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
771 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
773 # Start BGPd daemon on R1
774 start_router_daemons(tgen
, "r2", ["bgpd"])
776 for addr_type
in ADDR_TYPES
:
777 result
= verify_bgp_convergence(tgen
, topo
)
778 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
780 # Verifying BGP RIB routes
782 input_dict_1
= {key
: topo
["routers"][key
] for key
in ["r1"]}
783 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
)
784 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
786 # Verifying RIB routes after bringing up BGPd daemon
787 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
788 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
790 # Verifying BGP RIB routes
792 input_dict_2
= {key
: topo
["routers"][key
] for key
in ["r2"]}
793 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_2
)
794 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
796 # Verifying RIB routes before shutting down BGPd daemon
797 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
798 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
800 write_test_footer(tc_name
)
803 def test_BGP_GR_22_p2(request
):
805 Test Objective : Verify BGP-GR feature when helper node
806 is a transit router for it's iBGP peers.
810 tc_name
= request
.node
.name
811 write_test_header(tc_name
)
813 # Check router status
814 check_router_status(tgen
)
816 # Don't run this test if we have any failure.
817 if tgen
.routers_have_failure():
818 pytest
.skip(tgen
.errors
)
820 # Creating configuration from JSON
821 reset_config_on_routers(tgen
)
824 "[Step 1] : Test Setup " "[Helper Mode]R3-----R1[Restart Mode] Initilized"
827 # Configure graceful-restart
838 "graceful-restart-disable": True,
839 "next_hop_self": True,
852 "graceful-restart-disable": True,
853 "next_hop_self": True,
871 "r3": {"graceful-restart-helper": True}
882 "r3": {"graceful-restart-helper": True}
893 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r3")
895 for addr_type
in ADDR_TYPES
:
896 result
= verify_graceful_restart(
897 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r3"
899 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
902 "[Step 2] : Test Setup "
903 "[Restart Mode]R2-----[Helper Mode]R1[Disable Mode]"
904 "--------R3[Helper Mode] Initilized"
907 # Configure graceful-restart
917 "r1": {"graceful-restart-helper": True}
928 "r1": {"graceful-restart-helper": True}
937 "r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}},
940 configure_gr_followed_by_clear(tgen
, topo
, input_dict
, tc_name
, dut
="r1", peer
="r2")
942 for addr_type
in ADDR_TYPES
:
943 result
= verify_graceful_restart(
944 tgen
, topo
, addr_type
, input_dict
, dut
="r1", peer
="r2"
946 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
948 # Verifying BGP RIB routes
950 input_dict_1
= {key
: topo
["routers"][key
] for key
in ["r1"]}
951 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
)
952 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
954 # Verifying RIB routes before shutting down BGPd daemon
955 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
956 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
958 # Verifying BGP RIB routes
960 input_dict_2
= {key
: topo
["routers"][key
] for key
in ["r2"]}
961 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_2
)
962 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
964 # Verifying RIB routes before shutting down BGPd daemon
965 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
966 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
968 # Kill BGPd daemon on R1
969 kill_router_daemons(tgen
, "r2", ["bgpd"])
971 for addr_type
in ADDR_TYPES
:
972 # Verifying BGP RIB routes
974 input_dict_1
= {key
: topo
["routers"][key
] for key
in ["r1"]}
975 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
)
976 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
978 # Verifying RIB routes before shutting down BGPd daemon
979 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
980 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
982 # Verifying BGP RIB routes
984 input_dict_2
= {key
: topo
["routers"][key
] for key
in ["r2"]}
985 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_2
)
986 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
988 # Verifying RIB routes before shutting down BGPd daemon
989 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
990 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
992 # Start BGPd daemon on R1
993 start_router_daemons(tgen
, "r2", ["bgpd"])
995 for addr_type
in ADDR_TYPES
:
996 result
= verify_bgp_convergence(tgen
, topo
)
997 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
999 # Verifying BGP RIB routes
1001 input_dict_1
= {key
: topo
["routers"][key
] for key
in ["r1"]}
1002 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
)
1003 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1005 # Verifying RIB routes before shutting down BGPd daemon
1006 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
1007 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1009 # Verifying BGP RIB routes
1011 input_dict_2
= {key
: topo
["routers"][key
] for key
in ["r2"]}
1012 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_2
)
1013 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1015 # Verifying RIB routes before shutting down BGPd daemon
1016 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
1017 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1019 write_test_footer(tc_name
)
1022 if __name__
== "__main__":
1023 args
= ["-s"] + sys
.argv
[1:]
1024 sys
.exit(pytest
.main(args
))