Skip to content

Commit 1bfbb73

Browse files
donlope-ciscovrajeshe
authored andcommitted
fix for led color in test_system_health.py (sonic-net#22675)
What is the motivation for this PR? The assert in this function was triggering when run on simulators and HW devices How did you do it? How did you verify/test it? Verified with SIM Signed-off-by: Don Lopez <[email protected]> Signed-off-by: Venkata Gouri Rajesh Etla <[email protected]>
1 parent 4c83ce1 commit 1bfbb73

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

tests/system_health/test_system_health.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@
6363
EXPECT_PSU_HOT = '{} temperature is too hot'
6464
EXPECT_PSU_INVALID_VOLTAGE = '{} voltage is out of range'
6565

66+
DEFAULT_LED_CONFIG = {
67+
'fault': 'red',
68+
'normal': 'green',
69+
'booting': 'red'
70+
}
71+
6672

6773
@pytest.fixture(autouse=True, scope="module")
6874
def check_image_version(duthost):
@@ -516,12 +522,19 @@ def check_system_health_led_info(duthost):
516522
status_dict = {name: status for name, status in status_data}
517523
logger.info(f"Status dict is {status_dict}")
518524

525+
led_cfg = get_system_health_config(duthost, "led_color", DEFAULT_LED_CONFIG)
526+
527+
system_status_lower = system_led_status.lower()
519528
if all(status == "OK" for status in status_dict.values()):
520-
assert system_led_status.lower() == 'green', \
521-
f"System status LED is not green, but it is {system_led_status}"
529+
# Logic for healthy system: must match the 'normal' key value
530+
expected_normal = led_cfg["normal"].lower()
531+
assert system_status_lower == expected_normal, \
532+
f"System status LED is not the configured 'normal' color ({expected_normal}), but it is {system_led_status}"
522533
else:
523-
assert system_led_status.lower() in ["yellow", "amber", "red"], \
524-
f"System status LED is not yellow, amber, or red, but it is {system_led_status}"
534+
# Logic for faulted system: Iterate through led_cfg to find a match among non-normal keys
535+
not_normal = {color for key, color in led_cfg.items() if key != "normal"}
536+
assert system_status_lower in not_normal, \
537+
f"System status LED '{system_led_status}' does not match any colors defined in config: {not_normal}"
525538

526539
return True
527540

0 commit comments

Comments
 (0)