From bbed02b3d5212e88b28146502158ba8fb79bd4e4 Mon Sep 17 00:00:00 2001 From: Raghavendran Ramanathan Date: Thu, 2 Jan 2025 17:09:23 -0800 Subject: [PATCH 1/4] Handle non-multiasic part as well. --- tests/qos/qos_sai_base.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/qos/qos_sai_base.py b/tests/qos/qos_sai_base.py index ef6cb0ef6f5..34a34a050f9 100644 --- a/tests/qos/qos_sai_base.py +++ b/tests/qos/qos_sai_base.py @@ -2658,8 +2658,12 @@ def set_port_cir(interface, rate): 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=f"syncd{asic}", + container_name=dest, src=script_path, dst="/") From d2d8f5f6d9a59fc6944f387f04d7b0f2065d8fd3 Mon Sep 17 00:00:00 2001 From: Raghavendran Ramanathan Date: Mon, 6 Jan 2025 12:07:50 -0800 Subject: [PATCH 2/4] Change the PTF code to handle single or multi asic as well. --- tests/saitests/py3/sai_qos_tests.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/saitests/py3/sai_qos_tests.py b/tests/saitests/py3/sai_qos_tests.py index bfd06eb47c5..95e3a32dbff 100755 --- a/tests/saitests/py3/sai_qos_tests.py +++ b/tests/saitests/py3/sai_qos_tests.py @@ -3856,8 +3856,20 @@ def runTest(self): 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)) + if err and out == []: + if "Invalid value for " in " ".join(err): + cmd = "sudo show platform npu script -s set_scheduler.py" + 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 sAsic DUT.", file=sys.stderr) + else: + print("Success in setting scheduler in mAsic DUT.", file=sys.stderr) else: # Release port self.sai_thrift_port_tx_enable( From d4a4c79bccd30a8eea18359a8270015a44e7659e Mon Sep 17 00:00:00 2001 From: Raghavendran Ramanathan Date: Mon, 6 Jan 2025 22:14:08 -0800 Subject: [PATCH 3/4] Modified the logic to find if it is a single or multi asic. --- tests/saitests/py3/sai_qos_tests.py | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/tests/saitests/py3/sai_qos_tests.py b/tests/saitests/py3/sai_qos_tests.py index 95e3a32dbff..46d957074f2 100755 --- a/tests/saitests/py3/sai_qos_tests.py +++ b/tests/saitests/py3/sai_qos_tests.py @@ -3847,9 +3847,14 @@ def runTest(self): recv_pkt = scapy.Ether(received.packet) 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']) + 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, @@ -3857,19 +3862,9 @@ def runTest(self): self.test_params['dut_password'], cmd) if err and out == []: - if "Invalid value for " in " ".join(err): - cmd = "sudo show platform npu script -s set_scheduler.py" - 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 sAsic DUT.", file=sys.stderr) + raise RuntimeError("cmd({}) might have failed in the DUT. Error:{}".format(cmd, err)) else: - print("Success in setting scheduler in mAsic DUT.", file=sys.stderr) + print("Success in setting scheduler in DUT.", file=sys.stderr) else: # Release port self.sai_thrift_port_tx_enable( From fa3a6dcfec50cb4f212a5a53f560264085ef47b1 Mon Sep 17 00:00:00 2001 From: Raghavendran Ramanathan Date: Thu, 9 Jan 2025 07:04:45 -0800 Subject: [PATCH 4/4] Change the name of the function, remove '_and_run' part. --- tests/qos/qos_sai_base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/qos/qos_sai_base.py b/tests/qos/qos_sai_base.py index 34a34a050f9..30f122f01bc 100644 --- a/tests/qos/qos_sai_base.py +++ b/tests/qos/qos_sai_base.py @@ -2638,7 +2638,7 @@ def change_lag_lacp_timer(self, duthosts, get_src_dst_asic_and_duts, tbinfo, nbr "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"): + 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 = ''' @@ -2690,7 +2690,7 @@ def set_cir_change(self, get_src_dst_asic_and_duts, dutConfig): interfaces = match.group(1).split(' ') # Set scheduler to 5 Gbps. - self.copy_and_run_set_cir_script_cisco_8000( + self.copy_set_cir_script_cisco_8000( dut=dst_dut, ports=interfaces, asic=dst_index,