forked from sonic-net/sonic-mgmt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_po_cleanup.py
More file actions
61 lines (50 loc) · 1.99 KB
/
Copy pathtest_po_cleanup.py
File metadata and controls
61 lines (50 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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 = [
".*",
]
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)