Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set mux mode to manual to disable port toggle in cacl scripts on dualtor testbed #12883

Merged
merged 4 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions tests/cacl/test_cacl_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']:
Copy link
Contributor

@lolyu lolyu May 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check will allow if the testbed is a active-active dualtor: dualtor-aa.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an alternative is using fixture active_standby_ports and check if the returned list is empty.

def active_standby_ports(mux_config, tbinfo):

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
Expand All @@ -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
Expand Down
12 changes: 12 additions & 0 deletions tests/generic_config_updater/test_cacl.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ def get_iptable_rules(duthost):
return rules_chain


@pytest.fixture(scope="module", autouse=True)
def disable_port_toggle(duthosts, tbinfo):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's same piece of code, will it be worth to move it to dualtor common or dualtor utils, and call the fixture in tests?

It's up to you, not mandatory.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zjswhhh This new fixture is module fixture, which only works within script. If I move it to dualtor utils, it can't be used in specific script as module level and autouse.
All fixtures in dualtor_tor_common.py is session level, and I don't want to set max mode to manual for all test cases.

# 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):
"""
Expand Down
Loading