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

[Bug]: platform_test/counterpoll/test_counterpoll_watermark.py leaves config_db#.json with flex counters disabled. #15991

Open
arista-nwolfe opened this issue Dec 11, 2024 · 0 comments · May be fixed by #16002
Assignees

Comments

@arista-nwolfe
Copy link
Contributor

arista-nwolfe commented Dec 11, 2024

Issue Description

platform_test/counterpoll/test_counterpoll_watermark.py disables FLEX_COUNTERs and saves the config:

    with allure.step("disabling all counterpolls"):
        for asic in duthost.asics:
            ConterpollHelper.disable_counterpoll(asic, list(CounterpollConstants.COUNTERPOLL_MAPPING.values()))

    # verify relevant counterpolls (queue/watermark/pg-drop) are disabled
    with allure.step("Verifying initial output of {} on {} ..."
                     .format(CounterpollConstants.COUNTERPOLL_SHOW, duthost.hostname)):
        verify_all_counterpoll_status(duthost, DISABLE)

    with allure.step("saving config on dut {} after counterpoll disable...".format(duthost.hostname)):
        duthost.command('config save -y')

The test expects the fixture backup_and_restore_config_db to restore the config_db.json file back to it's original contents after the test completes.
However, the test uses a different fixture to pick the dut than the backup_and_restore_config_db fixture uses.
I.E.
test_counterpoll_queue_watermark_pg_drop uses enum_rand_one_per_hwsku_frontend_hostname
backup_and_restore_config_db uses rand_one_dut_hostname

This can result in the dut that is being backed up to be different from the one which is being tested.
E.G. test is run on LC4 and LC6

platform_tests/counterpoll/test_counterpoll_watermark.py::test_counterpoll_queue_watermark_pg_drop[cmp227-4] PASSED
platform_tests/counterpoll/test_counterpoll_watermark.py::test_counterpoll_queue_watermark_pg_drop[cmp227-6] PASSED

But looking at the logs I see the config_db that is backed up is on LC5:

10/12/2024 23:00:08 duthost_utils._backup_and_restore_config L0043 INFO   | Backup /etc/sonic/config_db.json to /host/config_db.json.before_test_function on cmp227-5

Additionally the bottom level function _backup_and_restore_config_db doesn't support multi-asic config_dbs:

def _backup_and_restore_config_db(duts, scope='function'):

    CONFIG_DB = "/etc/sonic/config_db.json"
    CONFIG_DB_BAK = "/host/config_db.json.before_test_{}".format(scope)

    if type(duts) is not list:
        duthosts = [duts]
    else:
        duthosts = duts

    for duthost in duthosts:
        logger.info("Backup {} to {} on {}".format(CONFIG_DB, CONFIG_DB_BAK, duthost.hostname))
        duthost.shell("cp {} {}".format(CONFIG_DB, CONFIG_DB_BAK))

    yield

    for duthost in duthosts:
        logger.info("Restore {} with {} on {}".format(CONFIG_DB, CONFIG_DB_BAK, duthost.hostname))
        duthost.shell("mv {} {}".format(CONFIG_DB_BAK, CONFIG_DB))

Results you see

The config_db.json files are modified after running platform_test/counterpoll/test_counterpoll_watermark.py
E.G.
Before:
/etc/sonic/config_db.json

"FLEX_COUNTER_TABLE": {
    "ACL": {
        "FLEX_COUNTER_DELAY_STATUS": "true",
        "FLEX_COUNTER_STATUS": "enable",
        "POLL_INTERVAL": "10000"
    }
},

After:
/etc/sonic/config_db.json

"FLEX_COUNTER_TABLE": {
    "ACL": {
        "FLEX_COUNTER_DELAY_STATUS": "false",
        "FLEX_COUNTER_STATUS": "disable",
        "POLL_INTERVAL": "10000"
    },
    "BUFFER_POOL_WATERMARK": {
        "FLEX_COUNTER_STATUS": "disable"
    },
    "PFCWD": {
        "FLEX_COUNTER_STATUS": "enable"
    },
    "PG_DROP": {
        "FLEX_COUNTER_STATUS": "disable"
    },
    "PG_WATERMARK": {
        "FLEX_COUNTER_STATUS": "disable"
    },
    "PORT": {
        "FLEX_COUNTER_STATUS": "disable"
    },
    "PORT_BUFFER_DROP": {
        "FLEX_COUNTER_STATUS": "disable"
    },
    "QUEUE": {
        "FLEX_COUNTER_STATUS": "disable"
    },
    "QUEUE_WATERMARK": {
        "FLEX_COUNTER_STATUS": "disable"
    },
    "RIF": {
        "FLEX_COUNTER_STATUS": "disable"
    }
},

Results you expected to see

The config_db.json files should not be modified after running platform_test/counterpoll/test_counterpoll_watermark.py

Is it platform specific

generic

Relevant log output

No response

Output of show version

No response

Attach files (if any)

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

3 participants