Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test_iface_namingmode] Adjusted the test according to the new buffer queue/pg counters optimization #6431

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions tests/common/helpers/sonic_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,3 +539,18 @@ class SonicDbNoCommandOutput(Exception):
Raised when no output is generated by the sonic-db-cli command.
"""
pass


def redis_get_keys(duthost, db_id, pattern):
"""
Get all keys for a given pattern in given redis database
:param duthost: DUT host object
:param db_id: ID of redis database
:param pattern: Redis key pattern
:return: A list of key name in string
"""
cmd = 'sonic-db-cli {} KEYS \"{}\"'.format(db_id, pattern)
logger.debug('Getting keys from redis by command: {}'.format(cmd))
output = duthost.shell(cmd)
content = output['stdout'].strip()
return content.split('\n') if content else None
44 changes: 29 additions & 15 deletions tests/iface_namingmode/test_iface_namingmode.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from tests.common.utilities import wait, wait_until
from netaddr import IPAddress
from tests.common.helpers.assertions import pytest_assert
from tests.common.helpers.sonic_db import redis_get_keys

pytestmark = [
pytest.mark.topology('any')
Expand Down Expand Up @@ -430,7 +431,7 @@ def setup_check_topo(self, duthosts, enum_rand_one_per_hwsku_frontend_hostname):
skip_test_for_multi_asic(
duthosts, enum_rand_one_per_hwsku_frontend_hostname)

def test_show_queue_counters(self, setup, setup_config_mode):
def test_show_queue_counters(self, setup, setup_config_mode, duthosts, enum_rand_one_per_hwsku_frontend_hostname):
"""
Checks whether 'show queue counters' lists the interface names as
per the configured naming mode
Expand All @@ -439,11 +440,22 @@ def test_show_queue_counters(self, setup, setup_config_mode):
queue_counter = dutHostGuest.shell('SONIC_CLI_IFACE_MODE={} sudo show queue counters | grep "UC\|MC\|ALL"'.format(ifmode))['stdout']
logger.info('queue_counter:\n{}'.format(queue_counter))

duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
buffer_queue_keys = redis_get_keys(duthost, 'CONFIG_DB', 'BUFFER_QUEUE|*')
interfaces = set()

for key in buffer_queue_keys:
try:
interfaces.add(key.split('|')[1])
except IndexError:
pass

if mode == 'alias':
for alias in setup['port_alias']:
for intf in interfaces:
alias = setup['port_name_map'][intf]
assert (re.search(r'{}\s+[U|M]C|ALL\d\s+\S+\s+\S+\s+\S+\s+\S+'.format(alias), queue_counter) is not None) and (setup['port_alias_map'][alias] not in queue_counter)
elif mode == 'default':
for intf in setup['default_interfaces']:
for intf in interfaces:
assert (re.search(r'{}\s+[U|M]C|ALL\d\s+\S+\s+\S+\s+\S+\s+\S+'.format(intf), queue_counter) is not None) and (setup['port_name_map'][intf] not in queue_counter)

def test_show_queue_counters_interface(self, setup_config_mode, sample_intf):
Expand All @@ -468,12 +480,13 @@ def test_show_queue_persistent_watermark_multicast(self, setup, setup_config_mod
show_queue_wm_mcast = dutHostGuest.shell('SONIC_CLI_IFACE_MODE={} show queue persistent-watermark multicast'.format(ifmode))['stdout']
logger.info('show_queue_wm_mcast:\n{}'.format(show_queue_wm_mcast))

if mode == 'alias':
for alias in setup['port_alias']:
assert re.search(r'{}'.format(alias), show_queue_wm_mcast) is not None
elif mode == 'default':
for intf in setup['default_interfaces']:
assert re.search(r'{}'.format(intf), show_queue_wm_mcast) is not None
if show_queue_wm_mcast != "Object map from the COUNTERS_DB is empty because the multicast queues are not configured in the CONFIG_DB!":
if mode == 'alias':
for alias in setup['port_alias']:
assert re.search(r'{}'.format(alias), show_queue_wm_mcast) is not None
elif mode == 'default':
for intf in setup['default_interfaces']:
assert re.search(r'{}'.format(intf), show_queue_wm_mcast) is not None

def test_show_queue_persistent_watermark_unicast(self, setup, setup_config_mode):
"""
Expand All @@ -500,12 +513,13 @@ def test_show_queue_watermark_multicast(self, setup, setup_config_mode):
show_queue_wm_mcast = dutHostGuest.shell('SONIC_CLI_IFACE_MODE={} show queue watermark multicast'.format(ifmode))['stdout']
logger.info('show_queue_wm_mcast:\n{}'.format(show_queue_wm_mcast))

if mode == 'alias':
for alias in setup['port_alias']:
assert re.search(r'{}'.format(alias), show_queue_wm_mcast) is not None
elif mode == 'default':
for intf in setup['default_interfaces']:
assert re.search(r'{}'.format(intf), show_queue_wm_mcast) is not None
if show_queue_wm_mcast != "Object map from the COUNTERS_DB is empty because the multicast queues are not configured in the CONFIG_DB!":
if mode == 'alias':
for alias in setup['port_alias']:
assert re.search(r'{}'.format(alias), show_queue_wm_mcast) is not None
elif mode == 'default':
for intf in setup['default_interfaces']:
assert re.search(r'{}'.format(intf), show_queue_wm_mcast) is not None

def test_show_queue_watermark_unicast(self, setup, setup_config_mode):
"""
Expand Down
Empty file added tests/snmp/__init__.py
Empty file.