Skip to content

Commit 59971e8

Browse files
yaqiangzwangxin
authored andcommitted
[system_health] Add support for check_system_health_info both old and new format (#7681)
What is the motivation for this PR? Test failed introduced by this PR sonic-net/sonic-buildimage#13497 has been fixed by this PR #7649. But in DUT with old image, it will failed. How did you do it? Add support for check_system_health_info to support both two formats How did you verify/test it? Run test Signed-off-by: Yaqiang Zhu <[email protected]>
1 parent 50d3c02 commit 59971e8

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tests/system_health/test_system_health.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,11 @@ def test_service_checker_with_process_exit(duthosts, enum_rand_one_per_hwsku_hos
134134
# use wait_until to check if SYSTEM_HEALTH_INFO has expected content
135135
# avoid waiting for too long or DEFAULT_INTERVAL is not long enough to refresh db
136136
category = '{}:{}'.format(container, critical_process)
137-
expected_value = "Process '{}' in container '{}' is not running".format(critical_process, container)
138-
result = wait_until(WAIT_TIMEOUT, 10, 2, check_system_health_info, duthost, category, expected_value)
137+
expected_values = ["Process '{}' in container '{}' is not running".format(critical_process, container),
138+
"'{}' is not running".format(critical_process)]
139+
result = wait_until(WAIT_TIMEOUT, 10, 2, check_system_health_info_any_of, duthost, category,
140+
expected_values)
141+
139142
assert result == True, '{} is not recorded'.format(critical_process)
140143
summary = redis_get_field_value(duthost, STATE_DB, HEALTH_TABLE_NAME, 'summary')
141144
assert summary == SUMMARY_NOT_OK, 'Expect summary {}, got {}'.format(SUMMARY_NOT_OK, summary)
@@ -365,6 +368,14 @@ def redis_get_system_health_info(duthost, db_id, key):
365368
output = duthost.shell(cmd)['stdout'].strip()
366369
return output
367370

371+
def check_system_health_info_any_of(duthost, category, expected_values):
372+
value = redis_get_field_value(duthost, STATE_DB, HEALTH_TABLE_NAME, category)
373+
for expected_value in expected_values:
374+
if value == expected_value:
375+
return True
376+
377+
return False
378+
368379
def check_system_health_info(duthost, category, expected_value):
369380
value = redis_get_field_value(duthost, STATE_DB, HEALTH_TABLE_NAME, category)
370381
return value == expected_value

0 commit comments

Comments
 (0)