From 6299775946f0e0a85bb7f88c3a3c485eb50ab114 Mon Sep 17 00:00:00 2001 From: Lawrence Lee Date: Fri, 2 Oct 2020 16:29:43 +0000 Subject: [PATCH] [sonic-config-engine]: Fix ndppd.conf test Signed-off-by: Lawrence Lee --- .../tests/sample_output/{ => py2}/ndppd.conf | 6 ++--- .../tests/sample_output/py3/ndppd.conf | 25 +++++++++++++++++++ src/sonic-config-engine/tests/test_j2files.py | 7 ++---- 3 files changed, 30 insertions(+), 8 deletions(-) rename src/sonic-config-engine/tests/sample_output/{ => py2}/ndppd.conf (100%) create mode 100644 src/sonic-config-engine/tests/sample_output/py3/ndppd.conf diff --git a/src/sonic-config-engine/tests/sample_output/ndppd.conf b/src/sonic-config-engine/tests/sample_output/py2/ndppd.conf similarity index 100% rename from src/sonic-config-engine/tests/sample_output/ndppd.conf rename to src/sonic-config-engine/tests/sample_output/py2/ndppd.conf index 28a239006d24..71ff1dfaf9ca 100644 --- a/src/sonic-config-engine/tests/sample_output/ndppd.conf +++ b/src/sonic-config-engine/tests/sample_output/py2/ndppd.conf @@ -6,15 +6,15 @@ # See man page for ndppd.conf.5 for descriptions of all available options proxy Vlan1000 { - rule fc01:1000::/64 { - static - } rule fc02:1000::/64 { static } rule fc03:1000::/64 { static } + rule fc01:1000::/64 { + static + } } proxy Vlan2000 { diff --git a/src/sonic-config-engine/tests/sample_output/py3/ndppd.conf b/src/sonic-config-engine/tests/sample_output/py3/ndppd.conf new file mode 100644 index 000000000000..71ff1dfaf9ca --- /dev/null +++ b/src/sonic-config-engine/tests/sample_output/py3/ndppd.conf @@ -0,0 +1,25 @@ +# =========== Managed by sonic-cfggen -- DO NOT edit manually! ==================== +# Generated by /usr/share/sonic/templates/ndppd.conf.j2 using config DB data +# File: /etc/ndppd.conf +# +# Config file for ndppd, the NDP Proxy Daemon +# See man page for ndppd.conf.5 for descriptions of all available options + +proxy Vlan1000 { + rule fc02:1000::/64 { + static + } + rule fc03:1000::/64 { + static + } + rule fc01:1000::/64 { + static + } +} + +proxy Vlan2000 { + rule fc01:2000::/64 { + static + } +} + diff --git a/src/sonic-config-engine/tests/test_j2files.py b/src/sonic-config-engine/tests/test_j2files.py index 278af1b20312..53c28dd43eba 100644 --- a/src/sonic-config-engine/tests/test_j2files.py +++ b/src/sonic-config-engine/tests/test_j2files.py @@ -171,14 +171,11 @@ def test_ipinip_multi_asic(self): def test_ndppd_conf(self): conf_template = os.path.join(self.test_dir, "ndppd.conf.j2") vlan_interfaces_json = os.path.join(self.test_dir, "data", "ndppd", "vlan_interfaces.json") - expected = os.path.join(self.test_dir, "sample_output", "ndppd.conf") + expected = os.path.join(self.test_dir, "sample_output", utils.PYvX_DIR, "ndppd.conf") argument = '-j {} -t {} > {}'.format(vlan_interfaces_json, conf_template, self.output_file) self.run_script(argument) - f = open(self.output_file) - contents = f.read() - f.close() - assert filecmp.cmp(expected, self.output_file), contents + assert filecmp.cmp(expected, self.output_file), self.run_diff(expected, self.output_file) def tearDown(self):