From 9fc78a0dfddca5fa03284d884065081c7cdcf134 Mon Sep 17 00:00:00 2001 From: Raghavendran Ramanathan Date: Tue, 25 Feb 2025 09:09:39 -0800 Subject: [PATCH 1/3] Porting 16315 to 202411. --- tests/qos/qos_sai_base.py | 10 +++++++--- tests/saitests/py3/sai_qos_tests.py | 15 +++++++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/tests/qos/qos_sai_base.py b/tests/qos/qos_sai_base.py index 5f7cd86f31f..7815838a922 100644 --- a/tests/qos/qos_sai_base.py +++ b/tests/qos/qos_sai_base.py @@ -2662,7 +2662,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 = ''' @@ -2682,8 +2682,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="/") @@ -2710,7 +2714,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, diff --git a/tests/saitests/py3/sai_qos_tests.py b/tests/saitests/py3/sai_qos_tests.py index bfd06eb47c5..46d957074f2 100755 --- a/tests/saitests/py3/sai_qos_tests.py +++ b/tests/saitests/py3/sai_qos_tests.py @@ -3847,17 +3847,24 @@ 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, self.test_params['dut_username'], self.test_params['dut_password'], cmd) - if err != "" and out == "": + 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( From fdd89f86477cf6497f87842340416554c00448a3 Mon Sep 17 00:00:00 2001 From: Raghavendran Ramanathan Date: Tue, 25 Feb 2025 09:24:14 -0800 Subject: [PATCH 2/3] Reverting above change. --- tests/qos/qos_sai_base.py | 10 +++------- tests/saitests/py3/sai_qos_tests.py | 15 ++++----------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/tests/qos/qos_sai_base.py b/tests/qos/qos_sai_base.py index 7815838a922..5f7cd86f31f 100644 --- a/tests/qos/qos_sai_base.py +++ b/tests/qos/qos_sai_base.py @@ -2662,7 +2662,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_set_cir_script_cisco_8000(self, dut, ports, asic="", speed="10000000"): + 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 = ''' @@ -2682,12 +2682,8 @@ 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=dest, + container_name=f"syncd{asic}", src=script_path, dst="/") @@ -2714,7 +2710,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_set_cir_script_cisco_8000( + self.copy_and_run_set_cir_script_cisco_8000( dut=dst_dut, ports=interfaces, asic=dst_index, diff --git a/tests/saitests/py3/sai_qos_tests.py b/tests/saitests/py3/sai_qos_tests.py index 46d957074f2..bfd06eb47c5 100755 --- a/tests/saitests/py3/sai_qos_tests.py +++ b/tests/saitests/py3/sai_qos_tests.py @@ -3847,24 +3847,17 @@ def runTest(self): recv_pkt = scapy.Ether(received.packet) 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_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 == []: + 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( From 4b49636ecad0addbdccc9cbd968bdec7ae8b0f23 Mon Sep 17 00:00:00 2001 From: Raghavendran Ramanathan Date: Tue, 25 Feb 2025 09:25:05 -0800 Subject: [PATCH 3/3] Porting 16315 to 202411. --- tests/qos/qos_sai_base.py | 10 +++++++--- tests/saitests/py3/sai_qos_tests.py | 15 +++++++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/tests/qos/qos_sai_base.py b/tests/qos/qos_sai_base.py index 5f7cd86f31f..7815838a922 100644 --- a/tests/qos/qos_sai_base.py +++ b/tests/qos/qos_sai_base.py @@ -2662,7 +2662,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 = ''' @@ -2682,8 +2682,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="/") @@ -2710,7 +2714,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, diff --git a/tests/saitests/py3/sai_qos_tests.py b/tests/saitests/py3/sai_qos_tests.py index bfd06eb47c5..46d957074f2 100755 --- a/tests/saitests/py3/sai_qos_tests.py +++ b/tests/saitests/py3/sai_qos_tests.py @@ -3847,17 +3847,24 @@ 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, self.test_params['dut_username'], self.test_params['dut_password'], cmd) - if err != "" and out == "": + 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(