blob: 3cbc96a2bc76a83670cb42a781edb23d59236a27 [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")
alshabibed97b5f2016-03-01 23:46:53 -080061 igmp.grps = [IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr="229.10.20.30")]
Zsolt Harasztiecf89452016-03-01 22:38:13 -080062 pkt = IGMPv3.fixup( scapy.Ether(src='00:00:00:00:be:ef') / scapy.IP() / igmp )
alshabibb9d4ee82016-03-01 14:12:42 -080063 pkt = pkt / ("0" * (100 - len(pkt)))
64
alshabibcde318b2016-03-01 22:49:13 -080065 self.testPacketIn(match, pkt)
Admin7e9c91d2015-08-25 15:53:49 -070066
alshabibb9d4ee82016-03-01 14:12:42 -080067
alshabibcde318b2016-03-01 22:49:13 -080068class IGMPQueryPacketOut(OltBaseTest):
Admind5212782015-12-09 17:17:57 -080069 """Verify sending multicast membership queries down to onu_ports"""
alshabibb9d4ee82016-03-01 14:12:42 -080070
Admind5212782015-12-09 17:17:57 -080071 def runTest(self):
72 logging.info("Running IGMP query packet out")
73
Zsolt Harasztife525502016-03-02 05:18:52 +000074 igmp = IGMPv3() # by default this is a query
Admind5212782015-12-09 17:17:57 -080075 pkt = buildIgmp(igmp)
76
Zsolt Harasztife525502016-03-02 05:18:52 +000077 msg = ofp.message.packet_out(
78 in_port=ofp.OFPP_CONTROLLER,
79 actions=[ofp.action.output(port=onu_port)],
80 buffer_id=ofp.OFP_NO_BUFFER,
81 data=str(pkt))
Admind5212782015-12-09 17:17:57 -080082
alshabibb9d4ee82016-03-01 14:12:42 -080083 self.controller.message_send(msg)
Admind5212782015-12-09 17:17:57 -080084
Zsolt Harasztife525502016-03-02 05:18:52 +000085 rv = self.controller.message_send(msg)
86 self.assertTrue(rv == 0, "Error sending put message")
Admind5212782015-12-09 17:17:57 -080087 verify_no_errors(self.controller)
88
89 verify_packet(self, pkt, onu_port)
90
alshabibb9d4ee82016-03-01 14:12:42 -080091
alshabibcde318b2016-03-01 22:49:13 -080092class TestMeter(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +000093
Admin7e9c91d2015-08-25 15:53:49 -070094 def runTest(self):
95 logging.info("Running Meter tests")
alshabibb9d4ee82016-03-01 14:12:42 -080096 dropMeterBand = ofp.meter_band.drop(rate=640)
97 meter_mod = ofp.message.meter_mod(xid=1, command=ofp.OFPMC_ADD, meter_id=1, meters=[dropMeterBand])
Admin7e9c91d2015-08-25 15:53:49 -070098 self.controller.message_send(meter_mod)
alshabibb9d4ee82016-03-01 14:12:42 -080099
Admin7e9c91d2015-08-25 15:53:49 -0700100 time.sleep(1)
101
102 verify_no_errors(self.controller)
103
Jonathan Hartf65e1812015-10-05 15:15:37 -0700104 vlan_id = 201
Admin7e9c91d2015-08-25 15:53:49 -0700105 match = ofp.match()
106 match.oxm_list.append(ofp.oxm.in_port(onu_port))
alshabibb9d4ee82016-03-01 14:12:42 -0800107 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
Admin02d052c2015-10-10 19:08:26 -0700108
109 request = ofp.message.flow_add(
110 table_id=test_param_get("table", 0),
111 cookie=42,
112 match=match,
113 instructions=[
114 ofp.instruction.apply_actions(
Zsolt Harasztife525502016-03-02 05:18:52 +0000115 actions=[ofp.action.output(port=olt_port)]),
116 ofp.instruction.meter(meter_id = 1)
alshabibb9d4ee82016-03-01 14:12:42 -0800117 ],
Admin02d052c2015-10-10 19:08:26 -0700118 buffer_id=ofp.OFP_NO_BUFFER,
119 priority=1000)
120
121 self.controller.message_send(request)
122 time.sleep(1)
123 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800124
Admin02d052c2015-10-10 19:08:26 -0700125 match = ofp.match()
126 match.oxm_list.append(ofp.oxm.in_port(olt_port))
127 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
Admin7e9c91d2015-08-25 15:53:49 -0700128
129 request = ofp.message.flow_add(
130 table_id=test_param_get("table", 0),
131 cookie=43,
132 match=match,
133 instructions=[
134 ofp.instruction.apply_actions(
Zsolt Harasztife525502016-03-02 05:18:52 +0000135 actions=[ofp.action.output(port=onu_port)]),
136 ofp.instruction.meter(meter_id = 1)
alshabibb9d4ee82016-03-01 14:12:42 -0800137 ],
Admin7e9c91d2015-08-25 15:53:49 -0700138 buffer_id=ofp.OFP_NO_BUFFER,
139 priority=1000)
140
141 self.controller.message_send(request)
Admin7e9c91d2015-08-25 15:53:49 -0700142 time.sleep(1)
Admin7e9c91d2015-08-25 15:53:49 -0700143 verify_no_errors(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700144 do_barrier(self.controller)
145 time.sleep(5)
alshabibb9d4ee82016-03-01 14:12:42 -0800146
Jonathan Hartf65e1812015-10-05 15:15:37 -0700147 inPkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=vlan_id, vlan_pcp=0)
148 # downstream
alshabibb9d4ee82016-03-01 14:12:42 -0800149 # self.dataplane.send(olt_port, str(inPkt))
150 # verify_packet(self, inPkt, onu_port)
Admin02d052c2015-10-10 19:08:26 -0700151 # upstream
alshabibb9d4ee82016-03-01 14:12:42 -0800152 # for i in range(1,400):
153 # self.dataplane.send(onu_port, str(inPkt))
154 # verify_packet(self, inPkt, olt_port)
Admin02d052c2015-10-10 19:08:26 -0700155
Jonathan Hartf65e1812015-10-05 15:15:37 -0700156 # clean up the test
alshabibb9d4ee82016-03-01 14:12:42 -0800157 meter_mod = ofp.message.meter_mod(xid=2, command=ofp.OFPMC_DELETE, meter_id=1)
Admin02d052c2015-10-10 19:08:26 -0700158 self.controller.message_send(meter_mod)
159 time.sleep(1)
160 delete_all_flows(self.controller)
161 verify_no_errors(self.controller)
162
Admin7e9c91d2015-08-25 15:53:49 -0700163
alshabibcde318b2016-03-01 22:49:13 -0800164class TestDuplicateMeter(OltBaseTest):
Admin7e9c91d2015-08-25 15:53:49 -0700165 def runTest(self):
166 logging.info("Running Duplicate Meter Test")
alshabibb9d4ee82016-03-01 14:12:42 -0800167 dropMeterBand = ofp.meter_band.drop(rate=500)
168 meter_mod = ofp.message.meter_mod(xid=1, command=ofp.OFPMC_ADD, meter_id=1, meters=[dropMeterBand])
Admin7e9c91d2015-08-25 15:53:49 -0700169 self.controller.message_send(meter_mod)
170 self.controller.message_send(meter_mod)
171
172 time.sleep(1)
alshabibb9d4ee82016-03-01 14:12:42 -0800173
Admin7e9c91d2015-08-25 15:53:49 -0700174 try:
175 verify_no_errors(self.controller)
176 except AssertionError as e:
Admin09b5cc62015-10-11 13:53:59 -0700177 if (not e.message == "unexpected error type=12 code=1"):
Admin7e9c91d2015-08-25 15:53:49 -0700178 raise AssertionError("Incorrect error type: %s" % e.message)
alshabibb9d4ee82016-03-01 14:12:42 -0800179
180
alshabibcde318b2016-03-01 22:49:13 -0800181class VlanTest(OltBaseTest):
Admin7e9c91d2015-08-25 15:53:49 -0700182 """Verify the switch can push/pop a VLAN tag and forward out a port """
alshabibb9d4ee82016-03-01 14:12:42 -0800183
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700184 def runTest(self):
185 logging.info("Running push VLAN test")
alshabibb9d4ee82016-03-01 14:12:42 -0800186
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700187 vlan_id = 200
alshabibb9d4ee82016-03-01 14:12:42 -0800188
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700189 delete_all_flows(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800190
191 # PUSH
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700192 match = ofp.match()
193 match.oxm_list.append(ofp.oxm.in_port(onu_port))
Zsolt Harasztife525502016-03-02 05:18:52 +0000194 if device_type == "cpqd":
195 match.oxm_list.append(ofp.oxm.vlan_vid(value=ofp.OFPVID_NONE))
196 actions = [
197 ofp.action.push_vlan(ethertype=0x8100),
198 ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id)),
199 ofp.action.set_field(ofp.oxm.vlan_pcp(0)),
200 ofp.action.output(port=olt_port)
201 ]
202 else: # pmc, normal
203 match.oxm_list.append(ofp.oxm.vlan_vid_masked(value=ofp.OFPVID_PRESENT, value_mask=ofp.OFPVID_PRESENT))
204 match.oxm_list.append(ofp.oxm.vlan_pcp(value = 0))
205 actions = [
206 ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id)),
207 ofp.action.set_field(ofp.oxm.vlan_pcp(0)),
208 ofp.action.output(port=olt_port)
209 ]
alshabibb9d4ee82016-03-01 14:12:42 -0800210
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700211 request = ofp.message.flow_add(
212 table_id=test_param_get("table", 0),
213 cookie=42,
214 match=match,
Zsolt Harasztife525502016-03-02 05:18:52 +0000215 instructions=[ofp.instruction.apply_actions(actions=actions)],
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700216 buffer_id=ofp.OFP_NO_BUFFER,
217 priority=1000)
218
Admin7e9c91d2015-08-25 15:53:49 -0700219 logging.info("Inserting flow tagging upstream")
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700220 self.controller.message_send(request)
Zsolt Harasztife525502016-03-02 05:18:52 +0000221 do_barrier(self.controller)
222 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800223
224 # POP
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700225 match = ofp.match()
226 match.oxm_list.append(ofp.oxm.in_port(olt_port))
227 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
Admin7e9c91d2015-08-25 15:53:49 -0700228
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700229 request = ofp.message.flow_add(
230 table_id=test_param_get("table", 0),
Admin7e9c91d2015-08-25 15:53:49 -0700231 cookie=43,
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700232 match=match,
233 instructions=[
234 ofp.instruction.apply_actions(
Jonathan Hartf65e1812015-10-05 15:15:37 -0700235 actions=[
236 ofp.action.pop_vlan(),
alshabibb9d4ee82016-03-01 14:12:42 -0800237 ofp.action.output(port=onu_port)])],
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700238 buffer_id=ofp.OFP_NO_BUFFER,
239 priority=1000)
240
Admin7e9c91d2015-08-25 15:53:49 -0700241 logging.info("Inserting flow tagging downstream")
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700242 self.controller.message_send(request)
243 do_barrier(self.controller)
Zsolt Harasztife525502016-03-02 05:18:52 +0000244 verify_no_errors(self.controller)
245
Admin7e9c91d2015-08-25 15:53:49 -0700246 time.sleep(5)
Admin99c2a272016-03-01 12:56:39 -0800247
Admin7e9c91d2015-08-25 15:53:49 -0700248 inPkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=0, vlan_pcp=0)
alshabibb9d4ee82016-03-01 14:12:42 -0800249 outPkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True,
Admin7e9c91d2015-08-25 15:53:49 -0700250 vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0)
alshabibb9d4ee82016-03-01 14:12:42 -0800251
Admin7e9c91d2015-08-25 15:53:49 -0700252 # Send untagged packet in the ONU port and expect tagged packet out the OLT port
253 self.dataplane.send(onu_port, str(inPkt))
254 verify_packet(self, outPkt, olt_port)
alshabibb9d4ee82016-03-01 14:12:42 -0800255
Admin7e9c91d2015-08-25 15:53:49 -0700256 # Send untagged packet in the OLT port and expect no packets to come out
257 self.dataplane.send(olt_port, str(inPkt))
258 verify_packets(self, outPkt, [])
alshabibb9d4ee82016-03-01 14:12:42 -0800259
Admin7e9c91d2015-08-25 15:53:49 -0700260 inPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True,
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700261 vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0)
Zsolt Harasztife525502016-03-02 05:18:52 +0000262 if device_type == 'pmc':
263 outPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=0, vlan_pcp=0)
264 else: # "normal", "cpqd""
265 outPkt = simple_udp_packet(pktlen=100)
Admin7e9c91d2015-08-25 15:53:49 -0700266
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700267 # Send tagged packet in the OLT port and expect untagged packet out the OLT port
268 self.dataplane.send(olt_port, str(inPkt))
269 verify_packet(self, outPkt, onu_port)
Admin7e9c91d2015-08-25 15:53:49 -0700270
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700271 # Send tagged packet in the ONU port and expect no packets to come out
272 self.dataplane.send(onu_port, str(inPkt))
Admin7e9c91d2015-08-25 15:53:49 -0700273 verify_packets(self, outPkt, [])
Jonathan Hartf65e1812015-10-05 15:15:37 -0700274
alshabibb9d4ee82016-03-01 14:12:42 -0800275
Jonathan Hartf65e1812015-10-05 15:15:37 -0700276
alshabibb9d4ee82016-03-01 14:12:42 -0800277
alshabibb9d4ee82016-03-01 14:12:42 -0800278
alshabibcde318b2016-03-01 22:49:13 -0800279class TestGroupAdd(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000280
Admin02d052c2015-10-10 19:08:26 -0700281 def runTest(self):
282 logging.info("Running Group tests")
283 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700284 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700285
alshabibb9d4ee82016-03-01 14:12:42 -0800286 test_group_id = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700287
288 # output to two ONU
289 group_add = createAllGroupAdd(test_group_id, ports=[onu_port, onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700290
291 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700292 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700293 verify_no_errors(self.controller)
294
295 # Remove the group and then readd it.
alshabibb9d4ee82016-03-01 14:12:42 -0800296 group_delete = ofp.message.group_delete(group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700297 self.controller.message_send(group_delete)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700298 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700299 verify_no_errors(self.controller)
300
Jonathan Hartf65e1812015-10-05 15:15:37 -0700301 group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700302 self.controller.message_send(group_add)
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
306
Jonathan Hartf65e1812015-10-05 15:15:37 -0700307 # clean up the test
alshabibb9d4ee82016-03-01 14:12:42 -0800308 group_delete = ofp.message.group_delete(group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700309 self.controller.message_send(group_delete)
alshabibb9d4ee82016-03-01 14:12:42 -0800310
Jonathan Hartf65e1812015-10-05 15:15:37 -0700311 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700312 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800313
314
alshabibcde318b2016-03-01 22:49:13 -0800315class TestGroupMod(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000316
Admin02d052c2015-10-10 19:08:26 -0700317 def runTest(self):
318 logging.info("Running Group tests")
319 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700320 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700321
alshabibb9d4ee82016-03-01 14:12:42 -0800322 test_group_id = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700323
324 group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700325
326 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700327 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700328 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800329
Jonathan Hartf65e1812015-10-05 15:15:37 -0700330 # Modifying the group
331 group_mod = createAllGroupMod(test_group_id, [onu_port2])
alshabibb9d4ee82016-03-01 14:12:42 -0800332
Jonathan Hartf65e1812015-10-05 15:15:37 -0700333 self.controller.message_send(group_mod)
334 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700335 verify_no_errors(self.controller)
336
Jonathan Hartf65e1812015-10-05 15:15:37 -0700337 # Add a bucket into the group
338 group_mod = createAllGroupMod(test_group_id, [onu_port, onu_port2])
339 self.controller.message_send(group_mod)
340 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700341 verify_no_errors(self.controller)
342
343 # Modifying a non-existing group
Jonathan Hartf65e1812015-10-05 15:15:37 -0700344 group_mod = createAllGroupMod(777, [onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700345
Jonathan Hartf65e1812015-10-05 15:15:37 -0700346 self.controller.message_send(group_mod)
347 do_barrier(self.controller)
348 errorExperienced = 0
Admin02d052c2015-10-10 19:08:26 -0700349 try:
350 verify_no_errors(self.controller)
351 except AssertionError as e:
Jonathan Hartf65e1812015-10-05 15:15:37 -0700352 errorExperienced = 1
Admin02d052c2015-10-10 19:08:26 -0700353 if (not (e.message == "unexpected error type=6 code=8")):
Jonathan Hartf65e1812015-10-05 15:15:37 -0700354 raise AssertionError("Incorrect error type: %s" % e.message)
alshabibb9d4ee82016-03-01 14:12:42 -0800355 if not errorExperienced:
Jonathan Hartf65e1812015-10-05 15:15:37 -0700356 raise AssertionError("An error message is expected, but not shown.")
alshabibb9d4ee82016-03-01 14:12:42 -0800357
358
Jonathan Hartf65e1812015-10-05 15:15:37 -0700359 # clean up the test
alshabibb9d4ee82016-03-01 14:12:42 -0800360 group_delete = ofp.message.group_delete(xid=2, group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700361 self.controller.message_send(group_delete)
alshabibb9d4ee82016-03-01 14:12:42 -0800362
Jonathan Hartf65e1812015-10-05 15:15:37 -0700363 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700364 verify_no_errors(self.controller)
365
alshabibb9d4ee82016-03-01 14:12:42 -0800366
alshabibcde318b2016-03-01 22:49:13 -0800367class TestDuplicateGroup(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000368
Admin02d052c2015-10-10 19:08:26 -0700369 def runTest(self):
370 logging.info("Running Group tests")
371 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700372 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700373
alshabibb9d4ee82016-03-01 14:12:42 -0800374 test_group_id = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700375 group_add = createAllGroupAdd(test_group_id, ports=[onu_port])
Admin02d052c2015-10-10 19:08:26 -0700376
377 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700378 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700379 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800380
Jonathan Hartf65e1812015-10-05 15:15:37 -0700381 # Add the same group id
alshabibb9d4ee82016-03-01 14:12:42 -0800382 duplicate_group_fail = 0
383
Admin02d052c2015-10-10 19:08:26 -0700384 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700385 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700386 try:
387 verify_no_errors(self.controller)
388 except AssertionError as e:
alshabibb9d4ee82016-03-01 14:12:42 -0800389 duplicate_group_fail = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700390 if (not e.message == "unexpected error type=6 code=0"):
391 raise AssertionError("Incorrect error type: %s" % e.message)
392 if not duplicate_group_fail:
393 raise AssertionError("Adding duplicate groups didn't raise an error.")
alshabibb9d4ee82016-03-01 14:12:42 -0800394
Jonathan Hartf65e1812015-10-05 15:15:37 -0700395 # clean up the test
alshabibb9d4ee82016-03-01 14:12:42 -0800396 group_delete = ofp.message.group_delete(xid=2, group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700397 self.controller.message_send(group_delete)
alshabibb9d4ee82016-03-01 14:12:42 -0800398
Jonathan Hartf65e1812015-10-05 15:15:37 -0700399 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700400 verify_no_errors(self.controller)
401
alshabibb9d4ee82016-03-01 14:12:42 -0800402
alshabibcde318b2016-03-01 22:49:13 -0800403class TestGroupAndFlow(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000404
Admin02d052c2015-10-10 19:08:26 -0700405 def runTest(self):
406 logging.info("Running Group tests")
407 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700408 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700409
Jonathan Hartf65e1812015-10-05 15:15:37 -0700410 # Create a group
alshabibb9d4ee82016-03-01 14:12:42 -0800411 test_group_id = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700412 group_add = createAllGroupAdd(test_group_id, ports=[onu_port])
Admin02d052c2015-10-10 19:08:26 -0700413
414 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700415 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700416 verify_no_errors(self.controller)
417
418 # Create a flow rule matching olt port and vlan id
419 match = ofp.match()
420 match.oxm_list.append(ofp.oxm.in_port(olt_port))
421 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | 201))
422
Jonathan Hartf65e1812015-10-05 15:15:37 -0700423 flow_pointing_to_group = ofp.message.flow_add(
Admin02d052c2015-10-10 19:08:26 -0700424 table_id=test_param_get("table", 0),
425 cookie=43,
426 match=match,
427 instructions=[
428 ofp.instruction.apply_actions(
alshabibb9d4ee82016-03-01 14:12:42 -0800429 actions=[ofp.action.group(group_id=test_group_id)])],
430 buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
Admin02d052c2015-10-10 19:08:26 -0700431
Jonathan Hartf65e1812015-10-05 15:15:37 -0700432 self.controller.message_send(flow_pointing_to_group)
433 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700434 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800435
Jonathan Hartf65e1812015-10-05 15:15:37 -0700436 # After letting a flow rule point to the group, test we can do group_mod
437 group_mod = createAllGroupMod(test_group_id, ports=[onu_port2])
438 self.controller.message_send(group_mod)
439 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700440 verify_no_errors(self.controller)
441
442 # Test we can remove flows and then remove group
alshabibb9d4ee82016-03-01 14:12:42 -0800443 flow_delete = ofp.message.flow_delete(table_id=test_param_get("table", 0))
Jonathan Hartf65e1812015-10-05 15:15:37 -0700444 self.controller.message_send(flow_delete)
445 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700446 verify_no_errors(self.controller)
447
alshabibb9d4ee82016-03-01 14:12:42 -0800448 group_delete = ofp.message.group_delete(xid=3, group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700449 self.controller.message_send(group_delete)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700450 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700451 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800452
Zsolt Harasztife525502016-03-02 05:18:52 +0000453 # Add the group and flow back, test it we can first remove group and then remove the flow.
Admindcb1bc72015-11-12 18:24:56 -0800454 '''group_add = createAllGroupAdd(test_group_id, ports=[onu_port])
Admin02d052c2015-10-10 19:08:26 -0700455 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700456
457 self.controller.message_send(flow_pointing_to_group)
458 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700459 verify_no_errors(self.controller)
460
461 group_delete = ofp.message.group_delete(xid = 4, group_id = test_group_id)
Admindcb1bc72015-11-12 18:24:56 -0800462 self.controller.message_send(group_delete)'''
Jonathan Hartf65e1812015-10-05 15:15:37 -0700463
464 self.controller.message_send(flow_delete)
465 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700466 verify_no_errors(self.controller)
467
468
alshabibcde318b2016-03-01 22:49:13 -0800469class TestGroupForwarding(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000470
Admin02d052c2015-10-10 19:08:26 -0700471 def runTest(self):
472 logging.info("Running Group datapath forwarding tests")
473 delete_all_flows(self.controller)
Admin99c2a272016-03-01 12:56:39 -0800474 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700475
Admin09b5cc62015-10-11 13:53:59 -0700476 vlan_id = 201
Admin02d052c2015-10-10 19:08:26 -0700477
Jonathan Hartf65e1812015-10-05 15:15:37 -0700478 # Create a group
alshabibb9d4ee82016-03-01 14:12:42 -0800479 test_group_id = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700480 group_add = createAllGroupAdd(test_group_id, [onu_port])
Admin02d052c2015-10-10 19:08:26 -0700481
482 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700483 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700484 verify_no_errors(self.controller)
485
486 # Create a flow rule matching olt port and vlan id
487 match = ofp.match()
488 match.oxm_list.append(ofp.oxm.in_port(olt_port))
489 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
490
491 request = ofp.message.flow_add(
492 table_id=test_param_get("table", 0),
493 cookie=43,
494 match=match,
495 instructions=[
496 ofp.instruction.apply_actions(
alshabibb9d4ee82016-03-01 14:12:42 -0800497 actions=[ofp.action.group(group_id=test_group_id)]),
498 ],
499 buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
Admin02d052c2015-10-10 19:08:26 -0700500
501 self.controller.message_send(request)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700502 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700503 verify_no_errors(self.controller)
Admin09b5cc62015-10-11 13:53:59 -0700504
505 # It takes some time for flows to propagate down to the data plane
Admindcb1bc72015-11-12 18:24:56 -0800506 time.sleep(10)
alshabibb9d4ee82016-03-01 14:12:42 -0800507
508 inPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True,
Admindcb1bc72015-11-12 18:24:56 -0800509 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 -0700510 outPkt = inPkt
511 self.dataplane.send(olt_port, str(inPkt))
512 verify_packet(self, outPkt, onu_port)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700513
Admindcb1bc72015-11-12 18:24:56 -0800514
Zsolt Harasztife525502016-03-02 05:18:52 +0000515 # Now put 2 ONU ports in the group and test that the input packet is
Jonathan Hartf65e1812015-10-05 15:15:37 -0700516 # duplicated out both ports
517 group_mod = createAllGroupMod(test_group_id, ports=[onu_port, onu_port2])
518 self.controller.message_send(group_mod)
519 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700520 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800521
Admin09b5cc62015-10-11 13:53:59 -0700522 # It takes some time for flows to propagate down to the data plane
Admindcb1bc72015-11-12 18:24:56 -0800523 time.sleep(10)
Admin09b5cc62015-10-11 13:53:59 -0700524
Jonathan Hartf65e1812015-10-05 15:15:37 -0700525 self.dataplane.send(olt_port, str(inPkt))
Jonathan Hartf65e1812015-10-05 15:15:37 -0700526 verify_packet(self, outPkt, onu_port2)
Admindcb1bc72015-11-12 18:24:56 -0800527 verify_packet(self, outPkt, onu_port)
alshabibb9d4ee82016-03-01 14:12:42 -0800528 # verify_packets(self, outPkt, [onu_port,onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700529
Jonathan Hartf65e1812015-10-05 15:15:37 -0700530 # clean up the test
alshabibb9d4ee82016-03-01 14:12:42 -0800531 request = ofp.message.flow_delete(table_id=test_param_get("table", 0))
Admin02d052c2015-10-10 19:08:26 -0700532 self.controller.message_send(request)
alshabibb9d4ee82016-03-01 14:12:42 -0800533 group_delete = ofp.message.group_delete(xid=2, group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700534 self.controller.message_send(group_delete)
alshabibb9d4ee82016-03-01 14:12:42 -0800535
Jonathan Hartf65e1812015-10-05 15:15:37 -0700536 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700537 verify_no_errors(self.controller)
538
Admindcb1bc72015-11-12 18:24:56 -0800539
alshabibcde318b2016-03-01 22:49:13 -0800540class TestGroupModForwarding(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000541
Admindcb1bc72015-11-12 18:24:56 -0800542 def runTest(self):
alshabibb9d4ee82016-03-01 14:12:42 -0800543 logging.info("Running datapath forwarding tests for group mod")
Admindcb1bc72015-11-12 18:24:56 -0800544 delete_all_flows(self.controller)
545 delete_all_groups(self.controller)
546
547 vlan_id = 201
548
549 # Create a group
alshabibb9d4ee82016-03-01 14:12:42 -0800550 test_group_id = 1
Admindcb1bc72015-11-12 18:24:56 -0800551 group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2])
552
553 self.controller.message_send(group_add)
554 do_barrier(self.controller)
555 verify_no_errors(self.controller)
556
557 # Create a flow rule matching olt port and vlan id
558 match = ofp.match()
559 match.oxm_list.append(ofp.oxm.in_port(olt_port))
560 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
561
562 request = ofp.message.flow_add(
563 table_id=test_param_get("table", 0),
564 cookie=43,
565 match=match,
566 instructions=[
567 ofp.instruction.apply_actions(
alshabibb9d4ee82016-03-01 14:12:42 -0800568 actions=[ofp.action.group(group_id=test_group_id)]),
569 ],
570 buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
Admindcb1bc72015-11-12 18:24:56 -0800571
572 self.controller.message_send(request)
573 do_barrier(self.controller)
574 verify_no_errors(self.controller)
575
576 # It takes some time for flows to propagate down to the data plane
577 time.sleep(10)
alshabibb9d4ee82016-03-01 14:12:42 -0800578
579 inPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True,
Admindcb1bc72015-11-12 18:24:56 -0800580 vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0, eth_dst="01:01:11:12:11:12")
581 outPkt = inPkt
582 self.dataplane.send(olt_port, str(inPkt))
583 verify_packet(self, outPkt, onu_port)
Admin99c2a272016-03-01 12:56:39 -0800584 verify_packet(self, outPkt, onu_port2)
Admindcb1bc72015-11-12 18:24:56 -0800585
586 # Now remove onu port 1 from the group and test that the input packet is no longer forwarded to onu port 1
587 group_mod = createAllGroupMod(test_group_id, ports=[onu_port2])
588 self.controller.message_send(group_mod)
589 do_barrier(self.controller)
590 verify_no_errors(self.controller)
591
592 time.sleep(10)
593 self.dataplane.send(olt_port, str(inPkt))
594 verify_no_packet(self, outPkt, onu_port)
595 verify_packet(self, outPkt, onu_port2)
596
Zsolt Harasztife525502016-03-02 05:18:52 +0000597 # 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 -0800598 group_mod = createAllGroupMod(test_group_id, ports=[])
599 self.controller.message_send(group_mod)
600 do_barrier(self.controller)
601 verify_no_errors(self.controller)
602 time.sleep(10)
603 self.dataplane.send(olt_port, str(inPkt))
604 verify_packets(self, outPkt, [])
605
606
alshabibcde318b2016-03-01 22:49:13 -0800607class TransparentVlanTest(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000608
Admin02d052c2015-10-10 19:08:26 -0700609 def runTest(self):
610 logging.info("Running transparent vlan tests")
Admin09b5cc62015-10-11 13:53:59 -0700611 delete_all_flows(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700612
Jonathan Hartf65e1812015-10-05 15:15:37 -0700613 vlan_id = 201
Admin02d052c2015-10-10 19:08:26 -0700614 match = ofp.match()
615 match.oxm_list.append(ofp.oxm.in_port(onu_port))
alshabibb9d4ee82016-03-01 14:12:42 -0800616 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
Admin02d052c2015-10-10 19:08:26 -0700617
618 request = ofp.message.flow_add(
619 table_id=test_param_get("table", 0),
620 cookie=42,
621 match=match,
622 instructions=[
623 ofp.instruction.apply_actions(
624 actions=[
625 ofp.action.output(port=olt_port)]),
alshabibb9d4ee82016-03-01 14:12:42 -0800626 ],
Admin02d052c2015-10-10 19:08:26 -0700627 buffer_id=ofp.OFP_NO_BUFFER,
628 priority=1000)
629
630 self.controller.message_send(request)
alshabibb9d4ee82016-03-01 14:12:42 -0800631
Admin02d052c2015-10-10 19:08:26 -0700632 match = ofp.match()
633 match.oxm_list.append(ofp.oxm.in_port(olt_port))
634 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
635
636 request = ofp.message.flow_add(
637 table_id=test_param_get("table", 0),
638 cookie=43,
639 match=match,
640 instructions=[
641 ofp.instruction.apply_actions(
642 actions=[
643 ofp.action.output(port=onu_port)]),
alshabibb9d4ee82016-03-01 14:12:42 -0800644 ],
Admin02d052c2015-10-10 19:08:26 -0700645 buffer_id=ofp.OFP_NO_BUFFER,
646 priority=1000)
647
648 self.controller.message_send(request)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700649 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700650 verify_no_errors(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700651
Admin09b5cc62015-10-11 13:53:59 -0700652 # It takes some time for flows to propagate down to the data plane
653 time.sleep(2)
alshabibb9d4ee82016-03-01 14:12:42 -0800654
Jonathan Hartf65e1812015-10-05 15:15:37 -0700655 inPkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=vlan_id, vlan_pcp=0)
Zsolt Harasztife525502016-03-02 05:18:52 +0000656
Admin02d052c2015-10-10 19:08:26 -0700657 # upstream
658 self.dataplane.send(onu_port, str(inPkt))
659 verify_packet(self, inPkt, olt_port)
Zsolt Harasztife525502016-03-02 05:18:52 +0000660
Admin99c2a272016-03-01 12:56:39 -0800661 # downstream
662 self.dataplane.send(olt_port, str(inPkt))
663 verify_packet(self, inPkt, onu_port)
Admin02d052c2015-10-10 19:08:26 -0700664
Jonathan Hartf65e1812015-10-05 15:15:37 -0700665 # clean up the test
Admin02d052c2015-10-10 19:08:26 -0700666 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700667 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700668 verify_no_errors(self.controller)
669
alshabibed97b5f2016-03-01 23:46:53 -0800670class TestMulticastForwarding(IGMPPacketIn):
671
672 def runTest(self):
673 delete_all_groups(self.controller)
674 # send igmp join packet
675 super(TestMulticastForwarding, self).runTest()
676
677 vlan_id = 201
678
679 group = createAllGroupAdd(1, onu_port)
680
681 self.controller.message_send(group_add)
682 do_barrier(self.controller)
683 verify_no_errors(self.controller)
684
685 # Create a flow rule matching olt port and vlan id
686 match = ofp.match()
687 match.oxm_list.append(ofp.oxm.in_port(olt_port))
688 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
689
690 request = ofp.message.flow_add(
691 table_id=test_param_get("table", 0),
692 cookie=43,
693 match=match,
694 instructions=[
695 ofp.instruction.apply_actions(
696 actions=[ofp.action.group(group_id=1)]),
697 ],
698 buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
699
700 self.controller.message_send(request)
701 do_barrier(self.controller)
702 verify_no_errors(self.controller)
703
704 # It takes some time for flows to propagate down to the data plane
705 time.sleep(5)
706
707 pkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=vlan_id, vlan_pcp=0, \
708 eth_dst = "01:00:5E:00:00:01", ip_dst = "229.10.20.30")
709
710 # downstream
711 self.dataplane.send(olt_port, str(pkt))
712 verify_packet(self, pkt, onu_port)
713
714 # clean up the test
715 delete_all_flows(self.controller)
716 do_barrier(self.controller)
717 verify_no_errors(self.controller)
718 delete_all_groups(self.controller)
719
720
alshabibcde318b2016-03-01 22:49:13 -0800721class RemoveRuleTest(OltBaseTest):
alshabib28c03c32016-03-01 20:33:51 -0800722
723 def runTest(self):
724 logging.info("Testing Rule removal")
alshabibe165af22016-03-01 21:42:17 -0800725 delete_all_flows(self.controller)
Admin44f754e2016-03-01 23:00:46 -0800726 self.processEapolRule(onu_port)
alshabibe165af22016-03-01 21:42:17 -0800727
alshabib9929a152016-03-01 21:25:18 -0800728 #wait for the rule to settle
729 time.sleep(3)
730
Admin44f754e2016-03-01 23:00:46 -0800731 self.installDoubleTaggingRules(1, 2)
alshabibe165af22016-03-01 21:42:17 -0800732
alshabib9929a152016-03-01 21:25:18 -0800733 #wait for the rules to settle
734 time.sleep(3)
735
736 stats = get_flow_stats(self, ofp.match())
737
Admin53e10b62016-03-01 21:52:18 -0800738 self.assertTrue(len(stats) == 5, \
739 "Wrong number of rules reports; reported %s, expected 5\n\n %s" % (len(stats), stats))
alshabib9929a152016-03-01 21:25:18 -0800740
Admin44f754e2016-03-01 23:00:46 -0800741 self.processEapolRule(onu_port, install = False)
alshabib9929a152016-03-01 21:25:18 -0800742 time.sleep(3)
743
744 stats = get_flow_stats(self, ofp.match())
745
Admin53e10b62016-03-01 21:52:18 -0800746 self.assertTrue(len(stats) == 4, \
747 "Wrong number of rules reports; reported %s, expected 4\n\n %s" % (len(stats), stats))
alshabib9929a152016-03-01 21:25:18 -0800748
alshabibd6be76e2016-03-01 22:21:00 -0800749 eapol = ofp.oxm.eth_type(0x888e)
750 found = False
751 for fe in stats:
752 if eapol in fe.match.oxm_list:
753 found = True
754
755 self.assertFalse(found, "Removed incorrect flow rule")
alshabib28c03c32016-03-01 20:33:51 -0800756
757
alshabibcde318b2016-03-01 22:49:13 -0800758class MultipleDoubleTaggingForwarding(OltBaseTest):
alshabib28c03c32016-03-01 20:33:51 -0800759
alshabib5d53c482016-03-01 23:25:39 -0800760 def runTest(self):
alshabib28c03c32016-03-01 20:33:51 -0800761 logging.info("Testing multiple Q-in-Q rules")
alshabib3f3da0e2016-03-01 23:23:45 -0800762
763 self.installDoubleTaggingRules(10, 5, cookie=42, onu = onu_port)
764
765 time.sleep(5)
766
767 self.installDoubleTaggingRules(20, 10, cookie=50, onu = onu_port2)
768
769 time.sleep(5)
770
771 self.testPacketFlow(10, 5, onu=onu_port)
772 self.testPacketFlow(20, 10, onu=onu_port2)
773
alshabib28c03c32016-03-01 20:33:51 -0800774 pass
775
alshabibb9d4ee82016-03-01 14:12:42 -0800776
alshabibd6be76e2016-03-01 22:21:00 -0800777class DoubleVlanTest(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000778
Adminb17b1662015-10-19 15:50:53 -0700779 def runTest(self):
780 logging.info("Running double vlan tests")
781 delete_all_flows(self.controller)
782
783 c_vlan_id = 100
alshabibb9d4ee82016-03-01 14:12:42 -0800784 s_vlan_id = 102
Zsolt Harasztife525502016-03-02 05:18:52 +0000785
alshabibd6be76e2016-03-01 22:21:00 -0800786 self.installDoubleTaggingRules(s_vlan_id, c_vlan_id)
Adminb17b1662015-10-19 15:50:53 -0700787
Adminb17b1662015-10-19 15:50:53 -0700788 # It takes some time for flows to propagate down to the data plane
789 time.sleep(10)
alshabibb9d4ee82016-03-01 14:12:42 -0800790
Zsolt Harasztife525502016-03-02 05:18:52 +0000791 # Test packet flows
alshabib3f3da0e2016-03-01 23:23:45 -0800792 self.testPacketFlow(s_vlan_id, c_vlan_id)
Adminb17b1662015-10-19 15:50:53 -0700793
794 # clean up the test
795 delete_all_flows(self.controller)
796 do_barrier(self.controller)
797 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800798
799
alshabibcde318b2016-03-01 22:49:13 -0800800class TestCyclingDoubleVlan(OltBaseTest):
alshabibb9d4ee82016-03-01 14:12:42 -0800801 """Cycle through vlans and test traffic flow"""
802
803 def runTest(self):
804 logging.info("Running cycling vlan test")
805
alshabib2ecca692016-03-01 15:10:38 -0800806 for stag in xrange(2, 4000, 100):
807 for ctag in xrange(2, 4000, 100):
alshabibf1f07dd2016-03-01 15:50:35 -0800808 delete_all_flows(self.controller)
809 time.sleep(5)
Admin44f754e2016-03-01 23:00:46 -0800810 self.installDoubleTaggingRules(stag, ctag)
alshabibf1f07dd2016-03-01 15:50:35 -0800811 time.sleep(5)
alshabib3f3da0e2016-03-01 23:23:45 -0800812 self.testPacketFlow(stag, ctag)
alshabibb9d4ee82016-03-01 14:12:42 -0800813
alshabib9929a152016-03-01 21:25:18 -0800814
alshabibb9b39a72016-03-01 15:52:03 -0800815
alshabibb9d4ee82016-03-01 14:12:42 -0800816
alshabibb9d4ee82016-03-01 14:12:42 -0800817
alshabibb9d4ee82016-03-01 14:12:42 -0800818
alshabibb9d4ee82016-03-01 14:12:42 -0800819
alshabibb9d4ee82016-03-01 14:12:42 -0800820
alshabibb9d4ee82016-03-01 14:12:42 -0800821
alshabibb9d4ee82016-03-01 14:12:42 -0800822