diff --git a/tests/cacl/test_cacl_application.py b/tests/cacl/test_cacl_application.py index 6df1fc743f9..78efab36960 100644 --- a/tests/cacl/test_cacl_application.py +++ b/tests/cacl/test_cacl_application.py @@ -17,6 +17,18 @@ ] +@pytest.fixture(scope="module", autouse=True) +def disable_port_toggle(duthosts, tbinfo): + # set mux mode to manual on both TORs to avoid port state change during test + if "dualtor" in tbinfo['topo']['name']: + for dut in duthosts: + dut.shell("sudo config mux mode manual all") + yield + if "dualtor" in tbinfo['topo']['name']: + for dut in duthosts: + dut.shell("sudo config mux mode auto all") + + @pytest.fixture(scope="function", params=["active_tor", "standby_tor"]) def duthost_dualtor(request, upper_tor_host, lower_tor_host): # noqa F811 which_tor = request.param @@ -28,9 +40,7 @@ def duthost_dualtor(request, upper_tor_host, lower_tor_host): # noqa F811 else: logger.info("Select upper tor...") dut = upper_tor_host - dut.shell("sudo config mux mode manual all") - yield dut - dut.shell("sudo config mux mode auto all") + return dut @pytest.fixture diff --git a/tests/generic_config_updater/test_cacl.py b/tests/generic_config_updater/test_cacl.py index b9a8e3fcd47..5764bb01f2f 100644 --- a/tests/generic_config_updater/test_cacl.py +++ b/tests/generic_config_updater/test_cacl.py @@ -42,6 +42,18 @@ def get_iptable_rules(duthost): return rules_chain +@pytest.fixture(scope="module", autouse=True) +def disable_port_toggle(duthosts, tbinfo): + # set mux mode to manual on both TORs to avoid port state change during test + if "dualtor" in tbinfo['topo']['name']: + for dut in duthosts: + dut.shell("sudo config mux mode manual all") + yield + if "dualtor" in tbinfo['topo']['name']: + for dut in duthosts: + dut.shell("sudo config mux mode auto all") + + @pytest.fixture(autouse=True) def setup_env(duthosts, rand_one_dut_hostname): """