Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a fixture to set scheduler to slower speeds and revert it back. #15718

Merged
merged 10 commits into from
Dec 23, 2024
57 changes: 57 additions & 0 deletions tests/qos/qos_sai_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2624,3 +2624,60 @@ def change_lag_lacp_timer(self, duthosts, get_src_dst_asic_and_duts, tbinfo, nbr
logger.info(
"Changing lacp timer multiplier to default for %s in %s" % (neighbor_lag_member, peer_device))
vm_host.no_lacp_time_multiplier(neighbor_lag_member)

def copy_and_run_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)
dut.docker_copy_to_all_asics(
container_name=f"syncd{asic}",
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]*.*)'
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(' ')

for intf in interfaces:
# Set scheduler to 5 Gbps.
self.copy_and_run_set_cir_script_cisco_8000(
dut=dst_dut,
port=intf,
Copy link
Contributor

@sdszhang sdszhang Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got this error:

        for intf in interfaces:
            # Set scheduler to 5 Gbps.
>           self.copy_and_run_set_cir_script_cisco_8000(
                dut=dst_dut,
                port=intf,
                asic=dst_index,
                speed=5 * 1000 * 1000 * 1000)
E           TypeError: copy_and_run_set_cir_script_cisco_8000() got an unexpected keyword argument 'port'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sdszhang , I apologize. I missed the update to this function in my previous commit. I have fixed it now. Thanks.

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 @@ -1517,7 +1517,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 @@ -2061,7 +2061,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
29 changes: 27 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,25 @@ 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':
cmd_opt = ""
if 'dst_asic_index' in self.test_params:
cmd_opt = "-n asic{}".format(self.test_params['dst_asic_index'])
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:
# 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 +3861,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
Loading