Skip to content
Merged
Changes from 3 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
64 changes: 64 additions & 0 deletions tests/pc/test_po_cleanup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import pytest
import logging
from tests.common.utilities import wait_until
from tests.common import config_reload


pytestmark = [
pytest.mark.topology('any'),
]

@pytest.fixture(autouse=True)
def ignore_expected_loganalyzer_exceptions(duthost, loganalyzer):
"""
Ignore expected failures logs during test execution.

LAG tests are triggering following syncd complaints but the don't cause
harm to DUT.

Args:
duthost: DUT fixture
loganalyzer: Loganalyzer utility fixture
"""
# when loganalyzer is disabled, the object could be None
if loganalyzer:
ignoreRegex = [
".*ERR syncd#syncd: :- process_on_fdb_event: invalid OIDs in fdb notifications, NOT translating and NOT storing in ASIC DB.*",
".*ERR syncd#syncd: :- process_on_fdb_event: FDB notification was not sent since it contain invalid OIDs, bug.*",
".*ERR syncd#syncd: :- translate_vid_to_rid: unable to get RID for VID.*",
".*ERR swss#orchagent: :- removeLag.*",
]
loganalyzer.ignore_regex.extend(ignoreRegex)
expectRegex = [
".*teamd#teammgrd: :- cleanTeamProcesses.*",
".*teamd#teamsyncd: :- cleanTeamSync.*"
]
loganalyzer.expect_regex.extend(expectRegex)


def check_kernel_po_interface_cleaned(duthost):
res = duthost.shell("ip link show | grep -c PortChannel", module_ignore_errors=True)["stdout_lines"][0].decode("utf-8")
return res == '0'


def test_po_cleanup(duthost):
"""
test port channel are cleaned up correctly and teammgrd and teamsyncd process
handle SIGTERM gracefully
"""
mg_facts = duthost.minigraph_facts(host=duthost.hostname)['ansible_facts']

if len(mg_facts['minigraph_portchannels'].keys()) == 0:
pytest.skip("Skip test due to there is no portchannel exists in current topology.")

try:
logging.info("Disable Teamd Feature")
duthost.shell("sudo config feature state teamd disabled")
# Check if Linux Kernel Portchannel Interface teamdev are clean up
if not wait_until(10, 1, check_kernel_po_interface_cleaned, duthost):
fail_msg = "PortChannel interface still exists in kernel"
pytest.fail(fail_msg)
finally:
# Do config reload to restor everything back
logging.info("Reloading config..")
config_reload(duthost)