Skip to content

Commit bbbff27

Browse files
PriyanshTratiyarraghav-cisco
authored andcommitted
feature/bgp sessions admin flap test (sonic-net#21520)
This PR adds the high‑scale BGP admin flap tests that build on top of the refactoring done in PR sonic-net#21335. It introduces new test cases and utilities to exercise BGP IPv6 convergence and scale behavior under repeated admin shutdown/startup (“flap”) scenarios for BGP sessions and interfaces. Signed-off-by: Priyansh Tratiya <[email protected]> Signed-off-by: Raghavendran Ramanathan <[email protected]>
1 parent 993eb1f commit bbbff27

2 files changed

Lines changed: 53 additions & 7 deletions

File tree

ansible/library/check_bgp_ipv6_routes_converged.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111

1212

1313
# Constants
14-
INTERFACE_COMMAND_TEMPLATE = "sudo config interface {action} {target}"
14+
CONFIG_INTERFACE_COMMAND_TEMPLATE = "sudo config interface {action} {target}"
15+
CONFIG_BGP_SESSIONS_COMMAND_TEMPLATE = "sudo config bgp {action} {target}"
1516

1617

1718
def get_bgp_ipv6_routes(module):
@@ -26,11 +27,21 @@ def _perform_action_on_connections(module, action, connection_type, targets, all
2627
"""
2728
Perform actions (shutdown/startup) on BGP sessions or interfaces.
2829
"""
29-
30+
# Action on BGP sessions
31+
if connection_type == "bgp_sessions":
32+
if all_neighbors:
33+
cmd = CONFIG_BGP_SESSIONS_COMMAND_TEMPLATE.format(action=action, target="all")
34+
_execute_command_on_dut(module, cmd)
35+
else:
36+
for session in targets:
37+
target_session = "neighbor " + session
38+
cmd = CONFIG_BGP_SESSIONS_COMMAND_TEMPLATE.format(action=action, target=target_session)
39+
_execute_command_on_dut(module, cmd)
40+
logging.info(f"BGP sessions {action} completed.")
3041
# Action on Interfaces
31-
if connection_type == "ports":
42+
elif connection_type == "ports":
3243
ports_str = ",".join(targets)
33-
cmd = INTERFACE_COMMAND_TEMPLATE.format(action=action, target=ports_str)
44+
cmd = CONFIG_INTERFACE_COMMAND_TEMPLATE.format(action=action, target=ports_str)
3445
_execute_command_on_dut(module, cmd)
3546
logging.info(f"Interfaces {action} completed.")
3647
else:
@@ -102,7 +113,7 @@ def main():
102113
expected_routes = json.loads(module.params['expected_routes'])
103114

104115
shutdown_connections = module.params.get('shutdown_connections', [])
105-
connection_type = module.params['connection_type']
116+
connection_type = module.params.get('connection_type', 'none')
106117
shutdown_all_connections = module.params['shutdown_all_connections']
107118
timeout = module.params['timeout']
108119
interval = module.params['interval']

tests/bgp/test_ipv6_bgp_scale.py

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

372380
def 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'])
778813
def test_sessions_flapping(
779814
request,

0 commit comments

Comments
 (0)