-
Notifications
You must be signed in to change notification settings - Fork 1k
Updated test_po_cleanup.py for multi-asic platforms. #3069
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
Changes from 6 commits
febcacd
9582616
940ebe4
77a5528
5fada78
215ebfc
c98ef92
04a425d
4d2fa26
cb10827
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,36 +27,38 @@ def ignore_expected_loganalyzer_exceptions(rand_one_dut_hostname, loganalyzer): | |
| ] | ||
| loganalyzer[rand_one_dut_hostname].ignore_regex.extend(ignoreRegex) | ||
| expectRegex = [ | ||
| ".*teamd#teammgrd: :- cleanTeamProcesses.*", | ||
| ".*teamd#teamsyncd: :- cleanTeamSync.*" | ||
| ".*teammgrd: :- cleanTeamProcesses.*", | ||
| ".*teamsyncd: :- cleanTeamSync.*" | ||
| ] | ||
| loganalyzer[rand_one_dut_hostname].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") | ||
| def check_kernel_po_interface_cleaned(duthost, asic_index): | ||
| namespace = duthost.get_namespace_from_asic_id(asic_index) | ||
| res = duthost.shell(duthost.get_linux_ip_cmd_for_namespace("ip link show | grep -c PortChannel", namespace),module_ignore_errors=True)["stdout_lines"][0].decode("utf-8") | ||
| return res == '0' | ||
|
|
||
|
|
||
| def test_po_cleanup(duthosts, rand_one_dut_hostname, tbinfo): | ||
| """ | ||
| test port channel are cleaned up correctly and teammgrd and teamsyncd process | ||
| handle SIGTERM gracefully | ||
| """ | ||
| @pytest.fixture(scope="module", autouse=True) | ||
| def disable_teamd(duthosts, rand_one_dut_hostname, tbinfo): | ||
smaheshm marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| duthost = duthosts[rand_one_dut_hostname] | ||
| mg_facts = duthost.get_extended_minigraph_facts(tbinfo) | ||
|
|
||
| if len(mg_facts['minigraph_portchannels'].keys()) == 0: | ||
|
||
| pytest.skip("Skip test due to there is no portchannel exists in current topology.") | ||
| yield | ||
| # Do config reload to restor everything back | ||
| logging.info("Reloading config..") | ||
| config_reload(duthost) | ||
|
|
||
| try: | ||
| logging.info("Disable Teamd Feature") | ||
| duthost.shell("sudo systemctl stop teamd") | ||
| # 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) | ||
| def test_po_cleanup(duthosts, rand_one_dut_hostname, enum_asic_index): | ||
| """ | ||
| test port channel are cleaned up correctly and teammgrd and teamsyncd process | ||
| handle SIGTERM gracefully | ||
| """ | ||
| duthost = duthosts[rand_one_dut_hostname] | ||
| logging.info("Disable Teamd Feature") | ||
| duthost.shell("sudo systemctl stop swss{}".format('@' + str(enum_asic_index) if enum_asic_index is not None else '')) | ||
smaheshm marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # Check if Linux Kernel Portchannel Interface teamdev are clean up | ||
| if not wait_until(10, 1, check_kernel_po_interface_cleaned, duthost, enum_asic_index): | ||
| fail_msg = "PortChannel interface still exists in kernel" | ||
| pytest.fail(fail_msg) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine but would be good to generalize by overriding "shell" (similar to command) in sonic_asic.py and use something like the following. Up to you.