diff --git a/tests/common/devices/sonic.py b/tests/common/devices/sonic.py index 0d3df4d2ee8..2b16cb9c6b8 100644 --- a/tests/common/devices/sonic.py +++ b/tests/common/devices/sonic.py @@ -27,7 +27,6 @@ from tests.common import constants logger = logging.getLogger(__name__) - PROCESS_TO_CONTAINER_MAP = { "orchagent": "swss", "syncd": "syncd" @@ -2405,6 +2404,17 @@ def is_backend_portchannel(self, port_channel, mg_facts): def is_backend_port(self, port, mg_facts): return True if "Ethernet-BP" in port else False + def get_backplane_ports(self): + # get current interface data from config_db.json + config_facts = self.config_facts(host=self.hostname, source='running', verbose=False)['ansible_facts'] + config_db_ports = config_facts["PORT"] + # Build set of Ethernet ports with 18.x.202.0/31 IPs to exclude + excluded_ports = set() + for port, val in config_db_ports.items(): + if "role" in val: + excluded_ports.add(port) + return excluded_ports + def active_ip_interfaces(self, ip_ifs, tbinfo, ns_arg=DEFAULT_NAMESPACE, intf_num="all", ip_type="ipv4"): """ Return a dict of active IP (Ethernet or PortChannel) interfaces, with @@ -2415,10 +2425,10 @@ def active_ip_interfaces(self, ip_ifs, tbinfo, ns_arg=DEFAULT_NAMESPACE, intf_nu """ active_ip_intf_cnt = 0 mg_facts = self.get_extended_minigraph_facts(tbinfo, ns_arg) - config_facts_ports = self.config_facts(host=self.hostname, source="running")["ansible_facts"].get("PORT", {}) + excluded_ports = self.get_backplane_ports() ip_ifaces = {} for k, v in list(ip_ifs.items()): - if ((k.startswith("Ethernet") and config_facts_ports.get(k, {}).get("role", "") != "Dpc" and + if ((k.startswith("Ethernet") and (k not in excluded_ports) and (not k.startswith("Ethernet-BP")) and not is_inband_port(k)) or (k.startswith("PortChannel") and not self.is_backend_portchannel(k, mg_facts))): if ip_type == "ipv4": diff --git a/tests/qos/qos_sai_base.py b/tests/qos/qos_sai_base.py index 6d94dd826c2..eeae6e46c23 100644 --- a/tests/qos/qos_sai_base.py +++ b/tests/qos/qos_sai_base.py @@ -1002,16 +1002,23 @@ def dutConfig( dst_dut = get_src_dst_asic_and_duts['dst_dut'] src_mgFacts = src_dut.get_extended_minigraph_facts(tbinfo) topo = tbinfo["topo"]["name"] - src_mgFacts['minigraph_ptf_indices'] = { + + # Build a set of Ethernet ports to exclude (with 18.x.202.0/31 IPs) + excluded_ports = set() + excluded_ports.update(duthosts[0].get_backplane_ports()) + # Filter minigraph_ptf_indices to exclude dynamic ports + src_mgFacts["minigraph_ptf_indices"] = { key: value - for key, value in src_mgFacts['minigraph_ptf_indices'].items() - if not key.startswith("Ethernet-BP") - } - src_mgFacts['minigraph_ports'] = { + for key, value in src_mgFacts["minigraph_ptf_indices"].items() + if key not in excluded_ports + } + + # Filter minigraph_ports to exclude dynamic ports + src_mgFacts["minigraph_ports"] = { key: value - for key, value in src_mgFacts['minigraph_ports'].items() - if not key.startswith("Ethernet-BP") - } + for key, value in src_mgFacts["minigraph_ports"].items() + if key not in excluded_ports + } bgp_peer_ip_key = "peer_ipv6" if ip_type == "ipv6" else "peer_ipv4" ip_version = 6 if ip_type == "ipv6" else 4 vlan_info = {}