@@ -367,6 +367,14 @@ def _restore(duthost, connection_type, shutdown_connections, shutdown_all_connec
367367 if connection_type == 'ports' :
368368 logger .info (f"Recover interfaces { shutdown_connections } after failure" )
369369 duthost .no_shutdown_multiple (shutdown_connections )
370+ elif connection_type == 'bgp_sessions' :
371+ if shutdown_all_connections :
372+ logger .info ("Recover all BGP sessions after failure" )
373+ duthost .shell ("sudo config bgp startup all" )
374+ else :
375+ for session in shutdown_connections :
376+ logger .info (f"Recover BGP session { session } after failure" )
377+ duthost .shell (f"sudo config bgp startup neighbor { session } " )
370378
371379
372380def check_bgp_routes_converged (duthost , expected_routes , shutdown_connections = None , connection_type = 'none' ,
@@ -520,7 +528,7 @@ def flapper(duthost, pdp, bgp_peers_info, transient_setup, flapping_count, conne
520528 exp_mask = setup_packet_mask_counters (pdp , global_icmp_type )
521529 all_flap = (flapping_count == 'all' )
522530
523- # We are currently treating the shutdown action as a setup mechanism for a startup action to follow.
531+ # Currently treating the shutdown action as a setup mechanism for a startup action to follow.
524532 # So we only do the selection of flapping and injection neighbors when action is shutdown
525533 # And we reuse the same selection for startup action
526534 if action == 'shutdown' :
@@ -532,7 +540,7 @@ def flapper(duthost, pdp, bgp_peers_info, transient_setup, flapping_count, conne
532540 bgp_peers_info , all_flap , flapping_count
533541 )
534542
535- flapping_connections = {'ports' : flapping_ports }.get (connection_type , [])
543+ flapping_connections = {'ports' : flapping_ports , 'bgp_sessions' : flapping_neighbors }.get (connection_type , [])
536544 # Build expected routes after shutdown
537545 startup_routes = get_all_bgp_ipv6_routes (duthost , save_snapshot = False )
538546 neighbor_ecmp_routes = get_ecmp_routes (startup_routes , bgp_peers_info )
@@ -774,6 +782,33 @@ def test_nexthop_group_member_scale(
774782 pytest .fail ("BGP routes are not stable in long time" )
775783
776784
785+ @pytest .mark .parametrize ("flapping_neighbor_count" , [1 , 10 ])
786+ def test_bgp_admin_flap (
787+ request ,
788+ duthost ,
789+ ptfadapter ,
790+ bgp_peers_info ,
791+ flapping_neighbor_count
792+ ):
793+ """
794+ Validates that both control plane and data plane remain functional with acceptable downtime when BGP sessions are
795+ flapped (brought down and back up), simulating various failure or maintenance scenarios.
796+
797+ Uses the flapper function to orchestrate the flapping of BGP sessions and measure convergence times.
798+
799+ Parameters range from flapping a single session to all sessions.
800+
801+ Expected result:
802+ Dataplane downtime is less than MAX_BGP_SESSION_DOWNTIME or MAX_DOWNTIME_UNISOLATION for all ports.
803+ """
804+ pdp = ptfadapter .dataplane
805+ pdp .set_qlen (PACKET_QUEUE_LENGTH )
806+ # Measure shutdown convergence
807+ transient_setup = flapper (duthost , pdp , bgp_peers_info , None , flapping_neighbor_count , 'bgp_sessions' , 'shutdown' )
808+ # Measure startup convergence
809+ flapper (duthost , pdp , None , transient_setup , flapping_neighbor_count , 'bgp_sessions' , 'startup' )
810+
811+
777812@pytest .mark .parametrize ("flapping_port_count" , [1 , 10 , 20 , 'all' ])
778813def test_sessions_flapping (
779814 request ,
0 commit comments