[Mellanox] wait until hw-management watchdog files ready (#17618) (#17633)

This commit is contained in:
mssonicbld 2023-12-29 01:07:45 +08:00 committed by GitHub
parent a8ad19d4ac
commit fb83d4d82f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -283,7 +283,8 @@ def get_watchdog():
"""
Return WatchdogType1 or WatchdogType2 based on system
"""
utils.wait_until(lambda: os.path.exists('/run/hw-management/watchdog/main/state'), timeout=10, interval=1)
watchdog_main_device_name = None
for device in os.listdir("/dev/"):

View File

@ -36,6 +36,7 @@ from sonic_platform.watchdog import get_watchdog, \
class TestWatchdog:
@mock.patch('sonic_platform.utils.wait_until', mock.MagicMock())
@mock.patch('sonic_platform.watchdog.is_mlnx_wd_main')
@mock.patch('sonic_platform.watchdog.os.listdir')
def test_get_watchdog_no_device(self, mock_listdir, mock_is_main):
@ -50,6 +51,7 @@ class TestWatchdog:
mock_is_main.return_value = False
assert get_watchdog() is None
@mock.patch('sonic_platform.utils.wait_until', mock.MagicMock())
@mock.patch('sonic_platform.watchdog.is_mlnx_wd_main')
@mock.patch('sonic_platform.watchdog.is_wd_type2')
@mock.patch('sonic_platform.watchdog.os.listdir', mock.MagicMock(return_value=['watchdog1', 'watchdog2']))