Skip to content

Commit

Permalink
Fix python3 migration issue for qos sai test case (sonic-net#7958)
Browse files Browse the repository at this point in the history
Fix the issues: sonic-net#7866 and sonic-net#7884

What is the motivation for this PR?
Fix the test failure caused by python3 migration

How did you verify/test it?
Run qos sai and test_sub_port_l2_forwarding, and it could pass
  • Loading branch information
nhe-NV authored and parmarkj committed Oct 3, 2023
1 parent f94a91c commit 8909295
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions tests/qos/files/mellanox/qos_param_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@


class QosParamMellanox(object):
def __init__(self, qos_params, asic_type, speed_cable_len, dutConfig, ingressLosslessProfile,
ingressLossyProfile, egressLosslessProfile, egressLossyProfile, sharedHeadroomPoolSize, dualTor):
def __init__(self, qos_params, asic_type, speed_cable_len, dutConfig, ingressLosslessProfile, ingressLossyProfile,
egressLosslessProfile, egressLossyProfile, sharedHeadroomPoolSize, dualTor):
self.asic_param_dic = {
'spc1': {
'cell_size': 96,
Expand Down Expand Up @@ -107,7 +107,7 @@ def collect_qos_configurations(self):
for i in range(1, ingress_ports_num_shp):
for j in range(pgs_per_port):
pkts_num_trig_pfc_shp.append(occupancy_per_port + xon + hysteresis)
occupancy_per_port /= 2
occupancy_per_port //= 2
ingress_ports_list_shp.append(testPortIds[i])
self.qos_parameters['pkts_num_trig_pfc_shp'] = pkts_num_trig_pfc_shp
self.qos_parameters['src_port_ids'] = ingress_ports_list_shp
Expand Down
16 changes: 8 additions & 8 deletions tests/qos/qos_sai_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from tests.common.fixtures.duthost_utils import dut_qos_maps, separated_dscp_to_tc_map_on_uplink # noqa F401
from tests.common.utilities import wait_until
from tests.ptf_runner import ptf_runner
from tests.common.system_utils import docker # noqa F401
from tests.common.errors import RunAnsibleModuleFail

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -86,8 +87,9 @@ def dutTestParams(self, duthosts, enum_rand_one_per_hwsku_frontend_hostname, enu
if 'mac' in vlan and vlan['mac']:
dut_test_params["basicParams"]["def_vlan_mac"] = vlan['mac']
break
pytest_assert(dut_test_params["basicParams"]["def_vlan_mac"]
is not None, "Dual-TOR miss default VLAN MAC address")

pytest_assert(dut_test_params["basicParams"]["def_vlan_mac"] is not None,
"Dual-TOR miss default VLAN MAC address")
else:
try:
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
Expand Down Expand Up @@ -434,7 +436,7 @@ def __assignTestPortIps(self, mgFacts, topo):
testVlanIp = None
for vlan in mgFacts["minigraph_vlan_interfaces"]:
if mgFacts["minigraph_vlans"][testVlan]["name"] in vlan["attachto"]:
testVlanIp = ipaddress.ip_address(str(vlan["addr"])) # noqa F821
testVlanIp = ipaddress.ip_address(vlan["addr"]) # noqa F821
break
pytest_assert(testVlanIp, "Failed to obtain vlan IP")

Expand Down Expand Up @@ -682,8 +684,7 @@ def dutConfig(
[iface]["members"])
)
portIndex = mgFacts["minigraph_ptf_indices"][portName]
portIpMap = {
'peer_addr': addr["peer_ipv4"], 'port': portName}
portIpMap = {'peer_addr': addr["peer_ipv4"], 'port': portName}
dutPortIps.update({portIndex: portIpMap})

testPortIds = sorted(dutPortIps.keys())
Expand Down Expand Up @@ -1005,9 +1006,8 @@ def dutArpProxyConfig(self, duthost):
# so far, only record ARP proxy config to logging for debug purpose
vlanInterface = {}
try:
vlanInterface = json.loads(duthost.shell(
'sonic-cfggen -d --var-json "VLAN_INTERFACE"')['stdout'])
except Exception:
vlanInterface = json.loads(duthost.shell('sonic-cfggen -d --var-json "VLAN_INTERFACE"')['stdout'])
except: # noqa: E722
logger.info('Failed to read vlan interface config')
if not vlanInterface:
return
Expand Down

0 comments on commit 8909295

Please sign in to comment.