[swss]: Fix missing comma in the ports.json.j2 file (#1217)

Add J2 test case as well as a sample output

Signed-off-by: Shu0T1an ChenG <shuche@microsoft.com>
This commit is contained in:
Shuotian Cheng 2017-12-08 09:06:22 -08:00 committed by lguohan
parent 2276333ca8
commit 1859f53206
4 changed files with 39 additions and 1 deletions

View File

@ -4,7 +4,7 @@
{% if PORT[port].has_key('speed') %}
{
"PORT_TABLE:{{ port }}": {
"speed": "{{ PORT[port]['speed'] }}"
"speed": "{{ PORT[port]['speed'] }}",
"description": "{{ PORT[port]['description'] }}"
},
"OP": "SET"

View File

@ -0,0 +1,30 @@
[
{
"PORT_TABLE:Ethernet8": {
"speed": "40000",
"description": "Interface description"
},
"OP": "SET"
},
{
"PORT_TABLE:Ethernet0": {
"speed": "10000",
"description": ""
},
"OP": "SET"
},
{
"PORT_TABLE:Ethernet4": {
"speed": "25000",
"description": ""
},
"OP": "SET"
},
{
"PORT_TABLE:Ethernet12": {
"speed": "1000000",
"description": "Interface description"
},
"OP": "SET"
},
]

View File

@ -257,6 +257,7 @@
<PortName>0</PortName>
<Priority>0</Priority>
<Speed>1000000</Speed>
<Description>Interface description</Description>
</a:EthernetInterface>
</EthernetInterfaces>
<FlowControl>true</FlowControl>

View File

@ -9,6 +9,7 @@ class TestJ2Files(TestCase):
def setUp(self):
self.test_dir = os.path.dirname(os.path.realpath(__file__))
self.script_file = os.path.join(self.test_dir, '..', 'sonic-cfggen')
self.simple_minigraph = os.path.join(self.test_dir, 'simple-sample-graph.xml')
self.t0_minigraph = os.path.join(self.test_dir, 't0-sample-graph.xml')
self.pc_minigraph = os.path.join(self.test_dir, 'pc-test-graph.xml')
self.t0_port_config = os.path.join(self.test_dir, 't0-sample-port-config.ini')
@ -33,6 +34,12 @@ class TestJ2Files(TestCase):
data = json.loads(output)
self.assertEqual(data["Ethernet4"], "fortyGigE0/4")
def test_ports_json(self):
ports_template = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-orchagent', 'ports.json.j2')
argument = '-m ' + self.simple_minigraph + ' -p ' + self.t0_port_config + ' -t ' + ports_template + ' > ' + self.output_file
self.run_script(argument)
self.assertTrue(filecmp.cmp(os.path.join(self.test_dir, 'sample_output', 'ports.json'), self.output_file))
def test_lldp(self):
lldpd_conf_template = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-lldp-sv2', 'lldpd.conf.j2')
argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -t ' + lldpd_conf_template + ' > ' + self.output_file