[pytest] Test the feature of container checker.#2852
[pytest] Test the feature of container checker.#2852yozhao101 merged 7 commits intosonic-net:masterfrom
Conversation
Signed-off-by: Yong Zhao <yozhao@microsoft.com>
Signed-off-by: Yong Zhao <yozhao@microsoft.com>
|
can you add this to kvmtest.sh list? |
Signed-off-by: Yong Zhao <yozhao@microsoft.com>
| alerting_message = duthost.shell("sudo cat /var/log/syslog | grep -m 1 '.*monit.*container_checker'", | ||
| module_ignore_errors=True) | ||
|
|
||
| pytest_assert(len(alerting_message["stdout_lines"]) > 0, |
There was a problem hiding this comment.
| pytest_assert(len(alerting_message["stdout_lines"]) > 0, | |
| pytest_assert(len(stopped_containers_list) == 0 or len(alerting_message["stdout_lines"]) > 0, |
Although it's not likely to happen, I think it's better to add this check.
There was a problem hiding this comment.
Great suggestion! Will update.
| "Failed to get Monit alerting message from container_checker!") | ||
|
|
||
| for container_name in stopped_containers_list: | ||
| if container_name not in alerting_message["stdout_lines"][0]: |
There was a problem hiding this comment.
Why alerting_message["stdout_lines"][0] ? Always in the first line?
There was a problem hiding this comment.
At here, after the running containers except database were stopped for 6 minutes, the script container_checker would write the alerting message into the syslog. So at the line 223, I used the command sudo cat /var/log/syslog | grep -m 1 '.*monit.*container_checker' to try to get the message generated by container_checker. Since this command will only get a single alerting message from syslog, that's why at there I used alerting_message["stdout_lines"][0]. I do not know whether such method is appropriate or not? Any suggestions?
There was a problem hiding this comment.
Updated with a flexible method! Please review again!
| return False | ||
|
|
||
|
|
||
| def clear_failed_flag_and_restart(duthost, container_name): |
There was a problem hiding this comment.
Same definition is found in test_container_autorestart.py. Could you help to make it a common utility in tests/common/helpers/dut_utils.py ? Thanks
There was a problem hiding this comment.
Great suggestion! Will move this function and its related functions to the file tests/common/helpers/dut_utils.py.
|
can you fix your test failing? |
tests/kvmtest.sh
Outdated
| platform_tests/test_cpu_memory_usage.py \ | ||
| bgp/test_bgpmon.py" | ||
| bgp/test_bgpmon.py" \ | ||
| container_checker/test_container_checker.py |
There was a problem hiding this comment.
The above two lines should be:
bgp/test_bgpmon.py \
container_checker/test_container_checker.py"
Otherwise, the kvmtest.sh script will try to run container_checker/test_container_checker.py and will fail.
There was a problem hiding this comment.
Good catch! Fixed.
| Args: | ||
| duthost: Host DUT. | ||
| container_name: Name of container. | ||
| should be running: Boolean value. |
There was a problem hiding this comment.
should be running -> should_be_running
Signed-off-by: Yong Zhao <yozhao@microsoft.com>
Signed-off-by: Yong Zhao <yozhao@microsoft.com>
Signed-off-by: Yong Zhao <yozhao@microsoft.com>
Fixed. |
Added. |
|
LGTM. Let's watch test results in regression test. |
…AD (sonic-net#15532) #### Why I did it Update submodule sonic-utilities to the latest HEAD ``` 50296b90 - [202012][dhcp-relay] Fix dhcp6relay counter issue (sonic-net#2866) (sonic-net#2873) (Fri Jun 30 18:08:53 2023 +0800) <Yaqiang Zhu> 160030c4 - [202012][dhcp_relay] Add "Reconfigure", "Information-Request", "Malformed" counter options (sonic-net#2844) (Sun Jun 11 20:35:30 2023 -0700) <kellyyeh> e6289ced - [vlan][dhcp_relay] Clear dhcpv6 relay counter while deleting vlan (sonic-net#2852) (Fri Jun 2 18:20:21 2023 +0000) <Yaqiang Zhu> 885082ec - correctly parsing complete ipv6 vnet info (sonic-net#2827) (Thu May 25 06:01:40 2023 +0000) <Keith Lu> ``` ##### Work item tracking - Microsoft ADO 22635770
…atically (sonic-net#15320) src/sonic-utilities * ec472146 - (HEAD -> 202205, origin/202205) fix show interface neighbor expected empty issue (sonic-net#2465) (3 minutes ago) [jcaiMR] * d1f4413c - [vlan][dhcp_relay] Clear dhcpv6 relay counter while deleting vlan (sonic-net#2852) (6 hours ago) [Yaqiang Zhu] * 051f28ce - [db-migrator] Fix hwsku match for 6100 and add errors when hwsku is None (sonic-net#2821) (7 hours ago) [Vaibhav Hemant Dixit]
…atically (sonic-net#15422) #### Why I did it src/sonic-utilities ``` * 1246bc81 - (HEAD -> 202211, origin/202211) [config reload]Config Reload Enhancement (sonic-net#2693) (sonic-net#2863) (2 days ago) [Sudharsan Dhamal Gopalarathnam] * d69aae4d - [vlan][dhcp_relay] Clear dhcpv6 relay counter while deleting vlan (sonic-net#2852) (2 days ago) [Yaqiang Zhu] * 0f6bf8ac - [config]: Dynamically start and stop ndppd (sonic-net#2814) (2 days ago) [Lawrence Lee] * 48a63ff1 - Fix issue: out of range sflow polling interval is accepted and stored in config_db (sonic-net#2847) (2 days ago) [Junchao-Mellanox] ``` #### How I did it #### How to verify it #### Description for the changelog
Description of PR
Summary:
This PR aims to test the feature of container checker and PR link is sonic-net/sonic-buildimage#6251.
Fixes # (issue)
Type of change
Approach
What is the motivation for this PR?
This PR aims to test the feature of container checker and PR link of container checker is sonic-net/sonic-buildimage#6251.
The script of
container_checkerwas run periodically by Monit and aims to monitor the running status of each container. Currently the auto-restart feature was enabled. If a critical process exited unexpected, the container will be restarted. If the container was restarted 3 times during 20 minutes, then it will not run anymore unless we cleared the flag using the commandsudo systemctl reset-failed <container_name>manually.How did you do it?
This pytest script will test the script
container_checkerin the following steps:How did you verify/test it?
I tested this pytest script on a virtual testbed.
Any platform specific information?
N/A
Supported testbed topology if it's a new test case?
N/A
Documentation