Skip to content

Commit 9b77a9b

Browse files
authored
Merge pull request #46 from mssonicbld/sonicbld/202506-merge
```<br>* e75e8b9 - (HEAD -> 202506) Merge branch '202505' of https://github.com/sonic-net/sonic-platform-daemons into 202506 (2025-09-06) [Sonic Automation] * c5e545e - (origin/202505) [202505] [xcvrd] Improve logging in case of unable to find appropriate match for optic SI settings (#672) (#673) (2025-09-06) [mihirpat1]<br>```
2 parents f3bd628 + e75e8b9 commit 9b77a9b

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

sonic-xcvrd/tests/test_xcvrd.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4620,3 +4620,31 @@ def wait_until(total_wait_time, interval, call_back, *args, **kwargs):
46204620
time.sleep(interval)
46214621
wait_time += interval
46224622
return False
4623+
4624+
class TestOpticSiParser(object):
4625+
def test_get_optics_si_settings_value_no_values_with_empty_default(self):
4626+
"""Test get_optics_si_settings_value logging when port exists but has empty config and no default values"""
4627+
from xcvrd.xcvrd_utilities.optics_si_parser import get_optics_si_settings_value
4628+
import xcvrd.xcvrd_utilities.optics_si_parser as parser
4629+
4630+
original_dict = parser.g_optics_si_dict
4631+
4632+
# Set up scenario where:
4633+
# 1. Port exists in PORT_MEDIA_SETTINGS but has empty configuration
4634+
# 2. This makes len(optics_si_dict) == 0
4635+
# 3. Default dict is empty (len(default_dict) == 0)
4636+
parser.g_optics_si_dict = {
4637+
'PORT_MEDIA_SETTINGS': {
4638+
'5': {} # Port exists but is empty - this triggers len(optics_si_dict) == 0
4639+
}
4640+
}
4641+
4642+
try:
4643+
# This should trigger the log_info line at lines 119-121
4644+
# since len(optics_si_dict) == 0 and len(default_dict) == 0
4645+
result = get_optics_si_settings_value(5, 25, "VENDOR-1234", "VENDOR")
4646+
4647+
# Should return empty dict when no values found and no defaults
4648+
assert result == {}
4649+
finally:
4650+
parser.g_optics_si_dict = original_dict

sonic-xcvrd/xcvrd/xcvrd_utilities/optics_si_parser.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ def get_optics_si_settings_value(physical_port, lane_speed, key, vendor_name_str
6565
if len(default_dict) != 0:
6666
return default_dict
6767
else:
68-
helper_logger.log_error("Error: No values for physical port '{}'".format(physical_port))
68+
helper_logger.log_info("No values for physical port '{}' lane speed '{}' "
69+
"key '{}' vendor '{}'".format(
70+
physical_port, lane_speed, key, vendor_name_str))
6971
return {}
7072

7173
key_dict = {}

0 commit comments

Comments
 (0)