Skip to content

Commit 942b849

Browse files
Porting 15718 to 202405: Adding a fixture to set scheduler to slower speeds and revert it back. (#16199)
Description of PR Summary: Fixes the flakiness of DWRR testcase. The PR adds a new fixture that slows down the scheduler without changing the underlying algorithm. This allows the dWRR test to pass consitently. Approach What is the motivation for this PR? How did you do it? How did you verify/test it? Any platform specific information? Supported testbed topology if it's a new test case? Documentation co-authorized by: [email protected]
1 parent 0bf61eb commit 942b849

File tree

3 files changed

+98
-4
lines changed

3 files changed

+98
-4
lines changed

tests/qos/qos_sai_base.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2585,3 +2585,65 @@ def isLonglink(self, dut_host):
25852585
if cable_length >= 120000:
25862586
return True
25872587
return False
2588+
2589+
def copy_set_cir_script_cisco_8000(self, dut, ports, asic="", speed="10000000"):
2590+
if dut.facts['asic_type'] != "cisco-8000":
2591+
raise RuntimeError("This function should have been called only for cisco-8000.")
2592+
dshell_script = '''
2593+
from common import *
2594+
from sai_utils import *
2595+
2596+
def set_port_cir(interface, rate):
2597+
mp = get_mac_port(interface)
2598+
sch = mp.get_scheduler()
2599+
sch.set_credit_cir(rate)
2600+
sch.set_credit_eir_or_pir(rate, False)
2601+
2602+
'''
2603+
2604+
for intf in ports:
2605+
dshell_script += f'\nset_port_cir("{intf}", {speed})'
2606+
2607+
script_path = "/tmp/set_scheduler.py"
2608+
dut.copy(content=dshell_script, dest=script_path)
2609+
2610+
if dut.sonichost.is_multi_asic:
2611+
dest = f"syncd{asic}"
2612+
else:
2613+
dest = "syncd"
2614+
dut.docker_copy_to_all_asics(
2615+
container_name=dest,
2616+
src=script_path,
2617+
dst="/")
2618+
2619+
@pytest.fixture(scope="function", autouse=False)
2620+
def set_cir_change(self, get_src_dst_asic_and_duts, dutConfig):
2621+
dst_port = dutConfig['dutInterfaces'][dutConfig["testPorts"]["dst_port_id"]]
2622+
dst_dut = get_src_dst_asic_and_duts['dst_dut']
2623+
dst_asic = get_src_dst_asic_and_duts['dst_asic']
2624+
dst_index = dst_asic.asic_index
2625+
2626+
if dst_dut.facts['asic_type'] != "cisco-8000":
2627+
yield
2628+
return
2629+
2630+
interfaces = [dst_port]
2631+
output = dst_asic.shell(f"show interface portchannel | grep {dst_port}", module_ignore_errors=True)['stdout']
2632+
if output != '':
2633+
output = output.replace('(S)', '')
2634+
pattern = ' *[0-9]* *PortChannel[0-9]* *LACP\\(A\\)\\(Up\\) *(Ethernet[0-9]*.*)'
2635+
import re
2636+
match = re.match(pattern, output)
2637+
if not match:
2638+
raise RuntimeError(f"Couldn't find required interfaces out of the output:{output}")
2639+
interfaces = match.group(1).split(' ')
2640+
2641+
# Set scheduler to 5 Gbps.
2642+
self.copy_set_cir_script_cisco_8000(
2643+
dut=dst_dut,
2644+
ports=interfaces,
2645+
asic=dst_index,
2646+
speed=5 * 1000 * 1000 * 1000)
2647+
2648+
yield
2649+
return

tests/qos/test_qos_sai.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,7 @@ def testQosSaiDot1pPgMapping(
15401540

15411541
def testQosSaiDwrr(
15421542
self, ptfhost, duthosts, get_src_dst_asic_and_duts, dutTestParams, dutConfig, dutQosConfig, change_port_speed,
1543-
skip_src_dst_different_asic
1543+
skip_src_dst_different_asic, set_cir_change
15441544
):
15451545
"""
15461546
Test QoS SAI DWRR
@@ -2090,7 +2090,7 @@ def testQosSaiSeparatedDscpToPgMapping(self, duthost, request, ptfhost,
20902090

20912091
def testQosSaiDwrrWeightChange(
20922092
self, get_src_dst_asic_and_duts, ptfhost, dutTestParams, dutConfig, dutQosConfig,
2093-
updateSchedProfile, skip_src_dst_different_asic
2093+
updateSchedProfile, skip_src_dst_different_asic, set_cir_change
20942094
):
20952095
"""
20962096
Test QoS SAI DWRR runtime weight change

tests/saitests/py3/sai_qos_tests.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3818,8 +3818,32 @@ def runTest(self):
38183818
break
38193819
recv_pkt = scapy.Ether(received.packet)
38203820

3821-
# Release port
3822-
self.sai_thrift_port_tx_enable(self.dst_client, asic_type, [dst_port_id], enable_port_by_unblock_queue=False)
3821+
if asic_type == 'cisco-8000':
3822+
out, err, ret = self.exec_cmd_on_dut(
3823+
self.dst_server_ip,
3824+
self.test_params['dut_username'],
3825+
self.test_params['dut_password'],
3826+
"show platform summary | egrep 'ASIC Count' | awk -F: '{print $2}'")
3827+
cmd_opt = "-n asic{}".format(self.test_params['dst_asic_index'])
3828+
if out[0].strip() == "1":
3829+
cmd_opt = ""
3830+
cmd = "sudo show platform npu script {} -s set_scheduler.py".format(cmd_opt)
3831+
out, err, ret = self.exec_cmd_on_dut(
3832+
self.dst_server_ip,
3833+
self.test_params['dut_username'],
3834+
self.test_params['dut_password'],
3835+
cmd)
3836+
if err and out == []:
3837+
raise RuntimeError("cmd({}) might have failed in the DUT. Error:{}".format(cmd, err))
3838+
else:
3839+
print("Success in setting scheduler in DUT.", file=sys.stderr)
3840+
else:
3841+
# Release port
3842+
self.sai_thrift_port_tx_enable(
3843+
self.dst_client,
3844+
asic_type,
3845+
[dst_port_id],
3846+
enable_port_by_unblock_queue=False)
38233847

38243848
cnt = 0
38253849
pkts = []
@@ -3844,6 +3868,14 @@ def runTest(self):
38443868
# Ignore captured non-IP packet
38453869
continue
38463870

3871+
if asic_type == 'cisco-8000':
3872+
# Release port
3873+
self.sai_thrift_port_tx_enable(
3874+
self.dst_client,
3875+
asic_type,
3876+
[dst_port_id],
3877+
enable_port_by_unblock_queue=False)
3878+
38473879
queue_pkt_counters = [0] * (max(prio_list) + 1)
38483880
queue_num_of_pkts = [0] * (max(prio_list) + 1)
38493881
for prio, q_cnt in zip(prio_list, q_pkt_cnt):

0 commit comments

Comments
 (0)