Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions tests/qos/qos_sai_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2585,3 +2585,65 @@ def isLonglink(self, dut_host):
if cable_length >= 120000:
return True
return False

def copy_set_cir_script_cisco_8000(self, dut, ports, asic="", speed="10000000"):
if dut.facts['asic_type'] != "cisco-8000":
raise RuntimeError("This function should have been called only for cisco-8000.")
dshell_script = '''
from common import *
from sai_utils import *

def set_port_cir(interface, rate):
mp = get_mac_port(interface)
sch = mp.get_scheduler()
sch.set_credit_cir(rate)
sch.set_credit_eir_or_pir(rate, False)

'''

for intf in ports:
dshell_script += f'\nset_port_cir("{intf}", {speed})'

script_path = "/tmp/set_scheduler.py"
dut.copy(content=dshell_script, dest=script_path)

if dut.sonichost.is_multi_asic:
dest = f"syncd{asic}"
else:
dest = "syncd"
dut.docker_copy_to_all_asics(
container_name=dest,
src=script_path,
dst="/")

@pytest.fixture(scope="function", autouse=False)
def set_cir_change(self, get_src_dst_asic_and_duts, dutConfig):
dst_port = dutConfig['dutInterfaces'][dutConfig["testPorts"]["dst_port_id"]]
dst_dut = get_src_dst_asic_and_duts['dst_dut']
dst_asic = get_src_dst_asic_and_duts['dst_asic']
dst_index = dst_asic.asic_index

if dst_dut.facts['asic_type'] != "cisco-8000":
yield
return

interfaces = [dst_port]
output = dst_asic.shell(f"show interface portchannel | grep {dst_port}", module_ignore_errors=True)['stdout']
if output != '':
output = output.replace('(S)', '')
pattern = ' *[0-9]* *PortChannel[0-9]* *LACP\\(A\\)\\(Up\\) *(Ethernet[0-9]*.*)'
import re
match = re.match(pattern, output)
if not match:
raise RuntimeError(f"Couldn't find required interfaces out of the output:{output}")
interfaces = match.group(1).split(' ')

# Set scheduler to 5 Gbps.
self.copy_set_cir_script_cisco_8000(
dut=dst_dut,
ports=interfaces,
asic=dst_index,
speed=5 * 1000 * 1000 * 1000)

yield
return
4 changes: 2 additions & 2 deletions tests/qos/test_qos_sai.py
Original file line number Diff line number Diff line change
Expand Up @@ -1540,7 +1540,7 @@ def testQosSaiDot1pPgMapping(

def testQosSaiDwrr(
self, ptfhost, duthosts, get_src_dst_asic_and_duts, dutTestParams, dutConfig, dutQosConfig, change_port_speed,
skip_src_dst_different_asic
skip_src_dst_different_asic, set_cir_change
):
"""
Test QoS SAI DWRR
Expand Down Expand Up @@ -2090,7 +2090,7 @@ def testQosSaiSeparatedDscpToPgMapping(self, duthost, request, ptfhost,

def testQosSaiDwrrWeightChange(
self, get_src_dst_asic_and_duts, ptfhost, dutTestParams, dutConfig, dutQosConfig,
updateSchedProfile, skip_src_dst_different_asic
updateSchedProfile, skip_src_dst_different_asic, set_cir_change
):
"""
Test QoS SAI DWRR runtime weight change
Expand Down
36 changes: 34 additions & 2 deletions tests/saitests/py3/sai_qos_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3818,8 +3818,32 @@ def runTest(self):
break
recv_pkt = scapy.Ether(received.packet)

# Release port
self.sai_thrift_port_tx_enable(self.dst_client, asic_type, [dst_port_id], enable_port_by_unblock_queue=False)
if asic_type == 'cisco-8000':
out, err, ret = self.exec_cmd_on_dut(
self.dst_server_ip,
self.test_params['dut_username'],
self.test_params['dut_password'],
"show platform summary | egrep 'ASIC Count' | awk -F: '{print $2}'")
cmd_opt = "-n asic{}".format(self.test_params['dst_asic_index'])
if out[0].strip() == "1":
cmd_opt = ""
cmd = "sudo show platform npu script {} -s set_scheduler.py".format(cmd_opt)
out, err, ret = self.exec_cmd_on_dut(
self.dst_server_ip,
self.test_params['dut_username'],
self.test_params['dut_password'],
cmd)
if err and out == []:
raise RuntimeError("cmd({}) might have failed in the DUT. Error:{}".format(cmd, err))
else:
print("Success in setting scheduler in DUT.", file=sys.stderr)
else:
# Release port
self.sai_thrift_port_tx_enable(
self.dst_client,
asic_type,
[dst_port_id],
enable_port_by_unblock_queue=False)

cnt = 0
pkts = []
Expand All @@ -3844,6 +3868,14 @@ def runTest(self):
# Ignore captured non-IP packet
continue

if asic_type == 'cisco-8000':
# Release port
self.sai_thrift_port_tx_enable(
self.dst_client,
asic_type,
[dst_port_id],
enable_port_by_unblock_queue=False)

queue_pkt_counters = [0] * (max(prio_list) + 1)
queue_num_of_pkts = [0] * (max(prio_list) + 1)
for prio, q_cnt in zip(prio_list, q_pkt_cnt):
Expand Down