21
21
RUNNING_CONFIG_YANG_FAILURE = os .path .join (DATA_DIR , "running_config_yang_failure.json" )
22
22
GOLDEN_INPUT_YANG_FAILURE = os .path .join (DATA_DIR , "golden_input_yang_failure.json" )
23
23
FINAL_CONFIG_YANG_FAILURE = os .path .join (DATA_DIR , "final_config_yang_failure.json" )
24
+ MULTI_ASIC_MACSEC_OV = os .path .join (DATA_DIR , "multi_asic_macsec_ov.json" )
25
+ MULTI_ASIC_DEVICE_METADATA_RM = os .path .join (DATA_DIR , "multi_asic_dm_rm.json" )
24
26
25
27
# Load sonic-cfggen from source since /usr/local/bin/sonic-cfggen does not have .py extension.
26
28
sonic_cfggen = load_module_from_source ('sonic_cfggen' , '/usr/local/bin/sonic-cfggen' )
@@ -275,15 +277,15 @@ def setup_class(cls):
275
277
276
278
def test_macsec_override (self ):
277
279
def read_json_file_side_effect (filename ):
280
+ with open (MULTI_ASIC_MACSEC_OV , "r" ) as f :
281
+ macsec_profile = json .load (f )
278
282
return macsec_profile
279
283
db = Db ()
280
284
cfgdb_clients = db .cfgdb_clients
281
- macsec_profile = {}
282
- profile_content = {"profile" : {"key" : "value" }}
283
285
284
- for ns , config_db in cfgdb_clients . items ():
285
- macsec_profile [ ns ] = { }
286
- macsec_profile [ ns ][ 'MACSEC_PROFILE' ] = profile_content
286
+ # The profile_content was copied from MULTI_ASIC_MACSEC_OV, where all
287
+ # ns sharing the same content: {"profile": {"key": "value"} }
288
+ profile_content = { "profile" : { "key" : "value" }}
287
289
288
290
with mock .patch ('config.main.read_json_file' ,
289
291
mock .MagicMock (side_effect = read_json_file_side_effect )):
@@ -297,15 +299,14 @@ def read_json_file_side_effect(filename):
297
299
298
300
def test_device_metadata_table_rm (self ):
299
301
def read_json_file_side_effect (filename ):
302
+ with open (MULTI_ASIC_DEVICE_METADATA_RM , "r" ) as f :
303
+ device_metadata = json .load (f )
300
304
return device_metadata
301
305
db = Db ()
302
306
cfgdb_clients = db .cfgdb_clients
303
- device_metadata = {}
304
307
305
308
for ns , config_db in cfgdb_clients .items ():
306
309
assert 'DEVICE_METADATA' in config_db .get_config ()
307
- device_metadata [ns ] = {}
308
- device_metadata [ns ]['DEVICE_METADATA' ] = {}
309
310
310
311
with mock .patch ('config.main.read_json_file' ,
311
312
mock .MagicMock (side_effect = read_json_file_side_effect )):
0 commit comments