@@ -21,14 +21,9 @@ def setUp(self):
21
21
self .t0_7050cx3_port_config = os .path .join (self .test_dir , 't0_7050cx3_d48c8_port_config.ini' )
22
22
self .t1_mlnx_minigraph = os .path .join (self .test_dir , 't1-sample-graph-mlnx.xml' )
23
23
self .mlnx_port_config = os .path .join (self .test_dir , 'sample-port-config-mlnx.ini' )
24
- self .dell6100_t0_minigraph = os .path .join (self .test_dir , 'sample-dell-6100-t0-minigraph.xml' )
25
- self .mellanox2700_t0_minigraph = os .path .join (self .test_dir , 'sample-mellanox-2700-t0-minigraph.xml' )
26
- self .mellanox2410_t1_minigraph = os .path .join (self .test_dir , 'sample-mellanox-2410-t1-minigraph.xml' )
27
- self .arista7050_t0_minigraph = os .path .join (self .test_dir , 'sample-arista-7050-t0-minigraph.xml' )
28
24
self .multi_asic_minigraph = os .path .join (self .test_dir , 'multi_npu_data' , 'sample-minigraph.xml' )
29
25
self .multi_asic_port_config = os .path .join (self .test_dir , 'multi_npu_data' , 'sample_port_config-0.ini' )
30
26
self .radv_test_minigraph = os .path .join (self .test_dir , 'radv-test-sample-graph.xml' )
31
- self .dell9332_t1_minigraph = os .path .join (self .test_dir , 'sample-dell-9332-t1-minigraph.xml' )
32
27
self .output_file = os .path .join (self .test_dir , 'output' )
33
28
os .environ ["CFGGEN_UNIT_TESTING" ] = "2"
34
29
@@ -235,120 +230,47 @@ def test_l2switch_template_dualtor(self):
235
230
self .assertEqual (sample_output_json , output_json )
236
231
237
232
def test_qos_arista7050_render_template (self ):
238
- arista_dir_path = os .path .join (self .test_dir , '..' , '..' , '..' , 'device' , 'arista' , 'x86_64-arista_7050_qx32s' , 'Arista-7050-QX-32S' )
239
- qos_file = os .path .join (arista_dir_path , 'qos.json.j2' )
240
- port_config_ini_file = os .path .join (arista_dir_path , 'port_config.ini' )
241
-
242
- # copy qos_config.j2 to the Arista 7050 directory to have all templates in one directory
243
- qos_config_file = os .path .join (self .test_dir , '..' , '..' , '..' , 'files' , 'build_templates' , 'qos_config.j2' )
244
- shutil .copy2 (qos_config_file , arista_dir_path )
245
-
246
- argument = '-m ' + self .arista7050_t0_minigraph + ' -p ' + port_config_ini_file + ' -t ' + qos_file + ' > ' + self .output_file
247
- self .run_script (argument )
248
-
249
- # cleanup
250
- qos_config_file_new = os .path .join (arista_dir_path , 'qos_config.j2' )
251
- os .remove (qos_config_file_new )
252
-
253
- sample_output_file = os .path .join (self .test_dir , 'sample_output' , utils .PYvX_DIR , 'qos-arista7050.json' )
254
- assert utils .cmp (sample_output_file , self .output_file )
233
+ self ._test_qos_render_template ('arista' , 'x86_64-arista_7050_qx32s' , 'Arista-7050-QX-32S' , 'sample-arista-7050-t0-minigraph.xml' , 'qos-arista7050.json' )
255
234
256
235
def test_qos_dell9332_render_template (self ):
257
- dell_dir_path = os .path .join (self .test_dir , '..' , '..' , '..' , 'device' , 'dell' , 'x86_64-dellemc_z9332f_d1508-r0' , 'DellEMC-Z9332f-O32' )
258
- qos_file = os .path .join (dell_dir_path , 'qos.json.j2' )
259
- port_config_ini_file = os .path .join (dell_dir_path , 'port_config.ini' )
260
-
261
- # copy qos_config.j2 to the Dell Z9332 directory to have all templates in one directory
262
- qos_config_file = os .path .join (self .test_dir , '..' , '..' , '..' , 'files' , 'build_templates' , 'qos_config.j2' )
263
- shutil .copy2 (qos_config_file , dell_dir_path )
264
-
265
- argument = '-m ' + self .dell9332_t1_minigraph + ' -p ' + port_config_ini_file + ' -t ' + qos_file + ' > ' + self .output_file
266
- self .run_script (argument )
267
-
268
- # cleanup
269
- qos_config_file_new = os .path .join (dell_dir_path , 'qos_config.j2' )
270
- os .remove (qos_config_file_new )
271
-
272
- sample_output_file = os .path .join (self .test_dir , 'sample_output' , utils .PYvX_DIR , 'qos-dell9332.json' )
273
- assert utils .cmp (sample_output_file , self .output_file )
236
+ self ._test_qos_render_template ('dell' , 'x86_64-dellemc_z9332f_d1508-r0' , 'DellEMC-Z9332f-O32' , 'sample-dell-9332-t1-minigraph.xml' , 'qos-dell9332.json' )
274
237
275
238
def test_qos_dell6100_render_template (self ):
276
- dell_dir_path = os .path .join (self .test_dir , '..' , '..' , '..' , 'device' , 'dell' , 'x86_64-dell_s6100_c2538-r0' , 'Force10-S6100' )
277
- qos_file = os .path .join (dell_dir_path , 'qos.json.j2' )
278
- port_config_ini_file = os .path .join (dell_dir_path , 'port_config.ini' )
239
+ self ._test_qos_render_template ('dell' , 'x86_64-dell_s6100_c2538-r0' , 'Force10-S6100' , 'sample-dell-6100-t0-minigraph.xml' , 'qos-dell6100.json' )
279
240
280
- # copy qos_config.j2 to the Dell S6100 directory to have all templates in one directory
241
+ def _test_qos_render_template (self , vendor , platform , sku , minigraph , expected ):
242
+ file_exist , dir_exist = self .create_machine_conf (platform , vendor )
243
+ dir_path = os .path .join (self .test_dir , '..' , '..' , '..' , 'device' , vendor , platform , sku )
244
+ qos_file = os .path .join (dir_path , 'qos.json.j2' )
245
+ port_config_ini_file = os .path .join (dir_path , 'port_config.ini' )
246
+
247
+ # copy qos_config.j2 to the SKU directory to have all templates in one directory
281
248
qos_config_file = os .path .join (self .test_dir , '..' , '..' , '..' , 'files' , 'build_templates' , 'qos_config.j2' )
282
- shutil .copy2 (qos_config_file , dell_dir_path )
249
+ shutil .copy2 (qos_config_file , dir_path )
283
250
284
- argument = '-m ' + self .dell6100_t0_minigraph + ' -p ' + port_config_ini_file + ' -t ' + qos_file + ' > ' + self .output_file
251
+ minigraph = os .path .join (self .test_dir , minigraph )
252
+ argument = '-m ' + minigraph + ' -p ' + port_config_ini_file + ' -t ' + qos_file + ' > ' + self .output_file
285
253
self .run_script (argument )
286
254
287
255
# cleanup
288
- qos_config_file_new = os .path .join (dell_dir_path , 'qos_config.j2' )
256
+ qos_config_file_new = os .path .join (dir_path , 'qos_config.j2' )
289
257
os .remove (qos_config_file_new )
290
258
291
- sample_output_file = os .path .join (self .test_dir , 'sample_output' , utils .PYvX_DIR , 'qos-dell6100.json' )
259
+ self .remove_machine_conf (file_exist , dir_exist )
260
+
261
+ sample_output_file = os .path .join (self .test_dir , 'sample_output' , utils .PYvX_DIR , expected )
292
262
assert utils .cmp (sample_output_file , self .output_file )
293
263
294
264
def test_buffers_dell6100_render_template (self ):
295
- dell_dir_path = os .path .join (self .test_dir , '..' , '..' , '..' , 'device' , 'dell' , 'x86_64-dell_s6100_c2538-r0' , 'Force10-S6100' )
296
- buffers_file = os .path .join (dell_dir_path , 'buffers.json.j2' )
297
- port_config_ini_file = os .path .join (dell_dir_path , 'port_config.ini' )
298
-
299
- # copy buffers_config.j2 to the Dell S6100 directory to have all templates in one directory
300
- buffers_config_file = os .path .join (self .test_dir , '..' , '..' , '..' , 'files' , 'build_templates' , 'buffers_config.j2' )
301
- shutil .copy2 (buffers_config_file , dell_dir_path )
302
-
303
- argument = '-m ' + self .dell6100_t0_minigraph + ' -p ' + port_config_ini_file + ' -t ' + buffers_file + ' > ' + self .output_file
304
- self .run_script (argument )
305
-
306
- # cleanup
307
- buffers_config_file_new = os .path .join (dell_dir_path , 'buffers_config.j2' )
308
- os .remove (buffers_config_file_new )
309
-
310
- sample_output_file = os .path .join (self .test_dir , 'sample_output' , utils .PYvX_DIR , 'buffers-dell6100.json' )
311
- assert utils .cmp (sample_output_file , self .output_file )
265
+ self ._test_buffers_render_template ('dell' , 'x86_64-dell_s6100_c2538-r0' , 'Force10-S6100' , 'sample-dell-6100-t0-minigraph.xml' , 'buffers.json.j2' , 'buffers-dell6100.json' )
312
266
313
267
def test_buffers_mellanox2700_render_template (self ):
314
268
# Mellanox buffer template rendering for single ingress pool mode
315
- mellanox_dir_path = os .path .join (self .test_dir , '..' , '..' , '..' , 'device' , 'mellanox' , 'x86_64-mlnx_msn2700-r0' , 'Mellanox-SN2700-D48C8' )
316
- buffers_file = os .path .join (mellanox_dir_path , 'buffers.json.j2' )
317
- port_config_ini_file = os .path .join (mellanox_dir_path , 'port_config.ini' )
318
-
319
- # copy buffers_config.j2 to the Mellanox 2700 directory to have all templates in one directory
320
- buffers_config_file = os .path .join (self .test_dir , '..' , '..' , '..' , 'files' , 'build_templates' , 'buffers_config.j2' )
321
- shutil .copy2 (buffers_config_file , mellanox_dir_path )
322
-
323
- argument = '-m ' + self .mellanox2700_t0_minigraph + ' -p ' + port_config_ini_file + ' -t ' + buffers_file + ' > ' + self .output_file
324
- self .run_script (argument )
325
-
326
- # cleanup
327
- buffers_config_file_new = os .path .join (mellanox_dir_path , 'buffers_config.j2' )
328
- os .remove (buffers_config_file_new )
329
-
330
- sample_output_file = os .path .join (self .test_dir , 'sample_output' , utils .PYvX_DIR , 'buffers-mellanox2700.json' )
331
- assert utils .cmp (sample_output_file , self .output_file )
269
+ self ._test_buffers_render_template ('mellanox' , 'x86_64-mlnx_msn2700-r0' , 'Mellanox-SN2700-D48C8' , 'sample-mellanox-2700-t0-minigraph.xml' , 'buffers.json.j2' , 'buffers-mellanox2700.json' )
332
270
333
271
def test_buffers_mellanox2410_render_template (self ):
334
272
# Mellanox buffer template rendering for double ingress pools mode
335
- mellanox_dir_path = os .path .join (self .test_dir , '..' , '..' , '..' , 'device' , 'mellanox' , 'x86_64-mlnx_msn2410-r0' , 'ACS-MSN2410' )
336
- buffers_file = os .path .join (mellanox_dir_path , 'buffers.json.j2' )
337
- port_config_ini_file = os .path .join (mellanox_dir_path , 'port_config.ini' )
338
-
339
- # copy buffers_config.j2 to the Mellanox 2410 directory to have all templates in one directory
340
- buffers_config_file = os .path .join (self .test_dir , '..' , '..' , '..' , 'files' , 'build_templates' , 'buffers_config.j2' )
341
- shutil .copy2 (buffers_config_file , mellanox_dir_path )
342
-
343
- argument = '-m ' + self .mellanox2410_t1_minigraph + ' -p ' + port_config_ini_file + ' -t ' + buffers_file + ' > ' + self .output_file
344
- self .run_script (argument )
345
-
346
- # cleanup
347
- buffers_config_file_new = os .path .join (mellanox_dir_path , 'buffers_config.j2' )
348
- os .remove (buffers_config_file_new )
349
-
350
- sample_output_file = os .path .join (self .test_dir , 'sample_output' , utils .PYvX_DIR , 'buffers-mellanox2410.json' )
351
- assert utils .cmp (sample_output_file , self .output_file )
273
+ self ._test_buffers_render_template ('mellanox' , 'x86_64-mlnx_msn2410-r0' , 'ACS-MSN2410' , 'sample-mellanox-2410-t1-minigraph.xml' , 'buffers.json.j2' , 'buffers-mellanox2410.json' )
352
274
353
275
def test_config_brcm_render_template (self ):
354
276
if utils .PYvX_DIR != 'py3' :
0 commit comments