Skip to content

Commit 9b008b7

Browse files
committed
add support test_show_tqueue_counters
chore: update test for t2 Signed-off-by: Austin Pham <[email protected]>
1 parent 430f05c commit 9b008b7

1 file changed

Lines changed: 53 additions & 61 deletions

File tree

tests/iface_namingmode/test_iface_namingmode.py

Lines changed: 53 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from tests.common.utilities import wait, wait_until
88
from netaddr import IPAddress
99
from tests.common.helpers.assertions import pytest_assert
10-
from tests.common.helpers.sonic_db import redis_get_keys
10+
from tests.common.helpers.sonic_db import SonicDbCli
1111

1212
pytestmark = [
1313
pytest.mark.topology('any', "t1-multi-asic")
@@ -20,12 +20,6 @@
2020
QUEUE_COUNTERS_RE_FMT = r'{}\s+[U|M]C|ALL\d\s+\S+\s+\S+\s+\S+\s+\S+'
2121

2222

23-
def skip_test_for_multi_asic(duthosts, enum_rand_one_per_hwsku_frontend_hostname):
24-
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
25-
if duthost.is_multi_asic:
26-
pytest.skip('CLI command not supported')
27-
28-
2923
@pytest.fixture(scope='module', autouse=True)
3024
def setup(duthosts, enum_rand_one_per_hwsku_frontend_hostname, tbinfo):
3125
"""
@@ -420,7 +414,7 @@ class TestShowPriorityGroup():
420414

421415
@pytest.fixture(scope="class", autouse=True)
422416
def setup_check_topo(self, duthosts, enum_rand_one_per_hwsku_frontend_hostname):
423-
skip_test_for_multi_asic(duthosts, enum_rand_one_per_hwsku_frontend_hostname)
417+
pass
424418

425419
def test_show_priority_group_persistent_watermark_headroom(self, setup, setup_config_mode):
426420
"""
@@ -493,65 +487,65 @@ def test_show_priority_group_watermark_shared(self, setup, setup_config_mode):
493487

494488
class TestShowQueue():
495489

496-
@pytest.fixture(scope="class", autouse=True)
497-
def setup_check_topo(self, duthosts, enum_rand_one_per_hwsku_frontend_hostname):
498-
skip_test_for_multi_asic(
499-
duthosts, enum_rand_one_per_hwsku_frontend_hostname)
500-
501490
def test_show_queue_counters(self, setup, setup_config_mode, duthosts, enum_rand_one_per_hwsku_frontend_hostname):
502491
"""
503492
Checks whether 'show queue counters' lists the interface names as
504493
per the configured naming mode
505494
"""
506-
dutHostGuest, mode, ifmode = setup_config_mode
507-
queue_counter = dutHostGuest.shell(
508-
r'SONIC_CLI_IFACE_MODE={} sudo show queue counters | grep "UC\|MC\|ALL"'.format(ifmode))['stdout']
509-
logger.info('queue_counter:\n{}'.format(queue_counter))
510495

511496
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
512-
buffer_queue_keys = redis_get_keys(duthost, 'CONFIG_DB', 'BUFFER_QUEUE|*')
513-
interfaces = set()
514-
515-
for key in buffer_queue_keys:
516-
try:
517-
fields = key.split("|")
518-
# The format of BUFFER_QUEUE entries on VOQ chassis is
519-
# 'BUFFER_QUEUE|<host name>|<asic-name>|Ethernet32|0-2'
520-
# where 'host name' could be any host in the chassis, including those from other
521-
# cards. This test only cares about local interfaces, so we can filter out the rest
522-
if duthost.facts['switch_type'] == 'voq':
523-
hostname = fields[1]
524-
if hostname != duthost.hostname:
497+
for asic in duthost.asics:
498+
dutHostGuest, mode, ifmode = setup_config_mode
499+
queue_counter = dutHostGuest.shell(
500+
r'SONIC_CLI_IFACE_MODE={} sudo show queue counters {} | grep "UC\|MC\|ALL"'.format(
501+
ifmode, asic.cli_ns_option
502+
))['stdout']
503+
logger.info('queue_counter:\n{}'.format(queue_counter))
504+
505+
configDbCli = SonicDbCli(duthost, "CONFIG_DB")
506+
buffer_queue_keys = configDbCli.get_keys("BUFFER_QUEUE|*")
507+
interfaces = set()
508+
509+
for key in buffer_queue_keys:
510+
try:
511+
fields = key.split("|")
512+
# The format of BUFFER_QUEUE entries on VOQ chassis is
513+
# 'BUFFER_QUEUE|<host name>|<asic-name>|Ethernet32|0-2'
514+
# where 'host name' could be any host in the chassis, including those from other
515+
# cards. This test only cares about local interfaces, so we can filter out the rest
516+
if duthost.facts['switch_type'] == 'voq':
517+
hostname = fields[1]
518+
if hostname != duthost.hostname:
519+
continue
520+
# The interface name is always the last but one field in the BUFFER_QUEUE entry key
521+
interfaces.add(fields[-2])
522+
except IndexError:
523+
pass
524+
525+
# For the test to be valid, we should have at least one interface selected
526+
assert (len(interfaces) > 0)
527+
528+
intfsChecked = 0
529+
if mode == 'alias':
530+
for intf in interfaces:
531+
alias = setup['port_name_map'][intf]
532+
assert (re.search(QUEUE_COUNTERS_RE_FMT.format(alias),
533+
queue_counter) is not None) \
534+
and (re.search(QUEUE_COUNTERS_RE_FMT.format(setup['port_alias_map'][alias]),
535+
queue_counter) is None)
536+
intfsChecked += 1
537+
elif mode == 'default':
538+
for intf in interfaces:
539+
if intf not in setup['port_name_map']:
525540
continue
526-
# The interface name is always the last but one field in the BUFFER_QUEUE entry key
527-
interfaces.add(fields[-2])
528-
except IndexError:
529-
pass
541+
assert (re.search(QUEUE_COUNTERS_RE_FMT.format(intf),
542+
queue_counter) is not None) \
543+
and (re.search(QUEUE_COUNTERS_RE_FMT.format(setup['port_name_map'][intf]),
544+
queue_counter) is None)
545+
intfsChecked += 1
530546

531-
# For the test to be valid, we should have at least one interface selected
532-
assert (len(interfaces) > 0)
533-
534-
intfsChecked = 0
535-
if mode == 'alias':
536-
for intf in interfaces:
537-
alias = setup['port_name_map'][intf]
538-
assert (re.search(QUEUE_COUNTERS_RE_FMT.format(alias),
539-
queue_counter) is not None) \
540-
and (re.search(QUEUE_COUNTERS_RE_FMT.format(setup['port_alias_map'][alias]),
541-
queue_counter) is None)
542-
intfsChecked += 1
543-
elif mode == 'default':
544-
for intf in interfaces:
545-
if intf not in setup['port_name_map']:
546-
continue
547-
assert (re.search(QUEUE_COUNTERS_RE_FMT.format(intf),
548-
queue_counter) is not None) \
549-
and (re.search(QUEUE_COUNTERS_RE_FMT.format(setup['port_name_map'][intf]),
550-
queue_counter) is None)
551-
intfsChecked += 1
552-
553-
# At least one interface should have been checked to have a valid result
554-
assert (intfsChecked > 0)
547+
# At least one interface should have been checked to have a valid result
548+
assert (intfsChecked > 0)
555549

556550
def test_show_queue_counters_interface(self, setup_config_mode, sample_intf):
557551
"""
@@ -725,7 +719,7 @@ class TestConfigInterface():
725719

726720
@pytest.fixture(scope="class", autouse=True)
727721
def setup_check_topo(self, tbinfo):
728-
if tbinfo['topo']['type'] not in ['t2', 't1']:
722+
if tbinfo['topo']['type'] not in ['t1']:
729723
pytest.skip('Unsupported topology')
730724

731725
def check_speed_change(self, duthost, asic_index, interface, change_speed):
@@ -938,8 +932,6 @@ def test_show_interfaces_neighbor_expected(setup, setup_config_mode, tbinfo, dut
938932
if tbinfo['topo']['type'] not in ['t1', 't2']:
939933
pytest.skip('Unsupported topology')
940934

941-
skip_test_for_multi_asic(duthosts, enum_rand_one_per_hwsku_frontend_hostname)
942-
943935
dutHostGuest, mode, ifmode = setup_config_mode
944936
minigraph_neighbors = setup['minigraph_facts']['minigraph_neighbors']
945937

0 commit comments

Comments
 (0)