blob: 891bb33c63e38a022e5ff2d677b49aae02de6183 [file] [log] [blame]
ShreyaPanditada75f752012-10-26 16:26:35 -04001"""These tests fall under Conformance Test-Suite (OF-SWITCH-1.0.0 TestCases).
2 Refer Documentation -- Detailed testing methodology
3 <Some of test-cases are directly taken from oftest> """
4
5"Test Suite 6 --> Flow Matches"
6
7
8import logging
9
10import unittest
11import random
12
13import oftest.controller as controller
14import oftest.cstruct as ofp
15import oftest.message as message
16import oftest.dataplane as dataplane
17import oftest.action as action
18import oftest.parse as parse
19import oftest.base_tests as base_tests
20import time
21
22from oftest.testutils import *
23from time import sleep
24from FuncUtils import *
25
26
27
28class AllWildcardMatch(base_tests.SimpleDataPlane):
29
30 """Verify for an all wildcarded flow all the injected packets would match that flow"""
31
32 def runTest(self):
33
34 logging.info("Running All Wildcard Match test")
35
36 of_ports = config["port_map"].keys()
37 of_ports.sort()
38 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
39
40 #Clear Switch State
41 rc = delete_all_flows(self.controller)
42 self.assertEqual(rc, 0, "Failed to delete all flows")
43
44 logging.info("Inserting an all wildcarded flow and sending packets with various match fields")
45 logging.info("Expecting all sent packets to match")
46
47 #Insert an All Wildcarded flow.
48 Wildcard_All(self,of_ports)
49
50 #check for different match fields and verify packet implements the action specified in the flow
51 pkt1 = simple_tcp_packet(dl_src="00:01:01:01:01:01");
52 self.dataplane.send(of_ports[0], str(pkt1))
53 egress_port=of_ports[1]
54 no_ports=set(of_ports).difference([egress_port])
55 yes_ports = of_ports[1]
56 receive_pkt_check(self.dataplane,pkt1,[yes_ports],no_ports,self)
57
58 pkt2 = simple_tcp_packet(dl_dst="00:01:01:01:01:01");
59 self.dataplane.send(of_ports[0], str(pkt2))
60 egress_port=of_ports[1]
61 no_ports=set(of_ports).difference([egress_port])
62 yes_ports = of_ports[1]
63 receive_pkt_check(self.dataplane,pkt2,[yes_ports],no_ports,self)
64
65 pkt3 = simple_tcp_packet(ip_src="192.168.2.1");
66 self.dataplane.send(of_ports[0], str(pkt3))
67 egress_port=of_ports[1]
68 no_ports=set(of_ports).difference([egress_port])
69 yes_ports = of_ports[1]
70 receive_pkt_check(self.dataplane,pkt3,[yes_ports],no_ports,self)
71
72 pkt4 = simple_tcp_packet(ip_dst="192.168.2.2");
73 self.dataplane.send(of_ports[0], str(pkt4))
74 egress_port=of_ports[1]
75 no_ports=set(of_ports).difference([egress_port])
76 yes_ports = of_ports[1]
77 receive_pkt_check(self.dataplane,pkt4,[yes_ports],no_ports,self)
78
79 pkt5 = simple_tcp_packet(ip_tos=2);
80 self.dataplane.send(of_ports[0], str(pkt5))
81 egress_port=of_ports[1]
82 no_ports=set(of_ports).difference([egress_port])
83 yes_ports = of_ports[1]
84 receive_pkt_check(self.dataplane,pkt5,[yes_ports],no_ports,self)
85
86 pkt6 = simple_tcp_packet(tcp_sport=8080);
87 self.dataplane.send(of_ports[0], str(pkt6))
88 egress_port=of_ports[1]
89 no_ports=set(of_ports).difference([egress_port])
90 yes_ports = of_ports[1]
91 receive_pkt_check(self.dataplane,pkt6,[yes_ports],no_ports,self)
92
93 pkt7 = simple_tcp_packet(tcp_dport=8081);
94 self.dataplane.send(of_ports[0], str(pkt7))
95 egress_port=of_ports[1]
96 no_ports=set(of_ports).difference([egress_port])
97 yes_ports = of_ports[1]
98 receive_pkt_check(self.dataplane,pkt7,[yes_ports],no_ports,self)
99
100
101
102class EthernetSrcAddress(base_tests.SimpleDataPlane):
103
104 """Verify match on single header field -- Ethernet Src Address """
105
106 def runTest(self):
107
108 logging.info("Running Ethernet Src Address test")
109
110 of_ports = config["port_map"].keys()
111 of_ports.sort()
112 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
113
114 #Clear Switch State
115 rc = delete_all_flows(self.controller)
116 self.assertEqual(rc, 0, "Failed to delete all flows")
117
118 logging.info("Inserting a flow with match on Ethernet Source Address ")
119 logging.info("Sending matching and non-matching packets")
120 logging.info("Verifying matching packets implements the action specified in the flow")
121
122 #Insert a Match On Ethernet Src Address flow
123 (pkt,match) = Match_Ethernet_Src_Address(self,of_ports)
124
125 #Sending packet matching the flow, verify it implements the action
126 self.dataplane.send(of_ports[0], str(pkt))
127
128 #Verify packet implements the action specified in the flow
129 egress_port=of_ports[1]
130 no_ports=set(of_ports).difference([egress_port])
131 yes_ports = of_ports[1]
132 receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
133
134 #Sending non matching packet , verify Packetin event gets triggered.
135 pkt2 = simple_tcp_packet(dl_src='00:01:01:01:01:02');
136 self.dataplane.send(of_ports[0], str(pkt2))
137
138 (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4)
139 self.assertTrue(response is not None, "PacketIn not received")
140
141class EthernetDstAddress(base_tests.SimpleDataPlane):
142
143 """Verify match on single Header Field Field -- Ethernet Dst Address """
144
145 def runTest(self):
146
147 logging.info("Running Ethernet Dst Address test")
148
149 of_ports = config["port_map"].keys()
150 of_ports.sort()
151 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
152
153 #Clear Switch State
154 rv = delete_all_flows(self.controller)
155 self.assertEqual(rv, 0, "Failed to delete all flows")
156
157 logging.info("Inserting a flow with match on Ethernet Destination Address ")
158 logging.info("Sending matching and non-matching packets")
159 logging.info("Verifying matching packets implements the action specified in the flow")
160
161 #Insert a Match on Destination Address flow
162 (pkt,match) = Match_Ethernet_Dst_Address(self,of_ports)
163
164 #Send Packet matching the flow
165 self.dataplane.send(of_ports[0], str(pkt))
166
167 #Verify packet implements the action specified in the flow
168 egress_port=of_ports[1]
169 no_ports=set(of_ports).difference([egress_port])
170 yes_ports = of_ports[1]
171 receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
172
173 #Send Non-matching packet
174 pkt2 = simple_tcp_packet(dl_dst='00:01:01:01:01:02');
175 self.dataplane.send(of_ports[0], str(pkt2))
176
177 #Verify PacketIn event gets triggered
178 (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4)
179 self.assertTrue(response is not None, "PacketIn not received")
180
181
182class EthernetType(base_tests.SimpleDataPlane):
183
184 """Verify match on single header field -- Ethernet Type """
185
186 def runTest(self):
187
188 logging.info("Running Ethernet Type test")
189
190 of_ports = config["port_map"].keys()
191 of_ports.sort()
192 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
193
194 #Clear Switch State
195 rc = delete_all_flows(self.controller)
196 self.assertEqual(rc, 0, "Failed to delete all flows")
197
198 logging.info("Inserting a flow with match on Ethernet Type ")
199 logging.info("Sending matching and non-matching packets")
200 logging.info("Verifying matching packets implements the action specified in the flow")
201
202 #Insert a Match on Ethernet Type flow
203 (pkt,match) = Match_Ethernet_Type(self,of_ports)
204
205 #Sending packet matching the flow
206 self.dataplane.send(of_ports[0], str(pkt))
207
208 #Verify packet implements the action specified in the flow
209 egress_port=of_ports[1]
210 no_ports=set(of_ports).difference([egress_port])
211 yes_ports = of_ports[1]
212 receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
213
214 #Sending non matching packet ,
215 pkt2 = simple_eth_packet(dl_type=0x0806);
216 self.dataplane.send(of_ports[0], str(pkt2))
217
218 #verify Packetin event gets triggered.
219 (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4)
220 self.assertTrue(response is not None, "PacketIn not received")
221
222
223class IngressPort(base_tests.SimpleDataPlane):
224
225 """Verify match on single Header Field Field -- In_port """
226
227 def runTest(self):
228
229 logging.info("Running Ingress Port test")
230
231 of_ports = config["port_map"].keys()
232 of_ports.sort()
233 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
234
235 #Clear Switch State
236 rc = delete_all_flows(self.controller)
237 self.assertEqual(rc, 0, "Failed to delete all flows")
238
239 logging.info("Inserting a flow with match on Ingress Port ")
240 logging.info("Sending matching and non-matching packets")
241 logging.info("Verifying matching packets implements the action specified in the flow")
242
243 #Insert a Match on Ingress Port FLow
244 (pkt,match) = Wildcard_All_Except_Ingress(self,of_ports,priority=0)
245
246 #Send Packet matching the flow i.e on in_port specified in the flow
247 self.dataplane.send(of_ports[0], str(pkt))
248
249 #Verify packet implements the action specified in the flow
250 egress_port=of_ports[1]
251 no_ports=set(of_ports).difference([egress_port])
252 yes_ports = of_ports[1]
253 receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
254
255 #Send Non-Matching Packet
256 self.dataplane.send(of_ports[1],str(pkt))
257
258 #Verify PacketIn event gets triggered
259 (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4)
260 self.assertTrue(response is not None, "PacketIn not received")
261
262class VlanId(base_tests.SimpleDataPlane):
263
264 """Verify match on single Header Field Field -- Vlan Id """
265
266 def runTest(self):
267
268 of_ports = config["port_map"].keys()
269 of_ports.sort()
270 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
271
272 #Clear Switch State
273 rc = delete_all_flows(self.controller)
274 self.assertEqual(rc, 0, "Failed to delete all flows")
275
276 logging.info("Inserting a flow with match on VLAN ID ")
277 logging.info("Sending matching and non-matching packets")
278 logging.info("Verifying matching packets implements the action specified in the flow")
279
280 #Create a flow with match on Vlan Id
281 (pkt,match) = Match_Vlan_Id(self,of_ports)
282
283 #Send tagged packet matching the flow i.e packet with same vlan id as in flow
284 self.dataplane.send(of_ports[0], str(pkt))
285
286 #Verify packet implements the action specified in the flow
287 egress_port=of_ports[1]
288 no_ports=set(of_ports).difference([egress_port])
289 yes_ports = of_ports[1]
290 receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
291
292 #Send Non-matching packet, i.e packet with different Vlan Id
293 pkt2 = simple_tcp_packet(dl_vlan_enable=True,dl_vlan=4);
294 self.dataplane.send(of_ports[0], str(pkt2))
295
296 #Verify PacketIn event gets triggered
297 (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4)
298 self.assertTrue(response is not None, "PacketIn not received")
299
300class VlanPCP(base_tests.SimpleDataPlane):
301
302 """"Verify match on single Header Field Field -- Vlan Priority"""
303
304 def runTest(self):
305
306 logging.info("Running VlanPCP1 test")
307
308 of_ports = config["port_map"].keys()
309 of_ports.sort()
310 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
311
312 #Clear Switch State
313 rv = delete_all_flows(self.controller)
314 self.assertEqual(rv, 0, "Failed to delete all flows")
315
316 logging.info("Inserting a flow with match on VLAN Priority ")
317 logging.info("Sending matching and non-matching packets")
318 logging.info("Verifying matching packets implements the action specified in the flow")
319
320 #Create a flow matching on VLAN Priority
321 (pkt,match) = Match_Vlan_Pcp(self,of_ports)
322
323 #Send tagged Packet matching the flow
324 self.dataplane.send(of_ports[0], str(pkt))
325
326 #Verify packet implements the action specified in the flow
327 egress_port=of_ports[1]
328 no_ports=set(of_ports).difference([egress_port])
329 yes_ports = of_ports[1]
330 receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
331
332 #Send tagged packet with same vlan_id but different vlan priority
333 pkt2 = simple_tcp_packet(dl_vlan_enable=True,dl_vlan=1,dl_vlan_pcp=20);
334 self.dataplane.send(in_port, str(pkt))
335
336class MultipleHeaderFieldL2(base_tests.SimpleDataPlane):
337
338 """Verify match on multiple header field -- Ethernet Type, Ethernet Source Address, Ethernet Destination Address """
339
340 def runTest(self):
341
342 logging.info("Running Multiple Header Field L2 test")
343
344 of_ports = config["port_map"].keys()
345 of_ports.sort()
346 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
347
348 #Clear Switch State
349 rc = delete_all_flows(self.controller)
350 self.assertEqual(rc, 0, "Failed to delete all flows")
351
352 logging.info("Inserting a flow with match on Multiple Header Field L2 ")
353 logging.info("Sending matching and non-matching packets")
354 logging.info("Verifying matching packets implements the action specified in the flow")
355
356 (pkt,match) = Match_Mul_L2(self,of_ports)
357
358 #Send eth packet matching the dl_type field, verify it implements the action
359 self.dataplane.send(of_ports[0], str(pkt))
360
361 #Verify packet implements the action specified in the flow
362 egress_port=of_ports[1]
363 no_ports=set(of_ports).difference([egress_port])
364 yes_ports = of_ports[1]
365 receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
366
367 #Sending non matching packet , verify Packetin event gets triggered.
368 pkt2 = simple_eth_packet(dl_type=0x0806,dl_src='00:01:01:01:01:02',dl_dst='00:01:01:01:01:01');
369 self.dataplane.send(of_ports[0], str(pkt2))
370
371 (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4)
372 self.assertTrue(response is not None, "PacketIn not received")
373
374class IpTos(base_tests.SimpleDataPlane):
375
376 """"Verify match on single Header Field Field -- Type of service"""
377
378 def runTest(self):
379
380 logging.info("Running Ip_Tos test")
381
382 of_ports = config["port_map"].keys()
383 of_ports.sort()
384 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
385
386 #Clear Switch State
387 rv = delete_all_flows(self.controller)
388 self.assertEqual(rv, 0, "Failed to delete all flows")
389
390 logging.info("Inserting a flow with match on Ip_Tos ")
391 logging.info("Sending matching and non-matching packets")
392 logging.info("Verifying matching packets implements the action specified in the flow")
393
394 #Create a flow matching on VLAN Priority
395 (pkt,match) = Match_Ip_Tos(self,of_ports)
396
397 #Send Packet matching the flow
398 self.dataplane.send(of_ports[0], str(pkt))
399
400 #Verify packet implements the action specified in the flow
401 egress_port=of_ports[1]
402 no_ports=set(of_ports).difference([egress_port])
403 yes_ports = of_ports[1]
404 receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
405
406 #Create a non-matching packet , verify packet_in get generated
407 pkt2 = simple_tcp_packet(ip_tos=20);
408 self.dataplane.send(of_ports[0], str(pkt2))
409 (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4)
410 self.assertTrue(response is not None, "PacketIn not received")
411
412
413class TcpSourcePort(base_tests.SimpleDataPlane):
414
415 """Verify match on Single header field -- Tcp Source Port, """
416
417 def runTest(self):
418
419 logging.info("Running Tcp Source Port test")
420
421 of_ports = config["port_map"].keys()
422 of_ports.sort()
423 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
424
425 #Clear Switch State
426 rc = delete_all_flows(self.controller)
427 self.assertEqual(rc, 0, "Failed to delete all flows")
428
429 logging.info("Inserting a flow with match on Tcp Tcp Source Port ")
430 logging.info("Sending matching and non-matching packets")
431 logging.info("Verifying matching packets implements the action specified in the flow")
432
433 (pkt,match) = Match_Tcp_Src(self,of_ports)
434
435 #Sending packet matching the tcp_sport, verify it implements the action
436 self.dataplane.send(of_ports[0], str(pkt))
437
438 #Verify packet implements the action specified in the flow
439 egress_port=of_ports[1]
440 no_ports=set(of_ports).difference([egress_port])
441 yes_ports = of_ports[1]
442 receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
443
444 #Sending non matching packet , verify Packetin event gets triggered.
445 pkt2 = simple_tcp_packet(tcp_sport=540);
446 self.dataplane.send(of_ports[0], str(pkt2))
447
448 (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4)
449 self.assertTrue(response is not None, "PacketIn not received")
450
451class TcpDstPort(base_tests.SimpleDataPlane):
452
453 """Verify match on Single header field -- Tcp Destination Port """
454
455 def runTest(self):
456
457 logging.info("Running Tcp Destination Port test")
458
459 of_ports = config["port_map"].keys()
460 of_ports.sort()
461 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
462
463 #Clear Switch State
464 rc = delete_all_flows(self.controller)
465 self.assertEqual(rc, 0, "Failed to delete all flows")
466
467 logging.info("Inserting a flow with match on Tcp Destination Port ")
468 logging.info("Sending matching and non-matching packets")
469 logging.info("Verifying matching packets implements the action specified in the flow")
470
471 (pkt,match) = Match_Tcp_Dst(self,of_ports)
472
473 #Sending packet matching the tcp_dport, verify it implements the action
474 self.dataplane.send(of_ports[0], str(pkt))
475
476 #Verify packet implements the action specified in the flow
477 egress_port=of_ports[1]
478 no_ports=set(of_ports).difference([egress_port])
479 yes_ports = of_ports[1]
480 receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
481
482 #Sending non matching packet , verify Packetin event gets triggered.
483 pkt2 = simple_tcp_packet(tcp_dport=541);
484 self.dataplane.send(of_ports[0], str(pkt2))
485
486 (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=10)
487 self.assertTrue(response is not None, "PacketIn not received")
488
489
490class ExactMatch(base_tests.SimpleDataPlane):
491
492 """Verify match on Single header field -- Exact Match """
493
494 def runTest(self):
495
496 logging.info("Running Tcp Exact Match test")
497
498 of_ports = config["port_map"].keys()
499 of_ports.sort()
500 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
501
502 #Clear Switch State
503 rc = delete_all_flows(self.controller)
504 self.assertEqual(rc, 0, "Failed to delete all flows")
505
506 logging.info("Inserting a flow with match for Exact Match ")
507 logging.info("Sending matching and non-matching packets")
508 logging.info("Verifying matching packets implements the action specified in the flow")
509
510 (pkt,match) = Exact_Match(self,of_ports)
511
512 #Sending packet matching all the fields of a tcp_packet, verify it implements the action
513 self.dataplane.send(of_ports[0], str(pkt))
514
515 #Verify packet implements the action specified in the flow
516 egress_port=of_ports[1]
517 no_ports=set(of_ports).difference([egress_port])
518 yes_ports = of_ports[1]
519 receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
520
521 #Sending non matching packet , verify Packetin event gets triggered.
522 pkt2 = simple_tcp_packet(tcp_sport=540);
523 self.dataplane.send(of_ports[0], str(pkt2))
524
525 (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4)
526 self.assertTrue(response is not None, "PacketIn not received")
527
528
529class MultipleHeaderFieldL4(base_tests.SimpleDataPlane):
530
531 """Verify match on multiple header field -- Tcp Source Port, Tcp Destination Port """
532
533 def runTest(self):
534
535 logging.info("Running Multiple Header Field L4 test")
536
537 of_ports = config["port_map"].keys()
538 of_ports.sort()
539 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
540
541 #Clear Switch State
542 rc = delete_all_flows(self.controller)
543 self.assertEqual(rc, 0, "Failed to delete all flows")
544
545 logging.info("Inserting a flow with match on Multiple Header Field L4 ")
546 logging.info("Sending matching and non-matching packets")
547 logging.info("Verifying matching packets implements the action specified in the flow")
548
549 (pkt,match) = Match_Mul_L4(self,of_ports)
550
551 #Sending packet matching the tcp_sport and tcp_dport field, verify it implements the action
552 self.dataplane.send(of_ports[0], str(pkt))
553
554 #Verify packet implements the action specified in the flow
555 egress_port=of_ports[1]
556 no_ports=set(of_ports).difference([egress_port])
557 yes_ports = of_ports[1]
558 receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
559
560 #Sending non matching packet , verify Packetin event gets triggered.
561 pkt2 = simple_tcp_packet(tcp_sport=540,tcp_dport=541);
562 self.dataplane.send(of_ports[0], str(pkt2))
563
564 (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4)
565 self.assertTrue(response is not None, "PacketIn not received")
566
567
568
569class ExactMatchHigh(base_tests.SimpleDataPlane):
570
571 """Verify that Exact Match has highest priority """
572
573 def runTest(self):
574
575 logging.info("Running Exact Match High Priority test")
576
577 of_ports = config["port_map"].keys()
578 of_ports.sort()
579 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
580
581 #Clear Switch State
582 rc = delete_all_flows(self.controller)
583 self.assertEqual(rc, 0, "Failed to delete all flows")
584
585 logging.info("Inserting a flow with Exact Match (low priority)")
586 logging.info("Inserting a overlapping wildcarded flow (higher priority)")
587 logging.info("Sending packets matching both the flows ")
588 logging.info("Verifying matching packets implements the action specified in the exact match flow")
589
590 #Insert two Overlapping Flows : Exact Match and Wildcard All.
591 (pkt,match) = Exact_Match_With_Prio(self,of_ports,priority=10)
592 (pkt2,match2) = Wildcard_All(self,of_ports,priority=20);
593
594 #Sending packet matching the both the flows , verify it implements the action specified in Exact Match Flow
595 self.dataplane.send(of_ports[0], str(pkt2))
596
597 #Verify packet implements the action specified in the flow
598 egress_port=of_ports[2]
599 no_ports=set(of_ports).difference([egress_port])
600 yes_ports = egress_port
601 receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
602
603
604class WildcardMatchHigh(base_tests.SimpleDataPlane):
605
606 """Verify that Wildcard Match with highest priority overrides the low priority WildcardMatch """
607
608 def runTest(self):
609
610 logging.info("Running Wildcard Match High Priority test")
611
612 of_ports = config["port_map"].keys()
613 of_ports.sort()
614 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
615
616 #Clear Switch State
617 rc = delete_all_flows(self.controller)
618 self.assertEqual(rc, 0, "Failed to delete all flows")
619
620 logging.info("Inserting two wildcarded flows with priorities ")
621 logging.info("Sending packets matching the flows")
622 logging.info("Verifying matching packets implements the action specified in the flow with higher priority")
623
624 (pkt,match) = Wildcard_All(self,of_ports,priority=20)
625 (pkt1,match1) = Wildcard_All_Except_Ingress1(self,of_ports,priority=10)
626
627 #Sending packet matching both the flows , verify it implements the action specified by Higher Priority flow
628 self.dataplane.send(of_ports[0], str(pkt1))
629
630 egress_port=of_ports[1]
631 no_ports=set(of_ports).difference([egress_port])
632 yes_ports = of_ports[1]
633 receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)