Skip to content

Commit

Permalink
[xcvrd] Fix issue: logical_port_name is not defined (#482)
Browse files Browse the repository at this point in the history
* [xcvrd] Fix issue: logical_port_name is not defined

* Add UT

---------

Co-authored-by: Prince George <45705344+prgeor@users.noreply.github.com>
  • Loading branch information
2 people authored and mssonicbld committed May 16, 2024
1 parent 867b0c7 commit 61df8be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions sonic-xcvrd/tests/test_xcvrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,15 @@ def test_fetch_optics_si_setting_with_comma(self):
def test_fetch_optics_si_setting_with_port(self):
self._check_fetch_optics_si_setting(1)

@patch('xcvrd.xcvrd_utilities.optics_si_parser.g_optics_si_dict', port_optics_si_settings)
@patch('xcvrd.xcvrd_utilities.optics_si_parser.get_module_vendor_key', MagicMock(return_value=(None, None)))
@patch('xcvrd.xcvrd._wrapper_get_presence', MagicMock(return_value=True))
def test_fetch_optics_si_setting_negative(self):
port = 1
lane_speed = 100
mock_sfp = MagicMock()
assert not optics_si_parser.fetch_optics_si_setting(port, lane_speed, mock_sfp)

@patch('xcvrd.xcvrd._wrapper_get_presence', MagicMock(return_value=True))
@patch('xcvrd.xcvrd_utilities.optics_si_parser.get_module_vendor_key', MagicMock(return_value=('CREDO-CAC82X321M','CREDO')))
def _check_fetch_optics_si_setting(self, index):
Expand Down
2 changes: 1 addition & 1 deletion sonic-xcvrd/xcvrd/xcvrd_utilities/optics_si_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def fetch_optics_si_setting(physical_port, lane_speed, sfp):
return optics_si
vendor_key, vendor_name = get_module_vendor_key(physical_port, sfp)
if vendor_key is None or vendor_name is None:
helper_logger.log_error("Error: No Vendor Key found for port '{}'".format(logical_port_name))
helper_logger.log_error("Error: No Vendor Key found for Module {}".format(physical_port))
return optics_si
optics_si = get_optics_si_settings_value(physical_port, lane_speed, vendor_key, vendor_name)
return optics_si
Expand Down

0 comments on commit 61df8be

Please sign in to comment.