Skip to content

Commit

Permalink
[golden_config_infra] Backup and Restore config before test (#14421)
Browse files Browse the repository at this point in the history
Description of PR
Summary: Default Config was changed during config_reload process. Need to backup and restore config.
Fixes # (issue) #14327

Type of change
 Bug fix
 Testbed and Framework(new/improvement)
 Test case(new/improvement)
Back port request
 202012
 202205
 202305
 202311
 202405
Approach
What is the motivation for this PR?
Fix config change issue. Remove t2 topo as it is not designed.

How did you do it?
Backup and restore

How did you verify/test it?
E2E test

co-authorized by: [email protected]
  • Loading branch information
wen587 authored and mssonicbld committed Sep 5, 2024
1 parent 0a1bbff commit 100932d
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

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"
CONFIG_DB_BACKUP = "/etc/sonic/config_db.json_before_override"


def file_exists_on_dut(duthost, filename):
Expand All @@ -40,6 +42,8 @@ def setup_env(duthosts, rand_one_dut_hostname, tbinfo):
if topo_type in ["m0", "mx"]:
original_pfcwd_value = update_pfcwd_default_state(duthost, "/etc/sonic/init_cfg.json", "disable")

# Backup configDB
backup_config(duthost, CONFIG_DB, CONFIG_DB_BACKUP)
if file_exists_on_dut(duthost, GOLDEN_CONFIG):
backup_config(duthost, GOLDEN_CONFIG, GOLDEN_CONFIG_BACKUP)

Expand All @@ -51,6 +55,8 @@ def setup_env(duthosts, rand_one_dut_hostname, tbinfo):
if topo_type in ["m0", "mx"]:
update_pfcwd_default_state(duthost, "/etc/sonic/init_cfg.json", original_pfcwd_value)

# Restore configDB after test.
restore_config(duthost, CONFIG_DB, CONFIG_DB_BACKUP)
if file_exists_on_dut(duthost, GOLDEN_CONFIG_BACKUP):
restore_config(duthost, GOLDEN_CONFIG, GOLDEN_CONFIG_BACKUP)
else:
Expand Down

0 comments on commit 100932d

Please sign in to comment.