Skip to content

Commit

Permalink
Support empty golden config file for multi-asic (#3670)
Browse files Browse the repository at this point in the history
What I did
config_sonic_basedon_testbed.yml creates an empty golden_config_db.json file under /etc/sonic for non mx platforms.
When this empty file exist db_migration fails for all asics for non mx platforms.

How I did it
Update db_migrator to support empty golden config file.

How to verify it
Run unit test and end to end test
  • Loading branch information
ganglyu authored and mssonicbld committed Dec 11, 2024
1 parent ffd7cf5 commit 4c51837
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/db_migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def generate_config_src(self, ns):
config_namespace = "localhost"
else:
config_namespace = ns
golden_config_data = golden_data[config_namespace]
golden_config_data = golden_data.get(config_namespace, None)
except Exception as e:
log.log_error('Caught exception while trying to load golden config: ' + str(e))
pass
Expand Down
7 changes: 7 additions & 0 deletions tests/db_migrator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,13 @@ def test_golden_config_hostname(self):
# hostname is from golden_config_db.json
assert hostname == 'SONiC-Golden-Config'

def test_golden_config_ns(self):
# golden_config_db.json.test has no namespace
import db_migrator
dbmgtr = db_migrator.DBMigrator("asic0")
result = json.dumps(dbmgtr.config_src_data)
assert 'SONiC-Golden-Config' not in result

class TestGoldenConfigInvalid(object):
@classmethod
def setup_class(cls):
Expand Down

0 comments on commit 4c51837

Please sign in to comment.