|
7 | 7 | from tests.common.utilities import wait, wait_until |
8 | 8 | from netaddr import IPAddress |
9 | 9 | 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 |
11 | 11 |
|
12 | 12 | pytestmark = [ |
13 | 13 | pytest.mark.topology('any', "t1-multi-asic") |
|
20 | 20 | QUEUE_COUNTERS_RE_FMT = r'{}\s+[U|M]C|ALL\d\s+\S+\s+\S+\s+\S+\s+\S+' |
21 | 21 |
|
22 | 22 |
|
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 | | - |
29 | 23 | @pytest.fixture(scope='module', autouse=True) |
30 | 24 | def setup(duthosts, enum_rand_one_per_hwsku_frontend_hostname, tbinfo): |
31 | 25 | """ |
@@ -420,7 +414,7 @@ class TestShowPriorityGroup(): |
420 | 414 |
|
421 | 415 | @pytest.fixture(scope="class", autouse=True) |
422 | 416 | 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 |
424 | 418 |
|
425 | 419 | def test_show_priority_group_persistent_watermark_headroom(self, setup, setup_config_mode): |
426 | 420 | """ |
@@ -493,65 +487,65 @@ def test_show_priority_group_watermark_shared(self, setup, setup_config_mode): |
493 | 487 |
|
494 | 488 | class TestShowQueue(): |
495 | 489 |
|
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 | | - |
501 | 490 | def test_show_queue_counters(self, setup, setup_config_mode, duthosts, enum_rand_one_per_hwsku_frontend_hostname): |
502 | 491 | """ |
503 | 492 | Checks whether 'show queue counters' lists the interface names as |
504 | 493 | per the configured naming mode |
505 | 494 | """ |
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)) |
510 | 495 |
|
511 | 496 | 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']: |
525 | 540 | 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 |
530 | 546 |
|
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) |
555 | 549 |
|
556 | 550 | def test_show_queue_counters_interface(self, setup_config_mode, sample_intf): |
557 | 551 | """ |
@@ -725,7 +719,7 @@ class TestConfigInterface(): |
725 | 719 |
|
726 | 720 | @pytest.fixture(scope="class", autouse=True) |
727 | 721 | def setup_check_topo(self, tbinfo): |
728 | | - if tbinfo['topo']['type'] not in ['t2', 't1']: |
| 722 | + if tbinfo['topo']['type'] not in ['t1']: |
729 | 723 | pytest.skip('Unsupported topology') |
730 | 724 |
|
731 | 725 | 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 |
938 | 932 | if tbinfo['topo']['type'] not in ['t1', 't2']: |
939 | 933 | pytest.skip('Unsupported topology') |
940 | 934 |
|
941 | | - skip_test_for_multi_asic(duthosts, enum_rand_one_per_hwsku_frontend_hostname) |
942 | | - |
943 | 935 | dutHostGuest, mode, ifmode = setup_config_mode |
944 | 936 | minigraph_neighbors = setup['minigraph_facts']['minigraph_neighbors'] |
945 | 937 |
|
|
0 commit comments