|
63 | 63 | EXPECT_PSU_HOT = '{} temperature is too hot' |
64 | 64 | EXPECT_PSU_INVALID_VOLTAGE = '{} voltage is out of range' |
65 | 65 |
|
| 66 | +DEFAULT_LED_CONFIG = { |
| 67 | + 'fault': 'red', |
| 68 | + 'normal': 'green', |
| 69 | + 'booting': 'red' |
| 70 | +} |
| 71 | + |
66 | 72 |
|
67 | 73 | @pytest.fixture(autouse=True, scope="module") |
68 | 74 | def check_image_version(duthost): |
@@ -516,12 +522,19 @@ def check_system_health_led_info(duthost): |
516 | 522 | status_dict = {name: status for name, status in status_data} |
517 | 523 | logger.info(f"Status dict is {status_dict}") |
518 | 524 |
|
| 525 | + led_cfg = get_system_health_config(duthost, "led_color", DEFAULT_LED_CONFIG) |
| 526 | + |
| 527 | + system_status_lower = system_led_status.lower() |
519 | 528 | 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}" |
522 | 533 | 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}" |
525 | 538 |
|
526 | 539 | return True |
527 | 540 |
|
|
0 commit comments