@@ -1746,7 +1746,7 @@ def test_CmisManagerTask_get_configured_tx_power_from_db(self, mock_table_helper
1746
1746
(2 , 0x11 , 'Credo' , False ),
1747
1747
(1 , 0x1 , 'Molex' , False )
1748
1748
])
1749
- def test_CmisManagerTask_is_need_low_power_first (self , appl , host_assign , vendor , expected ):
1749
+ def test_CmisManagerTask_need_lp_mode_for_dpdeinit (self , appl , host_assign , vendor , expected ):
1750
1750
port_mapping = PortMapping ()
1751
1751
stop_event = threading .Event ()
1752
1752
task = CmisManagerTask (DEFAULT_NAMESPACE , port_mapping , stop_event )
@@ -1756,6 +1756,55 @@ def test_CmisManagerTask_is_need_low_power_first(self, appl, host_assign, vendor
1756
1756
mock_xcvr_api .get_host_lane_assignment_option = MagicMock (return_value = host_assign )
1757
1757
assert task .need_lp_mode_for_dpdeinit (mock_xcvr_api , appl ) == expected
1758
1758
1759
+ @patch ('xcvrd.xcvrd.XcvrTableHelper.get_status_tbl' )
1760
+ @patch ('xcvrd.xcvrd.platform_chassis' )
1761
+ @patch ('xcvrd.xcvrd.is_fast_reboot_enabled' , MagicMock (return_value = (False )))
1762
+ @patch ('xcvrd.xcvrd.PortChangeObserver' , MagicMock (handle_port_update_event = MagicMock ()))
1763
+ @patch ('xcvrd.xcvrd._wrapper_get_sfp_type' , MagicMock (return_value = 'QSFP_DD' ))
1764
+ @patch ('xcvrd.xcvrd.CmisManagerTask.wait_for_port_config_done' , MagicMock ())
1765
+ @patch ('xcvrd.xcvrd.is_cmis_api' , MagicMock (return_value = True ))
1766
+ def test_CmisManagerTask_need_lp_mode_for_dpdeinit_set_power_expired (self , mock_chassis , mock_get_status_tbl ):
1767
+ # set low power mode expired
1768
+ mock_get_status_tbl = Table ("STATE_DB" , TRANSCEIVER_STATUS_TABLE )
1769
+ mock_xcvr_api = MagicMock ()
1770
+ mock_xcvr_api .is_flat_memory = MagicMock (return_value = False )
1771
+ mock_xcvr_api .is_coherent_module = MagicMock (return_value = False )
1772
+ mock_xcvr_api .get_tx_config_power = MagicMock (return_value = 0 )
1773
+ mock_xcvr_api .get_laser_config_freq = MagicMock (return_value = 0 )
1774
+ mock_xcvr_api .get_module_type_abbreviation = MagicMock (return_value = 'QSFP-DD' )
1775
+
1776
+ mock_sfp = MagicMock ()
1777
+ mock_sfp .get_presence = MagicMock (return_value = True )
1778
+ mock_sfp .get_xcvr_api = MagicMock (return_value = mock_xcvr_api )
1779
+ mock_chassis .get_all_sfps = MagicMock (return_value = [mock_sfp ])
1780
+ mock_chassis .get_sfp = MagicMock (return_value = mock_sfp )
1781
+
1782
+ port_mapping = PortMapping ()
1783
+ stop_event = threading .Event ()
1784
+ task = CmisManagerTask (DEFAULT_NAMESPACE , port_mapping , stop_event )
1785
+ task .xcvr_table_helper = XcvrTableHelper (DEFAULT_NAMESPACE )
1786
+ task .xcvr_table_helper .get_status_tbl .return_value = mock_get_status_tbl
1787
+
1788
+ port_change_event = PortChangeEvent ('PortConfigDone' , - 1 , 0 , PortChangeEvent .PORT_SET )
1789
+ task .on_port_update_event (port_change_event )
1790
+ assert task .isPortConfigDone
1791
+ port_change_event = PortChangeEvent ('Ethernet0' , 1 , 0 , PortChangeEvent .PORT_SET ,
1792
+ {'speed' :'400000' , 'lanes' :'1,2,3,4,5,6,7,8' })
1793
+ task .on_port_update_event (port_change_event )
1794
+ assert len (task .port_dict ) == 1
1795
+ task .port_mapping .logical_port_list = MagicMock ()
1796
+ task .get_host_tx_status = MagicMock (return_value = 'true' )
1797
+ task .get_port_admin_status = MagicMock (return_value = 'up' )
1798
+ task .task_stopping_event .is_set = MagicMock (side_effect = [False , False , True ])
1799
+ task .update_port_transceiver_status_table_sw_cmis_state ("Ethernet0" , CMIS_STATE_DP_DEINIT )
1800
+ mock_xcvr_api .get_module_state = MagicMock (return_value = 'ModulePwrDn' )
1801
+ task .need_lp_mode_for_dpdeinit = MagicMock (return_value = True )
1802
+ task .port_dict ['Ethernet0' ]['host_lanes_mask' ] = 0xff
1803
+ task .port_dict ['Ethernet0' ]['appl' ] = 1
1804
+ task .port_dict ['Ethernet0' ]['cmis_expired' ] = datetime .datetime .now () - datetime .timedelta (100 )
1805
+ task .task_worker ()
1806
+ assert get_cmis_state_from_state_db ('Ethernet0' , task .xcvr_table_helper .get_status_tbl (task .port_mapping .get_asic_id_for_logical_port ('Ethernet0' ))) == CMIS_STATE_INSERTED
1807
+
1759
1808
@patch ('xcvrd.xcvrd.platform_chassis' )
1760
1809
@patch ('xcvrd.xcvrd.is_fast_reboot_enabled' , MagicMock (return_value = (False )))
1761
1810
@patch ('xcvrd.xcvrd.PortChangeObserver' , MagicMock (handle_port_update_event = MagicMock ()))
0 commit comments