[sonic-config-engine] Add failure details in sonic-config-engine unit test. (#10210)

This commit is contained in:
Shilong Liu 2022-03-15 14:47:36 +08:00 committed by GitHub
parent 0243ed9538
commit 286ff289f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,3 @@
import filecmp
import json import json
import os import os
import shutil import shutil
@ -110,7 +109,7 @@ class TestJ2Files(TestCase):
self.run_script(argument) self.run_script(argument)
sample_output_file = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'ipinip.json') sample_output_file = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'ipinip.json')
assert utils.cmp(sample_output_file, self.output_file) assert utils.cmp(sample_output_file, self.output_file), self.run_diff(sample_output_file, self.output_file)
def test_l2switch_template(self): def test_l2switch_template(self):
argument = '-k Mellanox-SN2700 --preset l2 -p ' + self.t0_port_config argument = '-k Mellanox-SN2700 --preset l2 -p ' + self.t0_port_config
@ -211,7 +210,7 @@ class TestJ2Files(TestCase):
os.remove(qos_config_file_new) os.remove(qos_config_file_new)
sample_output_file = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'qos-arista7050.json') sample_output_file = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'qos-arista7050.json')
assert utils.cmp(sample_output_file, self.output_file) assert utils.cmp(sample_output_file, self.output_file), self.run_diff(sample_output_file, self.output_file)
def test_qos_and_buffer_arista7800r3_48cq2_lc_render_template(self): def test_qos_and_buffer_arista7800r3_48cq2_lc_render_template(self):
arista_dir_path = os.path.join(self.test_dir, '..', '..', '..', 'device', 'arista', 'x86_64-arista_7800r3_48cq2_lc', 'Arista-7800R3-48CQ2-C48') arista_dir_path = os.path.join(self.test_dir, '..', '..', '..', 'device', 'arista', 'x86_64-arista_7800r3_48cq2_lc', 'Arista-7800R3-48CQ2-C48')
@ -235,7 +234,7 @@ class TestJ2Files(TestCase):
os.remove(cfg_file_new) os.remove(cfg_file_new)
sample_output_file = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, sample_output_file) sample_output_file = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, sample_output_file)
assert filecmp.cmp(sample_output_file, self.output_file) assert utils.cmp(sample_output_file, self.output_file), self.run_diff(sample_output_file, self.output_file)
def test_qos_dell9332_render_template(self): def test_qos_dell9332_render_template(self):
dell_dir_path = os.path.join(self.test_dir, '..', '..', '..', 'device', 'dell', 'x86_64-dellemc_z9332f_d1508-r0', 'DellEMC-Z9332f-O32') dell_dir_path = os.path.join(self.test_dir, '..', '..', '..', 'device', 'dell', 'x86_64-dellemc_z9332f_d1508-r0', 'DellEMC-Z9332f-O32')
@ -254,7 +253,7 @@ class TestJ2Files(TestCase):
os.remove(qos_config_file_new) os.remove(qos_config_file_new)
sample_output_file = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'qos-dell9332.json') sample_output_file = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'qos-dell9332.json')
assert utils.cmp(sample_output_file, self.output_file) assert utils.cmp(sample_output_file, self.output_file), self.run_diff(sample_output_file, self.output_file)
def test_qos_dell6100_render_template(self): def test_qos_dell6100_render_template(self):
dell_dir_path = os.path.join(self.test_dir, '..', '..', '..', 'device', 'dell', 'x86_64-dell_s6100_c2538-r0', 'Force10-S6100') dell_dir_path = os.path.join(self.test_dir, '..', '..', '..', 'device', 'dell', 'x86_64-dell_s6100_c2538-r0', 'Force10-S6100')
@ -273,7 +272,7 @@ class TestJ2Files(TestCase):
os.remove(qos_config_file_new) os.remove(qos_config_file_new)
sample_output_file = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'qos-dell6100.json') sample_output_file = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'qos-dell6100.json')
assert utils.cmp(sample_output_file, self.output_file) assert utils.cmp(sample_output_file, self.output_file), self.run_diff(sample_output_file, self.output_file)
def _test_buffers_render_template(self, vendor, platform, sku, minigraph, buffer_template, expected): def _test_buffers_render_template(self, vendor, platform, sku, minigraph, buffer_template, expected):
dir_path = os.path.join(self.test_dir, '..', '..', '..', 'device', vendor, platform, sku) dir_path = os.path.join(self.test_dir, '..', '..', '..', 'device', vendor, platform, sku)
@ -293,7 +292,7 @@ class TestJ2Files(TestCase):
os.remove(buffers_config_file_new) os.remove(buffers_config_file_new)
sample_output_file = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, expected) sample_output_file = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, expected)
assert utils.cmp(sample_output_file, self.output_file) assert utils.cmp(sample_output_file, self.output_file), self.run_diff(sample_output_file, self.output_file)
def test_buffers_dell6100_render_template(self): def test_buffers_dell6100_render_template(self):
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') 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')
@ -313,7 +312,7 @@ class TestJ2Files(TestCase):
print(argument) print(argument)
self.run_script(argument) self.run_script(argument)
sample_output_file = os.path.join(self.test_dir, 'multi_npu_data', utils.PYvX_DIR, 'ipinip.json') sample_output_file = os.path.join(self.test_dir, 'multi_npu_data', utils.PYvX_DIR, 'ipinip.json')
assert utils.cmp(sample_output_file, self.output_file) assert utils.cmp(sample_output_file, self.output_file), self.run_diff(sample_output_file, self.output_file)
def test_swss_switch_render_template(self): def test_swss_switch_render_template(self):
switch_template = os.path.join( switch_template = os.path.join(
@ -342,7 +341,7 @@ class TestJ2Files(TestCase):
self.test_dir, 'sample_output', v["output"] self.test_dir, 'sample_output', v["output"]
) )
self.run_script(argument) self.run_script(argument)
assert utils.cmp(sample_output_file, self.output_file) assert utils.cmp(sample_output_file, self.output_file), self.run_diff(sample_output_file, self.output_file)
def test_swss_switch_render_template_multi_asic(self): def test_swss_switch_render_template_multi_asic(self):
# verify the ECMP hash seed changes per namespace # verify the ECMP hash seed changes per namespace
@ -374,7 +373,7 @@ class TestJ2Files(TestCase):
self.test_dir, 'sample_output', v["output"] self.test_dir, 'sample_output', v["output"]
) )
self.run_script(argument) self.run_script(argument)
assert utils.cmp(sample_output_file, self.output_file) assert utils.cmp(sample_output_file, self.output_file), self.run_diff(sample_output_file, self.output_file)
os.environ["NAMESPACE_ID"] = "" os.environ["NAMESPACE_ID"] = ""
def test_ndppd_conf(self): def test_ndppd_conf(self):