Skip to content

Commit addd303

Browse files
committed
Updated test function to be generic for different vendors
1 parent 4d99543 commit addd303

File tree

1 file changed

+22
-48
lines changed

1 file changed

+22
-48
lines changed

src/sonic-config-engine/tests/test_j2files.py

+22-48
Original file line numberDiff line numberDiff line change
@@ -323,77 +323,51 @@ def test_qos_and_buffer_arista7800r3_48cq2_lc_render_template(self):
323323
def test_qos_and_buffer_arista7800r3_48cqm2_lc_render_template(self):
324324
self.do_test_qos_and_buffer_arista7800r3_48cq2_lc_render_template('x86_64-arista_7800r3_48cqm2_lc', 'Arista-7800R3-48CQM2-C48')
325325

326-
def do_test_qos_and_buffer_arista7800r3_36dm2_lc_render_template(self, platform, hwsku, minigraph, qos_sample_output, buffer_sample_output):
327-
arista_dir_path = os.path.join(self.test_dir, '..', '..', '..', 'device', 'arista', platform, hwsku)
326+
def do_test_qos_and_buffer_lc_render_template(self, platform, vendor, hwsku, minigraph, qos_sample_output, buffer_sample_output):
327+
dir_path = os.path.join(self.test_dir, '..', '..', '..', 'device', vendor, platform, hwsku)
328328
# for asic0
329-
arista_dir_path = os.path.join(arista_dir_path, '0')
330-
qos_file = os.path.join(arista_dir_path, 'qos.json.j2')
331-
buffer_file = os.path.join(arista_dir_path, 'buffers.json.j2')
332-
port_config_ini_file = os.path.join(arista_dir_path, 'port_config.ini')
329+
dir_path = os.path.join(dir_path, '0')
330+
qos_file = os.path.join(dir_path, 'qos.json.j2')
331+
buffer_file = os.path.join(dir_path, 'buffers.json.j2')
332+
port_config_ini_file = os.path.join(dir_path, 'port_config.ini')
333333

334-
# copy qos_config.j2 and buffer_config.j2 to the Arista7800R3-36DM2-LC directory to have all templates in one directory
334+
# copy qos_config.j2 and buffer_config.j2 to have all templates in one directory
335335
qos_config_file = os.path.join(self.test_dir, '..', '..', '..', 'files', 'build_templates', 'qos_config.j2')
336-
shutil.copy2(qos_config_file, arista_dir_path)
336+
shutil.copy2(qos_config_file, dir_path)
337337
buffer_config_file = os.path.join(self.test_dir, '..', '..', '..', 'files', 'build_templates', 'buffers_config.j2')
338-
shutil.copy2(buffer_config_file, arista_dir_path)
338+
shutil.copy2(buffer_config_file, dir_path)
339339

340340
for template_file, cfg_file, sample_output_file in [(qos_file, 'qos_config.j2', qos_sample_output),
341341
(buffer_file, 'buffers_config.j2', buffer_sample_output) ]:
342342
argument = ['-m', minigraph, '-p', port_config_ini_file, '-t', template_file]
343343
self.run_script(argument, output_file=self.output_file)
344344

345345
# cleanup
346-
cfg_file_new = os.path.join(arista_dir_path, cfg_file)
346+
cfg_file_new = os.path.join(dir_path, cfg_file)
347347
os.remove(cfg_file_new)
348348

349349
sample_output_file = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, sample_output_file)
350350
assert utils.cmp(sample_output_file, self.output_file), self.run_diff(sample_output_file, self.output_file)
351351

352352
def test_qos_and_buffer_arista7800r3a_36dm2_c36_render_template(self):
353-
self.do_test_qos_and_buffer_arista7800r3_36dm2_lc_render_template('x86_64-arista_7800r3a_36dm2_lc', 'Arista-7800R3A-36DM2-C36',\
354-
self.arista7800r3a_36dm2_c36_lc_t2_minigraph, 'qos-arista7800r3a-36dm2-c36-lc.json',\
355-
'buffer-arista7800r3a-36dm2-c36-lc.json')
353+
self.do_test_qos_and_buffer_lc_render_template('x86_64-arista_7800r3a_36dm2_lc', 'arista', 'Arista-7800R3A-36DM2-C36',\
354+
self.arista7800r3a_36dm2_c36_lc_t2_minigraph, 'qos-arista7800r3a-36dm2-c36-lc.json',\
355+
'buffer-arista7800r3a-36dm2-c36-lc.json')
356356

357357
def test_qos_and_buffer_arista7800r3a_36dm2_d36_render_template(self):
358-
self.do_test_qos_and_buffer_arista7800r3_36dm2_lc_render_template('x86_64-arista_7800r3a_36dm2_lc', 'Arista-7800R3A-36DM2-D36',\
359-
self.arista7800r3a_36dm2_d36_lc_t2_minigraph, 'qos-arista7800r3a-36dm2-d36-lc.json',\
360-
'buffer-arista7800r3a-36dm2-d36-lc.json')
361-
362-
def do_test_qos_and_buffer_nokia_ixr7250e_render_template(self, platform, hwsku, minigraph, qos_sample_output, buffer_sample_output):
363-
nokia_dir_path = os.path.join(self.test_dir, '..', '..', '..', 'device', 'nokia', platform, hwsku)
364-
# for asic0
365-
nokia_dir_path = os.path.join(nokia_dir_path, '0')
366-
qos_file = os.path.join(nokia_dir_path, 'qos.json.j2')
367-
buffer_file = os.path.join(nokia_dir_path, 'buffers.json.j2')
368-
port_config_ini_file = os.path.join(nokia_dir_path, 'port_config.ini')
369-
370-
# copy qos_config.j2 and buffer_config.j2 to the Nokia-IXR7250E directory to have all templates in one directory
371-
qos_config_file = os.path.join(self.test_dir, '..', '..', '..', 'files', 'build_templates', 'qos_config.j2')
372-
shutil.copy2(qos_config_file, nokia_dir_path)
373-
buffer_config_file = os.path.join(self.test_dir, '..', '..', '..', 'files', 'build_templates', 'buffers_config.j2')
374-
shutil.copy2(buffer_config_file, nokia_dir_path)
375-
376-
for template_file, cfg_file, sample_output_file in [(qos_file, 'qos_config.j2', qos_sample_output),
377-
(buffer_file, 'buffers_config.j2', buffer_sample_output) ]:
378-
argument = ['-m', minigraph, '-p', port_config_ini_file, '-t', template_file]
379-
self.run_script(argument, output_file=self.output_file)
380-
381-
# cleanup
382-
cfg_file_new = os.path.join(nokia_dir_path, cfg_file)
383-
os.remove(cfg_file_new)
384-
385-
sample_output_file = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, sample_output_file)
386-
assert utils.cmp(sample_output_file, self.output_file), self.run_diff(sample_output_file, self.output_file)
358+
self.do_test_qos_and_buffer_lc_render_template('x86_64-arista_7800r3a_36dm2_lc', 'arista', 'Arista-7800R3A-36DM2-D36',\
359+
self.arista7800r3a_36dm2_d36_lc_t2_minigraph, 'qos-arista7800r3a-36dm2-d36-lc.json',\
360+
'buffer-arista7800r3a-36dm2-d36-lc.json')
387361

388362
def test_qos_and_buffer_nokia_ixr7250e_36x100g_render_template(self):
389-
self.do_test_qos_and_buffer_nokia_ixr7250e_render_template('x86_64-nokia_ixr7250e_36x400g-r0', 'Nokia-IXR7250E-36x100G',\
390-
self.nokia_ixr7250e_36x100g_t2_minigraph, 'qos-nokia-ixr7250e-36x100g.json',\
391-
'buffer-nokia-ixr7250e-36x100g.json')
363+
self.do_test_qos_and_buffer_lc_render_template('x86_64-nokia_ixr7250e_36x400g-r0', 'nokia', 'Nokia-IXR7250E-36x100G',\
364+
self.nokia_ixr7250e_36x100g_t2_minigraph, 'qos-nokia-ixr7250e-36x100g.json',\
365+
'buffer-nokia-ixr7250e-36x100g.json')
392366

393367
def test_qos_and_buffer_nokia_ixr7250e_36x400g_render_template(self):
394-
self.do_test_qos_and_buffer_nokia_ixr7250e_render_template('x86_64-nokia_ixr7250e_36x400g-r0', 'Nokia-IXR7250E-36x400G',\
395-
self.nokia_ixr7250e_36x400g_t2_minigraph, 'qos-nokia-ixr7250e-36x400g.json',\
396-
'buffer-nokia-ixr7250e-36x400g.json')
368+
self.do_test_qos_and_buffer_lc_render_template('x86_64-nokia_ixr7250e_36x400g-r0', 'nokia', 'Nokia-IXR7250E-36x400G',\
369+
self.nokia_ixr7250e_36x400g_t2_minigraph, 'qos-nokia-ixr7250e-36x400g.json',\
370+
'buffer-nokia-ixr7250e-36x400g.json')
397371

398372
def test_qos_dell9332_render_template(self):
399373
self._test_qos_render_template('dell', 'x86_64-dellemc_z9332f_d1508-r0', 'DellEMC-Z9332f-O32', 'sample-dell-9332-t1-minigraph.xml', 'qos-dell9332.json')

0 commit comments

Comments
 (0)