blob: 13c997afef513384895757eba6857d667dd239c5 [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
12from oftest.testutils import *
13
alshabibed97b5f2016-03-01 23:46:53 -080014from IGMP import IGMPv3, IGMPv3gr, IGMP_TYPE_V3_MEMBERSHIP_REPORT,\
15 IGMP_V3_GR_TYPE_INCLUDE,\
16 IGMP_V3_GR_TYPE_EXCLUDE
Zsolt Harasztife525502016-03-02 05:18:52 +000017
alshabibcde318b2016-03-01 22:49:13 -080018from oltconstants import *
Jonathan Hartf2511ca2015-07-07 14:18:19 -070019
alshabibb9d4ee82016-03-01 14:12:42 -080020
alshabibcde318b2016-03-01 22:49:13 -080021class EapolPacketIn(OltBaseTest):
Jonathan Hartf2511ca2015-07-07 14:18:19 -070022 """Verify packet-ins are sent for EAPOL packets """
alshabibb9d4ee82016-03-01 14:12:42 -080023
Jonathan Hartf2511ca2015-07-07 14:18:19 -070024 def runTest(self):
25 logging.info("Running EAPOL Packet In test")
26
27 match = ofp.match()
28 match.oxm_list.append(ofp.oxm.eth_type(0x888e))
29 # Use ethertype 0x888e and multicast destination MAC address
30 pkt = simple_eth_packet(pktlen=60, eth_dst='01:00:5E:7F:FF:FF', eth_type=0x888e)
alshabibb9d4ee82016-03-01 14:12:42 -080031
alshabibcde318b2016-03-01 22:49:13 -080032 self.testPacketIn(match, pkt)
Jonathan Hartf2511ca2015-07-07 14:18:19 -070033
alshabibb9d4ee82016-03-01 14:12:42 -080034
alshabibcde318b2016-03-01 22:49:13 -080035class ARPPacketIn(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +000036 """Verify packet-ins are sent for ARP packets """
alshabib9929a152016-03-01 21:25:18 -080037
Zsolt Harasztife525502016-03-02 05:18:52 +000038 def runTest(self):
39 logging.info("Running ARP Packet In test")
alshabib9929a152016-03-01 21:25:18 -080040
Zsolt Harasztife525502016-03-02 05:18:52 +000041 match = ofp.match()
42 match.oxm_list.append(ofp.oxm.eth_type(0x0806))
43
44 # Use ethertype 0x0806
45 pkt = simple_eth_packet(eth_type=0x0806)
46
alshabibcde318b2016-03-01 22:49:13 -080047 self.testPacketIn(match, pkt)
alshabib9929a152016-03-01 21:25:18 -080048
49
alshabibcde318b2016-03-01 22:49:13 -080050class IGMPPacketIn(OltBaseTest):
Jonathan Hartf2511ca2015-07-07 14:18:19 -070051 """Verify packet-ins are sent for IGMP packets """
alshabibb9d4ee82016-03-01 14:12:42 -080052
Jonathan Hartf2511ca2015-07-07 14:18:19 -070053 def runTest(self):
54 logging.info("Running IGMP Packet In test")
55
56 match = ofp.match()
57 match.oxm_list.append(ofp.oxm.eth_type(0x800))
58 match.oxm_list.append(ofp.oxm.ip_proto(2))
Jonathan Hartf2511ca2015-07-07 14:18:19 -070059
Zsolt Harasztiecf89452016-03-01 22:38:13 -080060 igmp = IGMPv3(type=IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30, gaddr="224.0.0.1")
Admin99a3ed92016-03-02 17:22:50 -080061 igmp.grps = [IGMPv3gr(rtype=IGMP_V3_GR_TYPE_INCLUDE, mcaddr="229.10.20.30")]
62 pkt = IGMPv3.fixup( scapy.Ether(src='00:00:00:00:be:ef', dst='01:00:5e:00:00:01') \
63 / scapy.IP(src='192.168.0.123', dst='224.0.0.22') / igmp )
64 if len(pkt) < 60:
65 pad_len = 60 - len(pkt)
66 pad = scapy.PAD()
67 pad.load = '\x00' * pad_len
68 pkt = pkt/pad
alshabibb9d4ee82016-03-01 14:12:42 -080069
alshabibcde318b2016-03-01 22:49:13 -080070 self.testPacketIn(match, pkt)
Admin7e9c91d2015-08-25 15:53:49 -070071
alshabibb9d4ee82016-03-01 14:12:42 -080072
alshabibcde318b2016-03-01 22:49:13 -080073class IGMPQueryPacketOut(OltBaseTest):
Admind5212782015-12-09 17:17:57 -080074 """Verify sending multicast membership queries down to onu_ports"""
alshabibb9d4ee82016-03-01 14:12:42 -080075
Admind5212782015-12-09 17:17:57 -080076 def runTest(self):
77 logging.info("Running IGMP query packet out")
78
Zsolt Harasztife525502016-03-02 05:18:52 +000079 igmp = IGMPv3() # by default this is a query
Admind5212782015-12-09 17:17:57 -080080 pkt = buildIgmp(igmp)
81
Zsolt Harasztife525502016-03-02 05:18:52 +000082 msg = ofp.message.packet_out(
83 in_port=ofp.OFPP_CONTROLLER,
84 actions=[ofp.action.output(port=onu_port)],
85 buffer_id=ofp.OFP_NO_BUFFER,
86 data=str(pkt))
Admind5212782015-12-09 17:17:57 -080087
alshabibb9d4ee82016-03-01 14:12:42 -080088 self.controller.message_send(msg)
Admind5212782015-12-09 17:17:57 -080089
Zsolt Harasztife525502016-03-02 05:18:52 +000090 rv = self.controller.message_send(msg)
91 self.assertTrue(rv == 0, "Error sending put message")
Admind5212782015-12-09 17:17:57 -080092 verify_no_errors(self.controller)
93
94 verify_packet(self, pkt, onu_port)
95
alshabibb9d4ee82016-03-01 14:12:42 -080096
alshabibcde318b2016-03-01 22:49:13 -080097class TestMeter(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +000098
Admin7e9c91d2015-08-25 15:53:49 -070099 def runTest(self):
100 logging.info("Running Meter tests")
alshabibb9d4ee82016-03-01 14:12:42 -0800101 dropMeterBand = ofp.meter_band.drop(rate=640)
102 meter_mod = ofp.message.meter_mod(xid=1, command=ofp.OFPMC_ADD, meter_id=1, meters=[dropMeterBand])
Admin7e9c91d2015-08-25 15:53:49 -0700103 self.controller.message_send(meter_mod)
alshabibb9d4ee82016-03-01 14:12:42 -0800104
Admin7e9c91d2015-08-25 15:53:49 -0700105 time.sleep(1)
106
107 verify_no_errors(self.controller)
108
Jonathan Hartf65e1812015-10-05 15:15:37 -0700109 vlan_id = 201
Admin7e9c91d2015-08-25 15:53:49 -0700110 match = ofp.match()
111 match.oxm_list.append(ofp.oxm.in_port(onu_port))
alshabibb9d4ee82016-03-01 14:12:42 -0800112 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
Admin02d052c2015-10-10 19:08:26 -0700113
114 request = ofp.message.flow_add(
115 table_id=test_param_get("table", 0),
116 cookie=42,
117 match=match,
118 instructions=[
119 ofp.instruction.apply_actions(
Zsolt Harasztife525502016-03-02 05:18:52 +0000120 actions=[ofp.action.output(port=olt_port)]),
121 ofp.instruction.meter(meter_id = 1)
alshabibb9d4ee82016-03-01 14:12:42 -0800122 ],
Admin02d052c2015-10-10 19:08:26 -0700123 buffer_id=ofp.OFP_NO_BUFFER,
124 priority=1000)
125
126 self.controller.message_send(request)
127 time.sleep(1)
128 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800129
Admin02d052c2015-10-10 19:08:26 -0700130 match = ofp.match()
131 match.oxm_list.append(ofp.oxm.in_port(olt_port))
132 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
Admin7e9c91d2015-08-25 15:53:49 -0700133
134 request = ofp.message.flow_add(
135 table_id=test_param_get("table", 0),
136 cookie=43,
137 match=match,
138 instructions=[
139 ofp.instruction.apply_actions(
Zsolt Harasztife525502016-03-02 05:18:52 +0000140 actions=[ofp.action.output(port=onu_port)]),
141 ofp.instruction.meter(meter_id = 1)
alshabibb9d4ee82016-03-01 14:12:42 -0800142 ],
Admin7e9c91d2015-08-25 15:53:49 -0700143 buffer_id=ofp.OFP_NO_BUFFER,
144 priority=1000)
145
146 self.controller.message_send(request)
Admin7e9c91d2015-08-25 15:53:49 -0700147 time.sleep(1)
Admin7e9c91d2015-08-25 15:53:49 -0700148 verify_no_errors(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700149 do_barrier(self.controller)
150 time.sleep(5)
alshabibb9d4ee82016-03-01 14:12:42 -0800151
Jonathan Hartf65e1812015-10-05 15:15:37 -0700152 inPkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=vlan_id, vlan_pcp=0)
153 # downstream
alshabibb9d4ee82016-03-01 14:12:42 -0800154 # self.dataplane.send(olt_port, str(inPkt))
155 # verify_packet(self, inPkt, onu_port)
Admin02d052c2015-10-10 19:08:26 -0700156 # upstream
alshabibb9d4ee82016-03-01 14:12:42 -0800157 # for i in range(1,400):
158 # self.dataplane.send(onu_port, str(inPkt))
159 # verify_packet(self, inPkt, olt_port)
Admin02d052c2015-10-10 19:08:26 -0700160
Jonathan Hartf65e1812015-10-05 15:15:37 -0700161 # clean up the test
alshabibb9d4ee82016-03-01 14:12:42 -0800162 meter_mod = ofp.message.meter_mod(xid=2, command=ofp.OFPMC_DELETE, meter_id=1)
Admin02d052c2015-10-10 19:08:26 -0700163 self.controller.message_send(meter_mod)
164 time.sleep(1)
165 delete_all_flows(self.controller)
166 verify_no_errors(self.controller)
167
Admin7e9c91d2015-08-25 15:53:49 -0700168
alshabibcde318b2016-03-01 22:49:13 -0800169class TestDuplicateMeter(OltBaseTest):
Admin7e9c91d2015-08-25 15:53:49 -0700170 def runTest(self):
171 logging.info("Running Duplicate Meter Test")
alshabibb9d4ee82016-03-01 14:12:42 -0800172 dropMeterBand = ofp.meter_band.drop(rate=500)
173 meter_mod = ofp.message.meter_mod(xid=1, command=ofp.OFPMC_ADD, meter_id=1, meters=[dropMeterBand])
Admin7e9c91d2015-08-25 15:53:49 -0700174 self.controller.message_send(meter_mod)
175 self.controller.message_send(meter_mod)
176
177 time.sleep(1)
alshabibb9d4ee82016-03-01 14:12:42 -0800178
Admin7e9c91d2015-08-25 15:53:49 -0700179 try:
180 verify_no_errors(self.controller)
181 except AssertionError as e:
Admin09b5cc62015-10-11 13:53:59 -0700182 if (not e.message == "unexpected error type=12 code=1"):
Admin7e9c91d2015-08-25 15:53:49 -0700183 raise AssertionError("Incorrect error type: %s" % e.message)
alshabibb9d4ee82016-03-01 14:12:42 -0800184
185
alshabibcde318b2016-03-01 22:49:13 -0800186class VlanTest(OltBaseTest):
Admin7e9c91d2015-08-25 15:53:49 -0700187 """Verify the switch can push/pop a VLAN tag and forward out a port """
alshabibb9d4ee82016-03-01 14:12:42 -0800188
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700189 def runTest(self):
190 logging.info("Running push VLAN test")
alshabibb9d4ee82016-03-01 14:12:42 -0800191
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700192 vlan_id = 200
alshabibb9d4ee82016-03-01 14:12:42 -0800193
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700194 delete_all_flows(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800195
196 # PUSH
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700197 match = ofp.match()
198 match.oxm_list.append(ofp.oxm.in_port(onu_port))
Zsolt Harasztife525502016-03-02 05:18:52 +0000199 if device_type == "cpqd":
200 match.oxm_list.append(ofp.oxm.vlan_vid(value=ofp.OFPVID_NONE))
201 actions = [
202 ofp.action.push_vlan(ethertype=0x8100),
203 ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id)),
204 ofp.action.set_field(ofp.oxm.vlan_pcp(0)),
205 ofp.action.output(port=olt_port)
206 ]
207 else: # pmc, normal
208 match.oxm_list.append(ofp.oxm.vlan_vid_masked(value=ofp.OFPVID_PRESENT, value_mask=ofp.OFPVID_PRESENT))
209 match.oxm_list.append(ofp.oxm.vlan_pcp(value = 0))
210 actions = [
211 ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id)),
212 ofp.action.set_field(ofp.oxm.vlan_pcp(0)),
213 ofp.action.output(port=olt_port)
214 ]
alshabibb9d4ee82016-03-01 14:12:42 -0800215
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700216 request = ofp.message.flow_add(
217 table_id=test_param_get("table", 0),
218 cookie=42,
219 match=match,
Zsolt Harasztife525502016-03-02 05:18:52 +0000220 instructions=[ofp.instruction.apply_actions(actions=actions)],
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700221 buffer_id=ofp.OFP_NO_BUFFER,
222 priority=1000)
223
Admin7e9c91d2015-08-25 15:53:49 -0700224 logging.info("Inserting flow tagging upstream")
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700225 self.controller.message_send(request)
Zsolt Harasztife525502016-03-02 05:18:52 +0000226 do_barrier(self.controller)
227 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800228
229 # POP
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700230 match = ofp.match()
231 match.oxm_list.append(ofp.oxm.in_port(olt_port))
232 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
Admin7e9c91d2015-08-25 15:53:49 -0700233
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700234 request = ofp.message.flow_add(
235 table_id=test_param_get("table", 0),
Admin7e9c91d2015-08-25 15:53:49 -0700236 cookie=43,
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700237 match=match,
238 instructions=[
239 ofp.instruction.apply_actions(
Jonathan Hartf65e1812015-10-05 15:15:37 -0700240 actions=[
241 ofp.action.pop_vlan(),
alshabibb9d4ee82016-03-01 14:12:42 -0800242 ofp.action.output(port=onu_port)])],
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700243 buffer_id=ofp.OFP_NO_BUFFER,
244 priority=1000)
245
Admin7e9c91d2015-08-25 15:53:49 -0700246 logging.info("Inserting flow tagging downstream")
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700247 self.controller.message_send(request)
248 do_barrier(self.controller)
Zsolt Harasztife525502016-03-02 05:18:52 +0000249 verify_no_errors(self.controller)
250
Admin7e9c91d2015-08-25 15:53:49 -0700251 time.sleep(5)
Admin99c2a272016-03-01 12:56:39 -0800252
Admin7e9c91d2015-08-25 15:53:49 -0700253 inPkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=0, vlan_pcp=0)
alshabibb9d4ee82016-03-01 14:12:42 -0800254 outPkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True,
Admin7e9c91d2015-08-25 15:53:49 -0700255 vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0)
alshabibb9d4ee82016-03-01 14:12:42 -0800256
Admin7e9c91d2015-08-25 15:53:49 -0700257 # Send untagged packet in the ONU port and expect tagged packet out the OLT port
258 self.dataplane.send(onu_port, str(inPkt))
259 verify_packet(self, outPkt, olt_port)
alshabibb9d4ee82016-03-01 14:12:42 -0800260
Admin7e9c91d2015-08-25 15:53:49 -0700261 # Send untagged packet in the OLT port and expect no packets to come out
262 self.dataplane.send(olt_port, str(inPkt))
263 verify_packets(self, outPkt, [])
alshabibb9d4ee82016-03-01 14:12:42 -0800264
Admin7e9c91d2015-08-25 15:53:49 -0700265 inPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True,
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700266 vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0)
Zsolt Harasztife525502016-03-02 05:18:52 +0000267 if device_type == 'pmc':
268 outPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=0, vlan_pcp=0)
269 else: # "normal", "cpqd""
270 outPkt = simple_udp_packet(pktlen=100)
Admin7e9c91d2015-08-25 15:53:49 -0700271
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700272 # Send tagged packet in the OLT port and expect untagged packet out the OLT port
273 self.dataplane.send(olt_port, str(inPkt))
274 verify_packet(self, outPkt, onu_port)
Admin7e9c91d2015-08-25 15:53:49 -0700275
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700276 # Send tagged packet in the ONU port and expect no packets to come out
277 self.dataplane.send(onu_port, str(inPkt))
Admin7e9c91d2015-08-25 15:53:49 -0700278 verify_packets(self, outPkt, [])
Jonathan Hartf65e1812015-10-05 15:15:37 -0700279
alshabibb9d4ee82016-03-01 14:12:42 -0800280
Jonathan Hartf65e1812015-10-05 15:15:37 -0700281
alshabibb9d4ee82016-03-01 14:12:42 -0800282
alshabibb9d4ee82016-03-01 14:12:42 -0800283
alshabibcde318b2016-03-01 22:49:13 -0800284class TestGroupAdd(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000285
Admin02d052c2015-10-10 19:08:26 -0700286 def runTest(self):
287 logging.info("Running Group tests")
288 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700289 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700290
alshabibb9d4ee82016-03-01 14:12:42 -0800291 test_group_id = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700292
293 # output to two ONU
294 group_add = createAllGroupAdd(test_group_id, ports=[onu_port, onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700295
296 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700297 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700298 verify_no_errors(self.controller)
299
300 # Remove the group and then readd it.
alshabibb9d4ee82016-03-01 14:12:42 -0800301 group_delete = ofp.message.group_delete(group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700302 self.controller.message_send(group_delete)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700303 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700304 verify_no_errors(self.controller)
305
Jonathan Hartf65e1812015-10-05 15:15:37 -0700306 group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700307 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700308 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700309 verify_no_errors(self.controller)
310
311
Jonathan Hartf65e1812015-10-05 15:15:37 -0700312 # clean up the test
alshabibb9d4ee82016-03-01 14:12:42 -0800313 group_delete = ofp.message.group_delete(group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700314 self.controller.message_send(group_delete)
alshabibb9d4ee82016-03-01 14:12:42 -0800315
Jonathan Hartf65e1812015-10-05 15:15:37 -0700316 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700317 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800318
319
alshabibcde318b2016-03-01 22:49:13 -0800320class TestGroupMod(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000321
Admin02d052c2015-10-10 19:08:26 -0700322 def runTest(self):
323 logging.info("Running Group tests")
324 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700325 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700326
alshabibb9d4ee82016-03-01 14:12:42 -0800327 test_group_id = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700328
329 group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700330
331 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700332 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700333 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800334
Jonathan Hartf65e1812015-10-05 15:15:37 -0700335 # Modifying the group
336 group_mod = createAllGroupMod(test_group_id, [onu_port2])
alshabibb9d4ee82016-03-01 14:12:42 -0800337
Jonathan Hartf65e1812015-10-05 15:15:37 -0700338 self.controller.message_send(group_mod)
339 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700340 verify_no_errors(self.controller)
341
Jonathan Hartf65e1812015-10-05 15:15:37 -0700342 # Add a bucket into the group
343 group_mod = createAllGroupMod(test_group_id, [onu_port, onu_port2])
344 self.controller.message_send(group_mod)
345 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700346 verify_no_errors(self.controller)
347
348 # Modifying a non-existing group
Jonathan Hartf65e1812015-10-05 15:15:37 -0700349 group_mod = createAllGroupMod(777, [onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700350
Jonathan Hartf65e1812015-10-05 15:15:37 -0700351 self.controller.message_send(group_mod)
352 do_barrier(self.controller)
353 errorExperienced = 0
Admin02d052c2015-10-10 19:08:26 -0700354 try:
355 verify_no_errors(self.controller)
356 except AssertionError as e:
Jonathan Hartf65e1812015-10-05 15:15:37 -0700357 errorExperienced = 1
Admin02d052c2015-10-10 19:08:26 -0700358 if (not (e.message == "unexpected error type=6 code=8")):
Jonathan Hartf65e1812015-10-05 15:15:37 -0700359 raise AssertionError("Incorrect error type: %s" % e.message)
alshabibb9d4ee82016-03-01 14:12:42 -0800360 if not errorExperienced:
Jonathan Hartf65e1812015-10-05 15:15:37 -0700361 raise AssertionError("An error message is expected, but not shown.")
alshabibb9d4ee82016-03-01 14:12:42 -0800362
363
Jonathan Hartf65e1812015-10-05 15:15:37 -0700364 # clean up the test
alshabibb9d4ee82016-03-01 14:12:42 -0800365 group_delete = ofp.message.group_delete(xid=2, group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700366 self.controller.message_send(group_delete)
alshabibb9d4ee82016-03-01 14:12:42 -0800367
Jonathan Hartf65e1812015-10-05 15:15:37 -0700368 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700369 verify_no_errors(self.controller)
370
alshabibb9d4ee82016-03-01 14:12:42 -0800371
alshabibcde318b2016-03-01 22:49:13 -0800372class TestDuplicateGroup(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000373
Admin02d052c2015-10-10 19:08:26 -0700374 def runTest(self):
375 logging.info("Running Group tests")
376 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700377 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700378
alshabibb9d4ee82016-03-01 14:12:42 -0800379 test_group_id = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700380 group_add = createAllGroupAdd(test_group_id, ports=[onu_port])
Admin02d052c2015-10-10 19:08:26 -0700381
382 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700383 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700384 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800385
Jonathan Hartf65e1812015-10-05 15:15:37 -0700386 # Add the same group id
alshabibb9d4ee82016-03-01 14:12:42 -0800387 duplicate_group_fail = 0
388
Admin02d052c2015-10-10 19:08:26 -0700389 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700390 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700391 try:
392 verify_no_errors(self.controller)
393 except AssertionError as e:
alshabibb9d4ee82016-03-01 14:12:42 -0800394 duplicate_group_fail = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700395 if (not e.message == "unexpected error type=6 code=0"):
396 raise AssertionError("Incorrect error type: %s" % e.message)
397 if not duplicate_group_fail:
398 raise AssertionError("Adding duplicate groups didn't raise an error.")
alshabibb9d4ee82016-03-01 14:12:42 -0800399
Jonathan Hartf65e1812015-10-05 15:15:37 -0700400 # clean up the test
alshabibb9d4ee82016-03-01 14:12:42 -0800401 group_delete = ofp.message.group_delete(xid=2, group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700402 self.controller.message_send(group_delete)
alshabibb9d4ee82016-03-01 14:12:42 -0800403
Jonathan Hartf65e1812015-10-05 15:15:37 -0700404 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700405 verify_no_errors(self.controller)
406
alshabibb9d4ee82016-03-01 14:12:42 -0800407
alshabibcde318b2016-03-01 22:49:13 -0800408class TestGroupAndFlow(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000409
Admin02d052c2015-10-10 19:08:26 -0700410 def runTest(self):
411 logging.info("Running Group tests")
412 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700413 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700414
Jonathan Hartf65e1812015-10-05 15:15:37 -0700415 # Create a group
alshabibb9d4ee82016-03-01 14:12:42 -0800416 test_group_id = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700417 group_add = createAllGroupAdd(test_group_id, ports=[onu_port])
Admin02d052c2015-10-10 19:08:26 -0700418
419 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700420 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700421 verify_no_errors(self.controller)
422
423 # Create a flow rule matching olt port and vlan id
424 match = ofp.match()
425 match.oxm_list.append(ofp.oxm.in_port(olt_port))
426 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | 201))
427
Jonathan Hartf65e1812015-10-05 15:15:37 -0700428 flow_pointing_to_group = ofp.message.flow_add(
Admin02d052c2015-10-10 19:08:26 -0700429 table_id=test_param_get("table", 0),
430 cookie=43,
431 match=match,
432 instructions=[
433 ofp.instruction.apply_actions(
alshabibb9d4ee82016-03-01 14:12:42 -0800434 actions=[ofp.action.group(group_id=test_group_id)])],
435 buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
Admin02d052c2015-10-10 19:08:26 -0700436
Jonathan Hartf65e1812015-10-05 15:15:37 -0700437 self.controller.message_send(flow_pointing_to_group)
438 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700439 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800440
Jonathan Hartf65e1812015-10-05 15:15:37 -0700441 # After letting a flow rule point to the group, test we can do group_mod
442 group_mod = createAllGroupMod(test_group_id, ports=[onu_port2])
443 self.controller.message_send(group_mod)
444 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700445 verify_no_errors(self.controller)
446
447 # Test we can remove flows and then remove group
alshabibb9d4ee82016-03-01 14:12:42 -0800448 flow_delete = ofp.message.flow_delete(table_id=test_param_get("table", 0))
Jonathan Hartf65e1812015-10-05 15:15:37 -0700449 self.controller.message_send(flow_delete)
450 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700451 verify_no_errors(self.controller)
452
alshabibb9d4ee82016-03-01 14:12:42 -0800453 group_delete = ofp.message.group_delete(xid=3, group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700454 self.controller.message_send(group_delete)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700455 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700456 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800457
Zsolt Harasztife525502016-03-02 05:18:52 +0000458 # Add the group and flow back, test it we can first remove group and then remove the flow.
Admindcb1bc72015-11-12 18:24:56 -0800459 '''group_add = createAllGroupAdd(test_group_id, ports=[onu_port])
Admin02d052c2015-10-10 19:08:26 -0700460 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700461
462 self.controller.message_send(flow_pointing_to_group)
463 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700464 verify_no_errors(self.controller)
465
466 group_delete = ofp.message.group_delete(xid = 4, group_id = test_group_id)
Admindcb1bc72015-11-12 18:24:56 -0800467 self.controller.message_send(group_delete)'''
Jonathan Hartf65e1812015-10-05 15:15:37 -0700468
469 self.controller.message_send(flow_delete)
470 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700471 verify_no_errors(self.controller)
472
473
alshabibcde318b2016-03-01 22:49:13 -0800474class TestGroupForwarding(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000475
Admin02d052c2015-10-10 19:08:26 -0700476 def runTest(self):
477 logging.info("Running Group datapath forwarding tests")
478 delete_all_flows(self.controller)
Admin99c2a272016-03-01 12:56:39 -0800479 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700480
Admin09b5cc62015-10-11 13:53:59 -0700481 vlan_id = 201
Admin02d052c2015-10-10 19:08:26 -0700482
Jonathan Hartf65e1812015-10-05 15:15:37 -0700483 # Create a group
alshabibb9d4ee82016-03-01 14:12:42 -0800484 test_group_id = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700485 group_add = createAllGroupAdd(test_group_id, [onu_port])
Admin02d052c2015-10-10 19:08:26 -0700486
487 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700488 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700489 verify_no_errors(self.controller)
490
491 # Create a flow rule matching olt port and vlan id
492 match = ofp.match()
493 match.oxm_list.append(ofp.oxm.in_port(olt_port))
494 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
495
496 request = ofp.message.flow_add(
497 table_id=test_param_get("table", 0),
498 cookie=43,
499 match=match,
500 instructions=[
501 ofp.instruction.apply_actions(
alshabibb9d4ee82016-03-01 14:12:42 -0800502 actions=[ofp.action.group(group_id=test_group_id)]),
503 ],
504 buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
Admin02d052c2015-10-10 19:08:26 -0700505
506 self.controller.message_send(request)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700507 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700508 verify_no_errors(self.controller)
Admin09b5cc62015-10-11 13:53:59 -0700509
510 # It takes some time for flows to propagate down to the data plane
Admindcb1bc72015-11-12 18:24:56 -0800511 time.sleep(10)
alshabibb9d4ee82016-03-01 14:12:42 -0800512
513 inPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True,
Admindcb1bc72015-11-12 18:24:56 -0800514 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 -0700515 outPkt = inPkt
516 self.dataplane.send(olt_port, str(inPkt))
517 verify_packet(self, outPkt, onu_port)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700518
Admindcb1bc72015-11-12 18:24:56 -0800519
Zsolt Harasztife525502016-03-02 05:18:52 +0000520 # Now put 2 ONU ports in the group and test that the input packet is
Jonathan Hartf65e1812015-10-05 15:15:37 -0700521 # duplicated out both ports
522 group_mod = createAllGroupMod(test_group_id, ports=[onu_port, onu_port2])
523 self.controller.message_send(group_mod)
524 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700525 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800526
Admin09b5cc62015-10-11 13:53:59 -0700527 # It takes some time for flows to propagate down to the data plane
Admindcb1bc72015-11-12 18:24:56 -0800528 time.sleep(10)
Admin09b5cc62015-10-11 13:53:59 -0700529
Jonathan Hartf65e1812015-10-05 15:15:37 -0700530 self.dataplane.send(olt_port, str(inPkt))
Jonathan Hartf65e1812015-10-05 15:15:37 -0700531 verify_packet(self, outPkt, onu_port2)
Admindcb1bc72015-11-12 18:24:56 -0800532 verify_packet(self, outPkt, onu_port)
alshabibb9d4ee82016-03-01 14:12:42 -0800533 # verify_packets(self, outPkt, [onu_port,onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700534
Jonathan Hartf65e1812015-10-05 15:15:37 -0700535 # clean up the test
alshabibb9d4ee82016-03-01 14:12:42 -0800536 request = ofp.message.flow_delete(table_id=test_param_get("table", 0))
Admin02d052c2015-10-10 19:08:26 -0700537 self.controller.message_send(request)
alshabibb9d4ee82016-03-01 14:12:42 -0800538 group_delete = ofp.message.group_delete(xid=2, group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700539 self.controller.message_send(group_delete)
alshabibb9d4ee82016-03-01 14:12:42 -0800540
Jonathan Hartf65e1812015-10-05 15:15:37 -0700541 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700542 verify_no_errors(self.controller)
543
Admindcb1bc72015-11-12 18:24:56 -0800544
alshabibcde318b2016-03-01 22:49:13 -0800545class TestGroupModForwarding(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000546
Admindcb1bc72015-11-12 18:24:56 -0800547 def runTest(self):
alshabibb9d4ee82016-03-01 14:12:42 -0800548 logging.info("Running datapath forwarding tests for group mod")
Admindcb1bc72015-11-12 18:24:56 -0800549 delete_all_flows(self.controller)
550 delete_all_groups(self.controller)
551
552 vlan_id = 201
553
554 # Create a group
alshabibb9d4ee82016-03-01 14:12:42 -0800555 test_group_id = 1
Admindcb1bc72015-11-12 18:24:56 -0800556 group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2])
557
558 self.controller.message_send(group_add)
559 do_barrier(self.controller)
560 verify_no_errors(self.controller)
561
562 # Create a flow rule matching olt port and vlan id
563 match = ofp.match()
564 match.oxm_list.append(ofp.oxm.in_port(olt_port))
565 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
566
567 request = ofp.message.flow_add(
568 table_id=test_param_get("table", 0),
569 cookie=43,
570 match=match,
571 instructions=[
572 ofp.instruction.apply_actions(
alshabibb9d4ee82016-03-01 14:12:42 -0800573 actions=[ofp.action.group(group_id=test_group_id)]),
574 ],
575 buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
Admindcb1bc72015-11-12 18:24:56 -0800576
577 self.controller.message_send(request)
578 do_barrier(self.controller)
579 verify_no_errors(self.controller)
580
581 # It takes some time for flows to propagate down to the data plane
582 time.sleep(10)
alshabibb9d4ee82016-03-01 14:12:42 -0800583
584 inPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True,
Admindcb1bc72015-11-12 18:24:56 -0800585 vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0, eth_dst="01:01:11:12:11:12")
586 outPkt = inPkt
587 self.dataplane.send(olt_port, str(inPkt))
588 verify_packet(self, outPkt, onu_port)
Admin99c2a272016-03-01 12:56:39 -0800589 verify_packet(self, outPkt, onu_port2)
Admindcb1bc72015-11-12 18:24:56 -0800590
591 # Now remove onu port 1 from the group and test that the input packet is no longer forwarded to onu port 1
592 group_mod = createAllGroupMod(test_group_id, ports=[onu_port2])
593 self.controller.message_send(group_mod)
594 do_barrier(self.controller)
595 verify_no_errors(self.controller)
596
597 time.sleep(10)
598 self.dataplane.send(olt_port, str(inPkt))
599 verify_no_packet(self, outPkt, onu_port)
600 verify_packet(self, outPkt, onu_port2)
601
Zsolt Harasztife525502016-03-02 05:18:52 +0000602 # 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 -0800603 group_mod = createAllGroupMod(test_group_id, ports=[])
604 self.controller.message_send(group_mod)
605 do_barrier(self.controller)
606 verify_no_errors(self.controller)
607 time.sleep(10)
608 self.dataplane.send(olt_port, str(inPkt))
609 verify_packets(self, outPkt, [])
610
611
alshabibcde318b2016-03-01 22:49:13 -0800612class TransparentVlanTest(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000613
Admin02d052c2015-10-10 19:08:26 -0700614 def runTest(self):
615 logging.info("Running transparent vlan tests")
Admin09b5cc62015-10-11 13:53:59 -0700616 delete_all_flows(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700617
Jonathan Hartf65e1812015-10-05 15:15:37 -0700618 vlan_id = 201
Admin02d052c2015-10-10 19:08:26 -0700619 match = ofp.match()
620 match.oxm_list.append(ofp.oxm.in_port(onu_port))
alshabibb9d4ee82016-03-01 14:12:42 -0800621 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
Admin02d052c2015-10-10 19:08:26 -0700622
623 request = ofp.message.flow_add(
624 table_id=test_param_get("table", 0),
625 cookie=42,
626 match=match,
627 instructions=[
628 ofp.instruction.apply_actions(
629 actions=[
630 ofp.action.output(port=olt_port)]),
alshabibb9d4ee82016-03-01 14:12:42 -0800631 ],
Admin02d052c2015-10-10 19:08:26 -0700632 buffer_id=ofp.OFP_NO_BUFFER,
633 priority=1000)
634
635 self.controller.message_send(request)
alshabibb9d4ee82016-03-01 14:12:42 -0800636
Admin02d052c2015-10-10 19:08:26 -0700637 match = ofp.match()
638 match.oxm_list.append(ofp.oxm.in_port(olt_port))
639 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
640
641 request = ofp.message.flow_add(
642 table_id=test_param_get("table", 0),
643 cookie=43,
644 match=match,
645 instructions=[
646 ofp.instruction.apply_actions(
647 actions=[
648 ofp.action.output(port=onu_port)]),
alshabibb9d4ee82016-03-01 14:12:42 -0800649 ],
Admin02d052c2015-10-10 19:08:26 -0700650 buffer_id=ofp.OFP_NO_BUFFER,
651 priority=1000)
652
653 self.controller.message_send(request)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700654 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700655 verify_no_errors(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700656
Admin09b5cc62015-10-11 13:53:59 -0700657 # It takes some time for flows to propagate down to the data plane
658 time.sleep(2)
alshabibb9d4ee82016-03-01 14:12:42 -0800659
Jonathan Hartf65e1812015-10-05 15:15:37 -0700660 inPkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=vlan_id, vlan_pcp=0)
Zsolt Harasztife525502016-03-02 05:18:52 +0000661
Admin02d052c2015-10-10 19:08:26 -0700662 # upstream
663 self.dataplane.send(onu_port, str(inPkt))
664 verify_packet(self, inPkt, olt_port)
Zsolt Harasztife525502016-03-02 05:18:52 +0000665
Admin99c2a272016-03-01 12:56:39 -0800666 # downstream
667 self.dataplane.send(olt_port, str(inPkt))
668 verify_packet(self, inPkt, onu_port)
Admin02d052c2015-10-10 19:08:26 -0700669
Jonathan Hartf65e1812015-10-05 15:15:37 -0700670 # clean up the test
Admin02d052c2015-10-10 19:08:26 -0700671 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700672 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700673 verify_no_errors(self.controller)
674
alshabibed97b5f2016-03-01 23:46:53 -0800675class TestMulticastForwarding(IGMPPacketIn):
676
677 def runTest(self):
678 delete_all_groups(self.controller)
679 # send igmp join packet
680 super(TestMulticastForwarding, self).runTest()
681
682 vlan_id = 201
683
alshabibc49e69c2016-03-01 23:49:25 -0800684 group = createAllGroupAdd(1, [onu_port])
alshabibed97b5f2016-03-01 23:46:53 -0800685
alshabib23f0e372016-03-01 23:50:37 -0800686 self.controller.message_send(group)
alshabibed97b5f2016-03-01 23:46:53 -0800687 do_barrier(self.controller)
688 verify_no_errors(self.controller)
689
690 # Create a flow rule matching olt port and vlan id
691 match = ofp.match()
692 match.oxm_list.append(ofp.oxm.in_port(olt_port))
693 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
694
695 request = ofp.message.flow_add(
696 table_id=test_param_get("table", 0),
697 cookie=43,
698 match=match,
699 instructions=[
700 ofp.instruction.apply_actions(
701 actions=[ofp.action.group(group_id=1)]),
702 ],
703 buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
704
705 self.controller.message_send(request)
706 do_barrier(self.controller)
707 verify_no_errors(self.controller)
708
709 # It takes some time for flows to propagate down to the data plane
710 time.sleep(5)
711
712 pkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=vlan_id, vlan_pcp=0, \
Admin99a3ed92016-03-02 17:22:50 -0800713 eth_dst = "01:00:5e:0a:14:1e", ip_dst = "229.10.20.30")
alshabibed97b5f2016-03-01 23:46:53 -0800714
715 # downstream
716 self.dataplane.send(olt_port, str(pkt))
717 verify_packet(self, pkt, onu_port)
718
719 # clean up the test
720 delete_all_flows(self.controller)
721 do_barrier(self.controller)
722 verify_no_errors(self.controller)
723 delete_all_groups(self.controller)
724
725
alshabibcde318b2016-03-01 22:49:13 -0800726class RemoveRuleTest(OltBaseTest):
alshabib28c03c32016-03-01 20:33:51 -0800727
728 def runTest(self):
729 logging.info("Testing Rule removal")
alshabibe165af22016-03-01 21:42:17 -0800730 delete_all_flows(self.controller)
Admin44f754e2016-03-01 23:00:46 -0800731 self.processEapolRule(onu_port)
alshabibe165af22016-03-01 21:42:17 -0800732
alshabib9929a152016-03-01 21:25:18 -0800733 #wait for the rule to settle
734 time.sleep(3)
735
Admin44f754e2016-03-01 23:00:46 -0800736 self.installDoubleTaggingRules(1, 2)
alshabibe165af22016-03-01 21:42:17 -0800737
alshabib9929a152016-03-01 21:25:18 -0800738 #wait for the rules to settle
739 time.sleep(3)
740
741 stats = get_flow_stats(self, ofp.match())
742
Admin53e10b62016-03-01 21:52:18 -0800743 self.assertTrue(len(stats) == 5, \
744 "Wrong number of rules reports; reported %s, expected 5\n\n %s" % (len(stats), stats))
alshabib9929a152016-03-01 21:25:18 -0800745
Admin44f754e2016-03-01 23:00:46 -0800746 self.processEapolRule(onu_port, install = False)
alshabib9929a152016-03-01 21:25:18 -0800747 time.sleep(3)
748
749 stats = get_flow_stats(self, ofp.match())
750
Admin53e10b62016-03-01 21:52:18 -0800751 self.assertTrue(len(stats) == 4, \
752 "Wrong number of rules reports; reported %s, expected 4\n\n %s" % (len(stats), stats))
alshabib9929a152016-03-01 21:25:18 -0800753
alshabibd6be76e2016-03-01 22:21:00 -0800754 eapol = ofp.oxm.eth_type(0x888e)
755 found = False
756 for fe in stats:
757 if eapol in fe.match.oxm_list:
758 found = True
759
760 self.assertFalse(found, "Removed incorrect flow rule")
alshabib28c03c32016-03-01 20:33:51 -0800761
762
alshabibb5a09bc2016-03-02 13:26:43 -0800763class MultipleDoubleTaggingForwarding(OltBaseTest):
alshabib28c03c32016-03-01 20:33:51 -0800764
alshabib5d53c482016-03-01 23:25:39 -0800765 def runTest(self):
alshabib28c03c32016-03-01 20:33:51 -0800766 logging.info("Testing multiple Q-in-Q rules")
Adminb3bae672016-03-02 13:00:08 -0800767 delete_all_flows(self.controller)
alshabib3f3da0e2016-03-01 23:23:45 -0800768
alshabibb5a09bc2016-03-02 13:26:43 -0800769 self.processEapolRule(onu_port)
alshabib57a536a2016-03-02 13:21:28 -0800770
771 time.sleep(1)
772
alshabib3f3da0e2016-03-01 23:23:45 -0800773 self.installDoubleTaggingRules(10, 5, cookie=42, onu = onu_port)
774
Adminb3bae672016-03-02 13:00:08 -0800775 time.sleep(1)
alshabib3f3da0e2016-03-01 23:23:45 -0800776
Adminb3bae672016-03-02 13:00:08 -0800777 self.installDoubleTaggingRules(10, 30, cookie=50, onu = onu_port2)
alshabib3f3da0e2016-03-01 23:23:45 -0800778
Adminb3bae672016-03-02 13:00:08 -0800779 time.sleep(1)
alshabib3f3da0e2016-03-01 23:23:45 -0800780
781 self.testPacketFlow(10, 5, onu=onu_port)
Adminb3bae672016-03-02 13:00:08 -0800782 self.testPacketFlow(10, 30, onu=onu_port2)
alshabib3f3da0e2016-03-01 23:23:45 -0800783
Adminb3bae672016-03-02 13:00:08 -0800784 delete_all_flows(self.controller)
alshabib28c03c32016-03-01 20:33:51 -0800785
alshabibb9d4ee82016-03-01 14:12:42 -0800786
alshabibd6be76e2016-03-01 22:21:00 -0800787class DoubleVlanTest(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000788
Adminb17b1662015-10-19 15:50:53 -0700789 def runTest(self):
790 logging.info("Running double vlan tests")
791 delete_all_flows(self.controller)
792
793 c_vlan_id = 100
alshabibb9d4ee82016-03-01 14:12:42 -0800794 s_vlan_id = 102
Zsolt Harasztife525502016-03-02 05:18:52 +0000795
alshabibd6be76e2016-03-01 22:21:00 -0800796 self.installDoubleTaggingRules(s_vlan_id, c_vlan_id)
Adminb17b1662015-10-19 15:50:53 -0700797
Adminb17b1662015-10-19 15:50:53 -0700798 # It takes some time for flows to propagate down to the data plane
799 time.sleep(10)
alshabibb9d4ee82016-03-01 14:12:42 -0800800
Zsolt Harasztife525502016-03-02 05:18:52 +0000801 # Test packet flows
alshabib3f3da0e2016-03-01 23:23:45 -0800802 self.testPacketFlow(s_vlan_id, c_vlan_id)
Adminb17b1662015-10-19 15:50:53 -0700803
804 # clean up the test
805 delete_all_flows(self.controller)
806 do_barrier(self.controller)
807 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800808
809
alshabibcde318b2016-03-01 22:49:13 -0800810class TestCyclingDoubleVlan(OltBaseTest):
alshabibb9d4ee82016-03-01 14:12:42 -0800811 """Cycle through vlans and test traffic flow"""
812
813 def runTest(self):
814 logging.info("Running cycling vlan test")
815
alshabib2ecca692016-03-01 15:10:38 -0800816 for stag in xrange(2, 4000, 100):
817 for ctag in xrange(2, 4000, 100):
alshabibf1f07dd2016-03-01 15:50:35 -0800818 delete_all_flows(self.controller)
819 time.sleep(5)
Admin44f754e2016-03-01 23:00:46 -0800820 self.installDoubleTaggingRules(stag, ctag)
alshabibf1f07dd2016-03-01 15:50:35 -0800821 time.sleep(5)
alshabib3f3da0e2016-03-01 23:23:45 -0800822 self.testPacketFlow(stag, ctag)
alshabibb9d4ee82016-03-01 14:12:42 -0800823
alshabib9929a152016-03-01 21:25:18 -0800824
alshabibb9b39a72016-03-01 15:52:03 -0800825
alshabibb9d4ee82016-03-01 14:12:42 -0800826
alshabibb9d4ee82016-03-01 14:12:42 -0800827
alshabibb9d4ee82016-03-01 14:12:42 -0800828
alshabibb9d4ee82016-03-01 14:12:42 -0800829
alshabibb9d4ee82016-03-01 14:12:42 -0800830
alshabibb9d4ee82016-03-01 14:12:42 -0800831
alshabibb9d4ee82016-03-01 14:12:42 -0800832