Skip to content

Commit 1141ee7

Browse files
authored
TOR BGP failure testcases (#3167)
Dual TOR BGP failure testcases Testcases added: dualtor/test_tor_bgp_failure.py::test_active_tor_shutdown_bgp_upstream dualtor/test_tor_bgp_failure.py::test_standby_tor_shutdown_bgp_upstream dualtor/test_tor_bgp_failure.py::test_standby_tor_shutdown_bgp_downstream_active dualtor/test_tor_bgp_failure.py::test_active_tor_shutdown_bgp_downstream_standby
1 parent e914c20 commit 1141ee7

File tree

1 file changed

+110
-0
lines changed

1 file changed

+110
-0
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
import pytest
2+
3+
from tests.common.dualtor.control_plane_utils import verify_tor_states
4+
from tests.common.dualtor.data_plane_utils import send_t1_to_server_with_action, send_server_to_t1_with_action # lgtm[py/unused-import]
5+
from tests.common.dualtor.dual_tor_utils import upper_tor_host, lower_tor_host # lgtm[py/unused-import]
6+
from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports_to_upper_tor, toggle_all_simulator_ports_to_lower_tor # lgtm[py/unused-import]
7+
from tests.common.dualtor.tor_failure_utils import shutdown_tor_bgp # lgtm[py/unused-import]
8+
from tests.common.fixtures.ptfhost_utils import run_icmp_responder, run_garp_service, copy_ptftests_directory, change_mac_addresses # lgtm[py/unused-import]
9+
from tests.common.dualtor.tunnel_traffic_utils import tunnel_traffic_monitor
10+
11+
pytestmark = [
12+
pytest.mark.topology("dualtor")
13+
]
14+
15+
'''
16+
Below cases are out of scope:
17+
Case: T1 -> Standby ToR -> Server (Standby ToR BGP Down)
18+
Out of scope: taking down the standby ToR's BGP sessions means the T1 will never send traffic to that ToR
19+
Case: T1 -> Active ToR -> Server (Active ToR BGP Down)
20+
Out of scope: taking down the active ToR's BGP sessions means the T1 will never send traffic to that ToR
21+
22+
Remaining cases for bgp shutdown are defined in this module.
23+
'''
24+
25+
def test_active_tor_shutdown_bgp_upstream(
26+
upper_tor_host, lower_tor_host, send_server_to_t1_with_action,
27+
toggle_all_simulator_ports_to_upper_tor, shutdown_tor_bgp):
28+
'''
29+
Case: Server -> ToR -> T1 (Active ToR BGP Down)
30+
Action: Shutdown all BGP sessions on the active ToR
31+
Expectation:
32+
Verify packet flow after the active ToR (A) loses BGP sessions
33+
ToR A DBs indicate standby, ToR B DBs indicate active
34+
T1 switch receives packet from the new active ToR (B) and not the new standby ToR (A)
35+
Verify traffic interruption < 1 second
36+
'''
37+
send_server_to_t1_with_action(
38+
upper_tor_host, verify=True, delay=1,
39+
action=lambda: shutdown_tor_bgp(upper_tor_host)
40+
)
41+
verify_tor_states(
42+
expected_active_host=lower_tor_host,
43+
expected_standby_host=upper_tor_host
44+
)
45+
46+
47+
def test_standby_tor_shutdown_bgp_upstream(
48+
upper_tor_host, lower_tor_host, send_server_to_t1_with_action,
49+
toggle_all_simulator_ports_to_upper_tor, shutdown_tor_bgp):
50+
'''
51+
Case: Server -> ToR -> T1 (Standby ToR BGP Down)
52+
Action: Shutdown all BGP sessions on the standby ToR
53+
Expectation:
54+
Verify packet flow after the standby ToR (B) loses BGP sessions
55+
ToR A DBs indicate active, ToR B DBs indicate standby
56+
T1 switch receives packet from the active ToR (A), and not the standby ToR (B)
57+
'''
58+
send_server_to_t1_with_action(
59+
upper_tor_host, verify=True,
60+
action=lambda: shutdown_tor_bgp(lower_tor_host)
61+
)
62+
verify_tor_states(
63+
expected_active_host=upper_tor_host,
64+
expected_standby_host=lower_tor_host
65+
)
66+
67+
68+
def test_standby_tor_shutdown_bgp_downstream_active(
69+
upper_tor_host, lower_tor_host, send_t1_to_server_with_action,
70+
toggle_all_simulator_ports_to_upper_tor, shutdown_tor_bgp,
71+
tunnel_traffic_monitor):
72+
'''
73+
Case: T1 -> Active ToR -> Server (Standby ToR BGP Down)
74+
Action: Shutdown all BGP sessions on the standby ToR
75+
Expectation:
76+
Verify packet flow after the standby ToR (B) loses BGP sessions
77+
T1 switch receives no IP-in-IP packet; server receives packet
78+
'''
79+
with tunnel_traffic_monitor(lower_tor_host, existing=False):
80+
send_t1_to_server_with_action(
81+
upper_tor_host, verify=True,
82+
action=lambda: shutdown_tor_bgp(lower_tor_host)
83+
)
84+
verify_tor_states(
85+
expected_active_host=upper_tor_host,
86+
expected_standby_host=lower_tor_host
87+
)
88+
89+
90+
def test_active_tor_shutdown_bgp_downstream_standby(
91+
upper_tor_host, lower_tor_host, send_t1_to_server_with_action,
92+
toggle_all_simulator_ports_to_upper_tor, shutdown_tor_bgp,
93+
tunnel_traffic_monitor):
94+
'''
95+
Case: T1 -> Standby ToR -> Server (Active ToR BGP Down)
96+
Action: Shutdown all BGP sessions on the active ToR
97+
Expectation:
98+
Verify packet flow after the active ToR (A) loses BGP sessions
99+
T1 switch receives no IP-in-IP packet; server receives packet;
100+
verify traffic interruption is < 1 second
101+
'''
102+
with tunnel_traffic_monitor(lower_tor_host, existing=False):
103+
send_t1_to_server_with_action(
104+
lower_tor_host, verify=True, delay=1,
105+
action=lambda: shutdown_tor_bgp(upper_tor_host)
106+
)
107+
verify_tor_states(
108+
expected_active_host=lower_tor_host,
109+
expected_standby_host=upper_tor_host
110+
)

0 commit comments

Comments
 (0)