Skip to content

Commit 582e368

Browse files
vadymhlushko-mlnxwangxin
authored andcommitted
[test_snmp_queue] Adjusted the test according to the new buffer queue/pg counters optimization (#6744)
What is the motivation for this PR? Because of the new implementation sonic-swss/pull/2432 from now on, there is a valid case if there are no queue counters inside the COUNTERS_DB. In order for queue counters to be presented in COUNTERS_DB the appropriate queues should be configured inside the CONFIG_DB (e.g "QUEUE|Ethernet14|7-8") Signed-off-by: Vadym Hlushko <vadymh@nvidia.com>
1 parent 386f59b commit 582e368

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

tests/snmp/test_snmp_queue.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,39 @@
11
import pytest
22
from tests.common.helpers.snmp_helpers import get_snmp_facts
3+
from tests.common.helpers.sonic_db import redis_get_keys
34

45
pytestmark = [
56
pytest.mark.topology('any'),
67
pytest.mark.device_type('vs')
78
]
89

9-
def test_snmp_queues(duthosts, enum_rand_one_per_hwsku_hostname, localhost, creds_all_duts, collect_techsupport_all_duts):
10+
11+
def test_snmp_queues(duthosts, enum_rand_one_per_hwsku_hostname, localhost, creds_all_duts,
12+
collect_techsupport_all_duts):
1013
duthost = duthosts[enum_rand_one_per_hwsku_hostname]
1114
hostip = duthost.host.options['inventory_manager'].get_host(duthost.hostname).vars['ansible_host']
1215

13-
snmp_facts = get_snmp_facts(localhost, host=hostip, version="v2c", community=creds_all_duts[duthost.hostname]["snmp_rocommunity"], wait=True)['ansible_facts']
16+
q_keys = redis_get_keys(duthost, "CONFIG_DB", "QUEUE|*")
17+
18+
if q_keys is None:
19+
pytest.skip("No queues configured on interfaces")
20+
21+
q_interfaces = set()
22+
# get interfaces which has configured queues
23+
for key in q_keys:
24+
intf = key.split('|')
25+
# 'QUEUE|Ethernet*|2'
26+
if len(intf) == 3:
27+
q_interfaces.add(intf[1])
28+
29+
snmp_facts = get_snmp_facts(localhost, host=hostip, version="v2c",
30+
community=creds_all_duts[duthost.hostname]["snmp_rocommunity"],
31+
wait=True)['ansible_facts']
1432

1533
for k, v in snmp_facts['snmp_interfaces'].items():
1634
if "Ethernet" in v['description']:
17-
if not v.has_key('queues'):
18-
pytest.fail("port %s does not have queue counters" % v['name'])
35+
intf = v['description'].split(':')
36+
# 'ARISTA*:Ethernet*'
37+
if len(intf) == 2:
38+
if intf[1] in q_interfaces and 'queues' not in v:
39+
pytest.fail("port %s does not have queue counters" % v['name'])

0 commit comments

Comments
 (0)