Skip to content

Commit

Permalink
[sonic-cfggen] Enhance ACL unit test to also test control plane (serv…
Browse files Browse the repository at this point in the history
…ice) ACLs (#1349)
  • Loading branch information
jleveque authored Jan 30, 2018
1 parent 91effa2 commit 8cf03b0
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 13 deletions.
10 changes: 7 additions & 3 deletions src/sonic-config-engine/tests/pc-test-graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,14 @@
<DataAcls/>
<AclInterfaces>
<AclInterface>
<AttachTo>
PortChannel01;PortChannel02;PortChannel03;PortChannel04
</AttachTo>
<AttachTo>PortChannel01;PortChannel02;PortChannel03;PortChannel04</AttachTo>
<InAcl>DataAcl</InAcl>
<Type>DataPlane</Type>
</AclInterface>
<AclInterface>
<AttachTo>SNMP</AttachTo>
<InAcl>SNMP_ACL</InAcl>
<Type>SNMP</Type>
</AclInterface>
</AclInterfaces>
<DownstreamSummaries/>
Expand Down
10 changes: 7 additions & 3 deletions src/sonic-config-engine/tests/simple-sample-graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,14 @@
<DataAcls/>
<AclInterfaces>
<AclInterface>
<AttachTo>
PortChannel01
</AttachTo>
<AttachTo>PortChannel01</AttachTo>
<InAcl>DataAcl</InAcl>
<Type>DataPlane</Type>
</AclInterface>
<AclInterface>
<AttachTo>SNMP</AttachTo>
<InAcl>SNMP_ACL</InAcl>
<Type>SNMP</Type>
</AclInterface>
</AclInterfaces>
<DownstreamSummaries/>
Expand Down
57 changes: 57 additions & 0 deletions src/sonic-config-engine/tests/t0-sample-acl.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,63 @@
"config": {
"name": "everflow"
}
},
"SNMP-ACL": {
"acl-entries": {
"acl-entry": {
"1": {
"actions": {
"config": {
"forwarding-action": "ACCEPT"
}
},
"config": {
"sequence-id": 1
},
"ip": {
"config": {
"protocol": "IP_UDP",
"source-ip-address": "10.0.0.0/8"
}
}
},
"2": {
"actions": {
"config": {
"forwarding-action": "ACCEPT"
}
},
"config": {
"sequence-id": 2
},
"ip": {
"config": {
"protocol": "IP_UDP",
"source-ip-address": "100.64.0.0/10"
}
}
},
"3": {
"actions": {
"config": {
"forwarding-action": "ACCEPT"
}
},
"config": {
"sequence-id": 3
},
"ip": {
"config": {
"protocol": "IP_UDP",
"source-ip-address": "25.0.0.0/8"
}
}
}
}
},
"config": {
"name": "SNMP-ACL"
}
}
}
}
Expand Down
10 changes: 7 additions & 3 deletions src/sonic-config-engine/tests/t0-sample-bgp-speaker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,14 @@
<DataAcls/>
<AclInterfaces>
<AclInterface>
<AttachTo>
PortChannel01;PortChannel02;PortChannel03;PortChannel04
</AttachTo>
<AttachTo>PortChannel01;PortChannel02;PortChannel03;PortChannel04</AttachTo>
<InAcl>DataAcl</InAcl>
<Type>DataPlane</Type>
</AclInterface>
<AclInterface>
<AttachTo>SNMP</AttachTo>
<InAcl>SNMP_ACL</InAcl>
<Type>SNMP</Type>
</AclInterface>
</AclInterfaces>
<DownstreamSummaries/>
Expand Down
10 changes: 7 additions & 3 deletions src/sonic-config-engine/tests/t0-sample-graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,14 @@
<DataAcls/>
<AclInterfaces>
<AclInterface>
<AttachTo>
PortChannel01;PortChannel02;PortChannel03;PortChannel04
</AttachTo>
<AttachTo>PortChannel01;PortChannel02;PortChannel03;PortChannel04</AttachTo>
<InAcl>DataAcl</InAcl>
<Type>DataPlane</Type>
</AclInterface>
<AclInterface>
<AttachTo>SNMP</AttachTo>
<InAcl>SNMP_ACL</InAcl>
<Type>SNMP</Type>
</AclInterface>
</AclInterfaces>
<DownstreamSummaries/>
Expand Down
3 changes: 2 additions & 1 deletion src/sonic-config-engine/tests/test_cfggen.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ def test_render_template(self):
def test_minigraph_acl(self):
argument = '-m "' + self.sample_graph_t0 + '" -p "' + self.port_config + '" -v ACL_TABLE'
output = self.run_script(argument)
self.assertEqual(output.strip(), "{'DATAACL': {'type': 'L3', 'policy_desc': 'DATAACL', 'ports': ['Ethernet112', 'Ethernet116', 'Ethernet120', 'Ethernet124']}}")
self.assertEqual(output.strip(), "{'SNMP_ACL': {'type': 'CTRLPLANE', 'policy_desc': 'SNMP_ACL', 'service': 'SNMP', 'ports': []},"
" 'DATAACL': {'type': 'L3', 'policy_desc': 'DATAACL', 'ports': ['Ethernet112', 'Ethernet116', 'Ethernet120', 'Ethernet124']}}")

def test_minigraph_everflow(self):
argument = '-m "' + self.sample_graph_t0 + '" -p "' + self.port_config + '" -v MIRROR_SESSION'
Expand Down

0 comments on commit 8cf03b0

Please sign in to comment.