From 5f089b5826eacfeb70769c33f2ed1831748a6749 Mon Sep 17 00:00:00 2001 From: Chenyang Wang Date: Wed, 18 Dec 2024 14:41:37 +1100 Subject: [PATCH] refactor: enhance override config masic test --- .../test_override_config_table_masic.py | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 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 85912678342..ba7dac36904 100644 --- a/tests/override_config_table/test_override_config_table_masic.py +++ b/tests/override_config_table/test_override_config_table_masic.py @@ -78,8 +78,8 @@ def setup_env(duthosts, tbinfo, enum_rand_one_per_hwsku_frontend_hostname): restore_config(duthost, GOLDEN_CONFIG, GOLDEN_CONFIG_BACKUP) else: duthost.file(path=GOLDEN_CONFIG, state='absent') - # Restore config before test - config_reload(duthost) + # Restore config after test + config_reload(duthost, safe_reload=True) def load_minigraph_with_golden_empty_input(duthost): @@ -220,20 +220,29 @@ def load_minigraph_with_golden_empty_table_removal(duthost): ) -def test_load_minigraph_with_golden_config(duthosts, setup_env, tbinfo, enum_upstream_dut_hostname, - enum_rand_one_per_hwsku_frontend_hostname): +def is_upstream_t2_dut(duthost, tbinfo): + upstream_nbr_type = "T3" + minigraph_facts = duthost.get_extended_minigraph_facts(tbinfo) + minigraph_neighbors = minigraph_facts['minigraph_neighbors'] + for key, value in minigraph_neighbors.items(): + if upstream_nbr_type in value['name']: + return True + + return False + + +def test_load_minigraph_with_golden_config(duthosts, setup_env, tbinfo, enum_rand_one_per_hwsku_frontend_hostname): """ Test Golden Config override during load minigraph Note: Skip full config override for multi-asic duts for now, because we don't have CLI to get new golden config that contains 'localhost' and 'asicxx' """ duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname] - duthost_up = duthosts[enum_upstream_dut_hostname] if not duthost.is_multi_asic: pytest.skip("Skip override-config-table multi-asic testing on single-asic platforms,\ test provided golden config format is not compatible with single-asics") topo_type = tbinfo["topo"]["type"] - if topo_type == 't2' and duthost != duthost_up: + if topo_type == 't2' and not is_upstream_t2_dut(duthost, tbinfo): # Skip empty golden-config testing on upstream linecards, # since the handling of empty golden config doesn't work on upstream linecards load_minigraph_with_golden_empty_input(duthost)