blob: 2a68933c3d99666f00f76e7704495721d5b4350f [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
Zsolt Harasztiecf89452016-03-01 22:38:13 -080014from IGMP import IGMPv3, IGMPv3gr, IGMP_TYPE_V3_MEMBERSHIP_REPORT, IGMP_V3_GR_TYPE_INCLUDE
15
Zsolt Harasztife525502016-03-02 05:18:52 +000016
alshabibcde318b2016-03-01 22:49:13 -080017from oltconstants import *
Jonathan Hartf2511ca2015-07-07 14:18:19 -070018
alshabibb9d4ee82016-03-01 14:12:42 -080019
alshabibcde318b2016-03-01 22:49:13 -080020class EapolPacketIn(OltBaseTest):
Jonathan Hartf2511ca2015-07-07 14:18:19 -070021 """Verify packet-ins are sent for EAPOL packets """
alshabibb9d4ee82016-03-01 14:12:42 -080022
Jonathan Hartf2511ca2015-07-07 14:18:19 -070023 def runTest(self):
24 logging.info("Running EAPOL Packet In test")
25
26 match = ofp.match()
27 match.oxm_list.append(ofp.oxm.eth_type(0x888e))
28 # Use ethertype 0x888e and multicast destination MAC address
29 pkt = simple_eth_packet(pktlen=60, eth_dst='01:00:5E:7F:FF:FF', eth_type=0x888e)
alshabibb9d4ee82016-03-01 14:12:42 -080030
alshabibcde318b2016-03-01 22:49:13 -080031 self.testPacketIn(match, pkt)
Jonathan Hartf2511ca2015-07-07 14:18:19 -070032
alshabibb9d4ee82016-03-01 14:12:42 -080033
alshabibcde318b2016-03-01 22:49:13 -080034class ARPPacketIn(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +000035 """Verify packet-ins are sent for ARP packets """
alshabib9929a152016-03-01 21:25:18 -080036
Zsolt Harasztife525502016-03-02 05:18:52 +000037 def runTest(self):
38 logging.info("Running ARP Packet In test")
alshabib9929a152016-03-01 21:25:18 -080039
Zsolt Harasztife525502016-03-02 05:18:52 +000040 match = ofp.match()
41 match.oxm_list.append(ofp.oxm.eth_type(0x0806))
42
43 # Use ethertype 0x0806
44 pkt = simple_eth_packet(eth_type=0x0806)
45
alshabibcde318b2016-03-01 22:49:13 -080046 self.testPacketIn(match, pkt)
alshabib9929a152016-03-01 21:25:18 -080047
48
alshabibcde318b2016-03-01 22:49:13 -080049class IGMPPacketIn(OltBaseTest):
Jonathan Hartf2511ca2015-07-07 14:18:19 -070050 """Verify packet-ins are sent for IGMP packets """
alshabibb9d4ee82016-03-01 14:12:42 -080051
Jonathan Hartf2511ca2015-07-07 14:18:19 -070052 def runTest(self):
53 logging.info("Running IGMP Packet In test")
54
55 match = ofp.match()
56 match.oxm_list.append(ofp.oxm.eth_type(0x800))
57 match.oxm_list.append(ofp.oxm.ip_proto(2))
Jonathan Hartf2511ca2015-07-07 14:18:19 -070058
Zsolt Harasztiecf89452016-03-01 22:38:13 -080059 igmp = IGMPv3(type=IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30, gaddr="224.0.0.1")
60 igmp.grps = [IGMPv3gr(rtype=IGMP_V3_GR_TYPE_INCLUDE, mcaddr="229.10.20.30")]
61 pkt = IGMPv3.fixup( scapy.Ether(src='00:00:00:00:be:ef') / scapy.IP() / igmp )
alshabibb9d4ee82016-03-01 14:12:42 -080062 pkt = pkt / ("0" * (100 - len(pkt)))
63
alshabibcde318b2016-03-01 22:49:13 -080064 self.testPacketIn(match, pkt)
Admin7e9c91d2015-08-25 15:53:49 -070065
alshabibb9d4ee82016-03-01 14:12:42 -080066
alshabibcde318b2016-03-01 22:49:13 -080067class IGMPQueryPacketOut(OltBaseTest):
Admind5212782015-12-09 17:17:57 -080068 """Verify sending multicast membership queries down to onu_ports"""
alshabibb9d4ee82016-03-01 14:12:42 -080069
Admind5212782015-12-09 17:17:57 -080070 def runTest(self):
71 logging.info("Running IGMP query packet out")
72
Zsolt Harasztife525502016-03-02 05:18:52 +000073 igmp = IGMPv3() # by default this is a query
Admind5212782015-12-09 17:17:57 -080074 pkt = buildIgmp(igmp)
75
Zsolt Harasztife525502016-03-02 05:18:52 +000076 msg = ofp.message.packet_out(
77 in_port=ofp.OFPP_CONTROLLER,
78 actions=[ofp.action.output(port=onu_port)],
79 buffer_id=ofp.OFP_NO_BUFFER,
80 data=str(pkt))
Admind5212782015-12-09 17:17:57 -080081
alshabibb9d4ee82016-03-01 14:12:42 -080082 self.controller.message_send(msg)
Admind5212782015-12-09 17:17:57 -080083
Zsolt Harasztife525502016-03-02 05:18:52 +000084 rv = self.controller.message_send(msg)
85 self.assertTrue(rv == 0, "Error sending put message")
Admind5212782015-12-09 17:17:57 -080086 verify_no_errors(self.controller)
87
88 verify_packet(self, pkt, onu_port)
89
alshabibb9d4ee82016-03-01 14:12:42 -080090
alshabibcde318b2016-03-01 22:49:13 -080091class TestMeter(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +000092
Admin7e9c91d2015-08-25 15:53:49 -070093 def runTest(self):
94 logging.info("Running Meter tests")
alshabibb9d4ee82016-03-01 14:12:42 -080095 dropMeterBand = ofp.meter_band.drop(rate=640)
96 meter_mod = ofp.message.meter_mod(xid=1, command=ofp.OFPMC_ADD, meter_id=1, meters=[dropMeterBand])
Admin7e9c91d2015-08-25 15:53:49 -070097 self.controller.message_send(meter_mod)
alshabibb9d4ee82016-03-01 14:12:42 -080098
Admin7e9c91d2015-08-25 15:53:49 -070099 time.sleep(1)
100
101 verify_no_errors(self.controller)
102
Jonathan Hartf65e1812015-10-05 15:15:37 -0700103 vlan_id = 201
Admin7e9c91d2015-08-25 15:53:49 -0700104 match = ofp.match()
105 match.oxm_list.append(ofp.oxm.in_port(onu_port))
alshabibb9d4ee82016-03-01 14:12:42 -0800106 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
Admin02d052c2015-10-10 19:08:26 -0700107
108 request = ofp.message.flow_add(
109 table_id=test_param_get("table", 0),
110 cookie=42,
111 match=match,
112 instructions=[
113 ofp.instruction.apply_actions(
Zsolt Harasztife525502016-03-02 05:18:52 +0000114 actions=[ofp.action.output(port=olt_port)]),
115 ofp.instruction.meter(meter_id = 1)
alshabibb9d4ee82016-03-01 14:12:42 -0800116 ],
Admin02d052c2015-10-10 19:08:26 -0700117 buffer_id=ofp.OFP_NO_BUFFER,
118 priority=1000)
119
120 self.controller.message_send(request)
121 time.sleep(1)
122 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800123
Admin02d052c2015-10-10 19:08:26 -0700124 match = ofp.match()
125 match.oxm_list.append(ofp.oxm.in_port(olt_port))
126 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
Admin7e9c91d2015-08-25 15:53:49 -0700127
128 request = ofp.message.flow_add(
129 table_id=test_param_get("table", 0),
130 cookie=43,
131 match=match,
132 instructions=[
133 ofp.instruction.apply_actions(
Zsolt Harasztife525502016-03-02 05:18:52 +0000134 actions=[ofp.action.output(port=onu_port)]),
135 ofp.instruction.meter(meter_id = 1)
alshabibb9d4ee82016-03-01 14:12:42 -0800136 ],
Admin7e9c91d2015-08-25 15:53:49 -0700137 buffer_id=ofp.OFP_NO_BUFFER,
138 priority=1000)
139
140 self.controller.message_send(request)
Admin7e9c91d2015-08-25 15:53:49 -0700141 time.sleep(1)
Admin7e9c91d2015-08-25 15:53:49 -0700142 verify_no_errors(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700143 do_barrier(self.controller)
144 time.sleep(5)
alshabibb9d4ee82016-03-01 14:12:42 -0800145
Jonathan Hartf65e1812015-10-05 15:15:37 -0700146 inPkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=vlan_id, vlan_pcp=0)
147 # downstream
alshabibb9d4ee82016-03-01 14:12:42 -0800148 # self.dataplane.send(olt_port, str(inPkt))
149 # verify_packet(self, inPkt, onu_port)
Admin02d052c2015-10-10 19:08:26 -0700150 # upstream
alshabibb9d4ee82016-03-01 14:12:42 -0800151 # for i in range(1,400):
152 # self.dataplane.send(onu_port, str(inPkt))
153 # verify_packet(self, inPkt, olt_port)
Admin02d052c2015-10-10 19:08:26 -0700154
Jonathan Hartf65e1812015-10-05 15:15:37 -0700155 # clean up the test
alshabibb9d4ee82016-03-01 14:12:42 -0800156 meter_mod = ofp.message.meter_mod(xid=2, command=ofp.OFPMC_DELETE, meter_id=1)
Admin02d052c2015-10-10 19:08:26 -0700157 self.controller.message_send(meter_mod)
158 time.sleep(1)
159 delete_all_flows(self.controller)
160 verify_no_errors(self.controller)
161
Admin7e9c91d2015-08-25 15:53:49 -0700162
alshabibcde318b2016-03-01 22:49:13 -0800163class TestDuplicateMeter(OltBaseTest):
Admin7e9c91d2015-08-25 15:53:49 -0700164 def runTest(self):
165 logging.info("Running Duplicate Meter Test")
alshabibb9d4ee82016-03-01 14:12:42 -0800166 dropMeterBand = ofp.meter_band.drop(rate=500)
167 meter_mod = ofp.message.meter_mod(xid=1, command=ofp.OFPMC_ADD, meter_id=1, meters=[dropMeterBand])
Admin7e9c91d2015-08-25 15:53:49 -0700168 self.controller.message_send(meter_mod)
169 self.controller.message_send(meter_mod)
170
171 time.sleep(1)
alshabibb9d4ee82016-03-01 14:12:42 -0800172
Admin7e9c91d2015-08-25 15:53:49 -0700173 try:
174 verify_no_errors(self.controller)
175 except AssertionError as e:
Admin09b5cc62015-10-11 13:53:59 -0700176 if (not e.message == "unexpected error type=12 code=1"):
Admin7e9c91d2015-08-25 15:53:49 -0700177 raise AssertionError("Incorrect error type: %s" % e.message)
alshabibb9d4ee82016-03-01 14:12:42 -0800178
179
alshabibcde318b2016-03-01 22:49:13 -0800180class VlanTest(OltBaseTest):
Admin7e9c91d2015-08-25 15:53:49 -0700181 """Verify the switch can push/pop a VLAN tag and forward out a port """
alshabibb9d4ee82016-03-01 14:12:42 -0800182
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700183 def runTest(self):
184 logging.info("Running push VLAN test")
alshabibb9d4ee82016-03-01 14:12:42 -0800185
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700186 vlan_id = 200
alshabibb9d4ee82016-03-01 14:12:42 -0800187
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700188 delete_all_flows(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800189
190 # PUSH
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700191 match = ofp.match()
192 match.oxm_list.append(ofp.oxm.in_port(onu_port))
Zsolt Harasztife525502016-03-02 05:18:52 +0000193 if device_type == "cpqd":
194 match.oxm_list.append(ofp.oxm.vlan_vid(value=ofp.OFPVID_NONE))
195 actions = [
196 ofp.action.push_vlan(ethertype=0x8100),
197 ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id)),
198 ofp.action.set_field(ofp.oxm.vlan_pcp(0)),
199 ofp.action.output(port=olt_port)
200 ]
201 else: # pmc, normal
202 match.oxm_list.append(ofp.oxm.vlan_vid_masked(value=ofp.OFPVID_PRESENT, value_mask=ofp.OFPVID_PRESENT))
203 match.oxm_list.append(ofp.oxm.vlan_pcp(value = 0))
204 actions = [
205 ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id)),
206 ofp.action.set_field(ofp.oxm.vlan_pcp(0)),
207 ofp.action.output(port=olt_port)
208 ]
alshabibb9d4ee82016-03-01 14:12:42 -0800209
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700210 request = ofp.message.flow_add(
211 table_id=test_param_get("table", 0),
212 cookie=42,
213 match=match,
Zsolt Harasztife525502016-03-02 05:18:52 +0000214 instructions=[ofp.instruction.apply_actions(actions=actions)],
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700215 buffer_id=ofp.OFP_NO_BUFFER,
216 priority=1000)
217
Admin7e9c91d2015-08-25 15:53:49 -0700218 logging.info("Inserting flow tagging upstream")
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700219 self.controller.message_send(request)
Zsolt Harasztife525502016-03-02 05:18:52 +0000220 do_barrier(self.controller)
221 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800222
223 # POP
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700224 match = ofp.match()
225 match.oxm_list.append(ofp.oxm.in_port(olt_port))
226 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
Admin7e9c91d2015-08-25 15:53:49 -0700227
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700228 request = ofp.message.flow_add(
229 table_id=test_param_get("table", 0),
Admin7e9c91d2015-08-25 15:53:49 -0700230 cookie=43,
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700231 match=match,
232 instructions=[
233 ofp.instruction.apply_actions(
Jonathan Hartf65e1812015-10-05 15:15:37 -0700234 actions=[
235 ofp.action.pop_vlan(),
alshabibb9d4ee82016-03-01 14:12:42 -0800236 ofp.action.output(port=onu_port)])],
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700237 buffer_id=ofp.OFP_NO_BUFFER,
238 priority=1000)
239
Admin7e9c91d2015-08-25 15:53:49 -0700240 logging.info("Inserting flow tagging downstream")
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700241 self.controller.message_send(request)
242 do_barrier(self.controller)
Zsolt Harasztife525502016-03-02 05:18:52 +0000243 verify_no_errors(self.controller)
244
Admin7e9c91d2015-08-25 15:53:49 -0700245 time.sleep(5)
Admin99c2a272016-03-01 12:56:39 -0800246
Admin7e9c91d2015-08-25 15:53:49 -0700247 inPkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=0, vlan_pcp=0)
alshabibb9d4ee82016-03-01 14:12:42 -0800248 outPkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True,
Admin7e9c91d2015-08-25 15:53:49 -0700249 vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0)
alshabibb9d4ee82016-03-01 14:12:42 -0800250
Admin7e9c91d2015-08-25 15:53:49 -0700251 # Send untagged packet in the ONU port and expect tagged packet out the OLT port
252 self.dataplane.send(onu_port, str(inPkt))
253 verify_packet(self, outPkt, olt_port)
alshabibb9d4ee82016-03-01 14:12:42 -0800254
Admin7e9c91d2015-08-25 15:53:49 -0700255 # Send untagged packet in the OLT port and expect no packets to come out
256 self.dataplane.send(olt_port, str(inPkt))
257 verify_packets(self, outPkt, [])
alshabibb9d4ee82016-03-01 14:12:42 -0800258
Admin7e9c91d2015-08-25 15:53:49 -0700259 inPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True,
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700260 vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0)
Zsolt Harasztife525502016-03-02 05:18:52 +0000261 if device_type == 'pmc':
262 outPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=0, vlan_pcp=0)
263 else: # "normal", "cpqd""
264 outPkt = simple_udp_packet(pktlen=100)
Admin7e9c91d2015-08-25 15:53:49 -0700265
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700266 # Send tagged packet in the OLT port and expect untagged packet out the OLT port
267 self.dataplane.send(olt_port, str(inPkt))
268 verify_packet(self, outPkt, onu_port)
Admin7e9c91d2015-08-25 15:53:49 -0700269
Jonathan Hartf2511ca2015-07-07 14:18:19 -0700270 # Send tagged packet in the ONU port and expect no packets to come out
271 self.dataplane.send(onu_port, str(inPkt))
Admin7e9c91d2015-08-25 15:53:49 -0700272 verify_packets(self, outPkt, [])
Jonathan Hartf65e1812015-10-05 15:15:37 -0700273
alshabibb9d4ee82016-03-01 14:12:42 -0800274
Jonathan Hartf65e1812015-10-05 15:15:37 -0700275
alshabibb9d4ee82016-03-01 14:12:42 -0800276
alshabibb9d4ee82016-03-01 14:12:42 -0800277
alshabibcde318b2016-03-01 22:49:13 -0800278class TestGroupAdd(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000279
Admin02d052c2015-10-10 19:08:26 -0700280 def runTest(self):
281 logging.info("Running Group tests")
282 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700283 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700284
alshabibb9d4ee82016-03-01 14:12:42 -0800285 test_group_id = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700286
287 # output to two ONU
288 group_add = createAllGroupAdd(test_group_id, ports=[onu_port, onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700289
290 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700291 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700292 verify_no_errors(self.controller)
293
294 # Remove the group and then readd it.
alshabibb9d4ee82016-03-01 14:12:42 -0800295 group_delete = ofp.message.group_delete(group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700296 self.controller.message_send(group_delete)
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
Jonathan Hartf65e1812015-10-05 15:15:37 -0700300 group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700301 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700302 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700303 verify_no_errors(self.controller)
304
305
Jonathan Hartf65e1812015-10-05 15:15:37 -0700306 # clean up the test
alshabibb9d4ee82016-03-01 14:12:42 -0800307 group_delete = ofp.message.group_delete(group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700308 self.controller.message_send(group_delete)
alshabibb9d4ee82016-03-01 14:12:42 -0800309
Jonathan Hartf65e1812015-10-05 15:15:37 -0700310 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700311 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800312
313
alshabibcde318b2016-03-01 22:49:13 -0800314class TestGroupMod(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000315
Admin02d052c2015-10-10 19:08:26 -0700316 def runTest(self):
317 logging.info("Running Group tests")
318 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700319 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700320
alshabibb9d4ee82016-03-01 14:12:42 -0800321 test_group_id = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700322
323 group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700324
325 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700326 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700327 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800328
Jonathan Hartf65e1812015-10-05 15:15:37 -0700329 # Modifying the group
330 group_mod = createAllGroupMod(test_group_id, [onu_port2])
alshabibb9d4ee82016-03-01 14:12:42 -0800331
Jonathan Hartf65e1812015-10-05 15:15:37 -0700332 self.controller.message_send(group_mod)
333 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700334 verify_no_errors(self.controller)
335
Jonathan Hartf65e1812015-10-05 15:15:37 -0700336 # Add a bucket into the group
337 group_mod = createAllGroupMod(test_group_id, [onu_port, onu_port2])
338 self.controller.message_send(group_mod)
339 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700340 verify_no_errors(self.controller)
341
342 # Modifying a non-existing group
Jonathan Hartf65e1812015-10-05 15:15:37 -0700343 group_mod = createAllGroupMod(777, [onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700344
Jonathan Hartf65e1812015-10-05 15:15:37 -0700345 self.controller.message_send(group_mod)
346 do_barrier(self.controller)
347 errorExperienced = 0
Admin02d052c2015-10-10 19:08:26 -0700348 try:
349 verify_no_errors(self.controller)
350 except AssertionError as e:
Jonathan Hartf65e1812015-10-05 15:15:37 -0700351 errorExperienced = 1
Admin02d052c2015-10-10 19:08:26 -0700352 if (not (e.message == "unexpected error type=6 code=8")):
Jonathan Hartf65e1812015-10-05 15:15:37 -0700353 raise AssertionError("Incorrect error type: %s" % e.message)
alshabibb9d4ee82016-03-01 14:12:42 -0800354 if not errorExperienced:
Jonathan Hartf65e1812015-10-05 15:15:37 -0700355 raise AssertionError("An error message is expected, but not shown.")
alshabibb9d4ee82016-03-01 14:12:42 -0800356
357
Jonathan Hartf65e1812015-10-05 15:15:37 -0700358 # clean up the test
alshabibb9d4ee82016-03-01 14:12:42 -0800359 group_delete = ofp.message.group_delete(xid=2, group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700360 self.controller.message_send(group_delete)
alshabibb9d4ee82016-03-01 14:12:42 -0800361
Jonathan Hartf65e1812015-10-05 15:15:37 -0700362 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700363 verify_no_errors(self.controller)
364
alshabibb9d4ee82016-03-01 14:12:42 -0800365
alshabibcde318b2016-03-01 22:49:13 -0800366class TestDuplicateGroup(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000367
Admin02d052c2015-10-10 19:08:26 -0700368 def runTest(self):
369 logging.info("Running Group tests")
370 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700371 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700372
alshabibb9d4ee82016-03-01 14:12:42 -0800373 test_group_id = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700374 group_add = createAllGroupAdd(test_group_id, ports=[onu_port])
Admin02d052c2015-10-10 19:08:26 -0700375
376 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700377 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700378 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800379
Jonathan Hartf65e1812015-10-05 15:15:37 -0700380 # Add the same group id
alshabibb9d4ee82016-03-01 14:12:42 -0800381 duplicate_group_fail = 0
382
Admin02d052c2015-10-10 19:08:26 -0700383 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700384 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700385 try:
386 verify_no_errors(self.controller)
387 except AssertionError as e:
alshabibb9d4ee82016-03-01 14:12:42 -0800388 duplicate_group_fail = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700389 if (not e.message == "unexpected error type=6 code=0"):
390 raise AssertionError("Incorrect error type: %s" % e.message)
391 if not duplicate_group_fail:
392 raise AssertionError("Adding duplicate groups didn't raise an error.")
alshabibb9d4ee82016-03-01 14:12:42 -0800393
Jonathan Hartf65e1812015-10-05 15:15:37 -0700394 # clean up the test
alshabibb9d4ee82016-03-01 14:12:42 -0800395 group_delete = ofp.message.group_delete(xid=2, group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700396 self.controller.message_send(group_delete)
alshabibb9d4ee82016-03-01 14:12:42 -0800397
Jonathan Hartf65e1812015-10-05 15:15:37 -0700398 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700399 verify_no_errors(self.controller)
400
alshabibb9d4ee82016-03-01 14:12:42 -0800401
alshabibcde318b2016-03-01 22:49:13 -0800402class TestGroupAndFlow(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000403
Admin02d052c2015-10-10 19:08:26 -0700404 def runTest(self):
405 logging.info("Running Group tests")
406 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700407 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700408
Jonathan Hartf65e1812015-10-05 15:15:37 -0700409 # Create a group
alshabibb9d4ee82016-03-01 14:12:42 -0800410 test_group_id = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700411 group_add = createAllGroupAdd(test_group_id, ports=[onu_port])
Admin02d052c2015-10-10 19:08:26 -0700412
413 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700414 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700415 verify_no_errors(self.controller)
416
417 # Create a flow rule matching olt port and vlan id
418 match = ofp.match()
419 match.oxm_list.append(ofp.oxm.in_port(olt_port))
420 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | 201))
421
Jonathan Hartf65e1812015-10-05 15:15:37 -0700422 flow_pointing_to_group = ofp.message.flow_add(
Admin02d052c2015-10-10 19:08:26 -0700423 table_id=test_param_get("table", 0),
424 cookie=43,
425 match=match,
426 instructions=[
427 ofp.instruction.apply_actions(
alshabibb9d4ee82016-03-01 14:12:42 -0800428 actions=[ofp.action.group(group_id=test_group_id)])],
429 buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
Admin02d052c2015-10-10 19:08:26 -0700430
Jonathan Hartf65e1812015-10-05 15:15:37 -0700431 self.controller.message_send(flow_pointing_to_group)
432 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700433 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800434
Jonathan Hartf65e1812015-10-05 15:15:37 -0700435 # After letting a flow rule point to the group, test we can do group_mod
436 group_mod = createAllGroupMod(test_group_id, ports=[onu_port2])
437 self.controller.message_send(group_mod)
438 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700439 verify_no_errors(self.controller)
440
441 # Test we can remove flows and then remove group
alshabibb9d4ee82016-03-01 14:12:42 -0800442 flow_delete = ofp.message.flow_delete(table_id=test_param_get("table", 0))
Jonathan Hartf65e1812015-10-05 15:15:37 -0700443 self.controller.message_send(flow_delete)
444 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700445 verify_no_errors(self.controller)
446
alshabibb9d4ee82016-03-01 14:12:42 -0800447 group_delete = ofp.message.group_delete(xid=3, group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700448 self.controller.message_send(group_delete)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700449 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700450 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800451
Zsolt Harasztife525502016-03-02 05:18:52 +0000452 # Add the group and flow back, test it we can first remove group and then remove the flow.
Admindcb1bc72015-11-12 18:24:56 -0800453 '''group_add = createAllGroupAdd(test_group_id, ports=[onu_port])
Admin02d052c2015-10-10 19:08:26 -0700454 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700455
456 self.controller.message_send(flow_pointing_to_group)
457 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700458 verify_no_errors(self.controller)
459
460 group_delete = ofp.message.group_delete(xid = 4, group_id = test_group_id)
Admindcb1bc72015-11-12 18:24:56 -0800461 self.controller.message_send(group_delete)'''
Jonathan Hartf65e1812015-10-05 15:15:37 -0700462
463 self.controller.message_send(flow_delete)
464 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700465 verify_no_errors(self.controller)
466
467
alshabibcde318b2016-03-01 22:49:13 -0800468class TestGroupForwarding(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000469
Admin02d052c2015-10-10 19:08:26 -0700470 def runTest(self):
471 logging.info("Running Group datapath forwarding tests")
472 delete_all_flows(self.controller)
Admin99c2a272016-03-01 12:56:39 -0800473 delete_all_groups(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700474
Admin09b5cc62015-10-11 13:53:59 -0700475 vlan_id = 201
Admin02d052c2015-10-10 19:08:26 -0700476
Jonathan Hartf65e1812015-10-05 15:15:37 -0700477 # Create a group
alshabibb9d4ee82016-03-01 14:12:42 -0800478 test_group_id = 1
Jonathan Hartf65e1812015-10-05 15:15:37 -0700479 group_add = createAllGroupAdd(test_group_id, [onu_port])
Admin02d052c2015-10-10 19:08:26 -0700480
481 self.controller.message_send(group_add)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700482 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700483 verify_no_errors(self.controller)
484
485 # Create a flow rule matching olt port and vlan id
486 match = ofp.match()
487 match.oxm_list.append(ofp.oxm.in_port(olt_port))
488 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
489
490 request = ofp.message.flow_add(
491 table_id=test_param_get("table", 0),
492 cookie=43,
493 match=match,
494 instructions=[
495 ofp.instruction.apply_actions(
alshabibb9d4ee82016-03-01 14:12:42 -0800496 actions=[ofp.action.group(group_id=test_group_id)]),
497 ],
498 buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
Admin02d052c2015-10-10 19:08:26 -0700499
500 self.controller.message_send(request)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700501 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700502 verify_no_errors(self.controller)
Admin09b5cc62015-10-11 13:53:59 -0700503
504 # It takes some time for flows to propagate down to the data plane
Admindcb1bc72015-11-12 18:24:56 -0800505 time.sleep(10)
alshabibb9d4ee82016-03-01 14:12:42 -0800506
507 inPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True,
Admindcb1bc72015-11-12 18:24:56 -0800508 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 -0700509 outPkt = inPkt
510 self.dataplane.send(olt_port, str(inPkt))
511 verify_packet(self, outPkt, onu_port)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700512
Admindcb1bc72015-11-12 18:24:56 -0800513
Zsolt Harasztife525502016-03-02 05:18:52 +0000514 # Now put 2 ONU ports in the group and test that the input packet is
Jonathan Hartf65e1812015-10-05 15:15:37 -0700515 # duplicated out both ports
516 group_mod = createAllGroupMod(test_group_id, ports=[onu_port, onu_port2])
517 self.controller.message_send(group_mod)
518 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700519 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800520
Admin09b5cc62015-10-11 13:53:59 -0700521 # It takes some time for flows to propagate down to the data plane
Admindcb1bc72015-11-12 18:24:56 -0800522 time.sleep(10)
Admin09b5cc62015-10-11 13:53:59 -0700523
Jonathan Hartf65e1812015-10-05 15:15:37 -0700524 self.dataplane.send(olt_port, str(inPkt))
Jonathan Hartf65e1812015-10-05 15:15:37 -0700525 verify_packet(self, outPkt, onu_port2)
Admindcb1bc72015-11-12 18:24:56 -0800526 verify_packet(self, outPkt, onu_port)
alshabibb9d4ee82016-03-01 14:12:42 -0800527 # verify_packets(self, outPkt, [onu_port,onu_port2])
Admin02d052c2015-10-10 19:08:26 -0700528
Jonathan Hartf65e1812015-10-05 15:15:37 -0700529 # clean up the test
alshabibb9d4ee82016-03-01 14:12:42 -0800530 request = ofp.message.flow_delete(table_id=test_param_get("table", 0))
Admin02d052c2015-10-10 19:08:26 -0700531 self.controller.message_send(request)
alshabibb9d4ee82016-03-01 14:12:42 -0800532 group_delete = ofp.message.group_delete(xid=2, group_id=test_group_id)
Admin02d052c2015-10-10 19:08:26 -0700533 self.controller.message_send(group_delete)
alshabibb9d4ee82016-03-01 14:12:42 -0800534
Jonathan Hartf65e1812015-10-05 15:15:37 -0700535 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700536 verify_no_errors(self.controller)
537
Admindcb1bc72015-11-12 18:24:56 -0800538
alshabibcde318b2016-03-01 22:49:13 -0800539class TestGroupModForwarding(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000540
Admindcb1bc72015-11-12 18:24:56 -0800541 def runTest(self):
alshabibb9d4ee82016-03-01 14:12:42 -0800542 logging.info("Running datapath forwarding tests for group mod")
Admindcb1bc72015-11-12 18:24:56 -0800543 delete_all_flows(self.controller)
544 delete_all_groups(self.controller)
545
546 vlan_id = 201
547
548 # Create a group
alshabibb9d4ee82016-03-01 14:12:42 -0800549 test_group_id = 1
Admindcb1bc72015-11-12 18:24:56 -0800550 group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2])
551
552 self.controller.message_send(group_add)
553 do_barrier(self.controller)
554 verify_no_errors(self.controller)
555
556 # Create a flow rule matching olt port and vlan id
557 match = ofp.match()
558 match.oxm_list.append(ofp.oxm.in_port(olt_port))
559 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
560
561 request = ofp.message.flow_add(
562 table_id=test_param_get("table", 0),
563 cookie=43,
564 match=match,
565 instructions=[
566 ofp.instruction.apply_actions(
alshabibb9d4ee82016-03-01 14:12:42 -0800567 actions=[ofp.action.group(group_id=test_group_id)]),
568 ],
569 buffer_id=ofp.OFP_NO_BUFFER, priority=1000)
Admindcb1bc72015-11-12 18:24:56 -0800570
571 self.controller.message_send(request)
572 do_barrier(self.controller)
573 verify_no_errors(self.controller)
574
575 # It takes some time for flows to propagate down to the data plane
576 time.sleep(10)
alshabibb9d4ee82016-03-01 14:12:42 -0800577
578 inPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True,
Admindcb1bc72015-11-12 18:24:56 -0800579 vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0, eth_dst="01:01:11:12:11:12")
580 outPkt = inPkt
581 self.dataplane.send(olt_port, str(inPkt))
582 verify_packet(self, outPkt, onu_port)
Admin99c2a272016-03-01 12:56:39 -0800583 verify_packet(self, outPkt, onu_port2)
Admindcb1bc72015-11-12 18:24:56 -0800584
585 # Now remove onu port 1 from the group and test that the input packet is no longer forwarded to onu port 1
586 group_mod = createAllGroupMod(test_group_id, ports=[onu_port2])
587 self.controller.message_send(group_mod)
588 do_barrier(self.controller)
589 verify_no_errors(self.controller)
590
591 time.sleep(10)
592 self.dataplane.send(olt_port, str(inPkt))
593 verify_no_packet(self, outPkt, onu_port)
594 verify_packet(self, outPkt, onu_port2)
595
Zsolt Harasztife525502016-03-02 05:18:52 +0000596 # 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 -0800597 group_mod = createAllGroupMod(test_group_id, ports=[])
598 self.controller.message_send(group_mod)
599 do_barrier(self.controller)
600 verify_no_errors(self.controller)
601 time.sleep(10)
602 self.dataplane.send(olt_port, str(inPkt))
603 verify_packets(self, outPkt, [])
604
605
alshabibcde318b2016-03-01 22:49:13 -0800606class TransparentVlanTest(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000607
Admin02d052c2015-10-10 19:08:26 -0700608 def runTest(self):
609 logging.info("Running transparent vlan tests")
Admin09b5cc62015-10-11 13:53:59 -0700610 delete_all_flows(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700611
Jonathan Hartf65e1812015-10-05 15:15:37 -0700612 vlan_id = 201
Admin02d052c2015-10-10 19:08:26 -0700613 match = ofp.match()
614 match.oxm_list.append(ofp.oxm.in_port(onu_port))
alshabibb9d4ee82016-03-01 14:12:42 -0800615 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
Admin02d052c2015-10-10 19:08:26 -0700616
617 request = ofp.message.flow_add(
618 table_id=test_param_get("table", 0),
619 cookie=42,
620 match=match,
621 instructions=[
622 ofp.instruction.apply_actions(
623 actions=[
624 ofp.action.output(port=olt_port)]),
alshabibb9d4ee82016-03-01 14:12:42 -0800625 ],
Admin02d052c2015-10-10 19:08:26 -0700626 buffer_id=ofp.OFP_NO_BUFFER,
627 priority=1000)
628
629 self.controller.message_send(request)
alshabibb9d4ee82016-03-01 14:12:42 -0800630
Admin02d052c2015-10-10 19:08:26 -0700631 match = ofp.match()
632 match.oxm_list.append(ofp.oxm.in_port(olt_port))
633 match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id))
634
635 request = ofp.message.flow_add(
636 table_id=test_param_get("table", 0),
637 cookie=43,
638 match=match,
639 instructions=[
640 ofp.instruction.apply_actions(
641 actions=[
642 ofp.action.output(port=onu_port)]),
alshabibb9d4ee82016-03-01 14:12:42 -0800643 ],
Admin02d052c2015-10-10 19:08:26 -0700644 buffer_id=ofp.OFP_NO_BUFFER,
645 priority=1000)
646
647 self.controller.message_send(request)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700648 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700649 verify_no_errors(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700650
Admin09b5cc62015-10-11 13:53:59 -0700651 # It takes some time for flows to propagate down to the data plane
652 time.sleep(2)
alshabibb9d4ee82016-03-01 14:12:42 -0800653
Jonathan Hartf65e1812015-10-05 15:15:37 -0700654 inPkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=vlan_id, vlan_pcp=0)
Zsolt Harasztife525502016-03-02 05:18:52 +0000655
Admin02d052c2015-10-10 19:08:26 -0700656 # upstream
657 self.dataplane.send(onu_port, str(inPkt))
658 verify_packet(self, inPkt, olt_port)
Zsolt Harasztife525502016-03-02 05:18:52 +0000659
Admin99c2a272016-03-01 12:56:39 -0800660 # downstream
661 self.dataplane.send(olt_port, str(inPkt))
662 verify_packet(self, inPkt, onu_port)
Admin02d052c2015-10-10 19:08:26 -0700663
Jonathan Hartf65e1812015-10-05 15:15:37 -0700664 # clean up the test
Admin02d052c2015-10-10 19:08:26 -0700665 delete_all_flows(self.controller)
Jonathan Hartf65e1812015-10-05 15:15:37 -0700666 do_barrier(self.controller)
Admin02d052c2015-10-10 19:08:26 -0700667 verify_no_errors(self.controller)
668
alshabibcde318b2016-03-01 22:49:13 -0800669class RemoveRuleTest(OltBaseTest):
alshabib28c03c32016-03-01 20:33:51 -0800670
671 def runTest(self):
672 logging.info("Testing Rule removal")
alshabibe165af22016-03-01 21:42:17 -0800673 delete_all_flows(self.controller)
alshabib9929a152016-03-01 21:25:18 -0800674 processEapolRule(self, onu_port)
alshabibe165af22016-03-01 21:42:17 -0800675
alshabib9929a152016-03-01 21:25:18 -0800676 #wait for the rule to settle
677 time.sleep(3)
678
alshabibdde38ea2016-03-01 21:49:44 -0800679 installDoubleTaggingRules(1, 2, self.controller)
alshabibe165af22016-03-01 21:42:17 -0800680
alshabib9929a152016-03-01 21:25:18 -0800681 #wait for the rules to settle
682 time.sleep(3)
683
684 stats = get_flow_stats(self, ofp.match())
685
Admin53e10b62016-03-01 21:52:18 -0800686 self.assertTrue(len(stats) == 5, \
687 "Wrong number of rules reports; reported %s, expected 5\n\n %s" % (len(stats), stats))
alshabib9929a152016-03-01 21:25:18 -0800688
689 processEapolRule(self, onu_port, install = False)
690 time.sleep(3)
691
692 stats = get_flow_stats(self, ofp.match())
693
Admin53e10b62016-03-01 21:52:18 -0800694 self.assertTrue(len(stats) == 4, \
695 "Wrong number of rules reports; reported %s, expected 4\n\n %s" % (len(stats), stats))
alshabib9929a152016-03-01 21:25:18 -0800696
alshabibd6be76e2016-03-01 22:21:00 -0800697 eapol = ofp.oxm.eth_type(0x888e)
698 found = False
699 for fe in stats:
700 if eapol in fe.match.oxm_list:
701 found = True
702
703 self.assertFalse(found, "Removed incorrect flow rule")
alshabib28c03c32016-03-01 20:33:51 -0800704
705
alshabibcde318b2016-03-01 22:49:13 -0800706class MultipleDoubleTaggingForwarding(OltBaseTest):
alshabib28c03c32016-03-01 20:33:51 -0800707
708 def runTests(self):
709 logging.info("Testing multiple Q-in-Q rules")
710 pass
711
alshabibb9d4ee82016-03-01 14:12:42 -0800712
alshabibd6be76e2016-03-01 22:21:00 -0800713class DoubleVlanTest(OltBaseTest):
Zsolt Harasztife525502016-03-02 05:18:52 +0000714
Adminb17b1662015-10-19 15:50:53 -0700715 def runTest(self):
716 logging.info("Running double vlan tests")
717 delete_all_flows(self.controller)
718
719 c_vlan_id = 100
alshabibb9d4ee82016-03-01 14:12:42 -0800720 s_vlan_id = 102
Zsolt Harasztife525502016-03-02 05:18:52 +0000721
alshabibd6be76e2016-03-01 22:21:00 -0800722 self.installDoubleTaggingRules(s_vlan_id, c_vlan_id)
Adminb17b1662015-10-19 15:50:53 -0700723
Adminb17b1662015-10-19 15:50:53 -0700724 # It takes some time for flows to propagate down to the data plane
725 time.sleep(10)
alshabibb9d4ee82016-03-01 14:12:42 -0800726
Zsolt Harasztife525502016-03-02 05:18:52 +0000727 # Test packet flows
728 testPacketFlow(self, c_vlan_id, s_vlan_id)
Adminb17b1662015-10-19 15:50:53 -0700729
730 # clean up the test
731 delete_all_flows(self.controller)
732 do_barrier(self.controller)
733 verify_no_errors(self.controller)
alshabibb9d4ee82016-03-01 14:12:42 -0800734
735
alshabibcde318b2016-03-01 22:49:13 -0800736class TestCyclingDoubleVlan(OltBaseTest):
alshabibb9d4ee82016-03-01 14:12:42 -0800737 """Cycle through vlans and test traffic flow"""
738
739 def runTest(self):
740 logging.info("Running cycling vlan test")
741
alshabib2ecca692016-03-01 15:10:38 -0800742 for stag in xrange(2, 4000, 100):
743 for ctag in xrange(2, 4000, 100):
alshabibf1f07dd2016-03-01 15:50:35 -0800744 delete_all_flows(self.controller)
745 time.sleep(5)
alshabibdde38ea2016-03-01 21:49:44 -0800746 installDoubleTaggingRules(stag, ctag, self.controller)
alshabibf1f07dd2016-03-01 15:50:35 -0800747 time.sleep(5)
alshabib28c03c32016-03-01 20:33:51 -0800748 testPacketFlow(self, ctag, stag)
alshabibb9d4ee82016-03-01 14:12:42 -0800749
alshabib9929a152016-03-01 21:25:18 -0800750
alshabibb9b39a72016-03-01 15:52:03 -0800751
alshabibb9d4ee82016-03-01 14:12:42 -0800752
alshabibb9d4ee82016-03-01 14:12:42 -0800753
alshabibb9d4ee82016-03-01 14:12:42 -0800754
alshabibb9d4ee82016-03-01 14:12:42 -0800755
alshabibb9d4ee82016-03-01 14:12:42 -0800756
alshabibb9d4ee82016-03-01 14:12:42 -0800757
alshabibb9d4ee82016-03-01 14:12:42 -0800758