Skip to content

Commit 20ca012

Browse files
committed
fix for led color in test_system_health.py
Signed-off-by: Don Lopez <donlope@cisco.com>
1 parent 4448b9d commit 20ca012

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

tests/system_health/test_system_health.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@
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+
}
6671

6772
@pytest.fixture(autouse=True, scope="module")
6873
def check_image_version(duthost):
@@ -516,12 +521,18 @@ def check_system_health_led_info(duthost):
516521
status_dict = {name: status for name, status in status_data}
517522
logger.info(f"Status dict is {status_dict}")
518523

524+
led_cfg = get_system_health_config(duthost, "led_color", DEFAULT_LED_CONFIG)
525+
526+
system_status_lower = system_led_status.lower()
519527
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}"
528+
# Logic for healthy system: must match the 'normal' key value
529+
expected_normal = led_cfg["normal"].lower()
530+
assert system_status_lower == expected_normal, \
531+
f"System status LED is not the configured 'normal' color ({expected_normal}), but it is {system_led_status}"
522532
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}"
533+
# Logic for faulted system: Iterate through led_cfg to find a match among non-normal keys
534+
not_normal = {color for key, color in led_cfg.items() if key != "normal"}
535+
assert system_status_lower in not_normal, f"System status LED '{system_led_status}' does not match any non-normal colors defined in config: {not_normal}"
525536

526537
return True
527538

0 commit comments

Comments
 (0)