Skip to content

Commit

Permalink
Remove redundant xcvr_table_helper init during CmisManagerTask init (#…
Browse files Browse the repository at this point in the history
…521)

Signed-off-by: Mihir Patel <[email protected]>
  • Loading branch information
mihirpat1 authored Jul 24, 2024
1 parent d6a4635 commit bf865c6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 10 additions & 0 deletions sonic-xcvrd/tests/test_xcvrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ def test_CmisManagerTask_get_xcvr_api_exception(self, mock_platform_chassis, moc
task.get_host_tx_status = MagicMock(return_value='true')
task.get_port_admin_status = MagicMock(return_value='up')
task.get_cfg_port_tbl = MagicMock()
task.xcvr_table_helper = XcvrTableHelper(DEFAULT_NAMESPACE)
task.xcvr_table_helper.get_status_tbl.return_value = mock_get_status_tbl
port_change_event = PortChangeEvent('Ethernet0', 1, 0, PortChangeEvent.PORT_SET,
{'speed':'400000', 'lanes':'1,2,3,4,5,6,7,8'})
Expand Down Expand Up @@ -1460,6 +1461,7 @@ def test_CmisManagerTask_update_port_transceiver_status_table_sw_cmis_state(self
port_change_event = PortChangeEvent('Ethernet0', 1, 0, PortChangeEvent.PORT_SET)
task.on_port_update_event(port_change_event)

task.xcvr_table_helper = XcvrTableHelper(DEFAULT_NAMESPACE)
task.xcvr_table_helper.get_status_tbl = MagicMock(return_value=None)
task.update_port_transceiver_status_table_sw_cmis_state("Ethernet0", CMIS_STATE_INSERTED)

Expand Down Expand Up @@ -1505,6 +1507,7 @@ def test_CmisManagerTask_get_configured_freq(self, mock_table_helper):
cfg_port_tbl = MagicMock()
cfg_port_tbl.get = MagicMock(return_value=(True, (('laser_freq', 193100),)))
mock_table_helper.get_cfg_port_tbl = MagicMock(return_value=cfg_port_tbl)
task.xcvr_table_helper = XcvrTableHelper(DEFAULT_NAMESPACE)
task.xcvr_table_helper.get_cfg_port_tbl = mock_table_helper.get_cfg_port_tbl
assert task.get_configured_laser_freq_from_db('Ethernet0') == 193100

Expand All @@ -1516,6 +1519,7 @@ def test_CmisManagerTask_get_configured_tx_power_from_db(self, mock_table_helper
cfg_port_tbl = MagicMock()
cfg_port_tbl.get = MagicMock(return_value=(True, (('tx_power', -10),)))
mock_table_helper.get_cfg_port_tbl = MagicMock(return_value=cfg_port_tbl)
task.xcvr_table_helper = XcvrTableHelper(DEFAULT_NAMESPACE)
task.xcvr_table_helper.get_cfg_port_tbl = mock_table_helper.get_cfg_port_tbl
assert task.get_configured_tx_power_from_db('Ethernet0') == -10

Expand Down Expand Up @@ -1690,6 +1694,7 @@ def test_CmisManagerTask_post_port_active_apsel_to_db_error_cases(self, mock_fie
host_lanes_mask = 0xff

# Case: table does not exist
task.xcvr_table_helper = XcvrTableHelper(DEFAULT_NAMESPACE)
task.xcvr_table_helper.get_intf_tbl = MagicMock(return_value=None)
task.post_port_active_apsel_to_db(mock_xcvr_api, lport, host_lanes_mask)
assert mock_field_value_pairs.call_count == 0
Expand Down Expand Up @@ -1747,6 +1752,7 @@ def test_CmisManagerTask_post_port_active_apsel_to_db(self):
port_mapping = PortMapping()
stop_event = threading.Event()
task = CmisManagerTask(DEFAULT_NAMESPACE, port_mapping, stop_event)
task.xcvr_table_helper = XcvrTableHelper(DEFAULT_NAMESPACE)
task.xcvr_table_helper.get_intf_tbl = MagicMock(return_value=int_tbl)

# case: partial lanes update
Expand Down Expand Up @@ -1893,6 +1899,7 @@ def test_CmisManagerTask_task_worker(self, mock_chassis, mock_get_status_tbl):
stop_event = threading.Event()
task = CmisManagerTask(DEFAULT_NAMESPACE, port_mapping, stop_event)
task.port_mapping.logical_port_list = ['Ethernet0']
task.xcvr_table_helper = XcvrTableHelper(DEFAULT_NAMESPACE)
task.xcvr_table_helper.get_status_tbl.return_value = mock_get_status_tbl
task.task_stopping_event.is_set = MagicMock(side_effect=[False, False, True])
task.task_worker()
Expand Down Expand Up @@ -1959,6 +1966,7 @@ def test_CmisManagerTask_task_worker(self, mock_chassis, mock_get_status_tbl):
stop_event = threading.Event()
task = CmisManagerTask(DEFAULT_NAMESPACE, port_mapping, stop_event)
task.port_mapping.logical_port_list = ['Ethernet1']
task.xcvr_table_helper = XcvrTableHelper(DEFAULT_NAMESPACE)
task.xcvr_table_helper.get_status_tbl.return_value = mock_get_status_tbl
task.task_stopping_event.is_set = MagicMock(side_effect=[False, False, True])
task.task_worker()
Expand Down Expand Up @@ -2095,6 +2103,7 @@ def test_CmisManagerTask_task_worker_fastboot(self, mock_chassis, mock_get_statu
stop_event = threading.Event()
task = CmisManagerTask(DEFAULT_NAMESPACE, port_mapping, stop_event)
task.port_mapping.logical_port_list = ['Ethernet0']
task.xcvr_table_helper = XcvrTableHelper(DEFAULT_NAMESPACE)
task.xcvr_table_helper.get_status_tbl.return_value = mock_get_status_tbl
task.task_stopping_event.is_set = MagicMock(side_effect=[False, False, True])
task.task_worker()
Expand Down Expand Up @@ -2230,6 +2239,7 @@ def test_CmisManagerTask_task_worker_host_tx_ready_false(self, mock_chassis, moc
stop_event = threading.Event()
task = CmisManagerTask(DEFAULT_NAMESPACE, port_mapping, stop_event)
task.port_mapping.logical_port_list = ['Ethernet0']
task.xcvr_table_helper = XcvrTableHelper(DEFAULT_NAMESPACE)
task.xcvr_table_helper.get_status_tbl.return_value = mock_get_status_tbl
task.task_stopping_event.is_set = MagicMock(side_effect=[False, False, True])
task.task_worker()
Expand Down
1 change: 0 additions & 1 deletion sonic-xcvrd/xcvrd/xcvrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,6 @@ def __init__(self, namespaces, port_mapping, main_thread_stop_event, skip_cmis_m
self.main_thread_stop_event = main_thread_stop_event
self.port_dict = {}
self.port_mapping = copy.deepcopy(port_mapping)
self.xcvr_table_helper = XcvrTableHelper(namespaces)
self.isPortInitDone = False
self.isPortConfigDone = False
self.skip_cmis_mgr = skip_cmis_mgr
Expand Down

0 comments on commit bf865c6

Please sign in to comment.