From a57ab20f2ad32a879baece5fa268841da627b18f Mon Sep 17 00:00:00 2001 From: Justin Wong Date: Thu, 21 Nov 2024 15:42:40 -0800 Subject: [PATCH 1/3] Fix acl/test_stress_acl.py using bad interface name for ACL table creation In `acl/test_stress_acl.py`, it attempts to retrieve an interface that can be used to create a ACL table. DUTs with and without PortChannels require different methods respectively. Currently, it checks by filtering with topo. However, some topology flags can have configurations that have or not have PortChannels, making topos no longer a sufficient check. Fix by checking if a PortChannel exists. If it does - use it. If it does not - fallback on the secondary method to retrieve a normal interface name if its a not a dualtor topo (due to https://github.com/sonic-net/sonic-mgmt/pull/6960). --- tests/acl/test_stress_acl.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/acl/test_stress_acl.py b/tests/acl/test_stress_acl.py index 47244a30bc4..caad2d2a8cf 100644 --- a/tests/acl/test_stress_acl.py +++ b/tests/acl/test_stress_acl.py @@ -91,12 +91,15 @@ def prepare_test_file(rand_selected_dut): @pytest.fixture(scope='module') def prepare_test_port(rand_selected_dut, tbinfo): mg_facts = rand_selected_dut.get_extended_minigraph_facts(tbinfo) - if tbinfo["topo"]["type"] == "mx": - dut_port = mg_facts["minigraph_acls"]["DataAcl"][0] - else: - dut_port = list(mg_facts['minigraph_portchannels'].keys())[0] + + ports = list(mg_facts['minigraph_portchannels']) + if tbinfo["topo"]["type"] != "dualtor" and not ports: + ports = mg_facts["minigraph_acls"]["DataAcl"] + + dut_port = ports[0] if ports else None + if not dut_port: - pytest.skip('No portchannels found') + pytest.skip('No portchannels available in dualtor topo') if "Ethernet" in dut_port: dut_eth_port = dut_port elif "PortChannel" in dut_port: From 54a43286e0ca7eb8caa35b1b05007d0efbb93ec8 Mon Sep 17 00:00:00 2001 From: Justin Wong Date: Thu, 28 Nov 2024 18:42:58 +0000 Subject: [PATCH 2/3] Improve skip reason message --- tests/acl/test_stress_acl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/acl/test_stress_acl.py b/tests/acl/test_stress_acl.py index caad2d2a8cf..593a3665a90 100644 --- a/tests/acl/test_stress_acl.py +++ b/tests/acl/test_stress_acl.py @@ -99,7 +99,7 @@ def prepare_test_port(rand_selected_dut, tbinfo): dut_port = ports[0] if ports else None if not dut_port: - pytest.skip('No portchannels available in dualtor topo') + pytest.skip('No portchannels available in dualtor topo or no interfaces found on DUT') if "Ethernet" in dut_port: dut_eth_port = dut_port elif "PortChannel" in dut_port: From 27074bf535415032e6f564598faebcf65af18a93 Mon Sep 17 00:00:00 2001 From: Justin Wong Date: Fri, 13 Dec 2024 07:51:27 +0000 Subject: [PATCH 3/3] Removed dualtor-specific checks As discussed in PR conversation, there is no need for dualtor to have any special checks. Generalizing the checks for all topos. --- tests/acl/test_stress_acl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/acl/test_stress_acl.py b/tests/acl/test_stress_acl.py index 593a3665a90..ca0a80e5589 100644 --- a/tests/acl/test_stress_acl.py +++ b/tests/acl/test_stress_acl.py @@ -93,13 +93,13 @@ def prepare_test_port(rand_selected_dut, tbinfo): mg_facts = rand_selected_dut.get_extended_minigraph_facts(tbinfo) ports = list(mg_facts['minigraph_portchannels']) - if tbinfo["topo"]["type"] != "dualtor" and not ports: + if not ports: ports = mg_facts["minigraph_acls"]["DataAcl"] dut_port = ports[0] if ports else None if not dut_port: - pytest.skip('No portchannels available in dualtor topo or no interfaces found on DUT') + pytest.skip('No portchannels nor dataacl ports found') if "Ethernet" in dut_port: dut_eth_port = dut_port elif "PortChannel" in dut_port: