fix(conftest): always regenerate pre-test config snapshot from live CONFIG_DB#24660
Open
rookie-who wants to merge 1 commit into
Open
fix(conftest): always regenerate pre-test config snapshot from live CONFIG_DB#24660rookie-who wants to merge 1 commit into
rookie-who wants to merge 1 commit into
Conversation
…ONFIG_DB The config_db_check sanity checker uses running_golden_config.json as the pre-test baseline. Previously, this file was only generated if it didn't already exist on the DUT, which meant it could become stale. Daemon-written fields like BGP_NEIGHBOR admin_status (from bgpcfgd when default_bgp_status is set) and DEVICE_METADATA zebra_nexthop get added to CONFIG_DB at runtime but may not be in a cached snapshot. This causes spurious config_db_check failures when the post-test snapshot includes these daemon-injected fields but the stale pre-test snapshot does not. Fix by always regenerating the snapshot from live CONFIG_DB via sonic-cfggen before each test. This ensures the pre-test baseline reflects the fully-converged state including all daemon-written fields. Fixes flaky failures in tests like: test_load_minigraph_with_golden_config (override_config_table) Signed-off-by: rookie-who <rookie-who@users.noreply.github.com>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The
config_db_checksanity checker inconftest.pyusesrunning_golden_config.jsonas the pre-test CONFIG_DB baseline. Previously, this file was only generated if it didn't already exist on the DUT (created once duringtest_pretest), which meant it could become stale across test runs.Daemon-written fields get added to CONFIG_DB at runtime after
config reload/load_minigraph:BGP_NEIGHBOR|*/admin_status: up— written by bgpcfgd whendefault_bgp_status: downis set in DEVICE_METADATADEVICE_METADATA|localhost/zebra_nexthop: disabled— written by zebra config logicWhen the cached pre-test snapshot was created before these daemons finished writing, the post-test snapshot includes these fields but the pre-test snapshot does not, causing a spurious
config_db_check_failed: True.Fix
Always regenerate
running_golden_config.jsonfrom live CONFIG_DB (sonic-cfggen -d --print-data) before each test. This ensures the pre-test baseline reflects the fully-converged state including all daemon-injected fields.Affected tests
Fixes flaky
config_db_checkfailures observed in:override_config_table/test_override_config_table.py::test_load_minigraph_with_golden_configconfig reloadwith daemon-injected CONFIG_DB fieldsRisk
Low — this only changes when the snapshot file is regenerated (always vs. only-if-missing). The snapshot content is identical when daemons have converged. This also benefits the recovery system (
recover.py) which uses the same file forconfig_reload(config_source="running_golden_config"), ensuring recovery uses an up-to-date baseline.