blob: cb25ba3d0fa951b01917c10b1626d84bcd9eac30 [file] [log] [blame]
macauleye7df6402015-07-16 17:38:20 +08001"""
2Group table test
3Verify each group table can created correctly
4"""
5from oftest import config
macauley68bd7682015-08-03 09:20:32 +08006
7import logging
8import random
9
10from oftest import config
11import oftest
macauleye7df6402015-07-16 17:38:20 +080012import oftest.base_tests as base_tests
13import ofp
macauley68bd7682015-08-03 09:20:32 +080014
macauleye7df6402015-07-16 17:38:20 +080015from oftest.testutils import *
16from accton_util import *
17
macauley68bd7682015-08-03 09:20:32 +080018def getkey(type):
19 def byGroupId(stats_entry):
20 return stats_entry.group_id
21
macauley6f6ceb22015-08-07 09:37:12 +080022 def byGroupType(stats_entry):
macauley68bd7682015-08-03 09:20:32 +080023 return stats_entry.group_type
24
25
26 if type == "group_id":
27 return byGroupId
28 elif type == "group_type":
29 return byGroupType
macauley_cheng1be9d382015-08-31 15:18:48 +080030 else:
31 assert(0)
macauley68bd7682015-08-03 09:20:32 +080032 return byGroupId
macauley_cheng1be9d382015-08-31 15:18:48 +080033
macauley68bd7682015-08-03 09:20:32 +080034class L2InterfaceGroupOne(base_tests.SimpleDataPlane):
35 def runTest(self):
36 delete_all_flows(self.controller)
37 delete_all_groups(self.controller)
38
39 group_list1, msg1 = add_one_l2_interface_grouop(self.controller, config["port_map"].keys()[0], 1, False, False)
40 stats = get_stats(self, ofp.message.group_desc_stats_request())
41
42 verify_group_stats=[ofp.group_desc_stats_entry(
43 group_type=msg1.group_type,
44 group_id=msg1.group_id,
45 buckets=msg1.buckets)]
46
47 self.maxDiff=None
48
49 self.assertEquals(stats, verify_group_stats)
50
macauleye7df6402015-07-16 17:38:20 +080051class L2InterfaceGroup(base_tests.SimpleDataPlane):
52 def runTest(self):
macauleyfd08eda2015-07-17 15:59:04 +080053 delete_all_flows(self.controller)
54 delete_all_groups(self.controller)
macauleye7df6402015-07-16 17:38:20 +080055
macauleyfd08eda2015-07-17 15:59:04 +080056 group_list1, msg1 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 1, False, False)
57 group_list2, msg2 =add_l2_interface_grouop(self.controller, config["port_map"].keys(), 2, False, False)
macauley68bd7682015-08-03 09:20:32 +080058
macauleyfd08eda2015-07-17 15:59:04 +080059 stats = get_stats(self, ofp.message.group_desc_stats_request())
60
61 verify_group_stats=[]
macauley68bd7682015-08-03 09:20:32 +080062
macauleyfd08eda2015-07-17 15:59:04 +080063 for msg in msg1:
64 verify_group_stats.append(ofp.group_desc_stats_entry(
65 group_type=msg.group_type,
66 group_id=msg.group_id,
macauley68bd7682015-08-03 09:20:32 +080067 buckets=msg.buckets))
68
macauleyfd08eda2015-07-17 15:59:04 +080069 for msg in msg2:
70 verify_group_stats.append(ofp.group_desc_stats_entry(
71 group_type=msg.group_type,
72 group_id=msg.group_id,
macauley68bd7682015-08-03 09:20:32 +080073 buckets=msg.buckets))
macauleyfd08eda2015-07-17 15:59:04 +080074
macauley68bd7682015-08-03 09:20:32 +080075 verify_group_stats=sorted(verify_group_stats, key=getkey("group_id"))
76 stats=sorted(stats, key=getkey("group_id"))
macauley6f6ceb22015-08-07 09:37:12 +080077 #self.maxDiff=None
macauley68bd7682015-08-03 09:20:32 +080078 self.assertEquals(stats, verify_group_stats)
macauleyfd08eda2015-07-17 15:59:04 +080079
macauleye7df6402015-07-16 17:38:20 +080080class L2McastGroup(base_tests.SimpleDataPlane):
81 def runTest(self):
82 delete_all_flows(self.controller)
83 delete_all_groups(self.controller)
84
macauleyfd08eda2015-07-17 15:59:04 +080085 group_list1, msg1 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 1, False, False)
86 msg2=add_l2_mcast_group(self.controller, config["port_map"].keys(), 1, 1)
macauleye7df6402015-07-16 17:38:20 +080087
macauleyfd08eda2015-07-17 15:59:04 +080088 group_list1, msg3 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 2, False, False)
89 msg4=add_l2_mcast_group(self.controller, config["port_map"].keys(), 2, 2)
macauleye7df6402015-07-16 17:38:20 +080090
macauleyfd08eda2015-07-17 15:59:04 +080091 stats = get_stats(self, ofp.message.group_desc_stats_request())
92
93 verify_group_stats=[]
94 for msg in msg1:
95 verify_group_stats.append(ofp.group_desc_stats_entry(
96 group_type=msg.group_type,
97 group_id=msg.group_id,
98 buckets=msg.buckets)
99 )
100
101 verify_group_stats.append(ofp.group_desc_stats_entry(
102 group_type=msg2.group_type,
103 group_id=msg2.group_id,
104 buckets=msg2.buckets)
105 )
106
107 for msg in msg3:
108 verify_group_stats.append(ofp.group_desc_stats_entry(
109 group_type=msg.group_type,
110 group_id=msg.group_id,
111 buckets=msg.buckets)
112 )
113 verify_group_stats.append(ofp.group_desc_stats_entry(
114 group_type=msg4.group_type,
115 group_id=msg4.group_id,
116 buckets=msg4.buckets)
117 )
macauley68bd7682015-08-03 09:20:32 +0800118
119 verify_group_stats=sorted(verify_group_stats, key=getkey("group_id"))
120 stats=sorted(stats, key=getkey("group_id"))
121 self.maxDiff=None
macauleyfd08eda2015-07-17 15:59:04 +0800122 self.assertEquals(stats, verify_group_stats)
123
124
125class L2FloodGroup(base_tests.SimpleDataPlane):
126 def runTest(self):
127 delete_all_flows(self.controller)
128 delete_all_groups(self.controller)
129
130 group_list1, msg1 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 1, False, False)
131 msg2=add_l2_flood_group(self.controller, config["port_map"].keys(), 1, 1)
132
133 group_list1, msg3 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 2, False, False)
134 msg4=add_l2_flood_group(self.controller, config["port_map"].keys(), 2, 2)
135
136 stats = get_stats(self, ofp.message.group_desc_stats_request())
137
138 verify_group_stats=[]
139 for msg in msg1:
140 verify_group_stats.append(ofp.group_desc_stats_entry(
141 group_type=msg.group_type,
142 group_id=msg.group_id,
143 buckets=msg.buckets)
144 )
145
146 verify_group_stats.append(ofp.group_desc_stats_entry(
147 group_type=msg2.group_type,
148 group_id=msg2.group_id,
149 buckets=msg2.buckets)
150 )
151
152 for msg in msg3:
153 verify_group_stats.append(ofp.group_desc_stats_entry(
154 group_type=msg.group_type,
155 group_id=msg.group_id,
156 buckets=msg.buckets)
157 )
158 verify_group_stats.append(ofp.group_desc_stats_entry(
159 group_type=msg4.group_type,
160 group_id=msg4.group_id,
161 buckets=msg4.buckets)
162 )
macauley68bd7682015-08-03 09:20:32 +0800163
164 verify_group_stats=sorted(verify_group_stats, key=getkey("group_id"))
165 stats=sorted(stats, key=getkey("group_id"))
166 self.maxDiff=None
macauleyfd08eda2015-07-17 15:59:04 +0800167 self.assertEquals(stats, verify_group_stats)
168
169
170class L2RewriteGroup(base_tests.SimpleDataPlane):
171 def runTest(self):
172 delete_all_flows(self.controller)
173 delete_all_groups(self.controller)
174
175 group_list1, msg1 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 1, False, False)
176 msg2=add_l2_rewrite_group(self.controller, config["port_map"].keys()[0], 1, 1, [00,11,22,33,44,55], [00,22,22,22,22,22])
177
178 group_list1, msg3 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 2, False, False)
179 msg4=add_l2_rewrite_group(self.controller, config["port_map"].keys()[0], 2, 2, [00,11,22,33,44,55], [00,33,33,33,33,33])
180
181 stats = get_stats(self, ofp.message.group_desc_stats_request())
182
183 verify_group_stats=[]
184 for msg in msg1:
185 verify_group_stats.append(ofp.group_desc_stats_entry(
186 group_type=msg.group_type,
187 group_id=msg.group_id,
188 buckets=msg.buckets)
189 )
190
191 verify_group_stats.append(ofp.group_desc_stats_entry(
192 group_type=msg2.group_type,
193 group_id=msg2.group_id,
194 buckets=msg2.buckets)
195 )
196
197 for msg in msg3:
198 verify_group_stats.append(ofp.group_desc_stats_entry(
199 group_type=msg.group_type,
200 group_id=msg.group_id,
201 buckets=msg.buckets)
202 )
203 verify_group_stats.append(ofp.group_desc_stats_entry(
204 group_type=msg4.group_type,
205 group_id=msg4.group_id,
206 buckets=msg4.buckets)
207 )
208
macauley68bd7682015-08-03 09:20:32 +0800209 verify_group_stats=sorted(verify_group_stats, key=getkey("group_id"))
210 stats=sorted(stats, key=getkey("group_id"))
211
212 self.maxDiff=None
macauleyfd08eda2015-07-17 15:59:04 +0800213 self.assertEquals(stats, verify_group_stats)
214
215
216class L3UnicastGroup(base_tests.SimpleDataPlane):
217 def runTest(self):
218 delete_all_flows(self.controller)
219 delete_all_groups(self.controller)
220
221 group_list1, msg1 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 1, False, False)
222 msg2=add_l3_unicast_group(self.controller, config["port_map"].keys()[0], 1, 1, [0x00,0x11,0x22,0x33,0x44,0x55], [00,0x22,0x22,0x22,0x22,0x22])
223
224 group_list1, msg3 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 2, False, False)
225 msg4=add_l3_unicast_group(self.controller, config["port_map"].keys()[0], 2, 2, [0x00,0x11,0x22,0x33,0x44,0x55], [00,0x33,0x33,0x33,0x33,0x33])
226
227 stats = get_stats(self, ofp.message.group_desc_stats_request())
228
229 verify_group_stats=[]
230 for msg in msg1:
231 verify_group_stats.append(ofp.group_desc_stats_entry(
232 group_type=msg.group_type,
233 group_id=msg.group_id,
234 buckets=msg.buckets)
235 )
236
237 verify_group_stats.append(ofp.group_desc_stats_entry(
238 group_type=msg2.group_type,
239 group_id=msg2.group_id,
240 buckets=msg2.buckets)
241 )
242
243 for msg in msg3:
244 verify_group_stats.append(ofp.group_desc_stats_entry(
245 group_type=msg.group_type,
246 group_id=msg.group_id,
247 buckets=msg.buckets)
248 )
249 verify_group_stats.append(ofp.group_desc_stats_entry(
250 group_type=msg4.group_type,
251 group_id=msg4.group_id,
252 buckets=msg4.buckets)
253 )
macauley68bd7682015-08-03 09:20:32 +0800254
255 verify_group_stats=sorted(verify_group_stats, key=getkey("group_id"))
256 stats=sorted(stats, key=getkey("group_id"))
257
258 self.maxDiff=None
macauleyfd08eda2015-07-17 15:59:04 +0800259 self.assertEquals(stats, verify_group_stats)
260
261
262class L3ECMPGroup(base_tests.SimpleDataPlane):
263 def runTest(self):
264 delete_all_flows(self.controller)
265 delete_all_groups(self.controller)
266
267 group_list1, msg1 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 1, False, False)
268 msg2=add_l3_unicast_group(self.controller, config["port_map"].keys()[0], 1, 1, [0x00,0x11,0x22,0x33,0x44,0x55], [00,0x22,0x22,0x22,0x22,0x22])
269
270 group_list1, msg3 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 2, False, False)
271 msg4=add_l3_unicast_group(self.controller, config["port_map"].keys()[0], 2, 2, [0x00,0x11,0x22,0x33,0x44,0x55], [00,0x33,0x33,0x33,0x33,0x33])
272
273 group_ids=[msg2.group_id, msg4.group_id]
274
275 msg5=add_l3_ecmp_group(self.controller, 1, group_ids)
276
277 stats = get_stats(self, ofp.message.group_desc_stats_request())
278
279 verify_group_stats=[]
280 for msg in msg1:
281 verify_group_stats.append(ofp.group_desc_stats_entry(
282 group_type=msg.group_type,
283 group_id=msg.group_id,
284 buckets=msg.buckets)
285 )
286
287 verify_group_stats.append(ofp.group_desc_stats_entry(
288 group_type=msg2.group_type,
289 group_id=msg2.group_id,
290 buckets=msg2.buckets)
291 )
292
293 for msg in msg3:
294 verify_group_stats.append(ofp.group_desc_stats_entry(
295 group_type=msg.group_type,
296 group_id=msg.group_id,
297 buckets=msg.buckets)
298 )
299 verify_group_stats.append(ofp.group_desc_stats_entry(
300 group_type=msg4.group_type,
301 group_id=msg4.group_id,
302 buckets=msg4.buckets)
303 )
304 verify_group_stats.append(ofp.group_desc_stats_entry(
305 group_type=msg5.group_type,
306 group_id=msg5.group_id,
307 buckets=msg5.buckets)
308 )
309
macauley68bd7682015-08-03 09:20:32 +0800310 verify_group_stats=sorted(verify_group_stats, key=getkey("group_id"))
311 stats=sorted(stats, key=getkey("group_id"))
312
313 self.maxDiff=None
macauleyfd08eda2015-07-17 15:59:04 +0800314 self.assertEquals(stats, verify_group_stats)
315
316
317class L3InterfaceGroup(base_tests.SimpleDataPlane):
318 def runTest(self):
319 delete_all_flows(self.controller)
320 delete_all_groups(self.controller)
321
322 group_list1, msg1 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 1, False, False)
323 msg2=add_l3_interface_group(self.controller, config["port_map"].keys()[0], 1, 1, [0x00,0x11,0x22,0x33,0x44,0x55])
324 group_list1, msg3 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 2, False, False)
325 msg4=add_l3_interface_group(self.controller, config["port_map"].keys()[0], 2, 2, [0x00,0x11,0x22,0x33,0x44,0x66])
326
327 stats = get_stats(self, ofp.message.group_desc_stats_request())
328
329 verify_group_stats=[]
330 for msg in msg1:
331 verify_group_stats.append(ofp.group_desc_stats_entry(
332 group_type=msg.group_type,
333 group_id=msg.group_id,
334 buckets=msg.buckets)
335 )
336
337 verify_group_stats.append(ofp.group_desc_stats_entry(
338 group_type=msg2.group_type,
339 group_id=msg2.group_id,
340 buckets=msg2.buckets)
341 )
342
343 for msg in msg3:
344 verify_group_stats.append(ofp.group_desc_stats_entry(
345 group_type=msg.group_type,
346 group_id=msg.group_id,
347 buckets=msg.buckets)
348 )
349 verify_group_stats.append(ofp.group_desc_stats_entry(
350 group_type=msg4.group_type,
351 group_id=msg4.group_id,
352 buckets=msg4.buckets)
353 )
354
macauley68bd7682015-08-03 09:20:32 +0800355 verify_group_stats=sorted(verify_group_stats, key=getkey("group_id"))
356 stats=sorted(stats, key=getkey("group_id"))
357
358 self.maxDiff=None
macauleyfd08eda2015-07-17 15:59:04 +0800359 self.assertEquals(stats, verify_group_stats)
360
361
362class L3McastGroup(base_tests.SimpleDataPlane):
363 def runTest(self):
364 delete_all_flows(self.controller)
365 delete_all_groups(self.controller)
366
367 # Vlan 3 forward to vlan 3 port 1 and 2
368 # Vlan 3 foward to vlan 1 port 1
369 # Vlan 3 foward to vlan 2 port 1
370 # Vlan 3 foward to vlan 2 port 2
371 group_list1_1, msg1 = add_l2_interface_grouop(self.controller, [config["port_map"].keys()[0]], 1, False, False)
372 msg2=add_l3_interface_group(self.controller, config["port_map"].keys()[0], 1, 1, [0x00,0x11,0x22,0x33,0x44,0x11])
373 group_list1_2, msg3 = add_l2_interface_grouop(self.controller, [config["port_map"].keys()[0]], 2, False, False)
374 msg4=add_l3_interface_group(self.controller, config["port_map"].keys()[0], 2, 2, [0x00,0x11,0x22,0x33,0x44,0x22])
375 group_list2_1, msg5 = add_l2_interface_grouop(self.controller, [config["port_map"].keys()[1]], 2, False, False)
376 msg6=add_l3_interface_group(self.controller, config["port_map"].keys()[1], 2, 3, [0x00,0x11,0x22,0x33,0x44,0x33])
377 group_list3, msg7 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 3, False, False)
378
379 group_actions=[msg2.group_id, msg4.group_id, msg6.group_id]
380 group_actions.extend(group_list3)
381
382 msg8=add_l3_mcast_group(self.controller, 3, 1, group_actions)
383
384 stats = get_stats(self, ofp.message.group_desc_stats_request())
385
386 verify_group_stats=[]
387 for msg in msg1:
388 verify_group_stats.append(ofp.group_desc_stats_entry(
389 group_type=msg.group_type,
390 group_id=msg.group_id,
391 buckets=msg.buckets)
392 )
393
394 verify_group_stats.append(ofp.group_desc_stats_entry(
395 group_type=msg2.group_type,
396 group_id=msg2.group_id,
397 buckets=msg2.buckets)
398 )
399
400 for msg in msg3:
401 verify_group_stats.append(ofp.group_desc_stats_entry(
402 group_type=msg.group_type,
403 group_id=msg.group_id,
404 buckets=msg.buckets)
405 )
406 verify_group_stats.append(ofp.group_desc_stats_entry(
407 group_type=msg4.group_type,
408 group_id=msg4.group_id,
409 buckets=msg4.buckets)
410 )
411 for msg in msg5:
412 verify_group_stats.append(ofp.group_desc_stats_entry(
413 group_type=msg.group_type,
414 group_id=msg.group_id,
415 buckets=msg.buckets)
416 )
417 verify_group_stats.append(ofp.group_desc_stats_entry(
418 group_type=msg6.group_type,
419 group_id=msg6.group_id,
420 buckets=msg6.buckets)
421 )
422 for msg in msg7:
423 verify_group_stats.append(ofp.group_desc_stats_entry(
424 group_type=msg.group_type,
425 group_id=msg.group_id,
426 buckets=msg.buckets)
427 )
428
429 verify_group_stats.append(ofp.group_desc_stats_entry(
430 group_type=msg8.group_type,
431 group_id=msg8.group_id,
432 buckets=msg8.buckets)
433 )
macauley68bd7682015-08-03 09:20:32 +0800434
435 verify_group_stats=sorted(verify_group_stats, key=getkey("group_id"))
436 stats=sorted(stats, key=getkey("group_id"))
macauleyfd08eda2015-07-17 15:59:04 +0800437
macauley68bd7682015-08-03 09:20:32 +0800438 self.maxDiff=None
macauleyfd08eda2015-07-17 15:59:04 +0800439 self.assertEquals(stats, verify_group_stats)
macauley_cheng1be9d382015-08-31 15:18:48 +0800440
441
442class mpls_intf_group(base_tests.SimpleDataPlane):
443 """
444 create mpls intf group
445 1. ref l2_intf_group
446 2. ref l2_flood_group
447 """
448 def runTest(self):
449 delete_all_flows(self.controller)
450 delete_all_groups(self.controller)
macauleyfd08eda2015-07-17 15:59:04 +0800451
macauley_cheng1be9d382015-08-31 15:18:48 +0800452 test_vid=1
453
454 #ref l2_intf_group
455 l2_intf_gid, l2_intf_msg = add_one_l2_interface_grouop(self.controller, config["port_map"].keys()[0], test_vid, False, False)
456 mpls_intf_gid, mpls_intf_msg=add_mpls_intf_group(self.controller, l2_intf_gid, [0x00,0x11,0x11,0x11,0x11,0x11], [0x00,0x22,0x22,0x22,0x22,0x22], vid=test_vid, index=1)
457
458 stats = get_stats(self, ofp.message.group_desc_stats_request())
459
460 verify_group_stats=[]
461 verify_group_stats.append(ofp.group_desc_stats_entry(
462 group_type=l2_intf_msg.group_type,
463 group_id=l2_intf_msg.group_id,
464 buckets=l2_intf_msg.buckets)
465 )
466
467 verify_group_stats.append(ofp.group_desc_stats_entry(
468 group_type=mpls_intf_msg.group_type,
469 group_id=mpls_intf_msg.group_id,
470 buckets=mpls_intf_msg.buckets)
471 )
472 verify_group_stats=sorted(verify_group_stats, key=getkey("group_id"))
473 stats=sorted(stats, key=getkey("group_id"))
474 self.assertEquals(stats, verify_group_stats)
475
macauleyfd08eda2015-07-17 15:59:04 +0800476
macauley_cheng1be9d382015-08-31 15:18:48 +0800477class mpls_l2_vpn_group(base_tests.SimpleDataPlane):
478 """
479 create mpls intf group
480 1. ref l2_intf_group
481
482 """
483 def runTest(self):
484 delete_all_flows(self.controller)
485 delete_all_groups(self.controller)
486
487 test_vid=1
488 test_port=config["port_map"].keys()[0]
489 #ref l2_intf_group
490 l2_intf_gid, l2_intf_msg = add_one_l2_interface_grouop(self.controller, test_port, test_vid, False, False)
491 mpls_intf_gid, mpls_intf_msg=add_mpls_intf_group(self.controller, l2_intf_gid, [0x00,0x11,0x11,0x11,0x11,0x11], [0x00,0x22,0x22,0x22,0x22,0x22], vid=test_vid, index=1)
492 mpls_label_gid, mpls_label_msg=add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L2_VPN_LABEL,
493 index=1,
494 ref_gid=mpls_intf_gid,
495 push_l2_header=True,
496 push_vlan=True,
497 push_mpls_header=True,
498 push_cw=False,
499 set_mpls_label=10,
500 set_bos=0,
501 set_tc=7,
502 set_tc_from_table=False,
503 cpy_tc_outward=False,
504 set_ttl=250,
505 cpy_ttl_outward=False,
506 oam_lm_tx_count=False,
507 set_pri_from_table=False
508 )
509
510 verify_group_stats=[]
511 verify_group_stats.append(ofp.group_desc_stats_entry(
512 group_type=l2_intf_msg.group_type,
513 group_id=l2_intf_msg.group_id,
514 buckets=l2_intf_msg.buckets)
515 )
516
517 verify_group_stats.append(ofp.group_desc_stats_entry(
518 group_type=mpls_intf_msg.group_type,
519 group_id=mpls_intf_msg.group_id,
520 buckets=mpls_intf_msg.buckets)
521 )
522 verify_group_stats.append(ofp.group_desc_stats_entry(
523 group_type=mpls_label_msg.group_type,
524 group_id=mpls_label_msg.group_id,
525 buckets=mpls_label_msg.buckets)
526 )
527 verify_group_stats=sorted(verify_group_stats, key=getkey("group_id"))
528 stats= get_stats(self, ofp.message.group_desc_stats_request())
529 stats=sorted(stats, key=getkey("group_id"))
530 #DumpGroup(stats, verify_group_stats)
531 #AssertGroup(self, stats, verify_group_stats)
532 self.assertEquals(stats, verify_group_stats)
533
534
535class mpls_tunnel_lable1_group(base_tests.SimpleDataPlane):
536 """
537 create mpls intf group
538 1. ref l2_intf_group
539
540 """
541 def runTest(self):
542 delete_all_flows(self.controller)
543 delete_all_groups(self.controller)
544
545 test_vid=1
546 test_port=config["port_map"].keys()[0]
547 #ref l2_intf_group
548 l2_intf_gid, l2_intf_msg = add_one_l2_interface_grouop(self.controller, test_port, test_vid, False, False)
549 mpls_intf_gid, mpls_intf_msg=add_mpls_intf_group(self.controller, l2_intf_gid, [0x00,0x11,0x11,0x11,0x11,0x11], [0x00,0x22,0x22,0x22,0x22,0x22], vid=test_vid, index=1)
550 mpls_label_gid, mpls_label_msg=add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_TUNNEL_LABEL1,
551 index=1,
552 ref_gid=mpls_intf_gid,
553 push_l2_header=True,
554 push_vlan=True,
555 push_mpls_header=True,
556 push_cw=True,
557 set_mpls_label=10,
558 set_bos=0,
559 set_tc=7,
560 set_tc_from_table=False,
561 cpy_tc_outward=False,
562 set_ttl=250,
563 cpy_ttl_outward=False,
564 oam_lm_tx_count=False,
565 set_pri_from_table=False
566 )
567
568 stats = get_stats(self, ofp.message.group_desc_stats_request())
569
570 verify_group_stats=[]
571 verify_group_stats.append(ofp.group_desc_stats_entry(
572 group_type=l2_intf_msg.group_type,
573 group_id=l2_intf_msg.group_id,
574 buckets=l2_intf_msg.buckets)
575 )
576 verify_group_stats.append(ofp.group_desc_stats_entry(
577 group_type=mpls_intf_msg.group_type,
578 group_id=mpls_intf_msg.group_id,
579 buckets=mpls_intf_msg.buckets)
580 )
581 verify_group_stats.append(ofp.group_desc_stats_entry(
582 group_type=mpls_label_msg.group_type,
583 group_id=mpls_label_msg.group_id,
584 buckets=mpls_label_msg.buckets)
585 )
586 verify_group_stats=sorted(verify_group_stats, key=getkey("group_id"))
587 stats=sorted(stats, key=getkey("group_id"))
588 self.assertEquals(stats, verify_group_stats)
589
590
591class mpls_tunnel_lable2_group(base_tests.SimpleDataPlane):
592 """
593 create mpls intf group
594 1. ref l2_intf_group
595
596 """
597 def runTest(self):
598 delete_all_flows(self.controller)
599 delete_all_groups(self.controller)
600
601 test_vid=1
602 test_port=config["port_map"].keys()[0]
603 #ref l2_intf_group
604 l2_intf_gid, l2_intf_msg = add_one_l2_interface_grouop(self.controller, test_port, test_vid, False, False)
605 mpls_intf_gid, mpls_intf_msg=add_mpls_intf_group(self.controller, l2_intf_gid, [0x00,0x11,0x11,0x11,0x11,0x11], [0x00,0x22,0x22,0x22,0x22,0x22], vid=test_vid, index=1)
606 mpls_label_gid, mpls_label_msg=add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_TUNNEL_LABEL2,
607 index=1,
608 ref_gid=mpls_intf_gid,
609 push_l2_header=True,
610 push_vlan=True,
611 push_mpls_header=True,
612 push_cw=True,
613 set_mpls_label=10,
614 set_bos=0,
615 set_tc=7,
616 set_tc_from_table=False,
617 cpy_tc_outward=False,
618 set_ttl=250,
619 cpy_ttl_outward=False,
620 oam_lm_tx_count=False,
621 set_pri_from_table=False
622 )
623
624 stats = get_stats(self, ofp.message.group_desc_stats_request())
625
626 verify_group_stats=[]
627 verify_group_stats.append(ofp.group_desc_stats_entry(
628 group_type=l2_intf_msg.group_type,
629 group_id=l2_intf_msg.group_id,
630 buckets=l2_intf_msg.buckets)
631 )
632
633 verify_group_stats.append(ofp.group_desc_stats_entry(
634 group_type=mpls_intf_msg.group_type,
635 group_id=mpls_intf_msg.group_id,
636 buckets=mpls_intf_msg.buckets)
637 )
638 verify_group_stats.append(ofp.group_desc_stats_entry(
639 group_type=mpls_label_msg.group_type,
640 group_id=mpls_label_msg.group_id,
641 buckets=mpls_label_msg.buckets)
642 )
643 verify_group_stats=sorted(verify_group_stats, key=getkey("group_id"))
644 stats=sorted(stats, key=getkey("group_id"))
645 self.assertEquals(stats, verify_group_stats)
646
647class mpls_swap_label_group(base_tests.SimpleDataPlane):
648 """
649 create mpls intf group
650 1. ref l2_intf_group
651
652 """
653 def runTest(self):
654 delete_all_flows(self.controller)
655 delete_all_groups(self.controller)
656
657 test_vid=1
658 test_port=config["port_map"].keys()[0]
659 #ref l2_intf_group
660 l2_intf_gid, l2_intf_msg = add_one_l2_interface_grouop(self.controller, test_port, test_vid, False, False)
661 mpls_intf_gid, mpls_intf_msg=add_mpls_intf_group(self.controller, l2_intf_gid, [0x00,0x11,0x11,0x11,0x11,0x11], [0x00,0x22,0x22,0x22,0x22,0x22], vid=test_vid, index=1)
662 mpls_label_gid, mpls_label_msg=add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_SWAP_LABEL,
663 index=1,
664 ref_gid=mpls_intf_gid,
665 push_l2_header=True,
666 push_vlan=True,
667 push_mpls_header=True,
668 push_cw=True,
669 set_mpls_label=10,
670 set_bos=0,
671 set_tc=7,
672 set_tc_from_table=False,
673 cpy_tc_outward=False,
674 set_ttl=250,
675 cpy_ttl_outward=False,
676 oam_lm_tx_count=False,
677 set_pri_from_table=False
678 )
679
680 stats = get_stats(self, ofp.message.group_desc_stats_request())
681
682 verify_group_stats=[]
683 verify_group_stats.append(ofp.group_desc_stats_entry(
684 group_type=l2_intf_msg.group_type,
685 group_id=l2_intf_msg.group_id,
686 buckets=l2_intf_msg.buckets)
687 )
688
689 verify_group_stats.append(ofp.group_desc_stats_entry(
690 group_type=mpls_intf_msg.group_type,
691 group_id=mpls_intf_msg.group_id,
692 buckets=mpls_intf_msg.buckets)
693 )
694 verify_group_stats.append(ofp.group_desc_stats_entry(
695 group_type=mpls_label_msg.group_type,
696 group_id=mpls_label_msg.group_id,
697 buckets=mpls_label_msg.buckets)
698 )
699 verify_group_stats=sorted(verify_group_stats, key=getkey("group_id"))
700 stats=sorted(stats, key=getkey("group_id"))
701 self.assertEquals(stats, verify_group_stats)
702