[sonic-config-engine] Generate expected output with different cable len (#11092)
Why I did it To address internal build failures where the cable len for some of the skus is set to 300m for all tiers. How I did it For the buffers test, generate a new output file based off the original expected output with CABLE_LENGTH table updated to use 300m. In the comparison logic, compare against each of the expected output files and if any matches, the testcase is set to pass Signed-off-by: Neetha John <nejo@microsoft.com>
This commit is contained in:
parent
3304fcd3a5
commit
ef9fb9db05
@ -67,6 +67,20 @@ class TestJ2Files(TestCase):
|
|||||||
if not dir_exist:
|
if not dir_exist:
|
||||||
os.system('sudo rmdir /host')
|
os.system('sudo rmdir /host')
|
||||||
|
|
||||||
|
def modify_cable_len(self, base_file, file_dir):
|
||||||
|
input_file = os.path.join(file_dir, base_file)
|
||||||
|
with open(input_file, 'r') as ifd:
|
||||||
|
object = json.load(ifd)
|
||||||
|
if 'CABLE_LENGTH' in object and 'AZURE' in object['CABLE_LENGTH']:
|
||||||
|
for key in object['CABLE_LENGTH']['AZURE']:
|
||||||
|
object['CABLE_LENGTH']['AZURE'][key] = '300m'
|
||||||
|
prefix, extension = base_file.split('.')
|
||||||
|
output_file = '{}_300m.{}'.format(prefix, extension)
|
||||||
|
out_file_path = os.path.join(file_dir, output_file)
|
||||||
|
with open(out_file_path, 'w') as wfd:
|
||||||
|
json.dump(object, wfd, indent=4)
|
||||||
|
return output_file
|
||||||
|
|
||||||
def test_interfaces(self):
|
def test_interfaces(self):
|
||||||
interfaces_template = os.path.join(self.test_dir, '..', '..', '..', 'files', 'image_config', 'interfaces', 'interfaces.j2')
|
interfaces_template = os.path.join(self.test_dir, '..', '..', '..', 'files', 'image_config', 'interfaces', 'interfaces.j2')
|
||||||
argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -a \'{\"hwaddr\":\"e4:1d:2d:a5:f3:ad\"}\' -t ' + interfaces_template + ' > ' + self.output_file
|
argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -a \'{\"hwaddr\":\"e4:1d:2d:a5:f3:ad\"}\' -t ' + interfaces_template + ' > ' + self.output_file
|
||||||
@ -407,8 +421,21 @@ class TestJ2Files(TestCase):
|
|||||||
os.remove(buffers_config_file_new)
|
os.remove(buffers_config_file_new)
|
||||||
self.remove_machine_conf(file_exist, dir_exist)
|
self.remove_machine_conf(file_exist, dir_exist)
|
||||||
|
|
||||||
sample_output_file = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, expected)
|
out_file_dir = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR)
|
||||||
assert utils.cmp(sample_output_file, self.output_file), self.run_diff(sample_output_file, self.output_file)
|
expected_files = [expected, self.modify_cable_len(expected, out_file_dir)]
|
||||||
|
match = False
|
||||||
|
diff = ''
|
||||||
|
for out_file in expected_files:
|
||||||
|
sample_output_file = os.path.join(out_file_dir, out_file)
|
||||||
|
if utils.cmp(sample_output_file, self.output_file):
|
||||||
|
match = True
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
diff = diff + str(self.run_diff(sample_output_file, self.output_file))
|
||||||
|
|
||||||
|
os.remove(os.path.join(out_file_dir, expected_files[1]))
|
||||||
|
|
||||||
|
assert match, diff
|
||||||
|
|
||||||
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')
|
||||||
|
Loading…
Reference in New Issue
Block a user