From 5957f230c55a481b098017acc790c247fd18e937 Mon Sep 17 00:00:00 2001 From: "Marty Y. Lok" <76118573+mlok-nokia@users.noreply.github.com> Date: Wed, 11 Sep 2024 22:15:24 -0400 Subject: [PATCH] [PMON][psud] Fix the repeated NOTICE log message on Chassis platform (#529) * [PMON][psud] Fix the repeated NOTICE log message on Chassis platform Signed-off-by: mlok * Fix the Unit test --------- Signed-off-by: mlok --- sonic-psud/scripts/psud | 2 ++ sonic-psud/tests/test_PsuChassisInfo.py | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/sonic-psud/scripts/psud b/sonic-psud/scripts/psud index 013f8a082..e3f56be78 100644 --- a/sonic-psud/scripts/psud +++ b/sonic-psud/scripts/psud @@ -268,6 +268,8 @@ class PsuChassisInfo(logger.Logger): 'PSU supplied power warning: {}W supplied-power less than {}W consumed-power'.format( self.total_supplied_power, self.total_consumed_power) ) + if self.first_run: + self.first_run = False return set_led diff --git a/sonic-psud/tests/test_PsuChassisInfo.py b/sonic-psud/tests/test_PsuChassisInfo.py index f40836268..21bc7fe1e 100644 --- a/sonic-psud/tests/test_PsuChassisInfo.py +++ b/sonic-psud/tests/test_PsuChassisInfo.py @@ -76,14 +76,14 @@ def test_update_master_status(self): # Test good values while in good state ret = chassis_info.update_master_status() - assert ret == True + assert ret == False assert chassis_info.master_status_good == True # Test unknown total_supplied_power (0.0) chassis_info.total_supplied_power = 0.0 chassis_info.master_status_good = False ret = chassis_info.update_master_status() - assert ret == True + assert ret == False assert chassis_info.master_status_good == False # Test bad values while in good state @@ -282,6 +282,15 @@ def test_first_run(self): assert ret == True assert psud.Psu.get_status_master_led() == MockPsu.STATUS_LED_COLOR_RED + # first time with good power usage + chassis_info = psud.PsuChassisInfo(SYSLOG_IDENTIFIER, chassis) + chassis_info.total_supplied_power = 510.0 + chassis_info.total_consumed_power = 350.0 + ret = chassis_info.update_master_status() + assert ret == True + assert psud.Psu.get_status_master_led() == MockPsu.STATUS_LED_COLOR_GREEN + + chassis_info = psud.PsuChassisInfo(SYSLOG_IDENTIFIER, chassis) chassis_info.total_supplied_power = 510.0 chassis_info.total_consumed_power = 350.0 chassis_info.master_status_good = True