]>
git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/bgp_unique_rid/test_bgp_unique_rid.py
4 # Copyright (c) 2022 by VMware, Inc. ("VMware")
5 # Used Copyright (c) 2018 by Network Device Education Foundation,
6 # Inc. ("NetDEF") in this file.
8 # Permission to use, copy, modify, and/or distribute this software
9 # for any purpose with or without fee is hereby granted, provided
10 # that the above copyright notice and this permission notice appear
13 # THE SOFTWARE IS PROVIDED "AS IS" AND VMWARE DISCLAIMS ALL WARRANTIES
14 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL VMWARE BE LIABLE FOR
16 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
17 # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
18 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
19 # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
28 from copy
import deepcopy
30 # Save the Current Working Directory to find configuration files.
31 CWD
= os
. path
. dirname ( os
. path
. realpath ( __file__
))
32 sys
. path
. append ( os
. path
. join ( CWD
, "../" ))
33 sys
. path
. append ( os
. path
. join ( CWD
, "../lib/" ))
35 """Following tests are covered to test bgp unique rid functionality.
36 1. Verify eBGP session when same and different router ID is configured.
37 2. Verify iBGP session when same and different router ID is configured.
38 3. Verify two different eBGP sessions initiated with same router ID.
39 4. Chaos - Verify bgp unique rid functionality in chaos scenarios.
40 5. Chaos - Verify bgp unique rid functionality when router reboots with same loopback id.
41 6. Chaos - Verify bgp unique rid functionality when router reboots without any ip addresses.
44 #################################
46 #################################
57 | iBGP +-------+ eBGP +-------+
58 +---------- | R3 |========= | R4 |
70 # pylint: disable=C0413
71 # Import topogen and topotest helpers
72 from lib
. topogen
import Topogen
, get_topogen
73 from lib
. topojson
import build_config_from_json
74 from lib
. topolog
import logger
76 pytestmark
= [ pytest
. mark
. bgpd
, pytest
. mark
. ospfd
, pytest
. mark
. staticd
]
78 # Required to instantiate the topology builder class.
79 from lib
. common_config
import (
86 reset_config_on_routers
,
93 from lib
. topolog
import logger
95 verify_bgp_convergence
,
102 bgp_convergence
= False
122 bgp_convergence
= False
123 ADDR_TYPES
= check_address_types ()
124 routerid
= { "ipv4" : "10.10.10.14" , "ipv6" : "fd00:0:0:3::2" }
127 def setup_module ( mod
):
130 Set up the pytest environment
134 testsuite_run_time
= time
. asctime ( time
. localtime ( time
. time ()))
135 logger
. info ( "Testsuite start time: {}" . format ( testsuite_run_time
))
136 logger
. info ( "=" * 40 )
138 logger
. info ( "Running setup_module to create topology" )
140 # This function initiates the topology build with Topogen...
141 json_file
= "{}/bgp_unique_rid.json" . format ( CWD
)
142 tgen
= Topogen ( json_file
, mod
.__ name
__ )
144 topo
= tgen
. json_topo
145 # ... and here it calls Mininet initialization functions.
147 # Starting topology, create tmp files which are loaded to routers
148 # to start daemons and then start routers
151 # Creating configuration from JSON
152 build_config_from_json ( tgen
, topo
)
154 # Checking BGP convergence
155 global bgp_convergence
158 # Don't run this test if we have any failure.
159 if tgen
. routers_have_failure ():
160 pytest
. skip ( tgen
. errors
)
162 # Api call verify whether BGP is converged
163 bgp_convergence
= verify_bgp_convergence ( tgen
, topo
)
164 assert bgp_convergence
is True , "setup_module :Failed \n Error:" " {}" . format (
167 logger
. info ( "Running setup_module() done" )
170 def teardown_module ():
171 """Teardown the pytest environment"""
173 logger
. info ( "Running teardown_module to delete topology" )
177 # Stop toplogy and Remove tmp files
181 "Testsuite end time: {}" . format ( time
. asctime ( time
. localtime ( time
. time ())))
183 logger
. info ( "=" * 40 )
186 #####################################################
188 #####################################################
191 def test_bgp_unique_rid_ebgp_p0 ():
194 Verify eBGP session when same and different router ID is configured.
197 global bgp_convergence
199 if bgp_convergence
is not True :
200 pytest
. skip ( "skipped because of BGP Convergence failure" )
203 tc_name
= inspect
. stack ()[ 0 ][ 3 ]
204 write_test_header ( tc_name
)
205 if tgen
. routers_have_failure ():
206 check_router_status ( tgen
)
208 step ( "Configure base config as per the topology" )
209 reset_config_on_routers ( tgen
)
212 "Base config should be up, verify using BGP convergence on all \
213 the routers for IPv4 and IPv6 nbrs"
216 result
= verify_bgp_convergence ( tgen
, topo
)
217 assert result
is True , "Testcase {} :Failed \n Error: {}" . format ( tc_name
, result
)
219 step ( "Configure the same router id between R4 and R3 10.10.10.10" )
221 "r3" : { "bgp" : { "router_id" : "10.10.10.10" }},
222 "r4" : { "bgp" : { "router_id" : "10.10.10.10" }},
224 result
= create_router_bgp ( tgen
, topo
, input_dict
)
225 assert result
is True , "Testcase {} :Failed \n Error: {}" . format ( tc_name
, result
)
227 step ( "Verify neighbours are in ESTAB state." )
228 result
= verify_bgp_convergence ( tgen
, topo
)
229 assert result
is True , "Testcase {} :Failed \n Error: {}" . format ( tc_name
, result
)
231 step ( "Configure the same router id between R5 and R3 (10.10.10.10)" )
233 "r3" : { "bgp" : { "router_id" : "10.10.10.10" }},
234 "r5" : { "bgp" : { "router_id" : "10.10.10.10" }},
236 result
= create_router_bgp ( tgen
, topo
, input_dict
)
237 assert result
is True , "Testcase {} :Failed \n Error: {}" . format ( tc_name
, result
)
239 step ( "Verify neighbours are in ESTAB state." )
240 result
= verify_bgp_convergence ( tgen
, topo
)
241 assert result
is True , "Testcase {} :Failed \n Error: {}" . format ( tc_name
, result
)
243 step ( "modify the router id on r3 to different router id (11.11.11.11)" )
244 input_dict
= { "r3" : { "bgp" : { "router_id" : "11.11.11.11" }}}
245 result
= create_router_bgp ( tgen
, topo
, input_dict
)
246 assert result
is True , "Testcase {} :Failed \n Error: {}" . format ( tc_name
, result
)
248 step ( "Verify neighbours are in ESTAB state." )
249 result
= verify_bgp_convergence ( tgen
, topo
)
250 assert result
is True , "Testcase {} :Failed \n Error: {}" . format ( tc_name
, result
)
252 step ( "Reset bgp process" )
253 step ( "Verify neighbours are in ESTAB state." )
255 result
= clear_bgp_and_verify ( tgen
, topo
, dut
)
256 assert result
is True , "Testcase {} : Failed \n Error: {}" . format ( tc_name
, result
)
258 step ( "Clear ip bgp process with *" )
259 step ( "Verify neighbours are in ESTAB state." )
260 result
= clear_bgp_and_verify ( tgen
, topo
, dut
)
261 assert result
is True , "Testcase {} : Failed \n Error: {}" . format ( tc_name
, result
)
263 step ( "Configure neighbours between R3 and R4 in EVPN address family." )
271 "ipv4" : { "unicast" : {}},
272 "ipv6" : { "unicast" : {}},
285 "ipv4" : { "unicast" : {}},
286 "ipv6" : { "unicast" : {}},
294 result
= create_router_bgp ( tgen
, topo
, input_dict
)
295 assert result
is True , "Testcase {} :Failed \n Error: {}" . format ( tc_name
, result
)
297 step ( "Verify neighbours are in ESTAB state." )
298 result
= clear_bgp_and_verify ( tgen
, topo
, dut
)
299 assert result
is True , "Testcase {} : Failed \n Error: {}" . format ( tc_name
, result
)
301 write_test_footer ( tc_name
)
304 def test_bgp_unique_rid_ibgp_p0 ():
307 Verify iBGP session when same and different router ID is configured.
310 global bgp_convergence
312 if bgp_convergence
is not True :
313 pytest
. skip ( "skipped because of BGP Convergence failure" )
316 tc_name
= inspect
. stack ()[ 0 ][ 3 ]
317 write_test_header ( tc_name
)
318 if tgen
. routers_have_failure ():
319 check_router_status ( tgen
)
321 step ( "Configure base config as per the topology" )
322 reset_config_on_routers ( tgen
)
325 "Base config should be up, verify using BGP convergence on all \
326 the routers for IPv4 and IPv6 nbrs"
329 result
= verify_bgp_convergence ( tgen
, topo
)
330 assert result
is True , "Testcase {} :Failed \n Error: {}" . format ( tc_name
, result
)
332 step ( "Configure the same router id between R1 and R3 (10.10.10.10)" )
334 "r3" : { "bgp" : { "router_id" : "10.10.10.10" }},
335 "r1" : { "bgp" : { "router_id" : "10.10.10.10" }},
337 result
= create_router_bgp ( tgen
, topo
, input_dict
)
338 assert result
is True , "Testcase {} :Failed \n Error: {}" . format ( tc_name
, result
)
340 step ( "Verify neighbours are in idle state." )
341 result
= verify_bgp_convergence ( tgen
, topo
, expected
= False )
342 assert result
is not True , "Testcase {} :Failed \n Error: {}" . format (
346 step ( "Configure the same router id between R2 and R3 (10.10.10.10)" )
348 "r3" : { "bgp" : { "router_id" : "10.10.10.10" }},
349 "r2" : { "bgp" : { "router_id" : "10.10.10.10" }},
351 result
= create_router_bgp ( tgen
, topo
, input_dict
)
352 assert result
is True , "Testcase {} :Failed \n Error: {}" . format ( tc_name
, result
)
354 step ( "Verify neighbours are in idle state." )
355 result
= verify_bgp_convergence ( tgen
, topo
, expected
= False )
356 assert result
is not True , "Testcase {} :Failed \n Error: {}" . format (
360 step ( "modify the router id on r3 to different router id (11.11.11.11)" )
361 input_dict
= { "r3" : { "bgp" : { "router_id" : "11.11.11.11" }}}
362 result
= create_router_bgp ( tgen
, topo
, input_dict
)
363 assert result
is True , "Testcase {} :Failed \n Error: {}" . format ( tc_name
, result
)
365 step ( "Verify neighbours are in ESTAB state." )
366 result
= verify_bgp_convergence ( tgen
, topo
, dut
= "r3" )
367 assert result
is True , "Testcase {} :Failed \n Error: {}" . format ( tc_name
, result
)
369 step ( "Reset bgp process" )
370 step ( "Verify neighbours are in ESTAB state." )
372 result
= clear_bgp_and_verify ( tgen
, topo
, dut
)
373 assert result
is True , "Testcase {} : Failed \n Error: {}" . format ( tc_name
, result
)
375 step ( "Clear ip bgp process with *" )
376 result
= clear_bgp_and_verify ( tgen
, topo
, dut
)
377 assert result
is True , "Testcase {} : Failed \n Error: {}" . format ( tc_name
, result
)
379 write_test_footer ( tc_name
)
382 def test_bgp_unique_rid_multi_bgp_nbrs_p0 ():
385 3. Verify two different eBGP sessions initiated with same router ID
389 global bgp_convergence
, topo
391 if bgp_convergence
is not True :
392 pytest
. skip ( "skipped because of BGP Convergence failure" )
395 tc_name
= inspect
. stack ()[ 0 ][ 3 ]
396 write_test_header ( tc_name
)
397 if tgen
. routers_have_failure ():
398 check_router_status ( tgen
)
400 step ( "Configure base config as per the topology" )
401 reset_config_on_routers ( tgen
)
404 "Base config should be up, verify using BGP convergence on all \
405 the routers for IPv4 and IPv6 nbrs"
408 result
= verify_bgp_convergence ( tgen
, topo
)
409 assert result
is True , "Testcase {} :Failed \n Error: {}" . format ( tc_name
, result
)
411 step ( "Configure the same router id between R3, R4 and R5 (10.10.10.10)" )
413 "r3" : { "bgp" : { "router_id" : "10.10.10.10" }},
414 "r4" : { "bgp" : { "router_id" : "10.10.10.10" }},
415 "r5" : { "bgp" : { "router_id" : "10.10.10.10" }},
417 result
= create_router_bgp ( tgen
, topo
, input_dict
)
418 assert result
is True , "Testcase {} :Failed \n Error: {}" . format ( tc_name
, result
)
420 step ( "Verify neighbours are in ESTAB state." )
421 result
= verify_bgp_convergence ( tgen
, topo
)
422 assert result
is True , "Testcase {} :Failed \n Error: {}" . format ( tc_name
, result
)
425 "Configure the same IP address on on R4 and R5 loopback address and \
426 change the neighborship to loopback neighbours between R3 to R4 \
427 and R3 to R5 respectively."
430 topo1
= deepcopy ( topo
)
432 for rtr
in [ "r4" , "r5" ]:
433 topo1
[ "routers" ][ rtr
][ "links" ][ "lo" ][ "ipv4" ] = "192.168.1.1/32"
435 topo1
[ "routers" ][ "r3" ][ "links" ][ "lo" ][ "ipv4" ] = "192.168.1.3/32"
436 build_config_from_json ( tgen
, topo1
, save_bkup
= False )
439 "change the neighborship to loopback neighbours between R3 to R4 and R3 to R5 respectively."
441 for rtr
in [ "r4" , "r5" ]:
442 configure_bgp_on_rtr
= {
447 "unicast" : { "neighbor" : { rtr
: { "dest_link" : { "lo" : {}}}}}
453 result
= create_router_bgp ( tgen
, topo1
, configure_bgp_on_rtr
)
454 assert result
is True , "Testcase {} : Failed \n Error: {}" . format (
458 bgp_convergence
= verify_bgp_convergence ( tgen
, topo1
, dut
= "r3" )
459 assert bgp_convergence
is True , "Testcase {} : Failed \n Error: {}" . format (
460 tc_name
, bgp_convergence
463 step ( "Change the IP address on the R4 loopback." )
464 topo1
[ "routers" ][ "r4" ][ "links" ][ "lo" ][ "ipv4" ] = "192.168.1.4/32"
465 build_config_from_json ( tgen
, topo1
, save_bkup
= False )
467 step ( "Verify neighbours should be again in ESTAB state. (show ip bgp neighbours)" )
468 bgp_convergence
= verify_bgp_convergence ( tgen
, topo1
, dut
= "r3" )
469 assert bgp_convergence
is True , "Testcase {} : Failed \n Error: {}" . format (
470 tc_name
, bgp_convergence
473 step ( "Clear ip bgp process with *" )
474 result
= clear_bgp_and_verify ( tgen
, topo
, router
= "r3" )
475 assert result
is True , "Testcase {} : Failed \n Error: {}" . format ( tc_name
, result
)
477 write_test_footer ( tc_name
)
480 def test_bgp_unique_rid_chaos1_p2 ():
483 4. Chaos - Verify bgp unique rid functionality in chaos scenarios.
487 global bgp_convergence
489 if bgp_convergence
is not True :
490 pytest
. skip ( "skipped because of BGP Convergence failure" )
493 tc_name
= inspect
. stack ()[ 0 ][ 3 ]
494 write_test_header ( tc_name
)
495 if tgen
. routers_have_failure ():
496 check_router_status ( tgen
)
498 step ( "Configure base config as per the topology" )
499 reset_config_on_routers ( tgen
)
502 "Base config should be up, verify using BGP convergence on all \
503 the routers for IPv4 and IPv6 nbrs"
506 result
= verify_bgp_convergence ( tgen
, topo
)
507 assert result
is True , "Testcase {} :Failed \n Error: {}" . format ( tc_name
, result
)
509 step ( "Configure the same router id between R3, R4 and R5 (10.10.10.10)" )
511 "r3" : { "bgp" : { "router_id" : "10.10.10.10" }},
512 "r4" : { "bgp" : { "router_id" : "10.10.10.10" }},
513 "r5" : { "bgp" : { "router_id" : "10.10.10.10" }},
515 result
= create_router_bgp ( tgen
, topo
, input_dict
)
516 assert result
is True , "Testcase {} :Failed \n Error: {}" . format ( tc_name
, result
)
518 step ( "Verify neighbours are in ESTAB state." )
519 result
= verify_bgp_convergence ( tgen
, topo
)
520 assert result
is True , "Testcase {} :Failed \n Error: {}" . format ( tc_name
, result
)
523 "Verify eBGP session when same router ID is configured and bgpd process is restarted"
526 # restart bgpd router and verify
527 kill_router_daemons ( tgen
, "r3" , [ "bgpd" ])
528 start_router_daemons ( tgen
, "r3" , [ "bgpd" ])
531 "The session should be established between R3 & R4. "
532 "Once after restart bgp, neighbor should come back up ."
535 bgp_convergence
= verify_bgp_convergence ( tgen
, topo
)
536 assert bgp_convergence
is True , "Testcase {} : Failed \n Error: {}" . format (
537 tc_name
, bgp_convergence
541 "Verify eBGP session when same router ID is configured and neighbor shutdown is issued and again no shutdown."
554 "r3-link1" : { "shutdown" : True },
555 "r3-link2" : { "shutdown" : True },
556 "r3-link3" : { "shutdown" : True },
557 "r3-link4" : { "shutdown" : True },
558 "r3-link5" : { "shutdown" : True },
559 "r3-link6" : { "shutdown" : True },
560 "r3-link7" : { "shutdown" : True },
563 "r5" : { "dest_link" : { "r3" : { "shutdown" : True }}},
572 "r3-link1" : { "shutdown" : True },
573 "r3-link2" : { "shutdown" : True },
574 "r3-link3" : { "shutdown" : True },
575 "r3-link4" : { "shutdown" : True },
576 "r3-link5" : { "shutdown" : True },
577 "r3-link6" : { "shutdown" : True },
578 "r3-link7" : { "shutdown" : True },
581 "r5" : { "dest_link" : { "r3" : { "shutdown" : True }}},
589 result
= create_router_bgp ( tgen
, topo
, input_dict
)
590 assert result
is True , "Testcase {} :Failed \n Error: {}" . format ( tc_name
, result
)
602 "r3-link1" : { "shutdown" : False },
603 "r3-link2" : { "shutdown" : False },
604 "r3-link3" : { "shutdown" : False },
605 "r3-link4" : { "shutdown" : False },
606 "r3-link5" : { "shutdown" : False },
607 "r3-link6" : { "shutdown" : False },
608 "r3-link7" : { "shutdown" : False },
611 "r5" : { "dest_link" : { "r3" : { "shutdown" : False }}},
620 "r3-link1" : { "shutdown" : False },
621 "r3-link2" : { "shutdown" : False },
622 "r3-link3" : { "shutdown" : False },
623 "r3-link4" : { "shutdown" : False },
624 "r3-link5" : { "shutdown" : False },
625 "r3-link6" : { "shutdown" : False },
626 "r3-link7" : { "shutdown" : False },
629 "r5" : { "dest_link" : { "r3" : { "shutdown" : False }}},
637 result
= create_router_bgp ( tgen
, topo
, input_dict
)
638 assert result
is True , "Testcase {} :Failed \n Error: {}" . format ( tc_name
, result
)
641 "The session should be established between R3 & R4. "
642 "Once after restart bgp, neighbor should come back up ."
645 bgp_convergence
= verify_bgp_convergence ( tgen
, topo
)
646 assert bgp_convergence
is True , "Testcase {} : Failed \n Error: {}" . format (
647 tc_name
, bgp_convergence
651 "Verify eBGP session when same router ID is configured and neighbor config is deleted & reconfigured."
673 "r5" : { "dest_link" : { "r3" : {}}},
691 "r5" : { "dest_link" : { "r3" : {}}},
699 result
= create_router_bgp ( tgen
, topo
, input_dict
)
700 assert result
is True , "Testcase {} :Failed \n Error: {}" . format ( tc_name
, result
)
703 "The session should be established between R3 & R4. "
704 "Once after restart bgp, neighbor should come back up ."
707 bgp_convergence
= verify_bgp_convergence ( tgen
, topo
)
708 assert bgp_convergence
is True , "Testcase {} : Failed \n Error: {}" . format (
709 tc_name
, bgp_convergence
713 "Verify eBGP session when same router ID is configured and FRR router is restarted."
715 stop_router ( tgen
, "r3" )
716 start_router ( tgen
, "r3" )
719 "The session should be established between R3 & R4. "
720 "Once after restart bgp, neighbor should come back up ."
723 bgp_convergence
= verify_bgp_convergence ( tgen
, topo
)
724 assert bgp_convergence
is True , "Testcase {} : Failed \n Error: {}" . format (
725 tc_name
, bgp_convergence
729 "Verify eBGP session when same router ID is configured and zebra process is restarted"
732 kill_router_daemons ( tgen
, "r3" , [ "zebra" ])
733 start_router_daemons ( tgen
, "r3" , [ "zebra" ])
736 "The session should be established between R3 & R4. "
737 "Once after restart bgp, neighbor should come back up ."
740 bgp_convergence
= verify_bgp_convergence ( tgen
, topo
)
741 assert bgp_convergence
is True , "Testcase {} : Failed \n Error: {}" . format (
742 tc_name
, bgp_convergence
745 write_test_footer ( tc_name
)
748 def test_bgp_unique_rid_chaos3_p2 ():
751 4. Chaos - Verify bgp unique rid functionality when router reboots with same loopback id.
755 global bgp_convergence
757 if bgp_convergence
is not True :
758 pytest
. skip ( "skipped because of BGP Convergence failure" )
761 tc_name
= inspect
. stack ()[ 0 ][ 3 ]
762 write_test_header ( tc_name
)
763 if tgen
. routers_have_failure ():
764 check_router_status ( tgen
)
766 step ( "Configure base config as per the topology" )
767 reset_config_on_routers ( tgen
)
770 topo1
= deepcopy ( topo
)
772 for rtr
in topo
[ "routers" ]. keys ():
773 topo1
[ "routers" ][ rtr
][ "links" ][ "lo" ][ "ipv4" ] = "192.168.1.1/32"
775 topo1
[ "routers" ][ "r3" ][ "links" ][ "lo" ][ "ipv4" ] = "192.168.1.3/32"
776 build_config_from_json ( tgen
, topo1
, save_bkup
= False )
778 step ( "verify bgp convergence before starting test case" )
780 bgp_convergence
= verify_bgp_convergence ( tgen
, topo1
)
781 assert bgp_convergence
is True , "Testcase {} : Failed \n Error: {}" . format (
782 tc_name
, bgp_convergence
786 "Configure loopback on R1 to R5 with IP address 1.1.1.1 on all the routers. Change neighborship on all the routers using loopback neighborship ids."
788 for rtr
in [ "r1" , "r2" , "r4" , "r5" ]:
789 configure_bgp_on_rtr
= {
794 "unicast" : { "neighbor" : { rtr
: { "dest_link" : { "lo" : {}}}}}
800 result
= create_router_bgp ( tgen
, topo1
, configure_bgp_on_rtr
)
801 assert result
is True , "Testcase {} : Failed \n Error: {}" . format (
805 bgp_convergence
= verify_bgp_convergence ( tgen
, topo1
, dut
= "r3" )
806 assert bgp_convergence
is True , "Testcase {} : Failed \n Error: {}" . format (
807 tc_name
, bgp_convergence
810 step ( "Reboot the router (restart frr) or using watch frr." )
811 stop_router ( tgen
, "r3" )
812 start_router ( tgen
, "r3" )
814 step ( "Neighbors between R3, R4 and R3 to R5 should be in ESTB state." )
815 bgp_convergence
= verify_bgp_convergence ( tgen
, topo1
, dut
= "r3" )
816 assert bgp_convergence
is True , "Testcase {} : Failed \n Error: {}" . format (
817 tc_name
, bgp_convergence
820 step ( "Clear bgp process." )
821 clear_bgp_and_verify ( tgen
, topo
, "r3" )
823 step ( "Neighbors between R3, R4 and R3 to R5 should be in ESTB state." )
824 bgp_convergence
= verify_bgp_convergence ( tgen
, topo1
, dut
= "r3" )
825 assert bgp_convergence
is True , "Testcase {} : Failed \n Error: {}" . format (
826 tc_name
, bgp_convergence
829 write_test_footer ( tc_name
)
832 def test_bgp_unique_rid_chaos4_p2 ():
835 6. Chaos - Verify bgp unique rid functionality when router reboots without any ip addresses.
839 global bgp_convergence
841 if bgp_convergence
is not True :
842 pytest
. skip ( "skipped because of BGP Convergence failure" )
845 tc_name
= inspect
. stack ()[ 0 ][ 3 ]
846 write_test_header ( tc_name
)
847 if tgen
. routers_have_failure ():
848 check_router_status ( tgen
)
850 reset_config_on_routers ( tgen
)
853 topo1
= deepcopy ( topo
)
854 topo2
= deepcopy ( topo
)
857 "Configure base config as per the topology without loopback as well as Ip address on any of the interface."
859 for rtr
in topo
[ "routers" ]. keys ():
860 for intf
in topo
[ "routers" ][ rtr
][ "links" ]. keys ():
861 topo1
[ "routers" ][ rtr
][ "links" ][ intf
]. pop ( "ipv4" )
862 topo1
[ "routers" ][ rtr
][ "links" ][ intf
]. pop ( "ipv6" )
864 topo1
[ "routers" ][ rtr
][ "links" ][ intf
]. pop ( "ipv4" )
866 build_config_from_json ( tgen
, topo1
, save_bkup
= False )
868 bgp_convergence
= verify_bgp_convergence ( tgen
, topo
)
869 assert bgp_convergence
is True , "Testcase {} : Failed \n Error: {}" . format (
870 tc_name
, bgp_convergence
873 step ( "Configure the ip addresses on the physical interfaces" )
874 build_config_from_json ( tgen
, topo2
, save_bkup
= False )
876 step ( "All the neighbors should be in ESTAB state." )
877 bgp_convergence
= verify_bgp_convergence ( tgen
, topo
)
878 assert bgp_convergence
is True , "Testcase {} : Failed \n Error: {}" . format (
879 tc_name
, bgp_convergence
882 step ( "Configure loopback addresses with higher IP address " )
883 build_config_from_json ( tgen
, topo
, save_bkup
= False )
885 step ( "All the neighbors should be in ESTAB state." )
886 bgp_convergence
= verify_bgp_convergence ( tgen
, topo
)
887 assert bgp_convergence
is True , "Testcase {} : Failed \n Error: {}" . format (
888 tc_name
, bgp_convergence
891 step ( "Reboot the router (restart frr) or using watch frr." )
892 stop_router ( tgen
, "r3" )
893 start_router ( tgen
, "r3" )
895 step ( "Neighbors between R3, R4 and R3 to R5 should be in ESTB state." )
896 bgp_convergence
= verify_bgp_convergence ( tgen
, topo
, dut
= "r3" )
897 assert bgp_convergence
is True , "Testcase {} : Failed \n Error: {}" . format (
898 tc_name
, bgp_convergence
901 write_test_footer ( tc_name
)
904 if __name__
== "__main__" :
905 args
= [ "-s" ] + sys
. argv
[ 1 :]
906 sys
. exit ( pytest
. main ( args
))