blob: 59713a61032cd8742fcc62b4413f5b04d1fe7ddb [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")]
alshabibd0704562016-03-02 15:40:23 -080062 pkt = IGMPv3.fixup( scapy.Ether(src='00:00:00:00:be:ef', dst='01:00:5e:32:00:fe') \
63 / scapy.IP() / igmp )
alshabibb9d4ee82016-03-01 14:12:42 -080064 pkt = pkt / ("0" * (100 - len(pkt)))
65
alshabibcde318b2016-03-01 22:49:13 -080066 self.testPacketIn(match, pkt)
Admin7e9c91d2015-08-25 15:53:49 -070067
alshabibb9d4ee82016-03-01 14:12:42 -080068
alshabibcde318b2016-03-01 22:49:13 -080069class IGMPQueryPacketOut(OltBaseTest):
Admind5212782015-12-09 17:17:57 -080070 """Verify sending multicast membership queries down to onu_ports"""
alshabibb9d4ee82016-03-01 14:12:42 -080071
Admind5212782015-12-09 17:17:57 -080072 def runTest(self):
73 logging.info("Running IGMP query packet out")
74
Zsolt Harasztife525502016-03-02 05:18:52 +000075 igmp = IGMPv3() # by default this is a query
Admind5212782015-12-09 17:17:57 -080076 pkt = buildIgmp(igmp)
77
Zsolt Harasztife525502016-03-02 05:18:52 +000078 msg = ofp.message.packet_out(
79 in_port=ofp.OFPP_CONTROLLER,
80 actions=[ofp.action.output(port=onu_port)],
81 buffer_id=ofp.OFP_NO_BUFFER,
82 data=str(pkt))
Admind5212782015-12-09 17:17:57 -080083
alshabibb9d4ee82016-03-01 14:12:42 -080084 self.controller.message_send(msg)
Admind5212782015-12-09 17:17:57 -080085
Zsolt Harasztife525502016-03-02 05:18:52 +000086 rv = self.controller.message_send(msg)
87 self.assertTrue(rv == 0, "Error sending put message")
Admind5212782015-12-09 17:17:57 -080088 verify_no_errors(self.controller)
89
90 verify_packet(self, pkt, onu_port)
91
alshabibb9d4ee82016-03-01 14:12:42 -080092
alshabibcde318b2016-03-01 22:49:13 -080093class TestMeter(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +000094
Admin7e9c91d2015-08-25 15:53:49 -070095 def runTest(self):
96 logging.info("Running Meter tests")
alshabibb9d4ee82016-03-01 14:12:42 -080097 dropMeterBand = ofp.meter_band.drop(rate=640)
98 meter_mod = ofp.message.meter_mod(xid=1, command=ofp.OFPMC_ADD, meter_id=1, meters=[dropMeterBand])
Admin7e9c91d2015-08-25 15:53:49 -070099 self.controller.message_send(meter_mod)
alshabibb9d4ee82016-03-01 14:12:42 -0800100
Admin7e9c91d2015-08-25 15:53:49 -0700101 time.sleep(1)
102
103 verify_no_errors(self.controller)
104
Jonathan Hartf65e1812015-10-05 15:15:37 -0700105 vlan_id = 201
Admin7e9c91d2015-08-25 15:53:49 -0700106 match = ofp.match()
107 match.oxm_list.append(ofp.oxm.in_port(onu_port))
alshabibb9d4ee82016-03-01 14:12:42 -0800108 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
Admin02d052c2015-10-10 19:08:26 -0700109
110 request = ofp.message.flow_add(
111 table_id=test_param_get("table", 0),
112 cookie=42,
113 match=match,
114 instructions=[
115 ofp.instruction.apply_actions(
Zsolt Harasztife525502016-03-02 05:18:52 +0000116 actions=[ofp.action.output(port=olt_port)]),
117 ofp.instruction.meter(meter_id = 1)
alshabibb9d4ee82016-03-01 14:12:42 -0800118 ],
Admin02d052c2015-10-10 19:08:26 -0700119 buffer_id=ofp.OFP_NO_BUFFER,
120 priority=1000)
121
122 self.controller.message_send(request)
123 time.sleep(1)
124 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800125
Admin02d052c2015-10-10 19:08:26 -0700126 match = ofp.match()
127 match.oxm_list.append(ofp.oxm.in_port(olt_port))
128 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
Admin7e9c91d2015-08-25 15:53:49 -0700129
130 request = ofp.message.flow_add(
131 table_id=test_param_get("table", 0),
132 cookie=43,
133 match=match,
134 instructions=[
135 ofp.instruction.apply_actions(
Zsolt Harasztife525502016-03-02 05:18:52 +0000136 actions=[ofp.action.output(port=onu_port)]),
137 ofp.instruction.meter(meter_id = 1)
alshabibb9d4ee82016-03-01 14:12:42 -0800138 ],
Admin7e9c91d2015-08-25 15:53:49 -0700139 buffer_id=ofp.OFP_NO_BUFFER,
140 priority=1000)
141
142 self.controller.message_send(request)
Admin7e9c91d2015-08-25 15:53:49 -0700143 time.sleep(1)
Admin7e9c91d2015-08-25 15:53:49 -0700144 verify_no_errors(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700145 do_barrier(self.controller)
146 time.sleep(5)
alshabibb9d4ee82016-03-01 14:12:42 -0800147
Jonathan Hartf65e1812015-10-05 15:15:37 -0700148 inPkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=vlan_id, vlan_pcp=0)
149 # downstream
alshabibb9d4ee82016-03-01 14:12:42 -0800150 # self.dataplane.send(olt_port, str(inPkt))
151 # verify_packet(self, inPkt, onu_port)
Admin02d052c2015-10-10 19:08:26 -0700152 # upstream
alshabibb9d4ee82016-03-01 14:12:42 -0800153 # for i in range(1,400):
154 # self.dataplane.send(onu_port, str(inPkt))
155 # verify_packet(self, inPkt, olt_port)
Admin02d052c2015-10-10 19:08:26 -0700156
Jonathan Hartf65e1812015-10-05 15:15:37 -0700157 # clean up the test
alshabibb9d4ee82016-03-01 14:12:42 -0800158 meter_mod = ofp.message.meter_mod(xid=2, command=ofp.OFPMC_DELETE, meter_id=1)
Admin02d052c2015-10-10 19:08:26 -0700159 self.controller.message_send(meter_mod)
160 time.sleep(1)
161 delete_all_flows(self.controller)
162 verify_no_errors(self.controller)
163
Admin7e9c91d2015-08-25 15:53:49 -0700164
alshabibcde318b2016-03-01 22:49:13 -0800165class TestDuplicateMeter(OltBaseTest):
Admin7e9c91d2015-08-25 15:53:49 -0700166 def runTest(self):
167 logging.info("Running Duplicate Meter Test")
alshabibb9d4ee82016-03-01 14:12:42 -0800168 dropMeterBand = ofp.meter_band.drop(rate=500)
169 meter_mod = ofp.message.meter_mod(xid=1, command=ofp.OFPMC_ADD, meter_id=1, meters=[dropMeterBand])
Admin7e9c91d2015-08-25 15:53:49 -0700170 self.controller.message_send(meter_mod)
171 self.controller.message_send(meter_mod)
172
173 time.sleep(1)
alshabibb9d4ee82016-03-01 14:12:42 -0800174
Admin7e9c91d2015-08-25 15:53:49 -0700175 try:
176 verify_no_errors(self.controller)
177 except AssertionError as e:
Admin09b5cc62015-10-11 13:53:59 -0700178 if (not e.message == "unexpected error type=12 code=1"):
Admin7e9c91d2015-08-25 15:53:49 -0700179 raise AssertionError("Incorrect error type: %s" % e.message)
alshabibb9d4ee82016-03-01 14:12:42 -0800180
181
alshabibcde318b2016-03-01 22:49:13 -0800182class VlanTest(OltBaseTest):
Admin7e9c91d2015-08-25 15:53:49 -0700183 """Verify the switch can push/pop a VLAN tag and forward out a port """
alshabibb9d4ee82016-03-01 14:12:42 -0800184
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700185 def runTest(self):
186 logging.info("Running push VLAN test")
alshabibb9d4ee82016-03-01 14:12:42 -0800187
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700188 vlan_id = 200
alshabibb9d4ee82016-03-01 14:12:42 -0800189
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700190 delete_all_flows(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800191
192 # PUSH
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700193 match = ofp.match()
194 match.oxm_list.append(ofp.oxm.in_port(onu_port))
Zsolt Harasztife525502016-03-02 05:18:52 +0000195 if device_type == "cpqd":
196 match.oxm_list.append(ofp.oxm.vlan_vid(value=ofp.OFPVID_NONE))
197 actions = [
198 ofp.action.push_vlan(ethertype=0x8100),
199 ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id)),
200 ofp.action.set_field(ofp.oxm.vlan_pcp(0)),
201 ofp.action.output(port=olt_port)
202 ]
203 else: # pmc, normal
204 match.oxm_list.append(ofp.oxm.vlan_vid_masked(value=ofp.OFPVID_PRESENT, value_mask=ofp.OFPVID_PRESENT))
205 match.oxm_list.append(ofp.oxm.vlan_pcp(value = 0))
206 actions = [
207 ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id)),
208 ofp.action.set_field(ofp.oxm.vlan_pcp(0)),
209 ofp.action.output(port=olt_port)
210 ]
alshabibb9d4ee82016-03-01 14:12:42 -0800211
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700212 request = ofp.message.flow_add(
213 table_id=test_param_get("table", 0),
214 cookie=42,
215 match=match,
Zsolt Harasztife525502016-03-02 05:18:52 +0000216 instructions=[ofp.instruction.apply_actions(actions=actions)],
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700217 buffer_id=ofp.OFP_NO_BUFFER,
218 priority=1000)
219
Admin7e9c91d2015-08-25 15:53:49 -0700220 logging.info("Inserting flow tagging upstream")
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700221 self.controller.message_send(request)
Zsolt Harasztife525502016-03-02 05:18:52 +0000222 do_barrier(self.controller)
223 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800224
225 # POP
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700226 match = ofp.match()
227 match.oxm_list.append(ofp.oxm.in_port(olt_port))
228 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
Admin7e9c91d2015-08-25 15:53:49 -0700229
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700230 request = ofp.message.flow_add(
231 table_id=test_param_get("table", 0),
Admin7e9c91d2015-08-25 15:53:49 -0700232 cookie=43,
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700233 match=match,
234 instructions=[
235 ofp.instruction.apply_actions(
Jonathan Hartf65e1812015-10-05 15:15:37 -0700236 actions=[
237 ofp.action.pop_vlan(),
alshabibb9d4ee82016-03-01 14:12:42 -0800238 ofp.action.output(port=onu_port)])],
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700239 buffer_id=ofp.OFP_NO_BUFFER,
240 priority=1000)
241
Admin7e9c91d2015-08-25 15:53:49 -0700242 logging.info("Inserting flow tagging downstream")
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700243 self.controller.message_send(request)
244 do_barrier(self.controller)
Zsolt Harasztife525502016-03-02 05:18:52 +0000245 verify_no_errors(self.controller)
246
Admin7e9c91d2015-08-25 15:53:49 -0700247 time.sleep(5)
Admin99c2a272016-03-01 12:56:39 -0800248
Admin7e9c91d2015-08-25 15:53:49 -0700249 inPkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=0, vlan_pcp=0)
alshabibb9d4ee82016-03-01 14:12:42 -0800250 outPkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True,
Admin7e9c91d2015-08-25 15:53:49 -0700251 vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0)
alshabibb9d4ee82016-03-01 14:12:42 -0800252
Admin7e9c91d2015-08-25 15:53:49 -0700253 # Send untagged packet in the ONU port and expect tagged packet out the OLT port
254 self.dataplane.send(onu_port, str(inPkt))
255 verify_packet(self, outPkt, olt_port)
alshabibb9d4ee82016-03-01 14:12:42 -0800256
Admin7e9c91d2015-08-25 15:53:49 -0700257 # Send untagged packet in the OLT port and expect no packets to come out
258 self.dataplane.send(olt_port, str(inPkt))
259 verify_packets(self, outPkt, [])
alshabibb9d4ee82016-03-01 14:12:42 -0800260
Admin7e9c91d2015-08-25 15:53:49 -0700261 inPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True,
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700262 vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0)
Zsolt Harasztife525502016-03-02 05:18:52 +0000263 if device_type == 'pmc':
264 outPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=0, vlan_pcp=0)
265 else: # "normal", "cpqd""
266 outPkt = simple_udp_packet(pktlen=100)
Admin7e9c91d2015-08-25 15:53:49 -0700267
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700268 # Send tagged packet in the OLT port and expect untagged packet out the OLT port
269 self.dataplane.send(olt_port, str(inPkt))
270 verify_packet(self, outPkt, onu_port)
Admin7e9c91d2015-08-25 15:53:49 -0700271
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700272 # Send tagged packet in the ONU port and expect no packets to come out
273 self.dataplane.send(onu_port, str(inPkt))
Admin7e9c91d2015-08-25 15:53:49 -0700274 verify_packets(self, outPkt, [])
Jonathan Hartf65e1812015-10-05 15:15:37 -0700275
alshabibb9d4ee82016-03-01 14:12:42 -0800276
Jonathan Hartf65e1812015-10-05 15:15:37 -0700277
alshabibb9d4ee82016-03-01 14:12:42 -0800278
alshabibb9d4ee82016-03-01 14:12:42 -0800279
alshabibcde318b2016-03-01 22:49:13 -0800280class TestGroupAdd(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000281
Admin02d052c2015-10-10 19:08:26 -0700282 def runTest(self):
283 logging.info("Running Group tests")
284 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700285 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700286
alshabibb9d4ee82016-03-01 14:12:42 -0800287 test_group_id = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700288
289 # output to two ONU
290 group_add = createAllGroupAdd(test_group_id, ports=[onu_port, onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700291
292 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700293 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700294 verify_no_errors(self.controller)
295
296 # Remove the group and then readd it.
alshabibb9d4ee82016-03-01 14:12:42 -0800297 group_delete = ofp.message.group_delete(group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700298 self.controller.message_send(group_delete)
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
Jonathan Hartf65e1812015-10-05 15:15:37 -0700302 group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700303 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700304 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700305 verify_no_errors(self.controller)
306
307
Jonathan Hartf65e1812015-10-05 15:15:37 -0700308 # clean up the test
alshabibb9d4ee82016-03-01 14:12:42 -0800309 group_delete = ofp.message.group_delete(group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700310 self.controller.message_send(group_delete)
alshabibb9d4ee82016-03-01 14:12:42 -0800311
Jonathan Hartf65e1812015-10-05 15:15:37 -0700312 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700313 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800314
315
alshabibcde318b2016-03-01 22:49:13 -0800316class TestGroupMod(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000317
Admin02d052c2015-10-10 19:08:26 -0700318 def runTest(self):
319 logging.info("Running Group tests")
320 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700321 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700322
alshabibb9d4ee82016-03-01 14:12:42 -0800323 test_group_id = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700324
325 group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700326
327 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700328 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700329 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800330
Jonathan Hartf65e1812015-10-05 15:15:37 -0700331 # Modifying the group
332 group_mod = createAllGroupMod(test_group_id, [onu_port2])
alshabibb9d4ee82016-03-01 14:12:42 -0800333
Jonathan Hartf65e1812015-10-05 15:15:37 -0700334 self.controller.message_send(group_mod)
335 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700336 verify_no_errors(self.controller)
337
Jonathan Hartf65e1812015-10-05 15:15:37 -0700338 # Add a bucket into the group
339 group_mod = createAllGroupMod(test_group_id, [onu_port, onu_port2])
340 self.controller.message_send(group_mod)
341 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700342 verify_no_errors(self.controller)
343
344 # Modifying a non-existing group
Jonathan Hartf65e1812015-10-05 15:15:37 -0700345 group_mod = createAllGroupMod(777, [onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700346
Jonathan Hartf65e1812015-10-05 15:15:37 -0700347 self.controller.message_send(group_mod)
348 do_barrier(self.controller)
349 errorExperienced = 0
Admin02d052c2015-10-10 19:08:26 -0700350 try:
351 verify_no_errors(self.controller)
352 except AssertionError as e:
Jonathan Hartf65e1812015-10-05 15:15:37 -0700353 errorExperienced = 1
Admin02d052c2015-10-10 19:08:26 -0700354 if (not (e.message == "unexpected error type=6 code=8")):
Jonathan Hartf65e1812015-10-05 15:15:37 -0700355 raise AssertionError("Incorrect error type: %s" % e.message)
alshabibb9d4ee82016-03-01 14:12:42 -0800356 if not errorExperienced:
Jonathan Hartf65e1812015-10-05 15:15:37 -0700357 raise AssertionError("An error message is expected, but not shown.")
alshabibb9d4ee82016-03-01 14:12:42 -0800358
359
Jonathan Hartf65e1812015-10-05 15:15:37 -0700360 # clean up the test
alshabibb9d4ee82016-03-01 14:12:42 -0800361 group_delete = ofp.message.group_delete(xid=2, group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700362 self.controller.message_send(group_delete)
alshabibb9d4ee82016-03-01 14:12:42 -0800363
Jonathan Hartf65e1812015-10-05 15:15:37 -0700364 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700365 verify_no_errors(self.controller)
366
alshabibb9d4ee82016-03-01 14:12:42 -0800367
alshabibcde318b2016-03-01 22:49:13 -0800368class TestDuplicateGroup(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000369
Admin02d052c2015-10-10 19:08:26 -0700370 def runTest(self):
371 logging.info("Running Group tests")
372 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700373 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700374
alshabibb9d4ee82016-03-01 14:12:42 -0800375 test_group_id = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700376 group_add = createAllGroupAdd(test_group_id, ports=[onu_port])
Admin02d052c2015-10-10 19:08:26 -0700377
378 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700379 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700380 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800381
Jonathan Hartf65e1812015-10-05 15:15:37 -0700382 # Add the same group id
alshabibb9d4ee82016-03-01 14:12:42 -0800383 duplicate_group_fail = 0
384
Admin02d052c2015-10-10 19:08:26 -0700385 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700386 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700387 try:
388 verify_no_errors(self.controller)
389 except AssertionError as e:
alshabibb9d4ee82016-03-01 14:12:42 -0800390 duplicate_group_fail = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700391 if (not e.message == "unexpected error type=6 code=0"):
392 raise AssertionError("Incorrect error type: %s" % e.message)
393 if not duplicate_group_fail:
394 raise AssertionError("Adding duplicate groups didn't raise an error.")
alshabibb9d4ee82016-03-01 14:12:42 -0800395
Jonathan Hartf65e1812015-10-05 15:15:37 -0700396 # clean up the test
alshabibb9d4ee82016-03-01 14:12:42 -0800397 group_delete = ofp.message.group_delete(xid=2, group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700398 self.controller.message_send(group_delete)
alshabibb9d4ee82016-03-01 14:12:42 -0800399
Jonathan Hartf65e1812015-10-05 15:15:37 -0700400 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700401 verify_no_errors(self.controller)
402
alshabibb9d4ee82016-03-01 14:12:42 -0800403
alshabibcde318b2016-03-01 22:49:13 -0800404class TestGroupAndFlow(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000405
Admin02d052c2015-10-10 19:08:26 -0700406 def runTest(self):
407 logging.info("Running Group tests")
408 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700409 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700410
Jonathan Hartf65e1812015-10-05 15:15:37 -0700411 # Create a group
alshabibb9d4ee82016-03-01 14:12:42 -0800412 test_group_id = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700413 group_add = createAllGroupAdd(test_group_id, ports=[onu_port])
Admin02d052c2015-10-10 19:08:26 -0700414
415 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700416 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700417 verify_no_errors(self.controller)
418
419 # Create a flow rule matching olt port and vlan id
420 match = ofp.match()
421 match.oxm_list.append(ofp.oxm.in_port(olt_port))
422 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | 201))
423
Jonathan Hartf65e1812015-10-05 15:15:37 -0700424 flow_pointing_to_group = ofp.message.flow_add(
Admin02d052c2015-10-10 19:08:26 -0700425 table_id=test_param_get("table", 0),
426 cookie=43,
427 match=match,
428 instructions=[
429 ofp.instruction.apply_actions(
alshabibb9d4ee82016-03-01 14:12:42 -0800430 actions=[ofp.action.group(group_id=test_group_id)])],
431 buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
Admin02d052c2015-10-10 19:08:26 -0700432
Jonathan Hartf65e1812015-10-05 15:15:37 -0700433 self.controller.message_send(flow_pointing_to_group)
434 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700435 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800436
Jonathan Hartf65e1812015-10-05 15:15:37 -0700437 # After letting a flow rule point to the group, test we can do group_mod
438 group_mod = createAllGroupMod(test_group_id, ports=[onu_port2])
439 self.controller.message_send(group_mod)
440 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700441 verify_no_errors(self.controller)
442
443 # Test we can remove flows and then remove group
alshabibb9d4ee82016-03-01 14:12:42 -0800444 flow_delete = ofp.message.flow_delete(table_id=test_param_get("table", 0))
Jonathan Hartf65e1812015-10-05 15:15:37 -0700445 self.controller.message_send(flow_delete)
446 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700447 verify_no_errors(self.controller)
448
alshabibb9d4ee82016-03-01 14:12:42 -0800449 group_delete = ofp.message.group_delete(xid=3, group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700450 self.controller.message_send(group_delete)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700451 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700452 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800453
Zsolt Harasztife525502016-03-02 05:18:52 +0000454 # Add the group and flow back, test it we can first remove group and then remove the flow.
Admindcb1bc72015-11-12 18:24:56 -0800455 '''group_add = createAllGroupAdd(test_group_id, ports=[onu_port])
Admin02d052c2015-10-10 19:08:26 -0700456 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700457
458 self.controller.message_send(flow_pointing_to_group)
459 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700460 verify_no_errors(self.controller)
461
462 group_delete = ofp.message.group_delete(xid = 4, group_id = test_group_id)
Admindcb1bc72015-11-12 18:24:56 -0800463 self.controller.message_send(group_delete)'''
Jonathan Hartf65e1812015-10-05 15:15:37 -0700464
465 self.controller.message_send(flow_delete)
466 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700467 verify_no_errors(self.controller)
468
469
alshabibcde318b2016-03-01 22:49:13 -0800470class TestGroupForwarding(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000471
Admin02d052c2015-10-10 19:08:26 -0700472 def runTest(self):
473 logging.info("Running Group datapath forwarding tests")
474 delete_all_flows(self.controller)
Admin99c2a272016-03-01 12:56:39 -0800475 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700476
Admin09b5cc62015-10-11 13:53:59 -0700477 vlan_id = 201
Admin02d052c2015-10-10 19:08:26 -0700478
Jonathan Hartf65e1812015-10-05 15:15:37 -0700479 # Create a group
alshabibb9d4ee82016-03-01 14:12:42 -0800480 test_group_id = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700481 group_add = createAllGroupAdd(test_group_id, [onu_port])
Admin02d052c2015-10-10 19:08:26 -0700482
483 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700484 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700485 verify_no_errors(self.controller)
486
487 # Create a flow rule matching olt port and vlan id
488 match = ofp.match()
489 match.oxm_list.append(ofp.oxm.in_port(olt_port))
490 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
491
492 request = ofp.message.flow_add(
493 table_id=test_param_get("table", 0),
494 cookie=43,
495 match=match,
496 instructions=[
497 ofp.instruction.apply_actions(
alshabibb9d4ee82016-03-01 14:12:42 -0800498 actions=[ofp.action.group(group_id=test_group_id)]),
499 ],
500 buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
Admin02d052c2015-10-10 19:08:26 -0700501
502 self.controller.message_send(request)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700503 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700504 verify_no_errors(self.controller)
Admin09b5cc62015-10-11 13:53:59 -0700505
506 # It takes some time for flows to propagate down to the data plane
Admindcb1bc72015-11-12 18:24:56 -0800507 time.sleep(10)
alshabibb9d4ee82016-03-01 14:12:42 -0800508
509 inPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True,
Admindcb1bc72015-11-12 18:24:56 -0800510 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 -0700511 outPkt = inPkt
512 self.dataplane.send(olt_port, str(inPkt))
513 verify_packet(self, outPkt, onu_port)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700514
Admindcb1bc72015-11-12 18:24:56 -0800515
Zsolt Harasztife525502016-03-02 05:18:52 +0000516 # Now put 2 ONU ports in the group and test that the input packet is
Jonathan Hartf65e1812015-10-05 15:15:37 -0700517 # duplicated out both ports
518 group_mod = createAllGroupMod(test_group_id, ports=[onu_port, onu_port2])
519 self.controller.message_send(group_mod)
520 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700521 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800522
Admin09b5cc62015-10-11 13:53:59 -0700523 # It takes some time for flows to propagate down to the data plane
Admindcb1bc72015-11-12 18:24:56 -0800524 time.sleep(10)
Admin09b5cc62015-10-11 13:53:59 -0700525
Jonathan Hartf65e1812015-10-05 15:15:37 -0700526 self.dataplane.send(olt_port, str(inPkt))
Jonathan Hartf65e1812015-10-05 15:15:37 -0700527 verify_packet(self, outPkt, onu_port2)
Admindcb1bc72015-11-12 18:24:56 -0800528 verify_packet(self, outPkt, onu_port)
alshabibb9d4ee82016-03-01 14:12:42 -0800529 # verify_packets(self, outPkt, [onu_port,onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700530
Jonathan Hartf65e1812015-10-05 15:15:37 -0700531 # clean up the test
alshabibb9d4ee82016-03-01 14:12:42 -0800532 request = ofp.message.flow_delete(table_id=test_param_get("table", 0))
Admin02d052c2015-10-10 19:08:26 -0700533 self.controller.message_send(request)
alshabibb9d4ee82016-03-01 14:12:42 -0800534 group_delete = ofp.message.group_delete(xid=2, group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700535 self.controller.message_send(group_delete)
alshabibb9d4ee82016-03-01 14:12:42 -0800536
Jonathan Hartf65e1812015-10-05 15:15:37 -0700537 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700538 verify_no_errors(self.controller)
539
Admindcb1bc72015-11-12 18:24:56 -0800540
alshabibcde318b2016-03-01 22:49:13 -0800541class TestGroupModForwarding(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000542
Admindcb1bc72015-11-12 18:24:56 -0800543 def runTest(self):
alshabibb9d4ee82016-03-01 14:12:42 -0800544 logging.info("Running datapath forwarding tests for group mod")
Admindcb1bc72015-11-12 18:24:56 -0800545 delete_all_flows(self.controller)
546 delete_all_groups(self.controller)
547
548 vlan_id = 201
549
550 # Create a group
alshabibb9d4ee82016-03-01 14:12:42 -0800551 test_group_id = 1
Admindcb1bc72015-11-12 18:24:56 -0800552 group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2])
553
554 self.controller.message_send(group_add)
555 do_barrier(self.controller)
556 verify_no_errors(self.controller)
557
558 # Create a flow rule matching olt port and vlan id
559 match = ofp.match()
560 match.oxm_list.append(ofp.oxm.in_port(olt_port))
561 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
562
563 request = ofp.message.flow_add(
564 table_id=test_param_get("table", 0),
565 cookie=43,
566 match=match,
567 instructions=[
568 ofp.instruction.apply_actions(
alshabibb9d4ee82016-03-01 14:12:42 -0800569 actions=[ofp.action.group(group_id=test_group_id)]),
570 ],
571 buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
Admindcb1bc72015-11-12 18:24:56 -0800572
573 self.controller.message_send(request)
574 do_barrier(self.controller)
575 verify_no_errors(self.controller)
576
577 # It takes some time for flows to propagate down to the data plane
578 time.sleep(10)
alshabibb9d4ee82016-03-01 14:12:42 -0800579
580 inPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True,
Admindcb1bc72015-11-12 18:24:56 -0800581 vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0, eth_dst="01:01:11:12:11:12")
582 outPkt = inPkt
583 self.dataplane.send(olt_port, str(inPkt))
584 verify_packet(self, outPkt, onu_port)
Admin99c2a272016-03-01 12:56:39 -0800585 verify_packet(self, outPkt, onu_port2)
Admindcb1bc72015-11-12 18:24:56 -0800586
587 # Now remove onu port 1 from the group and test that the input packet is no longer forwarded to onu port 1
588 group_mod = createAllGroupMod(test_group_id, ports=[onu_port2])
589 self.controller.message_send(group_mod)
590 do_barrier(self.controller)
591 verify_no_errors(self.controller)
592
593 time.sleep(10)
594 self.dataplane.send(olt_port, str(inPkt))
595 verify_no_packet(self, outPkt, onu_port)
596 verify_packet(self, outPkt, onu_port2)
597
Zsolt Harasztife525502016-03-02 05:18:52 +0000598 # 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 -0800599 group_mod = createAllGroupMod(test_group_id, ports=[])
600 self.controller.message_send(group_mod)
601 do_barrier(self.controller)
602 verify_no_errors(self.controller)
603 time.sleep(10)
604 self.dataplane.send(olt_port, str(inPkt))
605 verify_packets(self, outPkt, [])
606
607
alshabibcde318b2016-03-01 22:49:13 -0800608class TransparentVlanTest(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000609
Admin02d052c2015-10-10 19:08:26 -0700610 def runTest(self):
611 logging.info("Running transparent vlan tests")
Admin09b5cc62015-10-11 13:53:59 -0700612 delete_all_flows(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700613
Jonathan Hartf65e1812015-10-05 15:15:37 -0700614 vlan_id = 201
Admin02d052c2015-10-10 19:08:26 -0700615 match = ofp.match()
616 match.oxm_list.append(ofp.oxm.in_port(onu_port))
alshabibb9d4ee82016-03-01 14:12:42 -0800617 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
Admin02d052c2015-10-10 19:08:26 -0700618
619 request = ofp.message.flow_add(
620 table_id=test_param_get("table", 0),
621 cookie=42,
622 match=match,
623 instructions=[
624 ofp.instruction.apply_actions(
625 actions=[
626 ofp.action.output(port=olt_port)]),
alshabibb9d4ee82016-03-01 14:12:42 -0800627 ],
Admin02d052c2015-10-10 19:08:26 -0700628 buffer_id=ofp.OFP_NO_BUFFER,
629 priority=1000)
630
631 self.controller.message_send(request)
alshabibb9d4ee82016-03-01 14:12:42 -0800632
Admin02d052c2015-10-10 19:08:26 -0700633 match = ofp.match()
634 match.oxm_list.append(ofp.oxm.in_port(olt_port))
635 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
636
637 request = ofp.message.flow_add(
638 table_id=test_param_get("table", 0),
639 cookie=43,
640 match=match,
641 instructions=[
642 ofp.instruction.apply_actions(
643 actions=[
644 ofp.action.output(port=onu_port)]),
alshabibb9d4ee82016-03-01 14:12:42 -0800645 ],
Admin02d052c2015-10-10 19:08:26 -0700646 buffer_id=ofp.OFP_NO_BUFFER,
647 priority=1000)
648
649 self.controller.message_send(request)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700650 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700651 verify_no_errors(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700652
Admin09b5cc62015-10-11 13:53:59 -0700653 # It takes some time for flows to propagate down to the data plane
654 time.sleep(2)
alshabibb9d4ee82016-03-01 14:12:42 -0800655
Jonathan Hartf65e1812015-10-05 15:15:37 -0700656 inPkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=vlan_id, vlan_pcp=0)
Zsolt Harasztife525502016-03-02 05:18:52 +0000657
Admin02d052c2015-10-10 19:08:26 -0700658 # upstream
659 self.dataplane.send(onu_port, str(inPkt))
660 verify_packet(self, inPkt, olt_port)
Zsolt Harasztife525502016-03-02 05:18:52 +0000661
Admin99c2a272016-03-01 12:56:39 -0800662 # downstream
663 self.dataplane.send(olt_port, str(inPkt))
664 verify_packet(self, inPkt, onu_port)
Admin02d052c2015-10-10 19:08:26 -0700665
Jonathan Hartf65e1812015-10-05 15:15:37 -0700666 # clean up the test
Admin02d052c2015-10-10 19:08:26 -0700667 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700668 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700669 verify_no_errors(self.controller)
670
alshabibed97b5f2016-03-01 23:46:53 -0800671class TestMulticastForwarding(IGMPPacketIn):
672
673 def runTest(self):
674 delete_all_groups(self.controller)
675 # send igmp join packet
676 super(TestMulticastForwarding, self).runTest()
677
678 vlan_id = 201
679
alshabibc49e69c2016-03-01 23:49:25 -0800680 group = createAllGroupAdd(1, [onu_port])
alshabibed97b5f2016-03-01 23:46:53 -0800681
alshabib23f0e372016-03-01 23:50:37 -0800682 self.controller.message_send(group)
alshabibed97b5f2016-03-01 23:46:53 -0800683 do_barrier(self.controller)
684 verify_no_errors(self.controller)
685
686 # Create a flow rule matching olt port and vlan id
687 match = ofp.match()
688 match.oxm_list.append(ofp.oxm.in_port(olt_port))
689 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
690
691 request = ofp.message.flow_add(
692 table_id=test_param_get("table", 0),
693 cookie=43,
694 match=match,
695 instructions=[
696 ofp.instruction.apply_actions(
697 actions=[ofp.action.group(group_id=1)]),
698 ],
699 buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
700
701 self.controller.message_send(request)
702 do_barrier(self.controller)
703 verify_no_errors(self.controller)
704
705 # It takes some time for flows to propagate down to the data plane
706 time.sleep(5)
707
708 pkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=vlan_id, vlan_pcp=0, \
709 eth_dst = "01:00:5E:00:00:01", ip_dst = "229.10.20.30")
710
711 # downstream
712 self.dataplane.send(olt_port, str(pkt))
713 verify_packet(self, pkt, onu_port)
714
715 # clean up the test
716 delete_all_flows(self.controller)
717 do_barrier(self.controller)
718 verify_no_errors(self.controller)
719 delete_all_groups(self.controller)
720
721
alshabibcde318b2016-03-01 22:49:13 -0800722class RemoveRuleTest(OltBaseTest):
alshabib28c03c32016-03-01 20:33:51 -0800723
724 def runTest(self):
725 logging.info("Testing Rule removal")
alshabibe165af22016-03-01 21:42:17 -0800726 delete_all_flows(self.controller)
Admin44f754e2016-03-01 23:00:46 -0800727 self.processEapolRule(onu_port)
alshabibe165af22016-03-01 21:42:17 -0800728
alshabib9929a152016-03-01 21:25:18 -0800729 #wait for the rule to settle
730 time.sleep(3)
731
Admin44f754e2016-03-01 23:00:46 -0800732 self.installDoubleTaggingRules(1, 2)
alshabibe165af22016-03-01 21:42:17 -0800733
alshabib9929a152016-03-01 21:25:18 -0800734 #wait for the rules to settle
735 time.sleep(3)
736
737 stats = get_flow_stats(self, ofp.match())
738
Admin53e10b62016-03-01 21:52:18 -0800739 self.assertTrue(len(stats) == 5, \
740 "Wrong number of rules reports; reported %s, expected 5\n\n %s" % (len(stats), stats))
alshabib9929a152016-03-01 21:25:18 -0800741
Admin44f754e2016-03-01 23:00:46 -0800742 self.processEapolRule(onu_port, install = False)
alshabib9929a152016-03-01 21:25:18 -0800743 time.sleep(3)
744
745 stats = get_flow_stats(self, ofp.match())
746
Admin53e10b62016-03-01 21:52:18 -0800747 self.assertTrue(len(stats) == 4, \
748 "Wrong number of rules reports; reported %s, expected 4\n\n %s" % (len(stats), stats))
alshabib9929a152016-03-01 21:25:18 -0800749
alshabibd6be76e2016-03-01 22:21:00 -0800750 eapol = ofp.oxm.eth_type(0x888e)
751 found = False
752 for fe in stats:
753 if eapol in fe.match.oxm_list:
754 found = True
755
756 self.assertFalse(found, "Removed incorrect flow rule")
alshabib28c03c32016-03-01 20:33:51 -0800757
758
alshabibb5a09bc2016-03-02 13:26:43 -0800759class MultipleDoubleTaggingForwarding(OltBaseTest):
alshabib28c03c32016-03-01 20:33:51 -0800760
alshabib5d53c482016-03-01 23:25:39 -0800761 def runTest(self):
alshabib28c03c32016-03-01 20:33:51 -0800762 logging.info("Testing multiple Q-in-Q rules")
Adminb3bae672016-03-02 13:00:08 -0800763 delete_all_flows(self.controller)
alshabib3f3da0e2016-03-01 23:23:45 -0800764
alshabibb5a09bc2016-03-02 13:26:43 -0800765 self.processEapolRule(onu_port)
alshabib57a536a2016-03-02 13:21:28 -0800766
767 time.sleep(1)
768
alshabib3f3da0e2016-03-01 23:23:45 -0800769 self.installDoubleTaggingRules(10, 5, cookie=42, onu = onu_port)
770
Adminb3bae672016-03-02 13:00:08 -0800771 time.sleep(1)
alshabib3f3da0e2016-03-01 23:23:45 -0800772
Adminb3bae672016-03-02 13:00:08 -0800773 self.installDoubleTaggingRules(10, 30, cookie=50, onu = onu_port2)
alshabib3f3da0e2016-03-01 23:23:45 -0800774
Adminb3bae672016-03-02 13:00:08 -0800775 time.sleep(1)
alshabib3f3da0e2016-03-01 23:23:45 -0800776
777 self.testPacketFlow(10, 5, onu=onu_port)
Adminb3bae672016-03-02 13:00:08 -0800778 self.testPacketFlow(10, 30, onu=onu_port2)
alshabib3f3da0e2016-03-01 23:23:45 -0800779
Adminb3bae672016-03-02 13:00:08 -0800780 delete_all_flows(self.controller)
alshabib28c03c32016-03-01 20:33:51 -0800781
alshabibb9d4ee82016-03-01 14:12:42 -0800782
alshabibd6be76e2016-03-01 22:21:00 -0800783class DoubleVlanTest(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000784
Adminb17b1662015-10-19 15:50:53 -0700785 def runTest(self):
786 logging.info("Running double vlan tests")
787 delete_all_flows(self.controller)
788
789 c_vlan_id = 100
alshabibb9d4ee82016-03-01 14:12:42 -0800790 s_vlan_id = 102
Zsolt Harasztife525502016-03-02 05:18:52 +0000791
alshabibd6be76e2016-03-01 22:21:00 -0800792 self.installDoubleTaggingRules(s_vlan_id, c_vlan_id)
Adminb17b1662015-10-19 15:50:53 -0700793
Adminb17b1662015-10-19 15:50:53 -0700794 # It takes some time for flows to propagate down to the data plane
795 time.sleep(10)
alshabibb9d4ee82016-03-01 14:12:42 -0800796
Zsolt Harasztife525502016-03-02 05:18:52 +0000797 # Test packet flows
alshabib3f3da0e2016-03-01 23:23:45 -0800798 self.testPacketFlow(s_vlan_id, c_vlan_id)
Adminb17b1662015-10-19 15:50:53 -0700799
800 # clean up the test
801 delete_all_flows(self.controller)
802 do_barrier(self.controller)
803 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800804
805
alshabibcde318b2016-03-01 22:49:13 -0800806class TestCyclingDoubleVlan(OltBaseTest):
alshabibb9d4ee82016-03-01 14:12:42 -0800807 """Cycle through vlans and test traffic flow"""
808
809 def runTest(self):
810 logging.info("Running cycling vlan test")
811
alshabib2ecca692016-03-01 15:10:38 -0800812 for stag in xrange(2, 4000, 100):
813 for ctag in xrange(2, 4000, 100):
alshabibf1f07dd2016-03-01 15:50:35 -0800814 delete_all_flows(self.controller)
815 time.sleep(5)
Admin44f754e2016-03-01 23:00:46 -0800816 self.installDoubleTaggingRules(stag, ctag)
alshabibf1f07dd2016-03-01 15:50:35 -0800817 time.sleep(5)
alshabib3f3da0e2016-03-01 23:23:45 -0800818 self.testPacketFlow(stag, ctag)
alshabibb9d4ee82016-03-01 14:12:42 -0800819
alshabib9929a152016-03-01 21:25:18 -0800820
alshabibb9b39a72016-03-01 15:52:03 -0800821
alshabibb9d4ee82016-03-01 14:12:42 -0800822
alshabibb9d4ee82016-03-01 14:12:42 -0800823
alshabibb9d4ee82016-03-01 14:12:42 -0800824
alshabibb9d4ee82016-03-01 14:12:42 -0800825
alshabibb9d4ee82016-03-01 14:12:42 -0800826
alshabibb9d4ee82016-03-01 14:12:42 -0800827
alshabibb9d4ee82016-03-01 14:12:42 -0800828