Skip to content

[Bug][Snappi]: enable_packet_aging_after_test in conf_test fails since it does not pass asic_value to the function. #13654

@amitpawar12

Description

@amitpawar12

Issue Description

This is priority0 issue and needs to be addressed on priority.

tests/snappi_tests/conftest.py calls following function:

@pytest.fixture(autouse=True, scope="module")
def enable_packet_aging_after_test(duthosts, rand_one_dut_hostname):
----- curtailed output ----
    yield

    duthost = duthosts[rand_one_dut_hostname]
    enable_packet_aging(duthost) # <<< no asic is passed here.....

The enable_packet_aging function however, is a bit volatile because there is no command if the asic_value is not passed:

File:tests/common/snappi_tests/common_helpers.py

    if isMellanoxDevice(duthost):
        duthost.copy(src="qos/files/mellanox/packets_aging.py", dest="/tmp")
        duthost.command("docker cp /tmp/packets_aging.py syncd:/")
        duthost.command("docker exec syncd python /packets_aging.py enable")
        duthost.command("docker exec syncd rm -rf /packets_aging.py")
    elif "platform_asic" in duthost.facts and duthost.facts["platform_asic"] == "broadcom-dnx":
        try:
            duthost.shell('bcmcmd -n {} "BCMSAI credit-watchdog enable"'.format(asic_value))
        except Exception:
            duthost.shell('bcmcmd -n {} "BCMSAI credit-watchdog enable"'.format(asic_value[-1]))

The cleanup fails because the asic_value is not passed.

Results you see

Error while cleaning up the test:

03:44:26 __init__._fixture_generator_decorator    L0093 INFO   | -------------------- fixture enable_packet_aging_after_test teardown starts --------------------
03:44:27 __init__._fixture_generator_decorator    L0099 ERROR  | 
TypeError("'NoneType' object has no attribute '__getitem__'",)
Traceback (most recent call last):
  File "/data/tests/common/plugins/log_section_start/__init__.py", line 95, in _fixture_generator_decorator
    next(it)
  File "/data/tests/snappi_tests/conftest.py", line 79, in enable_packet_aging_after_test
    enable_packet_aging(duthost)
  File "/data/tests/common/snappi_tests/common_helpers.py", line 817, in enable_packet_aging
    duthost.shell('bcmcmd -n {} "BCMSAI credit-watchdog enable"'.format(asic_value[-1]))
TypeError: 'NoneType' object has no attribute '__getitem__'
03:44:27 __init__._fixture_generator_decorator    L0102 INFO   | -------------------- fixture enable_packet_aging_after_test teardown ends --------------------

snappi_tests/multidut/systest/test_non_congestion_imix.py::test_multiple_prio_diff_dist[chassis_xxx-linecard_configuration_set0] ERROR                                       [100%]


fixture_generator = <function enable_packet_aging_after_test at 0x7fae5b99f3d0>
args = ([<xxx>, <xxx>, <xxx>, <xxx>], 'xxx')
kargs = {}, it = <generator object enable_packet_aging_after_test at 0x7fae521b5410>, res = None, detail = TypeError("'NoneType' object has no attribute '__getitem__'",)

Results you expected to see

The enable_packet_aging should have corresponding code to enable credit watchdog irrespective of the ASICs (since it is enabled by default).

    if isMellanoxDevice(duthost):
        duthost.copy(src="qos/files/mellanox/packets_aging.py", dest="/tmp")
        duthost.command("docker cp /tmp/packets_aging.py syncd:/")
        duthost.command("docker exec syncd python /packets_aging.py enable")
        duthost.command("docker exec syncd rm -rf /packets_aging.py")
    elif "platform_asic" in duthost.facts and duthost.facts["platform_asic"] == "broadcom-dnx":
        for asic_value in duthost.facts['asics_present']: # This needs to be added for it to work.
            try:
                duthost.shell('bcmcmd -n {} "BCMSAI credit-watchdog enable"'.format(asic_value))
            except Exception:
                duthost.shell('bcmcmd -n {} "BCMSAI credit-watchdog enable"'.format(asic_value[-1]))

Is it platform specific

generic

Relevant log output

No response

Output of show version

No response

Attach files (if any)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions