@@ -141,6 +141,79 @@ def remove_mirror_acl_rule(self, table, rule):
141
141
tbl ._del (table + "|" + rule )
142
142
time .sleep (1 )
143
143
144
+ def test_CombinedMirrorTableCreation (self , dvs , testlog ):
145
+ self .setup_db (dvs )
146
+
147
+ acl_table = "MIRROR_TABLE"
148
+ ports = ["Ethernet0" , "Ethernet4" ]
149
+
150
+ # Create the table
151
+ self .create_acl_table (acl_table , ports , "MIRROR" )
152
+
153
+ # Check that the table has been created
154
+ tbl = swsscommon .Table (self .adb , "ASIC_STATE:SAI_OBJECT_TYPE_ACL_TABLE" )
155
+ table_entries = [k for k in tbl .getKeys () if k not in dvs .asicdb .default_acl_tables ]
156
+ assert len (table_entries ) == 1
157
+
158
+ # Get the data from the table
159
+ table_id = table_entries [0 ]
160
+ status , attributes = tbl .get (table_id )
161
+ assert status
162
+
163
+ # TODO: Refactor mirror table tests so that these attributes can be shared between tests for v4, v6, and
164
+ # dscp mirror tables.
165
+ expected_sai_attributes = [
166
+ "SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE" ,
167
+ "SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL" ,
168
+ "SAI_ACL_TABLE_ATTR_FIELD_SRC_IP" ,
169
+ "SAI_ACL_TABLE_ATTR_FIELD_DST_IP" ,
170
+ "SAI_ACL_TABLE_ATTR_FIELD_ICMP_TYPE" ,
171
+ "SAI_ACL_TABLE_ATTR_FIELD_ICMP_CODE" ,
172
+ "SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT" ,
173
+ "SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT" ,
174
+ "SAI_ACL_TABLE_ATTR_FIELD_TCP_FLAGS" ,
175
+ "SAI_ACL_TABLE_ATTR_FIELD_DSCP" ,
176
+ "SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE" ,
177
+ "SAI_ACL_TABLE_ATTR_FIELD_IN_PORTS" ,
178
+ "SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6" ,
179
+ "SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6" ,
180
+ "SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE" ,
181
+ "SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_CODE" ,
182
+ ]
183
+
184
+ expected_sai_list_attributes = [
185
+ "SAI_ACL_TABLE_ATTR_FIELD_ACL_RANGE_TYPE" ,
186
+ "SAI_ACL_TABLE_ATTR_ACL_BIND_POINT_TYPE_LIST"
187
+ ]
188
+
189
+ # Check that all of the V6 table attributes have been populated
190
+ assert (len (attributes ) == (len (expected_sai_attributes ) + len (expected_sai_list_attributes ) + 1 ))
191
+ for attribute in attributes :
192
+ key = attribute [0 ]
193
+ value = attribute [1 ]
194
+
195
+ if key in expected_sai_attributes :
196
+ assert value == "true"
197
+ elif key in expected_sai_list_attributes :
198
+ count = int (value [0 :1 ])
199
+ list_attrs = value [2 :].split (',' )
200
+ if key == "SAI_ACL_TABLE_ATTR_FIELD_ACL_RANGE_TYPE" :
201
+ assert set (list_attrs ) == set (["SAI_ACL_RANGE_TYPE_L4_DST_PORT_RANGE" , "SAI_ACL_RANGE_TYPE_L4_SRC_PORT_RANGE" ])
202
+ elif key == "SAI_ACL_TABLE_ATTR_ACL_BIND_POINT_TYPE_LIST" :
203
+ assert set (list_attrs ) == set (["SAI_ACL_BIND_POINT_TYPE_PORT" , "SAI_ACL_BIND_POINT_TYPE_LAG" ])
204
+ else :
205
+ print ("Encountered unexpected range attribute on mirror table: {}" .format (key ))
206
+ assert False
207
+ elif key == "SAI_ACL_TABLE_ATTR_ACL_STAGE" :
208
+ assert value == "SAI_ACL_STAGE_INGRESS"
209
+ else :
210
+ print ("Encountered unexpected attribute on mirror table: {}" .format (key ))
211
+ assert False
212
+
213
+ # Delete the table
214
+ self .remove_acl_table (acl_table )
215
+
216
+
144
217
# Test case - create a MIRROR table and a MIRRORV6 table in combined mode
145
218
# 0. predefine the VS capability: combined
146
219
# 1. create a mirror session
0 commit comments