@@ -80,14 +80,25 @@ def test_post_port_dom_info_to_db(self, mock_get_sfp_type):
8080 mock_get_sfp_type .return_value = 'QSFP_DD'
8181 post_port_dom_info_to_db (logical_port_name , port_mapping , dom_tbl , stop_event )
8282
83+ def test_post_port_dom_threshold_info_to_db (self , mock_get_sfp_type ):
84+ logical_port_name = "Ethernet0"
85+ port_mapping = PortMapping ()
86+ stop_event = threading .Event ()
87+ dom_threshold_tbl = Table ("STATE_DB" , TRANSCEIVER_DOM_THRESHOLD_TABLE )
88+ post_port_dom_info_to_db (logical_port_name , port_mapping , dom_threshold_tbl , stop_event )
89+ mock_get_sfp_type .return_value = 'QSFP_DD'
90+ post_port_dom_info_to_db (logical_port_name , port_mapping , dom_threshold_tbl , stop_event )
91+
8392 @patch ('xcvrd.xcvrd_utilities.port_mapping.PortMapping.logical_port_name_to_physical_port_list' , MagicMock (return_value = [0 ]))
8493 @patch ('xcvrd.xcvrd._wrapper_get_presence' , MagicMock (return_value = True ))
8594 def test_del_port_sfp_dom_info_from_db (self ):
8695 logical_port_name = "Ethernet0"
8796 port_mapping = PortMapping ()
8897 dom_tbl = Table ("STATE_DB" , TRANSCEIVER_DOM_SENSOR_TABLE )
98+ dom_threshold_tbl = Table ("STATE_DB" , TRANSCEIVER_DOM_THRESHOLD_TABLE )
8999 init_tbl = Table ("STATE_DB" , TRANSCEIVER_INFO_TABLE )
90100 del_port_sfp_dom_info_from_db (logical_port_name , port_mapping , init_tbl , dom_tbl )
101+ del_port_sfp_dom_info_from_db (logical_port_name , port_mapping , init_tbl , dom_threshold_tbl )
91102
92103 @patch ('xcvrd.xcvrd_utilities.port_mapping.PortMapping.logical_port_name_to_physical_port_list' , MagicMock (return_value = [0 ]))
93104 @patch ('xcvrd.xcvrd._wrapper_get_presence' , MagicMock (return_value = True ))
@@ -115,8 +126,8 @@ def test_post_port_dom_threshold_info_to_db(self):
115126 logical_port_name = "Ethernet0"
116127 port_mapping = PortMapping ()
117128 stop_event = threading .Event ()
118- dom_tbl = Table ("STATE_DB" , TRANSCEIVER_DOM_SENSOR_TABLE )
119- post_port_dom_threshold_info_to_db (logical_port_name , port_mapping , dom_tbl , stop_event )
129+ dom_threshold_tbl = Table ("STATE_DB" , TRANSCEIVER_DOM_THRESHOLD_TABLE )
130+ post_port_dom_threshold_info_to_db (logical_port_name , port_mapping , dom_threshold_tbl , stop_event )
120131
121132 @patch ('xcvrd.xcvrd_utilities.port_mapping.PortMapping.logical_port_name_to_physical_port_list' , MagicMock (return_value = [0 ]))
122133 @patch ('xcvrd.xcvrd._wrapper_get_presence' , MagicMock (return_value = True ))
@@ -709,6 +720,7 @@ def test_SfpStateUpdateTask_handle_port_change_event(self, mock_table_helper):
709720 mock_table_helper .get_status_tbl = MagicMock (return_value = mock_table )
710721 mock_table_helper .get_int_tbl = MagicMock (return_value = mock_table )
711722 mock_table_helper .get_dom_tbl = MagicMock (return_value = mock_table )
723+ mock_table_helper .get_dom_threshold_tbl = MagicMock (return_value = mock_table )
712724 stopping_event = multiprocessing .Event ()
713725 port_mapping = PortMapping ()
714726 retry_eeprom_set = set ()
@@ -762,6 +774,7 @@ def test_SfpStateUpdateTask_retry_eeprom_reading(self, mock_post_sfp_info):
762774 task .xcvr_table_helper = XcvrTableHelper (DEFAULT_NAMESPACE )
763775 task .xcvr_table_helper .get_intf_tbl = MagicMock (return_value = mock_table )
764776 task .xcvr_table_helper .get_dom_tbl = MagicMock (return_value = mock_table )
777+ task .xcvr_table_helper .get_dom_threshold_tbl = MagicMock (return_value = mock_table )
765778 task .xcvr_table_helper .get_app_port_tbl = MagicMock (return_value = mock_table )
766779 task .retry_eeprom_reading ()
767780 assert mock_post_sfp_info .call_count == 0
@@ -888,7 +901,7 @@ def test_SfpStateUpdateTask_task_worker(self, mock_updata_status, mock_post_sfp_
888901 # Test state machine: handle SFP remove event
889902 task .task_worker (stop_event , sfp_error_event )
890903 assert mock_updata_status .call_count == 1
891- assert mock_del_dom .call_count == 1
904+ assert mock_del_dom .call_count == 2
892905
893906 stop_event .is_set = MagicMock (side_effect = [False , True ])
894907 error = int (SFP_STATUS_INSERTED ) | SfpBase .SFP_ERROR_BIT_BLOCKING | SfpBase .SFP_ERROR_BIT_POWER_BUDGET_EXCEEDED
@@ -898,7 +911,7 @@ def test_SfpStateUpdateTask_task_worker(self, mock_updata_status, mock_post_sfp_
898911 # Test state machine: handle SFP error event
899912 task .task_worker (stop_event , sfp_error_event )
900913 assert mock_updata_status .call_count == 1
901- assert mock_del_dom .call_count == 1
914+ assert mock_del_dom .call_count == 2
902915
903916 @patch ('xcvrd.xcvrd.XcvrTableHelper' )
904917 @patch ('xcvrd.xcvrd._wrapper_get_presence' )
@@ -920,9 +933,13 @@ class MockTable:
920933 dom_tbl = MockTable ()
921934 dom_tbl .get = MagicMock (return_value = (True , (('key3' , 'value3' ),)))
922935 dom_tbl .set = MagicMock ()
936+ dom_threshold_tbl = MockTable ()
937+ dom_threshold_tbl .get = MagicMock (return_value = (True , (('key4' , 'value4' ),)))
938+ dom_threshold_tbl .set = MagicMock ()
923939 mock_table_helper .get_status_tbl = MagicMock (return_value = status_tbl )
924940 mock_table_helper .get_intf_tbl = MagicMock (return_value = int_tbl )
925941 mock_table_helper .get_dom_tbl = MagicMock (return_value = dom_tbl )
942+ mock_table_helper .get_dom_threshold_tbl = MagicMock (return_value = dom_threshold_tbl )
926943
927944 port_mapping = PortMapping ()
928945 retry_eeprom_set = set ()
@@ -931,6 +948,7 @@ class MockTable:
931948 task .xcvr_table_helper .get_status_tbl = mock_table_helper .get_status_tbl
932949 task .xcvr_table_helper .get_intf_tbl = mock_table_helper .get_intf_tbl
933950 task .xcvr_table_helper .get_dom_tbl = mock_table_helper .get_dom_tbl
951+ task .xcvr_table_helper .get_dom_threshold_tbl = mock_table_helper .get_dom_threshold_tbl
934952 port_change_event = PortChangeEvent ('Ethernet0' , 1 , 0 , PortChangeEvent .PORT_ADD )
935953 task .port_mapping .handle_port_change_event (port_change_event )
936954 # SFP information is in the DB, copy the SFP information for the newly added logical port
@@ -941,6 +959,8 @@ class MockTable:
941959 int_tbl .set .assert_called_with ('Ethernet0' , (('key2' , 'value2' ),))
942960 dom_tbl .get .assert_called_with ('Ethernet0' )
943961 dom_tbl .set .assert_called_with ('Ethernet0' , (('key3' , 'value3' ),))
962+ dom_threshold_tbl .get .assert_called_with ('Ethernet0' )
963+ dom_threshold_tbl .set .assert_called_with ('Ethernet0' , (('key4' , 'value4' ),))
944964
945965 status_tbl .get .return_value = (False , ())
946966 mock_get_presence .return_value = True
@@ -969,7 +989,7 @@ class MockTable:
969989 assert mock_post_dom_info .call_count == 1
970990 mock_post_dom_info .assert_called_with ('Ethernet0' , task .port_mapping , dom_tbl )
971991 assert mock_post_dom_th .call_count == 1
972- mock_post_dom_th .assert_called_with ('Ethernet0' , task .port_mapping , dom_tbl )
992+ mock_post_dom_th .assert_called_with ('Ethernet0' , task .port_mapping , dom_threshold_tbl )
973993 assert mock_update_media_setting .call_count == 1
974994 assert 'Ethernet0' not in task .retry_eeprom_set
975995
0 commit comments