From a178ff7ea0b3a7ff59168b079f8bb5d8ffeaedf0 Mon Sep 17 00:00:00 2001 From: Yaqiang Zhu Date: Mon, 27 Feb 2023 16:31:58 +0800 Subject: [PATCH] [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 --- tests/bgp/conftest.py | 9 +++++++-- tests/conftest.py | 9 ++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/bgp/conftest.py b/tests/bgp/conftest.py index 436d920131e..3ac22949659 100644 --- a/tests/bgp/conftest.py +++ b/tests/bgp/conftest.py @@ -164,7 +164,7 @@ def restore_nbr_gr(node=None, results=None): @pytest.fixture(scope="module") -def setup_interfaces(duthosts, enum_rand_one_per_hwsku_frontend_hostname, ptfhost, request, tbinfo): +def setup_interfaces(duthosts, enum_rand_one_per_hwsku_frontend_hostname, ptfhost, request, tbinfo, topo_scenario): """Setup interfaces for the new BGP peers on PTF.""" def _is_ipv4_address(ip_addr): @@ -440,10 +440,15 @@ def _setup_interfaces_t1_or_t2(mg_facts, peer_count): peer_count = getattr(request.module, "PEER_COUNT", 1) if "dualtor" in tbinfo["topo"]["name"]: setup_func = _setup_interfaces_dualtor - elif tbinfo["topo"]["type"] in ["t0", "m0"]: + elif tbinfo["topo"]["type"] in ["t0"]: setup_func = _setup_interfaces_t0 elif tbinfo["topo"]["type"] in set(["t1", "t2"]): setup_func = _setup_interfaces_t1_or_t2 + elif tbinfo["topo"]["type"] == "m0": + if topo_scenario == "m0_t1_scenario": + setup_func = _setup_interfaces_t1_or_t2 + else: + setup_func = _setup_interfaces_t0 else: raise TypeError("Unsupported topology: %s" % tbinfo["topo"]["type"]) diff --git a/tests/conftest.py b/tests/conftest.py index f11cabbac6c..f728eb56dcf 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1214,8 +1214,8 @@ def pytest_generate_tests(metafunc): asics_selected = None asic_fixture_name = None + tbname, tbinfo = get_tbinfo(metafunc) if duts_selected is None: - tbname, tbinfo = get_tbinfo(metafunc) duts_selected = [tbinfo["duts"][0]] if "enum_asic_index" in metafunc.fixturenames: @@ -1288,6 +1288,13 @@ def pytest_generate_tests(metafunc): if 'enum_pfc_pause_delay_test_params' in metafunc.fixturenames: metafunc.parametrize("enum_pfc_pause_delay_test_params", pfc_pause_delay_test_params(metafunc)) + if 'topo_scenario' in metafunc.fixturenames: + if tbinfo['topo']['type'] == 'm0' and 'topo_scenario' in metafunc.fixturenames: + metafunc.parametrize('topo_scenario', ['m0_t0_scenario', 'm0_t1_scenario'], scope='module') + else: + metafunc.parametrize('topo_scenario', ['default'], scope='module') + + ### Override enum fixtures for duts and asics to ensure that parametrization happens once per module. @pytest.fixture(scope="module") def enum_dut_hostname(request):