From 2be379c1782217020502ab8f46226d6ed601b2d9 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 9 Dec 2025 23:37:46 +0000 Subject: [PATCH 1/2] override config tests (masic): don't stop at first bad table * tests/override_config_table/test_override_config_table_masic.py (load_minigraph_with_golden_empty_input): This function asserts on the first discrepancy found. We instead gather the (asic, table) tuples into a list, and assert if the list is not empty, showing the list in the assertion message. --- .../test_override_config_table_masic.py | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/tests/override_config_table/test_override_config_table_masic.py b/tests/override_config_table/test_override_config_table_masic.py index ba7dac3690..530f9b3647 100644 --- a/tests/override_config_table/test_override_config_table_masic.py +++ b/tests/override_config_table/test_override_config_table_masic.py @@ -6,7 +6,8 @@ from tests.common.utilities import update_pfcwd_default_state from tests.common.config_reload import config_reload from tests.common.utilities import backup_config, restore_config, get_running_config,\ - reload_minigraph_with_golden_config, file_exists_on_dut, NON_USER_CONFIG_TABLES + reload_minigraph_with_golden_config, file_exists_on_dut, compare_dicts_ignore_list_order, \ + NON_USER_CONFIG_TABLES GOLDEN_CONFIG = "/etc/sonic/golden_config_db.json" GOLDEN_CONFIG_BACKUP = "/etc/sonic/golden_config_db.json_before_override" @@ -89,6 +90,9 @@ def load_minigraph_with_golden_empty_input(duthost): initial_asic0_config = get_running_config(duthost, "asic0") empty_input = {} + + problem_tuples = [] + reload_minigraph_with_golden_config(duthost, empty_input) # Test host running config override @@ -96,21 +100,30 @@ def load_minigraph_with_golden_empty_input(duthost): for table in initial_host_config: if table in NON_USER_CONFIG_TABLES: continue - pytest_assert( - initial_host_config[table] == host_current_config[table], - "empty input compare fail! {}".format(table) - ) + + if table == "ACL_TABLE": + if not compare_dicts_ignore_list_order(initial_host_config[table], + host_current_config[table]): + problem_tuples.append((table, None)) + else: + if not initial_host_config[table] == host_current_config[table]: + problem_tuples.append((table, None)) # Test asic0 running config override asic0_current_config = get_running_config(duthost, "asic0") for table in initial_asic0_config: if table in NON_USER_CONFIG_TABLES: continue - pytest_assert( - initial_asic0_config[table] == asic0_current_config[table], - "empty input compare fail! {}".format(table) - ) + if table == "ACL_TABLE": + if not compare_dicts_ignore_list_order(initial_asic0_config[table], + asic0_current_config[table]): + problem_tuples.append((table, "asic0")) + else: + if not initial_asic0_config[table] == asic0_current_config[table]: + problem_tuples.append((table, "asic0")) + + pytest_assert(not problem_tuples, "empty input compare fail: {}".format(problem_tuples)) def load_minigraph_with_golden_partial_config(duthost): """Test Golden Config with partial config. From 73de7bdf51b5e552ec735f15a350aeafa5767ea6 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 9 Dec 2025 23:53:44 +0000 Subject: [PATCH 2/2] override config tests (masic): ignore certain tables in empty test (This change was already implemented for the non-msaic version of the test case.) In the test case test_load_minigraph_with_golden_config, the function load_minigraph_with_golden_empty_input asserts. This function expects all the tables to be identical after the golden config is overridden to be empty. But it looks as if the golden config is the source of several configurations: the "BMP" table, and "fec" : "rs" entries in the "PORT". Thus, when the golden config is replaced with an empty configuration, the entire "BMP" table, well as those "fec" properties in the "PORT" table, disappear. We propose a variable GOLDEN_OVERRIDDEN_TABLES for additional tables which that function should skip. This is similar to the existing variable NON_USER_CONFIG_TABLES which non-user-config tables that need to be skipped. tests/override_config_table/test_override_config_table_masic.py (GOLDEN_OVERRIDDEN_TABLES): New variable. (load_minigraph_with_golden_empty_input): Skip tables found in GOLDEN_OVERRIDDEN_TABLES. --- .../test_override_config_table_masic.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/override_config_table/test_override_config_table_masic.py b/tests/override_config_table/test_override_config_table_masic.py index 530f9b3647..3b64628b26 100644 --- a/tests/override_config_table/test_override_config_table_masic.py +++ b/tests/override_config_table/test_override_config_table_masic.py @@ -9,6 +9,10 @@ reload_minigraph_with_golden_config, file_exists_on_dut, compare_dicts_ignore_list_order, \ NON_USER_CONFIG_TABLES +# Tables known to be overriden in run-time config, which will appear different +# if the golden config is overridden empty. +GOLDEN_OVERRRIDDEN_TABLES = ["FEATURE", "PORT"] + GOLDEN_CONFIG = "/etc/sonic/golden_config_db.json" GOLDEN_CONFIG_BACKUP = "/etc/sonic/golden_config_db.json_before_override" CONFIG_DB = "/etc/sonic/config_db.json" @@ -98,7 +102,7 @@ def load_minigraph_with_golden_empty_input(duthost): # Test host running config override host_current_config = get_running_config(duthost) for table in initial_host_config: - if table in NON_USER_CONFIG_TABLES: + if table in NON_USER_CONFIG_TABLES or table in GOLDEN_OVERRRIDDEN_TABLES: continue if table == "ACL_TABLE": @@ -112,7 +116,7 @@ def load_minigraph_with_golden_empty_input(duthost): # Test asic0 running config override asic0_current_config = get_running_config(duthost, "asic0") for table in initial_asic0_config: - if table in NON_USER_CONFIG_TABLES: + if table in NON_USER_CONFIG_TABLES or table in GOLDEN_OVERRRIDDEN_TABLES: continue if table == "ACL_TABLE":