Skip to content

Commit 03d8335

Browse files
authored
Support empty golden config file for multi-asic (#3670)
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
1 parent 32e6de7 commit 03d8335

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

scripts/db_migrator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def generate_config_src(self, ns):
128128
config_namespace = "localhost"
129129
else:
130130
config_namespace = ns
131-
golden_config_data = golden_data[config_namespace]
131+
golden_config_data = golden_data.get(config_namespace, None)
132132
except Exception as e:
133133
log.log_error('Caught exception while trying to load golden config: ' + str(e))
134134
pass

tests/db_migrator_test.py

+7
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,13 @@ def test_golden_config_hostname(self):
856856
# hostname is from golden_config_db.json
857857
assert hostname == 'SONiC-Golden-Config'
858858

859+
def test_golden_config_ns(self):
860+
# golden_config_db.json.test has no namespace
861+
import db_migrator
862+
dbmgtr = db_migrator.DBMigrator("asic0")
863+
result = json.dumps(dbmgtr.config_src_data)
864+
assert 'SONiC-Golden-Config' not in result
865+
859866
class TestGoldenConfigInvalid(object):
860867
@classmethod
861868
def setup_class(cls):

0 commit comments

Comments
 (0)