Skip to content

Commit 8cf03b0

Browse files
authored
[sonic-cfggen] Enhance ACL unit test to also test control plane (service) ACLs (#1349)
1 parent 91effa2 commit 8cf03b0

File tree

6 files changed

+87
-13
lines changed

6 files changed

+87
-13
lines changed

src/sonic-config-engine/tests/pc-test-graph.xml

+7-3
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,14 @@
134134
<DataAcls/>
135135
<AclInterfaces>
136136
<AclInterface>
137-
<AttachTo>
138-
PortChannel01;PortChannel02;PortChannel03;PortChannel04
139-
</AttachTo>
137+
<AttachTo>PortChannel01;PortChannel02;PortChannel03;PortChannel04</AttachTo>
140138
<InAcl>DataAcl</InAcl>
139+
<Type>DataPlane</Type>
140+
</AclInterface>
141+
<AclInterface>
142+
<AttachTo>SNMP</AttachTo>
143+
<InAcl>SNMP_ACL</InAcl>
144+
<Type>SNMP</Type>
141145
</AclInterface>
142146
</AclInterfaces>
143147
<DownstreamSummaries/>

src/sonic-config-engine/tests/simple-sample-graph.xml

+7-3
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,14 @@
166166
<DataAcls/>
167167
<AclInterfaces>
168168
<AclInterface>
169-
<AttachTo>
170-
PortChannel01
171-
</AttachTo>
169+
<AttachTo>PortChannel01</AttachTo>
172170
<InAcl>DataAcl</InAcl>
171+
<Type>DataPlane</Type>
172+
</AclInterface>
173+
<AclInterface>
174+
<AttachTo>SNMP</AttachTo>
175+
<InAcl>SNMP_ACL</InAcl>
176+
<Type>SNMP</Type>
173177
</AclInterface>
174178
</AclInterfaces>
175179
<DownstreamSummaries/>

src/sonic-config-engine/tests/t0-sample-acl.json

+57
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,63 @@
112112
"config": {
113113
"name": "everflow"
114114
}
115+
},
116+
"SNMP-ACL": {
117+
"acl-entries": {
118+
"acl-entry": {
119+
"1": {
120+
"actions": {
121+
"config": {
122+
"forwarding-action": "ACCEPT"
123+
}
124+
},
125+
"config": {
126+
"sequence-id": 1
127+
},
128+
"ip": {
129+
"config": {
130+
"protocol": "IP_UDP",
131+
"source-ip-address": "10.0.0.0/8"
132+
}
133+
}
134+
},
135+
"2": {
136+
"actions": {
137+
"config": {
138+
"forwarding-action": "ACCEPT"
139+
}
140+
},
141+
"config": {
142+
"sequence-id": 2
143+
},
144+
"ip": {
145+
"config": {
146+
"protocol": "IP_UDP",
147+
"source-ip-address": "100.64.0.0/10"
148+
}
149+
}
150+
},
151+
"3": {
152+
"actions": {
153+
"config": {
154+
"forwarding-action": "ACCEPT"
155+
}
156+
},
157+
"config": {
158+
"sequence-id": 3
159+
},
160+
"ip": {
161+
"config": {
162+
"protocol": "IP_UDP",
163+
"source-ip-address": "25.0.0.0/8"
164+
}
165+
}
166+
}
167+
}
168+
},
169+
"config": {
170+
"name": "SNMP-ACL"
171+
}
115172
}
116173
}
117174
}

src/sonic-config-engine/tests/t0-sample-bgp-speaker.xml

+7-3
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,14 @@
259259
<DataAcls/>
260260
<AclInterfaces>
261261
<AclInterface>
262-
<AttachTo>
263-
PortChannel01;PortChannel02;PortChannel03;PortChannel04
264-
</AttachTo>
262+
<AttachTo>PortChannel01;PortChannel02;PortChannel03;PortChannel04</AttachTo>
265263
<InAcl>DataAcl</InAcl>
264+
<Type>DataPlane</Type>
265+
</AclInterface>
266+
<AclInterface>
267+
<AttachTo>SNMP</AttachTo>
268+
<InAcl>SNMP_ACL</InAcl>
269+
<Type>SNMP</Type>
266270
</AclInterface>
267271
</AclInterfaces>
268272
<DownstreamSummaries/>

src/sonic-config-engine/tests/t0-sample-graph.xml

+7-3
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,14 @@
262262
<DataAcls/>
263263
<AclInterfaces>
264264
<AclInterface>
265-
<AttachTo>
266-
PortChannel01;PortChannel02;PortChannel03;PortChannel04
267-
</AttachTo>
265+
<AttachTo>PortChannel01;PortChannel02;PortChannel03;PortChannel04</AttachTo>
268266
<InAcl>DataAcl</InAcl>
267+
<Type>DataPlane</Type>
268+
</AclInterface>
269+
<AclInterface>
270+
<AttachTo>SNMP</AttachTo>
271+
<InAcl>SNMP_ACL</InAcl>
272+
<Type>SNMP</Type>
269273
</AclInterface>
270274
</AclInterfaces>
271275
<DownstreamSummaries/>

src/sonic-config-engine/tests/test_cfggen.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ def test_render_template(self):
7373
def test_minigraph_acl(self):
7474
argument = '-m "' + self.sample_graph_t0 + '" -p "' + self.port_config + '" -v ACL_TABLE'
7575
output = self.run_script(argument)
76-
self.assertEqual(output.strip(), "{'DATAACL': {'type': 'L3', 'policy_desc': 'DATAACL', 'ports': ['Ethernet112', 'Ethernet116', 'Ethernet120', 'Ethernet124']}}")
76+
self.assertEqual(output.strip(), "{'SNMP_ACL': {'type': 'CTRLPLANE', 'policy_desc': 'SNMP_ACL', 'service': 'SNMP', 'ports': []},"
77+
" 'DATAACL': {'type': 'L3', 'policy_desc': 'DATAACL', 'ports': ['Ethernet112', 'Ethernet116', 'Ethernet120', 'Ethernet124']}}")
7778

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

0 commit comments

Comments
 (0)