Skip to content

Commit 4ae5ca3

Browse files
yaqiangzwangxin
authored andcommitted
[m0][bgp] Add support for m0 in bgp test to simulate both t0 and t1 scenario (#7581)
What is the motivation for this PR? In current bgp test for m0, just simulate scenario that m0 device performs like t1. But m0 is like both t1 and t0. How did you do it? Add suport for m0 in bgp test to simulate both t0 and t1 scenario How did you verify/test it? Run tests on m0 topo and t0 topo Signed-off-by: Yaqiang Zhu <[email protected]>
1 parent d896b59 commit 4ae5ca3

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

tests/bgp/conftest.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def restore_nbr_gr(node=None, results=None):
145145

146146

147147
@pytest.fixture(scope="module")
148-
def setup_interfaces(duthosts, enum_rand_one_per_hwsku_frontend_hostname, ptfhost, request, tbinfo):
148+
def setup_interfaces(duthosts, enum_rand_one_per_hwsku_frontend_hostname, ptfhost, request, tbinfo, topo_scenario):
149149
"""Setup interfaces for the new BGP peers on PTF."""
150150

151151
def _is_ipv4_address(ip_addr):
@@ -449,8 +449,13 @@ def _get_namespace(minigraph_config, intf):
449449
setup_func = _setup_interfaces_dualtor
450450
elif tbinfo["topo"]["type"] in ["t0", "mx"]:
451451
setup_func = _setup_interfaces_t0_or_mx
452-
elif tbinfo["topo"]["type"] in set(["t1", "t2", "m0"]):
452+
elif tbinfo["topo"]["type"] in set(["t1", "t2"]):
453453
setup_func = _setup_interfaces_t1_or_t2
454+
elif tbinfo["topo"]["type"] == "m0":
455+
if topo_scenario == "m0_t1_scenario":
456+
setup_func = _setup_interfaces_t1_or_t2
457+
else:
458+
setup_func = _setup_interfaces_t0_or_mx
454459
else:
455460
raise TypeError("Unsupported topology: %s" % tbinfo["topo"]["type"])
456461

tests/conftest.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1262,8 +1262,8 @@ def pytest_generate_tests(metafunc):
12621262
asics_selected = None
12631263
asic_fixture_name = None
12641264

1265+
tbname, tbinfo = get_tbinfo(metafunc)
12651266
if duts_selected is None:
1266-
tbname, tbinfo = get_tbinfo(metafunc)
12671267
duts_selected = [tbinfo["duts"][0]]
12681268

12691269
possible_asic_enums = ["enum_asic_index", "enum_frontend_asic_index", "enum_backend_asic_index", "enum_rand_one_asic_index", "enum_rand_one_frontend_asic_index"]
@@ -1340,6 +1340,12 @@ def pytest_generate_tests(metafunc):
13401340
if 'enum_pfc_pause_delay_test_params' in metafunc.fixturenames:
13411341
metafunc.parametrize("enum_pfc_pause_delay_test_params", pfc_pause_delay_test_params(metafunc))
13421342

1343+
if 'topo_scenario' in metafunc.fixturenames:
1344+
if tbinfo['topo']['type'] == 'm0' and 'topo_scenario' in metafunc.fixturenames:
1345+
metafunc.parametrize('topo_scenario', ['m0_t0_scenario', 'm0_t1_scenario'], scope='module')
1346+
else:
1347+
metafunc.parametrize('topo_scenario', ['default'], scope='module')
1348+
13431349

13441350
def parametrise_autoneg_tests():
13451351
folder = 'metadata'

0 commit comments

Comments
 (0)