Skip to content

Commit 7c74a0d

Browse files
patrickmacarthurselldinesh
authored andcommitted
sonic-mgmt: Fix namespace issues for qos tests on T2 single ASIC (sonic-net#15708)
We are seeing UnboundLocalError when running sonic-mgmt tests against a single-ASIC linecard: ``` UnboundLocalError: local variable 'dst_sys_port_id' referenced before assignment ``` Upon further investigation, this was determined to be happening because a previous attempt to fix this issue (PR sonic-net#13700) completely omitted the ASIC prefix, but the entries in SYSTEM_PORT in config_db do have an Asic0 prefix even on a single ASIC DUT. Resolve this by specifically adding the Asic0 prefix in the case of a single-ASIC T2 DUT, instead of leaving the prefix out. Tested by manually running qos tests on a T2 single ASIC DUT with these changes.
1 parent 25c97fc commit 7c74a0d

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

tests/qos/qos_sai_base.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,7 @@ def dutConfig(
10891089
dutPortIps[src_dut_index][src_asic_index] = {}
10901090
sysPortMap[src_dut_index][src_asic_index] = {}
10911091
active_ips = src_asic.get_active_ip_interfaces(tbinfo)
1092+
src_namespace_prefix = src_asic.namespace + '|' if src_asic.namespace else f'Asic{src_asic.asic_index}|'
10921093
for iface, addr in active_ips.items():
10931094
if iface.startswith("Ethernet") and ("Ethernet-Rec" not in iface):
10941095
portIndex = src_mgFacts["minigraph_ptf_indices"][iface]
@@ -1097,7 +1098,7 @@ def dutConfig(
10971098
# Map port IDs to system port for dnx chassis
10981099
if 'platform_asic' in get_src_dst_asic_and_duts["src_dut"].facts and \
10991100
get_src_dst_asic_and_duts["src_dut"].facts['platform_asic'] == 'broadcom-dnx':
1100-
sys_key = src_asic.namespace + '|' + iface if src_asic.namespace else iface
1101+
sys_key = src_namespace_prefix + iface
11011102
if sys_key in src_system_port:
11021103
system_port = src_system_port[sys_key]['system_port_id']
11031104
sysPort = {'port': iface, 'system_port': system_port, 'port_type': iface}
@@ -1114,7 +1115,7 @@ def dutConfig(
11141115
if 'platform_asic' in get_src_dst_asic_and_duts["src_dut"].facts and \
11151116
get_src_dst_asic_and_duts["src_dut"].facts['platform_asic'] == 'broadcom-dnx':
11161117
for portName in src_mgFacts["minigraph_portchannels"][iface]["members"]:
1117-
sys_key = src_asic.namespace + '|' + portName if src_asic.namespace else portName
1118+
sys_key = src_namespace_prefix + portName
11181119
port_Index = src_mgFacts["minigraph_ptf_indices"][portName]
11191120
if sys_key in src_system_port:
11201121
system_port = src_system_port[sys_key]['system_port_id']
@@ -1132,6 +1133,7 @@ def dutConfig(
11321133
dutPortIps[dst_dut_index] = {}
11331134
testPortIds[dst_dut_index] = {}
11341135
sysPortMap[dst_dut_index] = {}
1136+
dst_system_port = {}
11351137
if 'platform_asic' in get_src_dst_asic_and_duts["src_dut"].facts and \
11361138
get_src_dst_asic_and_duts["src_dut"].facts['platform_asic'] == 'broadcom-dnx':
11371139
dst_system_port = dst_dut.config_facts(host=dst_dut.hostname, source='running')[
@@ -1141,6 +1143,7 @@ def dutConfig(
11411143
dst_system_port = src_system_port
11421144
dutPortIps[dst_dut_index][dst_asic_index] = {}
11431145
sysPortMap[dst_dut_index][dst_asic_index] = {}
1146+
dst_namespace_prefix = dst_asic.namespace + '|' if dst_asic.namespace else f'Asic{dst_asic.asic_index}|'
11441147
active_ips = dst_asic.get_active_ip_interfaces(tbinfo)
11451148
for iface, addr in active_ips.items():
11461149
if iface.startswith("Ethernet") and ("Ethernet-Rec" not in iface):
@@ -1150,7 +1153,7 @@ def dutConfig(
11501153
# Map port IDs to system port IDs
11511154
if 'platform_asic' in get_src_dst_asic_and_duts["src_dut"].facts and \
11521155
get_src_dst_asic_and_duts["src_dut"].facts['platform_asic'] == 'broadcom-dnx':
1153-
sys_key = dst_asic.namespace + '|' + iface if dst_asic.namespace else iface
1156+
sys_key = dst_namespace_prefix + iface
11541157
if sys_key in dst_system_port:
11551158
system_port = dst_system_port[sys_key]['system_port_id']
11561159
sysPort = {'port': iface, 'system_port': system_port, 'port_type': iface}
@@ -1167,7 +1170,7 @@ def dutConfig(
11671170
if 'platform_asic' in get_src_dst_asic_and_duts["src_dut"].facts and \
11681171
get_src_dst_asic_and_duts["src_dut"].facts['platform_asic'] == 'broadcom-dnx':
11691172
for portName in dst_mgFacts["minigraph_portchannels"][iface]["members"]:
1170-
sys_key = dst_asic.namespace + '|' + portName if dst_asic.namespace else portName
1173+
sys_key = dst_namespace_prefix + portName
11711174
port_Index = dst_mgFacts["minigraph_ptf_indices"][portName]
11721175
if sys_key in dst_system_port:
11731176
system_port = dst_system_port[sys_key]['system_port_id']

tests/saitests/py3/sai_qos_tests.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4018,10 +4018,9 @@ def runTest(self):
40184018
self.dst_client, asic_type, port_list['dst'][dst_port_id])
40194019
# for t2 chassis
40204020
if platform_asic and platform_asic == "broadcom-dnx":
4021-
if dst_port_id in dst_sys_port_ids:
4022-
for port_id, sysport in dst_sys_port_ids.items():
4023-
if dst_port_id == port_id:
4024-
dst_sys_port_id = int(sysport)
4021+
assert dst_port_id in dst_sys_port_ids, \
4022+
"dst_port_id does not have a sys port id configured"
4023+
dst_sys_port_id = int(dst_sys_port_ids[dst_port_id])
40254024
log_message("actual dst_sys_port_id: {}".format(dst_sys_port_id), to_stderr=True)
40264025
voq_list = sai_thrift_get_voq_port_id(self.src_client, dst_sys_port_id)
40274026
voq_queue_counters_base = sai_thrift_read_port_voq_counters(self.src_client, voq_list)

0 commit comments

Comments
 (0)