diff --git a/dockers/docker-snmp-sv2/alias_map.j2 b/dockers/docker-snmp-sv2/alias_map.j2 index 76acb057480e..0f91fa26eabe 100644 --- a/dockers/docker-snmp-sv2/alias_map.j2 +++ b/dockers/docker-snmp-sv2/alias_map.j2 @@ -1,5 +1,5 @@ { {% for member in minigraph_ports.keys() %} - "{{member}}": "{{minigraph_ports[member]['alias']}}" + "{{member}}": "{{minigraph_ports[member]['alias']}}"{% if not loop.last %},{% endif %} {% endfor %} } diff --git a/src/sonic-config-engine/tests/test_j2files.py b/src/sonic-config-engine/tests/test_j2files.py index 30a67f0b6cd3..cf1e32aea519 100644 --- a/src/sonic-config-engine/tests/test_j2files.py +++ b/src/sonic-config-engine/tests/test_j2files.py @@ -1,6 +1,7 @@ import filecmp import os import subprocess +import json from unittest import TestCase @@ -21,6 +22,13 @@ def test_interfaces(self): argument = '-m "' + self.t0_minigraph + '" -p "' + self.t0_port_config + '" -t "' + interfaces_template + '"' output = self.run_script(argument) + def test_alias_map(self): + alias_map_template = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-snmp-sv2', 'alias_map.j2') + argument = '-m "' + self.t0_minigraph + '" -p "' + self.t0_port_config + '" -t "' + alias_map_template + '"' + output = self.run_script(argument) + data = json.loads(output) + self.assertEqual(data["Ethernet4"], "fortyGigE0/4") + def test_teamd(self): argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -v "minigraph_portchannels.keys() | join(\' \')"' output = self.run_script(argument) # Mock the output via config.sh in docker-teamd