From 4075a7dbe5579e5a3f70d0178e29eb536f7e903d Mon Sep 17 00:00:00 2001 From: Zhaohui Sun <94606222+ZhaohuiS@users.noreply.github.com> Date: Mon, 6 Jan 2025 13:40:04 +0800 Subject: [PATCH] Support 2 vlan config in topology for test_acl (#16322) What is the motivation for this PR? If enable 2vlan config in topology file(such as ansible/vars/topo_t0-116.yml): change from vlan_configs: default_vlan_config: one_vlan_a to vlan_configs: default_vlan_config: two_vlan_a Then vlan name is not Vlan1000 anymore, it could be Vlan100 or Vlan200. So, in https://github.com/sonic-net/sonic-mgmt/pull/9334/files, it sets default vlan name to Vlan1000 in pytest_generate_tests for T0 is not very reasonable. How did you do it? So, in test_acl, for T0 topology, still get vlan name from config, not from vlan_name parameter, then test_acl can pass. How did you verify/test it? Run test_acl on testbed with 2vlan config. --- tests/acl/test_acl.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/acl/test_acl.py b/tests/acl/test_acl.py index a4a45d5ebb6..d8504fe42ed 100644 --- a/tests/acl/test_acl.py +++ b/tests/acl/test_acl.py @@ -301,7 +301,7 @@ def setup(duthosts, ptfhost, rand_selected_dut, rand_unselected_dut, tbinfo, ptf DOWNSTREAM_DST_IP = DOWNSTREAM_DST_IP_M0_L3 DOWNSTREAM_IP_TO_ALLOW = DOWNSTREAM_IP_TO_ALLOW_M0_L3 DOWNSTREAM_IP_TO_BLOCK = DOWNSTREAM_IP_TO_BLOCK_M0_L3 - if topo in ["t0", "mx", "m0_vlan"]: + if topo in ["mx", "m0_vlan"]: vlan_ports = [mg_facts["minigraph_ptf_indices"][ifname] for ifname in mg_facts["minigraph_vlans"][vlan_name]["members"]] @@ -309,7 +309,14 @@ def setup(duthosts, ptfhost, rand_selected_dut, rand_unselected_dut, tbinfo, ptf vlan_table = config_facts["VLAN"] if "mac" in vlan_table[vlan_name]: vlan_mac = vlan_table[vlan_name]["mac"] - + elif topo in ["t0"]: + vlan_ports = [mg_facts["minigraph_ptf_indices"][ifname] + for ifname in list(mg_facts["minigraph_vlans"].values())[0]["members"]] + config_facts = rand_selected_dut.get_running_config_facts() + vlan_table = config_facts["VLAN"] + vlan_name = list(vlan_table.keys())[0] + if "mac" in vlan_table[vlan_name]: + vlan_mac = vlan_table[vlan_name]["mac"] # Get the list of upstream/downstream ports downstream_ports = defaultdict(list) upstream_ports = defaultdict(list)