Skip to content

Commit 037c537

Browse files
dayouliu1dcaugher
authored andcommitted
Add T0 upstream neighbor support to test_bgp_sentinel (sonic-net#21207)
What is the motivation for this PR? Add T0 upstream neighbor support to test_bgp_sentinel, such that test can provide coverage for t1-isol
1 parent 8926340 commit 037c537

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

tests/bgp/test_bgp_sentinel.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import ipaddress
99
from jinja2 import Template
1010
from tests.common.helpers.assertions import pytest_assert
11-
from tests.common.utilities import wait_until, wait_tcp_connection
11+
from tests.common.utilities import wait_until, wait_tcp_connection, get_upstream_neigh_type
1212
from bgp_helpers import CONSTANTS_FILE, BGPSENTINEL_CONFIG_FILE
1313
from bgp_helpers import BGP_SENTINEL_PORT_V4, BGP_SENTINEL_NAME_V4
1414
from bgp_helpers import BGP_SENTINEL_PORT_V6, BGP_SENTINEL_NAME_V6
@@ -88,8 +88,10 @@ def get_dut_listen_range(tbinfo):
8888
# Find spine route and get the bp_interface's network
8989
ipv4_subnet, ipv6_subnet, = None, None
9090
spine_bp_addr = {}
91+
upstream_nbr_type = get_upstream_neigh_type(tbinfo, is_upper=True)
9192
for k, v in tbinfo['topo']['properties']['configuration'].items():
92-
if 'spine' in v['properties']:
93+
if ((upstream_nbr_type == 'T0' and 'tor' in v['properties']) or
94+
(upstream_nbr_type == 'T2' and 'spine' in v['properties'])):
9395
ipv4_addr = ipaddress.ip_interface(v['bp_interface']['ipv4'].encode().decode())
9496
ipv6_addr = ipaddress.ip_interface(v['bp_interface']['ipv6'].encode().decode())
9597
ipv4_subnet = str(ipv4_addr.network)
@@ -362,7 +364,7 @@ def bgp_community(sentinel_community, request):
362364

363365

364366
@pytest.fixture(scope="module", params=['IPv4', 'IPv6'])
365-
def prepare_bgp_sentinel_routes(rand_selected_dut, common_setup_teardown, bgp_community, request):
367+
def prepare_bgp_sentinel_routes(rand_selected_dut, common_setup_teardown, bgp_community, request, tbinfo):
366368
duthost = rand_selected_dut
367369
ptfip, lo_ipv4_addr, lo_ipv6_addr, ipv4_nh, ipv6_nh, ibgp_sessions, ptf_bp_v4, ptf_bp_v6 = common_setup_teardown
368370

@@ -373,6 +375,13 @@ def prepare_bgp_sentinel_routes(rand_selected_dut, common_setup_teardown, bgp_co
373375
pytest.skip("IPv6 IBGP session is not established")
374376

375377
ipv4_routes, ipv6_routes = get_target_routes(duthost)
378+
upstream_nbr_type = get_upstream_neigh_type(tbinfo, is_upper=True)
379+
380+
if upstream_nbr_type == "T0" and "0.0.0.0/0" in ipv4_routes:
381+
ipv4_routes.remove("0.0.0.0/0")
382+
383+
if upstream_nbr_type == "T0" and "::/0" in ipv6_routes:
384+
ipv6_routes.remove("::/0")
376385

377386
# Check if the routes are announced to peers
378387
for route in ipv4_routes + ipv6_routes:

0 commit comments

Comments
 (0)