Skip to content

Commit a7a42f9

Browse files
aronovicdcaugher
authored andcommitted
* fix the issue sonic-net#20935 * fixed flake8 issues * update based on PR reviews
1 parent 66fb4bc commit a7a42f9

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

tests/snmp/test_snmp_queue_counters.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import pytest
22
import json
33
import re
4+
import logging
45
from tests.common import config_reload
56
from tests.common.helpers.assertions import pytest_assert
67
from tests.common.utilities import wait_until
78

9+
logger = logging.getLogger(__name__)
10+
811
CFG_DB_PATH = "/etc/sonic/config_db.json"
912
ORIG_CFG_DB = "/etc/sonic/orig_config_db.json"
1013
UNICAST_CTRS = 4
@@ -58,17 +61,34 @@ def get_queue_cntrs_oid(interface):
5861
return queue_cntrs_oid
5962

6063

61-
def get_asic_interface(inter_facts):
64+
def get_dpu_npu_port_list(duthost):
65+
dpu_npu_port_list = []
66+
67+
config_facts = duthost.config_facts(host=duthost.hostname, source="running")['ansible_facts']
68+
if config_facts is None:
69+
return dpu_npu_port_list
70+
if 'PORT' not in config_facts:
71+
return dpu_npu_port_list
72+
dpu_npu_port_list = [p for p, v in list(config_facts['PORT'].items()) if v.get('role', None) == 'Dpc']
73+
74+
logger.info(f"dpu npu port list: {dpu_npu_port_list}")
75+
return dpu_npu_port_list
76+
77+
78+
def get_asic_interface(inter_facts, duthost):
6279
"""
6380
@summary: Returns interface dynamically based on the asic chosen
6481
for single/multi-asic sonic host.
6582
"""
6683
ansible_inter_facts = inter_facts['ansible_interface_facts']
6784
interface = None
85+
internal_port_list = get_dpu_npu_port_list(duthost)
6886
for key, v in ansible_inter_facts.items():
6987
# Exclude internal interfaces
7088
if 'IB' in key or 'Rec' in key or 'BP' in key:
7189
continue
90+
if key in internal_port_list:
91+
continue
7292
if 'Ether' in key and v['active']:
7393
interface = key
7494
break
@@ -106,7 +126,7 @@ def test_snmp_queue_counters(duthosts,
106126
duthost.hostname).vars['ansible_host']
107127
asic = duthost.asic_instance(enum_frontend_asic_index)
108128
int_facts = asic.interface_facts()['ansible_facts']
109-
interface = get_asic_interface(int_facts)
129+
interface = get_asic_interface(int_facts, duthost)
110130
if interface is None:
111131
pytest.skip("No active interface present on the asic {}".format(asic))
112132
queue_cntrs_oid = get_queue_cntrs_oid(interface)

0 commit comments

Comments
 (0)