|
1 | 1 | import pytest |
2 | 2 | import json |
3 | 3 | import re |
| 4 | +import logging |
4 | 5 | from tests.common import config_reload |
5 | 6 | from tests.common.helpers.assertions import pytest_assert |
6 | 7 | from tests.common.utilities import wait_until |
7 | 8 |
|
| 9 | +logger = logging.getLogger(__name__) |
| 10 | + |
8 | 11 | CFG_DB_PATH = "/etc/sonic/config_db.json" |
9 | 12 | ORIG_CFG_DB = "/etc/sonic/orig_config_db.json" |
10 | 13 | UNICAST_CTRS = 4 |
@@ -58,17 +61,34 @@ def get_queue_cntrs_oid(interface): |
58 | 61 | return queue_cntrs_oid |
59 | 62 |
|
60 | 63 |
|
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): |
62 | 79 | """ |
63 | 80 | @summary: Returns interface dynamically based on the asic chosen |
64 | 81 | for single/multi-asic sonic host. |
65 | 82 | """ |
66 | 83 | ansible_inter_facts = inter_facts['ansible_interface_facts'] |
67 | 84 | interface = None |
| 85 | + internal_port_list = get_dpu_npu_port_list(duthost) |
68 | 86 | for key, v in ansible_inter_facts.items(): |
69 | 87 | # Exclude internal interfaces |
70 | 88 | if 'IB' in key or 'Rec' in key or 'BP' in key: |
71 | 89 | continue |
| 90 | + if key in internal_port_list: |
| 91 | + continue |
72 | 92 | if 'Ether' in key and v['active']: |
73 | 93 | interface = key |
74 | 94 | break |
@@ -106,7 +126,7 @@ def test_snmp_queue_counters(duthosts, |
106 | 126 | duthost.hostname).vars['ansible_host'] |
107 | 127 | asic = duthost.asic_instance(enum_frontend_asic_index) |
108 | 128 | int_facts = asic.interface_facts()['ansible_facts'] |
109 | | - interface = get_asic_interface(int_facts) |
| 129 | + interface = get_asic_interface(int_facts, duthost) |
110 | 130 | if interface is None: |
111 | 131 | pytest.skip("No active interface present on the asic {}".format(asic)) |
112 | 132 | queue_cntrs_oid = get_queue_cntrs_oid(interface) |
|
0 commit comments