Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Dec 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dockers/docker-orchagent/ports.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% if PORT[port].has_key('speed') %}
{
"PORT_TABLE:{{ port }}": {
"speed": "{{ PORT[port]['speed'] }}"
"speed": "{{ PORT[port]['speed'] }}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking care of this one.

"description": "{{ PORT[port]['description'] }}"
},
"OP": "SET"
Expand Down
30 changes: 30 additions & 0 deletions src/sonic-config-engine/tests/sample_output/ports.json
Original file line number Diff line number Diff line change
@@ -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"
},
]
1 change: 1 addition & 0 deletions src/sonic-config-engine/tests/simple-sample-graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@
<PortName>0</PortName>
<Priority>0</Priority>
<Speed>1000000</Speed>
<Description>Interface description</Description>
</a:EthernetInterface>
</EthernetInterfaces>
<FlowControl>true</FlowControl>
Expand Down
7 changes: 7 additions & 0 deletions src/sonic-config-engine/tests/test_j2files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -33,6 +34,12 @@ def test_alias_map(self):
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
Expand Down