blob: f68c88483e3d558194c7bd8cd59b2217fbbb5420 [file] [log] [blame]
Jonathan Hartf2511ca2015-07-07 14:18:19 -07001'''
2OFTests for functionality needed from the OLT.
3'''
Zsolt Harasztife525502016-03-02 05:18:52 +00004
Jonathan Hartf2511ca2015-07-07 14:18:19 -07005import logging
alshabibb9d4ee82016-03-01 14:12:42 -08006from __builtin__ import xrange
alshabibd6be76e2016-03-01 22:21:00 -08007from oltbase import OltBaseTest
Jonathan Hartf2511ca2015-07-07 14:18:19 -07008import oftest.packet as scapy
Jonathan Hartf2511ca2015-07-07 14:18:19 -07009import ofp
Admin7e9c91d2015-08-25 15:53:49 -070010import time
Jonathan Hartf2511ca2015-07-07 14:18:19 -070011
Zsolt Haraszti5360d032016-03-02 23:02:09 -080012from oltconstants import *
Jonathan Hartf2511ca2015-07-07 14:18:19 -070013from oftest.testutils import *
14
alshabibed97b5f2016-03-01 23:46:53 -080015from IGMP import IGMPv3, IGMPv3gr, IGMP_TYPE_V3_MEMBERSHIP_REPORT,\
16 IGMP_V3_GR_TYPE_INCLUDE,\
17 IGMP_V3_GR_TYPE_EXCLUDE
Zsolt Harasztife525502016-03-02 05:18:52 +000018
alshabibb9d4ee82016-03-01 14:12:42 -080019
alshabibcde318b2016-03-01 22:49:13 -080020class EapolPacketIn(OltBaseTest):
Jonathan Hartf2511ca2015-07-07 14:18:19 -070021 """Verify packet-ins are sent for EAPOL packets """
alshabibb9d4ee82016-03-01 14:12:42 -080022
Jonathan Hartf2511ca2015-07-07 14:18:19 -070023 def runTest(self):
24 logging.info("Running EAPOL Packet In test")
25
26 match = ofp.match()
27 match.oxm_list.append(ofp.oxm.eth_type(0x888e))
28 # Use ethertype 0x888e and multicast destination MAC address
29 pkt = simple_eth_packet(pktlen=60, eth_dst='01:00:5E:7F:FF:FF', eth_type=0x888e)
alshabibb9d4ee82016-03-01 14:12:42 -080030
alshabibcde318b2016-03-01 22:49:13 -080031 self.testPacketIn(match, pkt)
Jonathan Hartf2511ca2015-07-07 14:18:19 -070032
alshabibb9d4ee82016-03-01 14:12:42 -080033
alshabibcde318b2016-03-01 22:49:13 -080034class ARPPacketIn(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +000035 """Verify packet-ins are sent for ARP packets """
alshabib9929a152016-03-01 21:25:18 -080036
Zsolt Harasztife525502016-03-02 05:18:52 +000037 def runTest(self):
38 logging.info("Running ARP Packet In test")
alshabib9929a152016-03-01 21:25:18 -080039
Zsolt Harasztife525502016-03-02 05:18:52 +000040 match = ofp.match()
41 match.oxm_list.append(ofp.oxm.eth_type(0x0806))
42
43 # Use ethertype 0x0806
44 pkt = simple_eth_packet(eth_type=0x0806)
45
alshabibcde318b2016-03-01 22:49:13 -080046 self.testPacketIn(match, pkt)
alshabib9929a152016-03-01 21:25:18 -080047
48
alshabibcde318b2016-03-01 22:49:13 -080049class IGMPPacketIn(OltBaseTest):
Jonathan Hartf2511ca2015-07-07 14:18:19 -070050 """Verify packet-ins are sent for IGMP packets """
alshabibb9d4ee82016-03-01 14:12:42 -080051
Jonathan Hartf2511ca2015-07-07 14:18:19 -070052 def runTest(self):
53 logging.info("Running IGMP Packet In test")
54
55 match = ofp.match()
56 match.oxm_list.append(ofp.oxm.eth_type(0x800))
57 match.oxm_list.append(ofp.oxm.ip_proto(2))
Jonathan Hartf2511ca2015-07-07 14:18:19 -070058
Zsolt Harasztid0571402016-03-02 18:40:50 -080059 mcast_group = "229.10.20.30"
60 ip_src = '192.168.0.123'
61 ip_dst = '224.0.0.22'
62 pkt = self.buildIgmpReport(ip_src, ip_dst, '00:00:00:00:be:ef', join=[mcast_group], pad_to=60)
alshabibb9d4ee82016-03-01 14:12:42 -080063
alshabibcde318b2016-03-01 22:49:13 -080064 self.testPacketIn(match, pkt)
Admin7e9c91d2015-08-25 15:53:49 -070065
alshabibb9d4ee82016-03-01 14:12:42 -080066
alshabibcde318b2016-03-01 22:49:13 -080067class IGMPQueryPacketOut(OltBaseTest):
Admind5212782015-12-09 17:17:57 -080068 """Verify sending multicast membership queries down to onu_ports"""
alshabibb9d4ee82016-03-01 14:12:42 -080069
Admind5212782015-12-09 17:17:57 -080070 def runTest(self):
71 logging.info("Running IGMP query packet out")
72
Zsolt Harasztife525502016-03-02 05:18:52 +000073 igmp = IGMPv3() # by default this is a query
Zsolt Harasztid0571402016-03-02 18:40:50 -080074 pkt = self.buildIgmp(igmp)
Admind5212782015-12-09 17:17:57 -080075
Zsolt Harasztife525502016-03-02 05:18:52 +000076 msg = ofp.message.packet_out(
77 in_port=ofp.OFPP_CONTROLLER,
78 actions=[ofp.action.output(port=onu_port)],
79 buffer_id=ofp.OFP_NO_BUFFER,
80 data=str(pkt))
Admind5212782015-12-09 17:17:57 -080081
alshabibb9d4ee82016-03-01 14:12:42 -080082 self.controller.message_send(msg)
Admind5212782015-12-09 17:17:57 -080083
Zsolt Harasztife525502016-03-02 05:18:52 +000084 rv = self.controller.message_send(msg)
85 self.assertTrue(rv == 0, "Error sending put message")
Admind5212782015-12-09 17:17:57 -080086 verify_no_errors(self.controller)
87
88 verify_packet(self, pkt, onu_port)
89
alshabibb9d4ee82016-03-01 14:12:42 -080090
alshabibcde318b2016-03-01 22:49:13 -080091class TestMeter(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +000092
Admin7e9c91d2015-08-25 15:53:49 -070093 def runTest(self):
94 logging.info("Running Meter tests")
alshabibb9d4ee82016-03-01 14:12:42 -080095 dropMeterBand = ofp.meter_band.drop(rate=640)
96 meter_mod = ofp.message.meter_mod(xid=1, command=ofp.OFPMC_ADD, meter_id=1, meters=[dropMeterBand])
Admin7e9c91d2015-08-25 15:53:49 -070097 self.controller.message_send(meter_mod)
alshabibb9d4ee82016-03-01 14:12:42 -080098
Admin7e9c91d2015-08-25 15:53:49 -070099 time.sleep(1)
100
101 verify_no_errors(self.controller)
102
Jonathan Hartf65e1812015-10-05 15:15:37 -0700103 vlan_id = 201
Admin7e9c91d2015-08-25 15:53:49 -0700104 match = ofp.match()
105 match.oxm_list.append(ofp.oxm.in_port(onu_port))
alshabibb9d4ee82016-03-01 14:12:42 -0800106 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
Admin02d052c2015-10-10 19:08:26 -0700107
108 request = ofp.message.flow_add(
109 table_id=test_param_get("table", 0),
110 cookie=42,
111 match=match,
112 instructions=[
113 ofp.instruction.apply_actions(
Zsolt Harasztife525502016-03-02 05:18:52 +0000114 actions=[ofp.action.output(port=olt_port)]),
115 ofp.instruction.meter(meter_id = 1)
alshabibb9d4ee82016-03-01 14:12:42 -0800116 ],
Admin02d052c2015-10-10 19:08:26 -0700117 buffer_id=ofp.OFP_NO_BUFFER,
118 priority=1000)
119
120 self.controller.message_send(request)
121 time.sleep(1)
122 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800123
Admin02d052c2015-10-10 19:08:26 -0700124 match = ofp.match()
125 match.oxm_list.append(ofp.oxm.in_port(olt_port))
126 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
Admin7e9c91d2015-08-25 15:53:49 -0700127
128 request = ofp.message.flow_add(
129 table_id=test_param_get("table", 0),
130 cookie=43,
131 match=match,
132 instructions=[
133 ofp.instruction.apply_actions(
Zsolt Harasztife525502016-03-02 05:18:52 +0000134 actions=[ofp.action.output(port=onu_port)]),
135 ofp.instruction.meter(meter_id = 1)
alshabibb9d4ee82016-03-01 14:12:42 -0800136 ],
Admin7e9c91d2015-08-25 15:53:49 -0700137 buffer_id=ofp.OFP_NO_BUFFER,
138 priority=1000)
139
140 self.controller.message_send(request)
Admin7e9c91d2015-08-25 15:53:49 -0700141 time.sleep(1)
Admin7e9c91d2015-08-25 15:53:49 -0700142 verify_no_errors(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700143 do_barrier(self.controller)
144 time.sleep(5)
alshabibb9d4ee82016-03-01 14:12:42 -0800145
Jonathan Hartf65e1812015-10-05 15:15:37 -0700146 inPkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=vlan_id, vlan_pcp=0)
147 # downstream
alshabibb9d4ee82016-03-01 14:12:42 -0800148 # self.dataplane.send(olt_port, str(inPkt))
149 # verify_packet(self, inPkt, onu_port)
Admin02d052c2015-10-10 19:08:26 -0700150 # upstream
alshabibb9d4ee82016-03-01 14:12:42 -0800151 # for i in range(1,400):
152 # self.dataplane.send(onu_port, str(inPkt))
153 # verify_packet(self, inPkt, olt_port)
Admin02d052c2015-10-10 19:08:26 -0700154
Jonathan Hartf65e1812015-10-05 15:15:37 -0700155 # clean up the test
alshabibb9d4ee82016-03-01 14:12:42 -0800156 meter_mod = ofp.message.meter_mod(xid=2, command=ofp.OFPMC_DELETE, meter_id=1)
Admin02d052c2015-10-10 19:08:26 -0700157 self.controller.message_send(meter_mod)
158 time.sleep(1)
159 delete_all_flows(self.controller)
160 verify_no_errors(self.controller)
161
Admin7e9c91d2015-08-25 15:53:49 -0700162
alshabibcde318b2016-03-01 22:49:13 -0800163class TestDuplicateMeter(OltBaseTest):
Admin7e9c91d2015-08-25 15:53:49 -0700164 def runTest(self):
165 logging.info("Running Duplicate Meter Test")
alshabibb9d4ee82016-03-01 14:12:42 -0800166 dropMeterBand = ofp.meter_band.drop(rate=500)
167 meter_mod = ofp.message.meter_mod(xid=1, command=ofp.OFPMC_ADD, meter_id=1, meters=[dropMeterBand])
Admin7e9c91d2015-08-25 15:53:49 -0700168 self.controller.message_send(meter_mod)
169 self.controller.message_send(meter_mod)
170
171 time.sleep(1)
alshabibb9d4ee82016-03-01 14:12:42 -0800172
Admin7e9c91d2015-08-25 15:53:49 -0700173 try:
174 verify_no_errors(self.controller)
175 except AssertionError as e:
Admin09b5cc62015-10-11 13:53:59 -0700176 if (not e.message == "unexpected error type=12 code=1"):
Admin7e9c91d2015-08-25 15:53:49 -0700177 raise AssertionError("Incorrect error type: %s" % e.message)
alshabibb9d4ee82016-03-01 14:12:42 -0800178
179
alshabibcde318b2016-03-01 22:49:13 -0800180class VlanTest(OltBaseTest):
Admin7e9c91d2015-08-25 15:53:49 -0700181 """Verify the switch can push/pop a VLAN tag and forward out a port """
alshabibb9d4ee82016-03-01 14:12:42 -0800182
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700183 def runTest(self):
184 logging.info("Running push VLAN test")
alshabibb9d4ee82016-03-01 14:12:42 -0800185
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700186 vlan_id = 200
alshabibb9d4ee82016-03-01 14:12:42 -0800187
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700188 delete_all_flows(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800189
190 # PUSH
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700191 match = ofp.match()
192 match.oxm_list.append(ofp.oxm.in_port(onu_port))
Zsolt Harasztife525502016-03-02 05:18:52 +0000193 if device_type == "cpqd":
194 match.oxm_list.append(ofp.oxm.vlan_vid(value=ofp.OFPVID_NONE))
195 actions = [
196 ofp.action.push_vlan(ethertype=0x8100),
197 ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id)),
198 ofp.action.set_field(ofp.oxm.vlan_pcp(0)),
199 ofp.action.output(port=olt_port)
200 ]
201 else: # pmc, normal
202 match.oxm_list.append(ofp.oxm.vlan_vid_masked(value=ofp.OFPVID_PRESENT, value_mask=ofp.OFPVID_PRESENT))
203 match.oxm_list.append(ofp.oxm.vlan_pcp(value = 0))
204 actions = [
205 ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id)),
206 ofp.action.set_field(ofp.oxm.vlan_pcp(0)),
207 ofp.action.output(port=olt_port)
208 ]
alshabibb9d4ee82016-03-01 14:12:42 -0800209
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700210 request = ofp.message.flow_add(
211 table_id=test_param_get("table", 0),
212 cookie=42,
213 match=match,
Zsolt Harasztife525502016-03-02 05:18:52 +0000214 instructions=[ofp.instruction.apply_actions(actions=actions)],
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700215 buffer_id=ofp.OFP_NO_BUFFER,
216 priority=1000)
217
Admin7e9c91d2015-08-25 15:53:49 -0700218 logging.info("Inserting flow tagging upstream")
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700219 self.controller.message_send(request)
Zsolt Harasztife525502016-03-02 05:18:52 +0000220 do_barrier(self.controller)
221 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800222
223 # POP
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700224 match = ofp.match()
225 match.oxm_list.append(ofp.oxm.in_port(olt_port))
226 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
Admin7e9c91d2015-08-25 15:53:49 -0700227
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700228 request = ofp.message.flow_add(
229 table_id=test_param_get("table", 0),
Admin7e9c91d2015-08-25 15:53:49 -0700230 cookie=43,
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700231 match=match,
232 instructions=[
233 ofp.instruction.apply_actions(
Jonathan Hartf65e1812015-10-05 15:15:37 -0700234 actions=[
235 ofp.action.pop_vlan(),
alshabibb9d4ee82016-03-01 14:12:42 -0800236 ofp.action.output(port=onu_port)])],
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700237 buffer_id=ofp.OFP_NO_BUFFER,
238 priority=1000)
239
Admin7e9c91d2015-08-25 15:53:49 -0700240 logging.info("Inserting flow tagging downstream")
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700241 self.controller.message_send(request)
242 do_barrier(self.controller)
Zsolt Harasztife525502016-03-02 05:18:52 +0000243 verify_no_errors(self.controller)
244
Admin7e9c91d2015-08-25 15:53:49 -0700245 time.sleep(5)
Admin99c2a272016-03-01 12:56:39 -0800246
Admin7e9c91d2015-08-25 15:53:49 -0700247 inPkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=0, vlan_pcp=0)
alshabibb9d4ee82016-03-01 14:12:42 -0800248 outPkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True,
Admin7e9c91d2015-08-25 15:53:49 -0700249 vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0)
alshabibb9d4ee82016-03-01 14:12:42 -0800250
Admin7e9c91d2015-08-25 15:53:49 -0700251 # Send untagged packet in the ONU port and expect tagged packet out the OLT port
252 self.dataplane.send(onu_port, str(inPkt))
253 verify_packet(self, outPkt, olt_port)
alshabibb9d4ee82016-03-01 14:12:42 -0800254
Admin7e9c91d2015-08-25 15:53:49 -0700255 # Send untagged packet in the OLT port and expect no packets to come out
256 self.dataplane.send(olt_port, str(inPkt))
257 verify_packets(self, outPkt, [])
alshabibb9d4ee82016-03-01 14:12:42 -0800258
Admin7e9c91d2015-08-25 15:53:49 -0700259 inPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True,
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700260 vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0)
Zsolt Harasztife525502016-03-02 05:18:52 +0000261 if device_type == 'pmc':
262 outPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=0, vlan_pcp=0)
263 else: # "normal", "cpqd""
264 outPkt = simple_udp_packet(pktlen=100)
Admin7e9c91d2015-08-25 15:53:49 -0700265
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700266 # Send tagged packet in the OLT port and expect untagged packet out the OLT port
267 self.dataplane.send(olt_port, str(inPkt))
268 verify_packet(self, outPkt, onu_port)
Admin7e9c91d2015-08-25 15:53:49 -0700269
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700270 # Send tagged packet in the ONU port and expect no packets to come out
271 self.dataplane.send(onu_port, str(inPkt))
Admin7e9c91d2015-08-25 15:53:49 -0700272 verify_packets(self, outPkt, [])
Jonathan Hartf65e1812015-10-05 15:15:37 -0700273
alshabibb9d4ee82016-03-01 14:12:42 -0800274
alshabibcde318b2016-03-01 22:49:13 -0800275class TestGroupAdd(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000276
Admin02d052c2015-10-10 19:08:26 -0700277 def runTest(self):
278 logging.info("Running Group tests")
279 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700280 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700281
alshabibb9d4ee82016-03-01 14:12:42 -0800282 test_group_id = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700283
284 # output to two ONU
285 group_add = createAllGroupAdd(test_group_id, ports=[onu_port, onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700286
287 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700288 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700289 verify_no_errors(self.controller)
290
291 # Remove the group and then readd it.
alshabibb9d4ee82016-03-01 14:12:42 -0800292 group_delete = ofp.message.group_delete(group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700293 self.controller.message_send(group_delete)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700294 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700295 verify_no_errors(self.controller)
296
Jonathan Hartf65e1812015-10-05 15:15:37 -0700297 group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700298 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700299 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700300 verify_no_errors(self.controller)
301
302
Jonathan Hartf65e1812015-10-05 15:15:37 -0700303 # clean up the test
alshabibb9d4ee82016-03-01 14:12:42 -0800304 group_delete = ofp.message.group_delete(group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700305 self.controller.message_send(group_delete)
alshabibb9d4ee82016-03-01 14:12:42 -0800306
Jonathan Hartf65e1812015-10-05 15:15:37 -0700307 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700308 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800309
310
alshabibcde318b2016-03-01 22:49:13 -0800311class TestGroupMod(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000312
Admin02d052c2015-10-10 19:08:26 -0700313 def runTest(self):
314 logging.info("Running Group tests")
315 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700316 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700317
alshabibb9d4ee82016-03-01 14:12:42 -0800318 test_group_id = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700319
320 group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700321
322 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700323 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700324 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800325
Jonathan Hartf65e1812015-10-05 15:15:37 -0700326 # Modifying the group
327 group_mod = createAllGroupMod(test_group_id, [onu_port2])
alshabibb9d4ee82016-03-01 14:12:42 -0800328
Jonathan Hartf65e1812015-10-05 15:15:37 -0700329 self.controller.message_send(group_mod)
330 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700331 verify_no_errors(self.controller)
332
Jonathan Hartf65e1812015-10-05 15:15:37 -0700333 # Add a bucket into the group
334 group_mod = createAllGroupMod(test_group_id, [onu_port, onu_port2])
335 self.controller.message_send(group_mod)
336 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700337 verify_no_errors(self.controller)
338
339 # Modifying a non-existing group
Jonathan Hartf65e1812015-10-05 15:15:37 -0700340 group_mod = createAllGroupMod(777, [onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700341
Jonathan Hartf65e1812015-10-05 15:15:37 -0700342 self.controller.message_send(group_mod)
343 do_barrier(self.controller)
344 errorExperienced = 0
Admin02d052c2015-10-10 19:08:26 -0700345 try:
346 verify_no_errors(self.controller)
347 except AssertionError as e:
Jonathan Hartf65e1812015-10-05 15:15:37 -0700348 errorExperienced = 1
Admin02d052c2015-10-10 19:08:26 -0700349 if (not (e.message == "unexpected error type=6 code=8")):
Jonathan Hartf65e1812015-10-05 15:15:37 -0700350 raise AssertionError("Incorrect error type: %s" % e.message)
alshabibb9d4ee82016-03-01 14:12:42 -0800351 if not errorExperienced:
Jonathan Hartf65e1812015-10-05 15:15:37 -0700352 raise AssertionError("An error message is expected, but not shown.")
alshabibb9d4ee82016-03-01 14:12:42 -0800353
354
Jonathan Hartf65e1812015-10-05 15:15:37 -0700355 # clean up the test
alshabibb9d4ee82016-03-01 14:12:42 -0800356 group_delete = ofp.message.group_delete(xid=2, group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700357 self.controller.message_send(group_delete)
alshabibb9d4ee82016-03-01 14:12:42 -0800358
Jonathan Hartf65e1812015-10-05 15:15:37 -0700359 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700360 verify_no_errors(self.controller)
361
alshabibb9d4ee82016-03-01 14:12:42 -0800362
alshabibcde318b2016-03-01 22:49:13 -0800363class TestDuplicateGroup(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000364
Admin02d052c2015-10-10 19:08:26 -0700365 def runTest(self):
366 logging.info("Running Group tests")
367 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700368 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700369
alshabibb9d4ee82016-03-01 14:12:42 -0800370 test_group_id = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700371 group_add = createAllGroupAdd(test_group_id, ports=[onu_port])
Admin02d052c2015-10-10 19:08:26 -0700372
373 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700374 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700375 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800376
Jonathan Hartf65e1812015-10-05 15:15:37 -0700377 # Add the same group id
alshabibb9d4ee82016-03-01 14:12:42 -0800378 duplicate_group_fail = 0
379
Admin02d052c2015-10-10 19:08:26 -0700380 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700381 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700382 try:
383 verify_no_errors(self.controller)
384 except AssertionError as e:
alshabibb9d4ee82016-03-01 14:12:42 -0800385 duplicate_group_fail = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700386 if (not e.message == "unexpected error type=6 code=0"):
387 raise AssertionError("Incorrect error type: %s" % e.message)
388 if not duplicate_group_fail:
389 raise AssertionError("Adding duplicate groups didn't raise an error.")
alshabibb9d4ee82016-03-01 14:12:42 -0800390
Jonathan Hartf65e1812015-10-05 15:15:37 -0700391 # clean up the test
alshabibb9d4ee82016-03-01 14:12:42 -0800392 group_delete = ofp.message.group_delete(xid=2, group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700393 self.controller.message_send(group_delete)
alshabibb9d4ee82016-03-01 14:12:42 -0800394
Jonathan Hartf65e1812015-10-05 15:15:37 -0700395 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700396 verify_no_errors(self.controller)
397
alshabibb9d4ee82016-03-01 14:12:42 -0800398
alshabibcde318b2016-03-01 22:49:13 -0800399class TestGroupAndFlow(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000400
Admin02d052c2015-10-10 19:08:26 -0700401 def runTest(self):
402 logging.info("Running Group tests")
403 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700404 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700405
Jonathan Hartf65e1812015-10-05 15:15:37 -0700406 # Create a group
alshabibb9d4ee82016-03-01 14:12:42 -0800407 test_group_id = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700408 group_add = createAllGroupAdd(test_group_id, ports=[onu_port])
Admin02d052c2015-10-10 19:08:26 -0700409
410 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700411 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700412 verify_no_errors(self.controller)
413
414 # Create a flow rule matching olt port and vlan id
415 match = ofp.match()
416 match.oxm_list.append(ofp.oxm.in_port(olt_port))
417 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | 201))
418
Jonathan Hartf65e1812015-10-05 15:15:37 -0700419 flow_pointing_to_group = ofp.message.flow_add(
Admin02d052c2015-10-10 19:08:26 -0700420 table_id=test_param_get("table", 0),
421 cookie=43,
422 match=match,
423 instructions=[
424 ofp.instruction.apply_actions(
alshabibb9d4ee82016-03-01 14:12:42 -0800425 actions=[ofp.action.group(group_id=test_group_id)])],
426 buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
Admin02d052c2015-10-10 19:08:26 -0700427
Jonathan Hartf65e1812015-10-05 15:15:37 -0700428 self.controller.message_send(flow_pointing_to_group)
429 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700430 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800431
Jonathan Hartf65e1812015-10-05 15:15:37 -0700432 # After letting a flow rule point to the group, test we can do group_mod
433 group_mod = createAllGroupMod(test_group_id, ports=[onu_port2])
434 self.controller.message_send(group_mod)
435 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700436 verify_no_errors(self.controller)
437
438 # Test we can remove flows and then remove group
alshabibb9d4ee82016-03-01 14:12:42 -0800439 flow_delete = ofp.message.flow_delete(table_id=test_param_get("table", 0))
Jonathan Hartf65e1812015-10-05 15:15:37 -0700440 self.controller.message_send(flow_delete)
441 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700442 verify_no_errors(self.controller)
443
alshabibb9d4ee82016-03-01 14:12:42 -0800444 group_delete = ofp.message.group_delete(xid=3, group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700445 self.controller.message_send(group_delete)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700446 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700447 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800448
Zsolt Harasztife525502016-03-02 05:18:52 +0000449 # Add the group and flow back, test it we can first remove group and then remove the flow.
Admindcb1bc72015-11-12 18:24:56 -0800450 '''group_add = createAllGroupAdd(test_group_id, ports=[onu_port])
Admin02d052c2015-10-10 19:08:26 -0700451 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700452
453 self.controller.message_send(flow_pointing_to_group)
454 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700455 verify_no_errors(self.controller)
456
457 group_delete = ofp.message.group_delete(xid = 4, group_id = test_group_id)
Admindcb1bc72015-11-12 18:24:56 -0800458 self.controller.message_send(group_delete)'''
Jonathan Hartf65e1812015-10-05 15:15:37 -0700459
460 self.controller.message_send(flow_delete)
461 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700462 verify_no_errors(self.controller)
463
464
alshabibcde318b2016-03-01 22:49:13 -0800465class TestGroupForwarding(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000466
Admin02d052c2015-10-10 19:08:26 -0700467 def runTest(self):
468 logging.info("Running Group datapath forwarding tests")
469 delete_all_flows(self.controller)
Admin99c2a272016-03-01 12:56:39 -0800470 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700471
Admin09b5cc62015-10-11 13:53:59 -0700472 vlan_id = 201
Admin02d052c2015-10-10 19:08:26 -0700473
Jonathan Hartf65e1812015-10-05 15:15:37 -0700474 # Create a group
alshabibb9d4ee82016-03-01 14:12:42 -0800475 test_group_id = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700476 group_add = createAllGroupAdd(test_group_id, [onu_port])
Admin02d052c2015-10-10 19:08:26 -0700477
478 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700479 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700480 verify_no_errors(self.controller)
481
482 # Create a flow rule matching olt port and vlan id
483 match = ofp.match()
484 match.oxm_list.append(ofp.oxm.in_port(olt_port))
485 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
486
487 request = ofp.message.flow_add(
488 table_id=test_param_get("table", 0),
489 cookie=43,
490 match=match,
491 instructions=[
492 ofp.instruction.apply_actions(
alshabibb9d4ee82016-03-01 14:12:42 -0800493 actions=[ofp.action.group(group_id=test_group_id)]),
494 ],
495 buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
Admin02d052c2015-10-10 19:08:26 -0700496
497 self.controller.message_send(request)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700498 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700499 verify_no_errors(self.controller)
Admin09b5cc62015-10-11 13:53:59 -0700500
501 # It takes some time for flows to propagate down to the data plane
Admindcb1bc72015-11-12 18:24:56 -0800502 time.sleep(10)
alshabibb9d4ee82016-03-01 14:12:42 -0800503
504 inPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True,
Admindcb1bc72015-11-12 18:24:56 -0800505 vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0, eth_dst="01:01:11:12:11:12")
Admin02d052c2015-10-10 19:08:26 -0700506 outPkt = inPkt
507 self.dataplane.send(olt_port, str(inPkt))
508 verify_packet(self, outPkt, onu_port)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700509
Admindcb1bc72015-11-12 18:24:56 -0800510
Zsolt Harasztife525502016-03-02 05:18:52 +0000511 # Now put 2 ONU ports in the group and test that the input packet is
Jonathan Hartf65e1812015-10-05 15:15:37 -0700512 # duplicated out both ports
513 group_mod = createAllGroupMod(test_group_id, ports=[onu_port, onu_port2])
514 self.controller.message_send(group_mod)
515 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700516 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800517
Admin09b5cc62015-10-11 13:53:59 -0700518 # It takes some time for flows to propagate down to the data plane
Admindcb1bc72015-11-12 18:24:56 -0800519 time.sleep(10)
Admin09b5cc62015-10-11 13:53:59 -0700520
Jonathan Hartf65e1812015-10-05 15:15:37 -0700521 self.dataplane.send(olt_port, str(inPkt))
Jonathan Hartf65e1812015-10-05 15:15:37 -0700522 verify_packet(self, outPkt, onu_port2)
Admindcb1bc72015-11-12 18:24:56 -0800523 verify_packet(self, outPkt, onu_port)
alshabibb9d4ee82016-03-01 14:12:42 -0800524 # verify_packets(self, outPkt, [onu_port,onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700525
Jonathan Hartf65e1812015-10-05 15:15:37 -0700526 # clean up the test
alshabibb9d4ee82016-03-01 14:12:42 -0800527 request = ofp.message.flow_delete(table_id=test_param_get("table", 0))
Admin02d052c2015-10-10 19:08:26 -0700528 self.controller.message_send(request)
alshabibb9d4ee82016-03-01 14:12:42 -0800529 group_delete = ofp.message.group_delete(xid=2, group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700530 self.controller.message_send(group_delete)
alshabibb9d4ee82016-03-01 14:12:42 -0800531
Jonathan Hartf65e1812015-10-05 15:15:37 -0700532 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700533 verify_no_errors(self.controller)
534
Admindcb1bc72015-11-12 18:24:56 -0800535
alshabibcde318b2016-03-01 22:49:13 -0800536class TestGroupModForwarding(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000537
Admindcb1bc72015-11-12 18:24:56 -0800538 def runTest(self):
alshabibb9d4ee82016-03-01 14:12:42 -0800539 logging.info("Running datapath forwarding tests for group mod")
Admindcb1bc72015-11-12 18:24:56 -0800540 delete_all_flows(self.controller)
541 delete_all_groups(self.controller)
542
543 vlan_id = 201
544
545 # Create a group
alshabibb9d4ee82016-03-01 14:12:42 -0800546 test_group_id = 1
Admindcb1bc72015-11-12 18:24:56 -0800547 group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2])
548
549 self.controller.message_send(group_add)
550 do_barrier(self.controller)
551 verify_no_errors(self.controller)
552
553 # Create a flow rule matching olt port and vlan id
554 match = ofp.match()
555 match.oxm_list.append(ofp.oxm.in_port(olt_port))
556 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
557
558 request = ofp.message.flow_add(
559 table_id=test_param_get("table", 0),
560 cookie=43,
561 match=match,
562 instructions=[
563 ofp.instruction.apply_actions(
alshabibb9d4ee82016-03-01 14:12:42 -0800564 actions=[ofp.action.group(group_id=test_group_id)]),
565 ],
566 buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
Admindcb1bc72015-11-12 18:24:56 -0800567
568 self.controller.message_send(request)
569 do_barrier(self.controller)
570 verify_no_errors(self.controller)
571
572 # It takes some time for flows to propagate down to the data plane
573 time.sleep(10)
alshabibb9d4ee82016-03-01 14:12:42 -0800574
575 inPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True,
Admindcb1bc72015-11-12 18:24:56 -0800576 vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0, eth_dst="01:01:11:12:11:12")
577 outPkt = inPkt
578 self.dataplane.send(olt_port, str(inPkt))
579 verify_packet(self, outPkt, onu_port)
Admin99c2a272016-03-01 12:56:39 -0800580 verify_packet(self, outPkt, onu_port2)
Admindcb1bc72015-11-12 18:24:56 -0800581
582 # Now remove onu port 1 from the group and test that the input packet is no longer forwarded to onu port 1
583 group_mod = createAllGroupMod(test_group_id, ports=[onu_port2])
584 self.controller.message_send(group_mod)
585 do_barrier(self.controller)
586 verify_no_errors(self.controller)
587
588 time.sleep(10)
589 self.dataplane.send(olt_port, str(inPkt))
590 verify_no_packet(self, outPkt, onu_port)
591 verify_packet(self, outPkt, onu_port2)
592
Zsolt Harasztife525502016-03-02 05:18:52 +0000593 # Now remove all ports in the group and test that the input packet is no longer forwarded to any port
Admindcb1bc72015-11-12 18:24:56 -0800594 group_mod = createAllGroupMod(test_group_id, ports=[])
595 self.controller.message_send(group_mod)
596 do_barrier(self.controller)
597 verify_no_errors(self.controller)
598 time.sleep(10)
599 self.dataplane.send(olt_port, str(inPkt))
600 verify_packets(self, outPkt, [])
601
602
alshabibcde318b2016-03-01 22:49:13 -0800603class TransparentVlanTest(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000604
Admin02d052c2015-10-10 19:08:26 -0700605 def runTest(self):
606 logging.info("Running transparent vlan tests")
Admin09b5cc62015-10-11 13:53:59 -0700607 delete_all_flows(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700608
Jonathan Hartf65e1812015-10-05 15:15:37 -0700609 vlan_id = 201
Admin02d052c2015-10-10 19:08:26 -0700610 match = ofp.match()
611 match.oxm_list.append(ofp.oxm.in_port(onu_port))
alshabibb9d4ee82016-03-01 14:12:42 -0800612 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
Admin02d052c2015-10-10 19:08:26 -0700613
614 request = ofp.message.flow_add(
615 table_id=test_param_get("table", 0),
616 cookie=42,
617 match=match,
618 instructions=[
619 ofp.instruction.apply_actions(
620 actions=[
621 ofp.action.output(port=olt_port)]),
alshabibb9d4ee82016-03-01 14:12:42 -0800622 ],
Admin02d052c2015-10-10 19:08:26 -0700623 buffer_id=ofp.OFP_NO_BUFFER,
624 priority=1000)
625
626 self.controller.message_send(request)
alshabibb9d4ee82016-03-01 14:12:42 -0800627
Admin02d052c2015-10-10 19:08:26 -0700628 match = ofp.match()
629 match.oxm_list.append(ofp.oxm.in_port(olt_port))
630 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
631
632 request = ofp.message.flow_add(
633 table_id=test_param_get("table", 0),
634 cookie=43,
635 match=match,
636 instructions=[
637 ofp.instruction.apply_actions(
638 actions=[
639 ofp.action.output(port=onu_port)]),
alshabibb9d4ee82016-03-01 14:12:42 -0800640 ],
Admin02d052c2015-10-10 19:08:26 -0700641 buffer_id=ofp.OFP_NO_BUFFER,
642 priority=1000)
643
644 self.controller.message_send(request)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700645 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700646 verify_no_errors(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700647
Admin09b5cc62015-10-11 13:53:59 -0700648 # It takes some time for flows to propagate down to the data plane
649 time.sleep(2)
alshabibb9d4ee82016-03-01 14:12:42 -0800650
Jonathan Hartf65e1812015-10-05 15:15:37 -0700651 inPkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=vlan_id, vlan_pcp=0)
Zsolt Harasztife525502016-03-02 05:18:52 +0000652
Admin02d052c2015-10-10 19:08:26 -0700653 # upstream
654 self.dataplane.send(onu_port, str(inPkt))
655 verify_packet(self, inPkt, olt_port)
Zsolt Harasztife525502016-03-02 05:18:52 +0000656
Admin99c2a272016-03-01 12:56:39 -0800657 # downstream
658 self.dataplane.send(olt_port, str(inPkt))
659 verify_packet(self, inPkt, onu_port)
Admin02d052c2015-10-10 19:08:26 -0700660
Jonathan Hartf65e1812015-10-05 15:15:37 -0700661 # clean up the test
Admin02d052c2015-10-10 19:08:26 -0700662 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700663 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700664 verify_no_errors(self.controller)
665
alshabibed97b5f2016-03-01 23:46:53 -0800666class TestMulticastForwarding(IGMPPacketIn):
667
668 def runTest(self):
669 delete_all_groups(self.controller)
670 # send igmp join packet
671 super(TestMulticastForwarding, self).runTest()
672
673 vlan_id = 201
674
alshabibc49e69c2016-03-01 23:49:25 -0800675 group = createAllGroupAdd(1, [onu_port])
alshabibed97b5f2016-03-01 23:46:53 -0800676
alshabib23f0e372016-03-01 23:50:37 -0800677 self.controller.message_send(group)
alshabibed97b5f2016-03-01 23:46:53 -0800678 do_barrier(self.controller)
679 verify_no_errors(self.controller)
680
681 # Create a flow rule matching olt port and vlan id
682 match = ofp.match()
683 match.oxm_list.append(ofp.oxm.in_port(olt_port))
684 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
685
686 request = ofp.message.flow_add(
687 table_id=test_param_get("table", 0),
688 cookie=43,
689 match=match,
690 instructions=[
691 ofp.instruction.apply_actions(
692 actions=[ofp.action.group(group_id=1)]),
693 ],
694 buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
695
696 self.controller.message_send(request)
697 do_barrier(self.controller)
698 verify_no_errors(self.controller)
699
700 # It takes some time for flows to propagate down to the data plane
701 time.sleep(5)
702
703 pkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=vlan_id, vlan_pcp=0, \
Admin99a3ed92016-03-02 17:22:50 -0800704 eth_dst = "01:00:5e:0a:14:1e", ip_dst = "229.10.20.30")
alshabibed97b5f2016-03-01 23:46:53 -0800705
706 # downstream
707 self.dataplane.send(olt_port, str(pkt))
708 verify_packet(self, pkt, onu_port)
709
710 # clean up the test
711 delete_all_flows(self.controller)
712 do_barrier(self.controller)
713 verify_no_errors(self.controller)
714 delete_all_groups(self.controller)
715
716
alshabibcde318b2016-03-01 22:49:13 -0800717class RemoveRuleTest(OltBaseTest):
alshabib28c03c32016-03-01 20:33:51 -0800718
719 def runTest(self):
720 logging.info("Testing Rule removal")
alshabibe165af22016-03-01 21:42:17 -0800721 delete_all_flows(self.controller)
Zsolt Haraszti5b8b39c2016-03-02 22:25:51 -0800722 self.installEapolRule(onu_port)
alshabibe165af22016-03-01 21:42:17 -0800723
alshabib9929a152016-03-01 21:25:18 -0800724 #wait for the rule to settle
725 time.sleep(3)
726
Admin44f754e2016-03-01 23:00:46 -0800727 self.installDoubleTaggingRules(1, 2)
alshabibe165af22016-03-01 21:42:17 -0800728
alshabib9929a152016-03-01 21:25:18 -0800729 #wait for the rules to settle
730 time.sleep(3)
731
732 stats = get_flow_stats(self, ofp.match())
733
Admin53e10b62016-03-01 21:52:18 -0800734 self.assertTrue(len(stats) == 5, \
735 "Wrong number of rules reports; reported %s, expected 5\n\n %s" % (len(stats), stats))
alshabib9929a152016-03-01 21:25:18 -0800736
Zsolt Haraszti5b8b39c2016-03-02 22:25:51 -0800737 self.installEapolRule(onu_port, install=False)
alshabib9929a152016-03-01 21:25:18 -0800738 time.sleep(3)
739
740 stats = get_flow_stats(self, ofp.match())
741
Admin53e10b62016-03-01 21:52:18 -0800742 self.assertTrue(len(stats) == 4, \
743 "Wrong number of rules reports; reported %s, expected 4\n\n %s" % (len(stats), stats))
alshabib9929a152016-03-01 21:25:18 -0800744
alshabibd6be76e2016-03-01 22:21:00 -0800745 eapol = ofp.oxm.eth_type(0x888e)
746 found = False
747 for fe in stats:
748 if eapol in fe.match.oxm_list:
749 found = True
750
751 self.assertFalse(found, "Removed incorrect flow rule")
alshabib28c03c32016-03-01 20:33:51 -0800752
753
alshabibb5a09bc2016-03-02 13:26:43 -0800754class MultipleDoubleTaggingForwarding(OltBaseTest):
alshabib28c03c32016-03-01 20:33:51 -0800755
alshabib5d53c482016-03-01 23:25:39 -0800756 def runTest(self):
alshabib28c03c32016-03-01 20:33:51 -0800757 logging.info("Testing multiple Q-in-Q rules")
Adminb3bae672016-03-02 13:00:08 -0800758 delete_all_flows(self.controller)
alshabib3f3da0e2016-03-01 23:23:45 -0800759
Zsolt Haraszti5b8b39c2016-03-02 22:25:51 -0800760 self.installEapolRule(onu_port)
alshabib57a536a2016-03-02 13:21:28 -0800761
762 time.sleep(1)
763
Zsolt Harasztid0571402016-03-02 18:40:50 -0800764 self.installDoubleTaggingRules(10, 5, cookie=42, onu=onu_port)
alshabib3f3da0e2016-03-01 23:23:45 -0800765
Adminb3bae672016-03-02 13:00:08 -0800766 time.sleep(1)
alshabib3f3da0e2016-03-01 23:23:45 -0800767
Zsolt Harasztid0571402016-03-02 18:40:50 -0800768 self.installDoubleTaggingRules(10, 30, cookie=50, onu=onu_port2)
alshabib3f3da0e2016-03-01 23:23:45 -0800769
Adminb3bae672016-03-02 13:00:08 -0800770 time.sleep(1)
alshabib3f3da0e2016-03-01 23:23:45 -0800771
772 self.testPacketFlow(10, 5, onu=onu_port)
Adminb3bae672016-03-02 13:00:08 -0800773 self.testPacketFlow(10, 30, onu=onu_port2)
alshabib3f3da0e2016-03-01 23:23:45 -0800774
Adminb3bae672016-03-02 13:00:08 -0800775 delete_all_flows(self.controller)
alshabib28c03c32016-03-01 20:33:51 -0800776
alshabibb9d4ee82016-03-01 14:12:42 -0800777
alshabibd6be76e2016-03-01 22:21:00 -0800778class DoubleVlanTest(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000779
Adminb17b1662015-10-19 15:50:53 -0700780 def runTest(self):
781 logging.info("Running double vlan tests")
782 delete_all_flows(self.controller)
783
784 c_vlan_id = 100
alshabibb9d4ee82016-03-01 14:12:42 -0800785 s_vlan_id = 102
Zsolt Harasztife525502016-03-02 05:18:52 +0000786
alshabibd6be76e2016-03-01 22:21:00 -0800787 self.installDoubleTaggingRules(s_vlan_id, c_vlan_id)
Adminb17b1662015-10-19 15:50:53 -0700788
Adminb17b1662015-10-19 15:50:53 -0700789 # It takes some time for flows to propagate down to the data plane
790 time.sleep(10)
alshabibb9d4ee82016-03-01 14:12:42 -0800791
Zsolt Harasztife525502016-03-02 05:18:52 +0000792 # Test packet flows
alshabib3f3da0e2016-03-01 23:23:45 -0800793 self.testPacketFlow(s_vlan_id, c_vlan_id)
Adminb17b1662015-10-19 15:50:53 -0700794
795 # clean up the test
796 delete_all_flows(self.controller)
797 do_barrier(self.controller)
798 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800799
800
alshabibcde318b2016-03-01 22:49:13 -0800801class TestCyclingDoubleVlan(OltBaseTest):
alshabibb9d4ee82016-03-01 14:12:42 -0800802 """Cycle through vlans and test traffic flow"""
803
804 def runTest(self):
805 logging.info("Running cycling vlan test")
806
alshabib2ecca692016-03-01 15:10:38 -0800807 for stag in xrange(2, 4000, 100):
808 for ctag in xrange(2, 4000, 100):
alshabibf1f07dd2016-03-01 15:50:35 -0800809 delete_all_flows(self.controller)
810 time.sleep(5)
Admin44f754e2016-03-01 23:00:46 -0800811 self.installDoubleTaggingRules(stag, ctag)
alshabibf1f07dd2016-03-01 15:50:35 -0800812 time.sleep(5)
alshabib3f3da0e2016-03-01 23:23:45 -0800813 self.testPacketFlow(stag, ctag)