6
6
from tests .common .utilities import wait , wait_until
7
7
from netaddr import IPAddress
8
8
from tests .common .helpers .assertions import pytest_assert
9
+ from tests .common .helpers .sonic_db import redis_get_keys
9
10
10
11
pytestmark = [
11
12
pytest .mark .topology ('any' )
@@ -430,7 +431,7 @@ def setup_check_topo(self, duthosts, enum_rand_one_per_hwsku_frontend_hostname):
430
431
skip_test_for_multi_asic (
431
432
duthosts , enum_rand_one_per_hwsku_frontend_hostname )
432
433
433
- def test_show_queue_counters (self , setup , setup_config_mode ):
434
+ def test_show_queue_counters (self , setup , setup_config_mode , duthosts , enum_rand_one_per_hwsku_frontend_hostname ):
434
435
"""
435
436
Checks whether 'show queue counters' lists the interface names as
436
437
per the configured naming mode
@@ -439,11 +440,22 @@ def test_show_queue_counters(self, setup, setup_config_mode):
439
440
queue_counter = dutHostGuest .shell ('SONIC_CLI_IFACE_MODE={} sudo show queue counters | grep "UC\|MC\|ALL"' .format (ifmode ))['stdout' ]
440
441
logger .info ('queue_counter:\n {}' .format (queue_counter ))
441
442
443
+ duthost = duthosts [enum_rand_one_per_hwsku_frontend_hostname ]
444
+ buffer_queue_keys = redis_get_keys (duthost , 'CONFIG_DB' , 'BUFFER_QUEUE|*' )
445
+ interfaces = set ()
446
+
447
+ for key in buffer_queue_keys :
448
+ try :
449
+ interfaces .add (key .split ('|' )[1 ])
450
+ except IndexError :
451
+ pass
452
+
442
453
if mode == 'alias' :
443
- for alias in setup ['port_alias' ]:
454
+ for intf in interfaces :
455
+ alias = setup ['port_name_map' ][intf ]
444
456
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 )
445
457
elif mode == 'default' :
446
- for intf in setup [ 'default_interfaces' ] :
458
+ for intf in interfaces :
447
459
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 )
448
460
449
461
def test_show_queue_counters_interface (self , setup_config_mode , sample_intf ):
@@ -468,12 +480,13 @@ def test_show_queue_persistent_watermark_multicast(self, setup, setup_config_mod
468
480
show_queue_wm_mcast = dutHostGuest .shell ('SONIC_CLI_IFACE_MODE={} show queue persistent-watermark multicast' .format (ifmode ))['stdout' ]
469
481
logger .info ('show_queue_wm_mcast:\n {}' .format (show_queue_wm_mcast ))
470
482
471
- if mode == 'alias' :
472
- for alias in setup ['port_alias' ]:
473
- assert re .search (r'{}' .format (alias ), show_queue_wm_mcast ) is not None
474
- elif mode == 'default' :
475
- for intf in setup ['default_interfaces' ]:
476
- assert re .search (r'{}' .format (intf ), show_queue_wm_mcast ) is not None
483
+ if show_queue_wm_mcast != "Object map from the COUNTERS_DB is empty because the multicast queues are not configured in the CONFIG_DB!" :
484
+ if mode == 'alias' :
485
+ for alias in setup ['port_alias' ]:
486
+ assert re .search (r'{}' .format (alias ), show_queue_wm_mcast ) is not None
487
+ elif mode == 'default' :
488
+ for intf in setup ['default_interfaces' ]:
489
+ assert re .search (r'{}' .format (intf ), show_queue_wm_mcast ) is not None
477
490
478
491
def test_show_queue_persistent_watermark_unicast (self , setup , setup_config_mode ):
479
492
"""
@@ -500,12 +513,13 @@ def test_show_queue_watermark_multicast(self, setup, setup_config_mode):
500
513
show_queue_wm_mcast = dutHostGuest .shell ('SONIC_CLI_IFACE_MODE={} show queue watermark multicast' .format (ifmode ))['stdout' ]
501
514
logger .info ('show_queue_wm_mcast:\n {}' .format (show_queue_wm_mcast ))
502
515
503
- if mode == 'alias' :
504
- for alias in setup ['port_alias' ]:
505
- assert re .search (r'{}' .format (alias ), show_queue_wm_mcast ) is not None
506
- elif mode == 'default' :
507
- for intf in setup ['default_interfaces' ]:
508
- assert re .search (r'{}' .format (intf ), show_queue_wm_mcast ) is not None
516
+ if show_queue_wm_mcast != "Object map from the COUNTERS_DB is empty because the multicast queues are not configured in the CONFIG_DB!" :
517
+ if mode == 'alias' :
518
+ for alias in setup ['port_alias' ]:
519
+ assert re .search (r'{}' .format (alias ), show_queue_wm_mcast ) is not None
520
+ elif mode == 'default' :
521
+ for intf in setup ['default_interfaces' ]:
522
+ assert re .search (r'{}' .format (intf ), show_queue_wm_mcast ) is not None
509
523
510
524
def test_show_queue_watermark_unicast (self , setup , setup_config_mode ):
511
525
"""
0 commit comments