[sonic-cfggen]: Output differences for bgp configurations (#2768)

This commit is contained in:
pavel-shirshov 2019-04-10 22:55:54 -07:00 committed by lguohan
parent 61760185e1
commit 9b1663ce8a

View File

@ -23,8 +23,8 @@ class TestJ2Files(TestCase):
print 'CMD: sonic-cfggen ' + argument
return subprocess.check_output(self.script_file + ' ' + argument, shell=True)
def run_diff(self, file1, file2, diff):
return subprocess.check_output('diff {} {} >{}'.format(file1, file2, diff), shell=True)
def run_diff(self, file1, file2):
return subprocess.check_output('diff -u {} {} || true'.format(file1, file2), shell=True)
def test_interfaces(self):
interfaces_template = os.path.join(self.test_dir, '..', '..', '..', 'files', 'image_config', 'interfaces', 'interfaces.j2')
@ -61,7 +61,10 @@ class TestJ2Files(TestCase):
conf_template = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-fpm-quagga', 'bgpd.conf.j2')
argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -t ' + conf_template + ' > ' + self.output_file
self.run_script(argument)
self.assertTrue(filecmp.cmp(os.path.join(self.test_dir, 'sample_output', 'bgpd_quagga.conf'), self.output_file))
original_filename = os.path.join(self.test_dir, 'sample_output', 'bgpd_quagga.conf')
r = filecmp.cmp(original_filename, self.output_file)
diff_output = self.run_diff(original_filename, self.output_file) if not r else ""
self.assertTrue(r, "Diff:\n" + diff_output)
def test_zebra_quagga(self):
conf_template = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-fpm-quagga', 'zebra.conf.j2')