Jonathan Hart | f2511ca | 2015-07-07 14:18:19 -0700 | [diff] [blame] | 1 | ''' |
| 2 | OFTests for functionality needed from the OLT. |
| 3 | ''' |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 4 | |
Jonathan Hart | f2511ca | 2015-07-07 14:18:19 -0700 | [diff] [blame] | 5 | import logging |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 6 | from __builtin__ import xrange |
alshabib | d6be76e | 2016-03-01 22:21:00 -0800 | [diff] [blame] | 7 | from oltbase import OltBaseTest |
Jonathan Hart | f2511ca | 2015-07-07 14:18:19 -0700 | [diff] [blame] | 8 | import oftest.packet as scapy |
Jonathan Hart | f2511ca | 2015-07-07 14:18:19 -0700 | [diff] [blame] | 9 | import ofp |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 10 | import time |
Jonathan Hart | f2511ca | 2015-07-07 14:18:19 -0700 | [diff] [blame] | 11 | |
Zsolt Haraszti | 5360d03 | 2016-03-02 23:02:09 -0800 | [diff] [blame^] | 12 | from oltconstants import * |
Jonathan Hart | f2511ca | 2015-07-07 14:18:19 -0700 | [diff] [blame] | 13 | from oftest.testutils import * |
| 14 | |
alshabib | ed97b5f | 2016-03-01 23:46:53 -0800 | [diff] [blame] | 15 | from IGMP import IGMPv3, IGMPv3gr, IGMP_TYPE_V3_MEMBERSHIP_REPORT,\ |
| 16 | IGMP_V3_GR_TYPE_INCLUDE,\ |
| 17 | IGMP_V3_GR_TYPE_EXCLUDE |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 18 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 19 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 20 | class EapolPacketIn(OltBaseTest): |
Jonathan Hart | f2511ca | 2015-07-07 14:18:19 -0700 | [diff] [blame] | 21 | """Verify packet-ins are sent for EAPOL packets """ |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 22 | |
Jonathan Hart | f2511ca | 2015-07-07 14:18:19 -0700 | [diff] [blame] | 23 | 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) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 30 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 31 | self.testPacketIn(match, pkt) |
Jonathan Hart | f2511ca | 2015-07-07 14:18:19 -0700 | [diff] [blame] | 32 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 33 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 34 | class ARPPacketIn(OltBaseTest): |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 35 | """Verify packet-ins are sent for ARP packets """ |
alshabib | 9929a15 | 2016-03-01 21:25:18 -0800 | [diff] [blame] | 36 | |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 37 | def runTest(self): |
| 38 | logging.info("Running ARP Packet In test") |
alshabib | 9929a15 | 2016-03-01 21:25:18 -0800 | [diff] [blame] | 39 | |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 40 | 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 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 46 | self.testPacketIn(match, pkt) |
alshabib | 9929a15 | 2016-03-01 21:25:18 -0800 | [diff] [blame] | 47 | |
| 48 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 49 | class IGMPPacketIn(OltBaseTest): |
Jonathan Hart | f2511ca | 2015-07-07 14:18:19 -0700 | [diff] [blame] | 50 | """Verify packet-ins are sent for IGMP packets """ |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 51 | |
Jonathan Hart | f2511ca | 2015-07-07 14:18:19 -0700 | [diff] [blame] | 52 | 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 Hart | f2511ca | 2015-07-07 14:18:19 -0700 | [diff] [blame] | 58 | |
Zsolt Haraszti | d057140 | 2016-03-02 18:40:50 -0800 | [diff] [blame] | 59 | mcast_group = "229.10.20.30" |
| 60 | ip_src = '192.168.0.123' |
| 61 | ip_dst = '224.0.0.22' |
| 62 | pkt = self.buildIgmpReport(ip_src, ip_dst, '00:00:00:00:be:ef', join=[mcast_group], pad_to=60) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 63 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 64 | self.testPacketIn(match, pkt) |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 65 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 66 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 67 | class IGMPQueryPacketOut(OltBaseTest): |
Admin | d521278 | 2015-12-09 17:17:57 -0800 | [diff] [blame] | 68 | """Verify sending multicast membership queries down to onu_ports""" |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 69 | |
Admin | d521278 | 2015-12-09 17:17:57 -0800 | [diff] [blame] | 70 | def runTest(self): |
| 71 | logging.info("Running IGMP query packet out") |
| 72 | |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 73 | igmp = IGMPv3() # by default this is a query |
Zsolt Haraszti | d057140 | 2016-03-02 18:40:50 -0800 | [diff] [blame] | 74 | pkt = self.buildIgmp(igmp) |
Admin | d521278 | 2015-12-09 17:17:57 -0800 | [diff] [blame] | 75 | |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 76 | 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)) |
Admin | d521278 | 2015-12-09 17:17:57 -0800 | [diff] [blame] | 81 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 82 | self.controller.message_send(msg) |
Admin | d521278 | 2015-12-09 17:17:57 -0800 | [diff] [blame] | 83 | |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 84 | rv = self.controller.message_send(msg) |
| 85 | self.assertTrue(rv == 0, "Error sending put message") |
Admin | d521278 | 2015-12-09 17:17:57 -0800 | [diff] [blame] | 86 | verify_no_errors(self.controller) |
| 87 | |
| 88 | verify_packet(self, pkt, onu_port) |
| 89 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 90 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 91 | class TestMeter(OltBaseTest): |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 92 | |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 93 | def runTest(self): |
| 94 | logging.info("Running Meter tests") |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 95 | 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]) |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 97 | self.controller.message_send(meter_mod) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 98 | |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 99 | time.sleep(1) |
| 100 | |
| 101 | verify_no_errors(self.controller) |
| 102 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 103 | vlan_id = 201 |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 104 | match = ofp.match() |
| 105 | match.oxm_list.append(ofp.oxm.in_port(onu_port)) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 106 | match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id)) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 107 | |
| 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 Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 114 | actions=[ofp.action.output(port=olt_port)]), |
| 115 | ofp.instruction.meter(meter_id = 1) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 116 | ], |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 117 | 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) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 123 | |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 124 | 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)) |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 127 | |
| 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 Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 134 | actions=[ofp.action.output(port=onu_port)]), |
| 135 | ofp.instruction.meter(meter_id = 1) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 136 | ], |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 137 | buffer_id=ofp.OFP_NO_BUFFER, |
| 138 | priority=1000) |
| 139 | |
| 140 | self.controller.message_send(request) |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 141 | time.sleep(1) |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 142 | verify_no_errors(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 143 | do_barrier(self.controller) |
| 144 | time.sleep(5) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 145 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 146 | inPkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=vlan_id, vlan_pcp=0) |
| 147 | # downstream |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 148 | # self.dataplane.send(olt_port, str(inPkt)) |
| 149 | # verify_packet(self, inPkt, onu_port) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 150 | # upstream |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 151 | # for i in range(1,400): |
| 152 | # self.dataplane.send(onu_port, str(inPkt)) |
| 153 | # verify_packet(self, inPkt, olt_port) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 154 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 155 | # clean up the test |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 156 | meter_mod = ofp.message.meter_mod(xid=2, command=ofp.OFPMC_DELETE, meter_id=1) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 157 | self.controller.message_send(meter_mod) |
| 158 | time.sleep(1) |
| 159 | delete_all_flows(self.controller) |
| 160 | verify_no_errors(self.controller) |
| 161 | |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 162 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 163 | class TestDuplicateMeter(OltBaseTest): |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 164 | def runTest(self): |
| 165 | logging.info("Running Duplicate Meter Test") |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 166 | 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]) |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 168 | self.controller.message_send(meter_mod) |
| 169 | self.controller.message_send(meter_mod) |
| 170 | |
| 171 | time.sleep(1) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 172 | |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 173 | try: |
| 174 | verify_no_errors(self.controller) |
| 175 | except AssertionError as e: |
Admin | 09b5cc6 | 2015-10-11 13:53:59 -0700 | [diff] [blame] | 176 | if (not e.message == "unexpected error type=12 code=1"): |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 177 | raise AssertionError("Incorrect error type: %s" % e.message) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 178 | |
| 179 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 180 | class VlanTest(OltBaseTest): |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 181 | """Verify the switch can push/pop a VLAN tag and forward out a port """ |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 182 | |
Jonathan Hart | f2511ca | 2015-07-07 14:18:19 -0700 | [diff] [blame] | 183 | def runTest(self): |
| 184 | logging.info("Running push VLAN test") |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 185 | |
Jonathan Hart | f2511ca | 2015-07-07 14:18:19 -0700 | [diff] [blame] | 186 | vlan_id = 200 |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 187 | |
Jonathan Hart | f2511ca | 2015-07-07 14:18:19 -0700 | [diff] [blame] | 188 | delete_all_flows(self.controller) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 189 | |
| 190 | # PUSH |
Jonathan Hart | f2511ca | 2015-07-07 14:18:19 -0700 | [diff] [blame] | 191 | match = ofp.match() |
| 192 | match.oxm_list.append(ofp.oxm.in_port(onu_port)) |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 193 | 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 | ] |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 209 | |
Jonathan Hart | f2511ca | 2015-07-07 14:18:19 -0700 | [diff] [blame] | 210 | request = ofp.message.flow_add( |
| 211 | table_id=test_param_get("table", 0), |
| 212 | cookie=42, |
| 213 | match=match, |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 214 | instructions=[ofp.instruction.apply_actions(actions=actions)], |
Jonathan Hart | f2511ca | 2015-07-07 14:18:19 -0700 | [diff] [blame] | 215 | buffer_id=ofp.OFP_NO_BUFFER, |
| 216 | priority=1000) |
| 217 | |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 218 | logging.info("Inserting flow tagging upstream") |
Jonathan Hart | f2511ca | 2015-07-07 14:18:19 -0700 | [diff] [blame] | 219 | self.controller.message_send(request) |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 220 | do_barrier(self.controller) |
| 221 | verify_no_errors(self.controller) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 222 | |
| 223 | # POP |
Jonathan Hart | f2511ca | 2015-07-07 14:18:19 -0700 | [diff] [blame] | 224 | 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)) |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 227 | |
Jonathan Hart | f2511ca | 2015-07-07 14:18:19 -0700 | [diff] [blame] | 228 | request = ofp.message.flow_add( |
| 229 | table_id=test_param_get("table", 0), |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 230 | cookie=43, |
Jonathan Hart | f2511ca | 2015-07-07 14:18:19 -0700 | [diff] [blame] | 231 | match=match, |
| 232 | instructions=[ |
| 233 | ofp.instruction.apply_actions( |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 234 | actions=[ |
| 235 | ofp.action.pop_vlan(), |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 236 | ofp.action.output(port=onu_port)])], |
Jonathan Hart | f2511ca | 2015-07-07 14:18:19 -0700 | [diff] [blame] | 237 | buffer_id=ofp.OFP_NO_BUFFER, |
| 238 | priority=1000) |
| 239 | |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 240 | logging.info("Inserting flow tagging downstream") |
Jonathan Hart | f2511ca | 2015-07-07 14:18:19 -0700 | [diff] [blame] | 241 | self.controller.message_send(request) |
| 242 | do_barrier(self.controller) |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 243 | verify_no_errors(self.controller) |
| 244 | |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 245 | time.sleep(5) |
Admin | 99c2a27 | 2016-03-01 12:56:39 -0800 | [diff] [blame] | 246 | |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 247 | inPkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=0, vlan_pcp=0) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 248 | outPkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True, |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 249 | vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 250 | |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 251 | # 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) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 254 | |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 255 | # 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, []) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 258 | |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 259 | inPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True, |
Jonathan Hart | f2511ca | 2015-07-07 14:18:19 -0700 | [diff] [blame] | 260 | vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0) |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 261 | 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) |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 265 | |
Jonathan Hart | f2511ca | 2015-07-07 14:18:19 -0700 | [diff] [blame] | 266 | # 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) |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 269 | |
Jonathan Hart | f2511ca | 2015-07-07 14:18:19 -0700 | [diff] [blame] | 270 | # Send tagged packet in the ONU port and expect no packets to come out |
| 271 | self.dataplane.send(onu_port, str(inPkt)) |
Admin | 7e9c91d | 2015-08-25 15:53:49 -0700 | [diff] [blame] | 272 | verify_packets(self, outPkt, []) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 273 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 274 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 275 | class TestGroupAdd(OltBaseTest): |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 276 | |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 277 | def runTest(self): |
| 278 | logging.info("Running Group tests") |
| 279 | delete_all_flows(self.controller) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 280 | delete_all_groups(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 281 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 282 | test_group_id = 1 |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 283 | |
| 284 | # output to two ONU |
| 285 | group_add = createAllGroupAdd(test_group_id, ports=[onu_port, onu_port2]) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 286 | |
| 287 | self.controller.message_send(group_add) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 288 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 289 | verify_no_errors(self.controller) |
| 290 | |
| 291 | # Remove the group and then readd it. |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 292 | group_delete = ofp.message.group_delete(group_id=test_group_id) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 293 | self.controller.message_send(group_delete) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 294 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 295 | verify_no_errors(self.controller) |
| 296 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 297 | group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2]) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 298 | self.controller.message_send(group_add) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 299 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 300 | verify_no_errors(self.controller) |
| 301 | |
| 302 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 303 | # clean up the test |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 304 | group_delete = ofp.message.group_delete(group_id=test_group_id) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 305 | self.controller.message_send(group_delete) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 306 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 307 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 308 | verify_no_errors(self.controller) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 309 | |
| 310 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 311 | class TestGroupMod(OltBaseTest): |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 312 | |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 313 | def runTest(self): |
| 314 | logging.info("Running Group tests") |
| 315 | delete_all_flows(self.controller) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 316 | delete_all_groups(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 317 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 318 | test_group_id = 1 |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 319 | |
| 320 | group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2]) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 321 | |
| 322 | self.controller.message_send(group_add) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 323 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 324 | verify_no_errors(self.controller) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 325 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 326 | # Modifying the group |
| 327 | group_mod = createAllGroupMod(test_group_id, [onu_port2]) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 328 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 329 | self.controller.message_send(group_mod) |
| 330 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 331 | verify_no_errors(self.controller) |
| 332 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 333 | # Add a bucket into the group |
| 334 | group_mod = createAllGroupMod(test_group_id, [onu_port, onu_port2]) |
| 335 | self.controller.message_send(group_mod) |
| 336 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 337 | verify_no_errors(self.controller) |
| 338 | |
| 339 | # Modifying a non-existing group |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 340 | group_mod = createAllGroupMod(777, [onu_port2]) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 341 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 342 | self.controller.message_send(group_mod) |
| 343 | do_barrier(self.controller) |
| 344 | errorExperienced = 0 |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 345 | try: |
| 346 | verify_no_errors(self.controller) |
| 347 | except AssertionError as e: |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 348 | errorExperienced = 1 |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 349 | if (not (e.message == "unexpected error type=6 code=8")): |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 350 | raise AssertionError("Incorrect error type: %s" % e.message) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 351 | if not errorExperienced: |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 352 | raise AssertionError("An error message is expected, but not shown.") |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 353 | |
| 354 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 355 | # clean up the test |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 356 | group_delete = ofp.message.group_delete(xid=2, group_id=test_group_id) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 357 | self.controller.message_send(group_delete) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 358 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 359 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 360 | verify_no_errors(self.controller) |
| 361 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 362 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 363 | class TestDuplicateGroup(OltBaseTest): |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 364 | |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 365 | def runTest(self): |
| 366 | logging.info("Running Group tests") |
| 367 | delete_all_flows(self.controller) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 368 | delete_all_groups(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 369 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 370 | test_group_id = 1 |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 371 | group_add = createAllGroupAdd(test_group_id, ports=[onu_port]) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 372 | |
| 373 | self.controller.message_send(group_add) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 374 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 375 | verify_no_errors(self.controller) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 376 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 377 | # Add the same group id |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 378 | duplicate_group_fail = 0 |
| 379 | |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 380 | self.controller.message_send(group_add) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 381 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 382 | try: |
| 383 | verify_no_errors(self.controller) |
| 384 | except AssertionError as e: |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 385 | duplicate_group_fail = 1 |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 386 | if (not e.message == "unexpected error type=6 code=0"): |
| 387 | raise AssertionError("Incorrect error type: %s" % e.message) |
| 388 | if not duplicate_group_fail: |
| 389 | raise AssertionError("Adding duplicate groups didn't raise an error.") |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 390 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 391 | # clean up the test |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 392 | group_delete = ofp.message.group_delete(xid=2, group_id=test_group_id) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 393 | self.controller.message_send(group_delete) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 394 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 395 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 396 | verify_no_errors(self.controller) |
| 397 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 398 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 399 | class TestGroupAndFlow(OltBaseTest): |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 400 | |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 401 | def runTest(self): |
| 402 | logging.info("Running Group tests") |
| 403 | delete_all_flows(self.controller) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 404 | delete_all_groups(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 405 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 406 | # Create a group |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 407 | test_group_id = 1 |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 408 | group_add = createAllGroupAdd(test_group_id, ports=[onu_port]) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 409 | |
| 410 | self.controller.message_send(group_add) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 411 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 412 | verify_no_errors(self.controller) |
| 413 | |
| 414 | # Create a flow rule matching olt port and vlan id |
| 415 | match = ofp.match() |
| 416 | match.oxm_list.append(ofp.oxm.in_port(olt_port)) |
| 417 | match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | 201)) |
| 418 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 419 | flow_pointing_to_group = ofp.message.flow_add( |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 420 | table_id=test_param_get("table", 0), |
| 421 | cookie=43, |
| 422 | match=match, |
| 423 | instructions=[ |
| 424 | ofp.instruction.apply_actions( |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 425 | actions=[ofp.action.group(group_id=test_group_id)])], |
| 426 | buffer_id=ofp.OFP_NO_BUFFER, priority=1000) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 427 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 428 | self.controller.message_send(flow_pointing_to_group) |
| 429 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 430 | verify_no_errors(self.controller) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 431 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 432 | # After letting a flow rule point to the group, test we can do group_mod |
| 433 | group_mod = createAllGroupMod(test_group_id, ports=[onu_port2]) |
| 434 | self.controller.message_send(group_mod) |
| 435 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 436 | verify_no_errors(self.controller) |
| 437 | |
| 438 | # Test we can remove flows and then remove group |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 439 | flow_delete = ofp.message.flow_delete(table_id=test_param_get("table", 0)) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 440 | self.controller.message_send(flow_delete) |
| 441 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 442 | verify_no_errors(self.controller) |
| 443 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 444 | group_delete = ofp.message.group_delete(xid=3, group_id=test_group_id) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 445 | self.controller.message_send(group_delete) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 446 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 447 | verify_no_errors(self.controller) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 448 | |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 449 | # Add the group and flow back, test it we can first remove group and then remove the flow. |
Admin | dcb1bc7 | 2015-11-12 18:24:56 -0800 | [diff] [blame] | 450 | '''group_add = createAllGroupAdd(test_group_id, ports=[onu_port]) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 451 | self.controller.message_send(group_add) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 452 | |
| 453 | self.controller.message_send(flow_pointing_to_group) |
| 454 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 455 | verify_no_errors(self.controller) |
| 456 | |
| 457 | group_delete = ofp.message.group_delete(xid = 4, group_id = test_group_id) |
Admin | dcb1bc7 | 2015-11-12 18:24:56 -0800 | [diff] [blame] | 458 | self.controller.message_send(group_delete)''' |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 459 | |
| 460 | self.controller.message_send(flow_delete) |
| 461 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 462 | verify_no_errors(self.controller) |
| 463 | |
| 464 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 465 | class TestGroupForwarding(OltBaseTest): |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 466 | |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 467 | def runTest(self): |
| 468 | logging.info("Running Group datapath forwarding tests") |
| 469 | delete_all_flows(self.controller) |
Admin | 99c2a27 | 2016-03-01 12:56:39 -0800 | [diff] [blame] | 470 | delete_all_groups(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 471 | |
Admin | 09b5cc6 | 2015-10-11 13:53:59 -0700 | [diff] [blame] | 472 | vlan_id = 201 |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 473 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 474 | # Create a group |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 475 | test_group_id = 1 |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 476 | group_add = createAllGroupAdd(test_group_id, [onu_port]) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 477 | |
| 478 | self.controller.message_send(group_add) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 479 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 480 | verify_no_errors(self.controller) |
| 481 | |
| 482 | # Create a flow rule matching olt port and vlan id |
| 483 | match = ofp.match() |
| 484 | match.oxm_list.append(ofp.oxm.in_port(olt_port)) |
| 485 | match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id)) |
| 486 | |
| 487 | request = ofp.message.flow_add( |
| 488 | table_id=test_param_get("table", 0), |
| 489 | cookie=43, |
| 490 | match=match, |
| 491 | instructions=[ |
| 492 | ofp.instruction.apply_actions( |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 493 | actions=[ofp.action.group(group_id=test_group_id)]), |
| 494 | ], |
| 495 | buffer_id=ofp.OFP_NO_BUFFER, priority=1000) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 496 | |
| 497 | self.controller.message_send(request) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 498 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 499 | verify_no_errors(self.controller) |
Admin | 09b5cc6 | 2015-10-11 13:53:59 -0700 | [diff] [blame] | 500 | |
| 501 | # It takes some time for flows to propagate down to the data plane |
Admin | dcb1bc7 | 2015-11-12 18:24:56 -0800 | [diff] [blame] | 502 | time.sleep(10) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 503 | |
| 504 | inPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True, |
Admin | dcb1bc7 | 2015-11-12 18:24:56 -0800 | [diff] [blame] | 505 | vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0, eth_dst="01:01:11:12:11:12") |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 506 | outPkt = inPkt |
| 507 | self.dataplane.send(olt_port, str(inPkt)) |
| 508 | verify_packet(self, outPkt, onu_port) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 509 | |
Admin | dcb1bc7 | 2015-11-12 18:24:56 -0800 | [diff] [blame] | 510 | |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 511 | # Now put 2 ONU ports in the group and test that the input packet is |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 512 | # duplicated out both ports |
| 513 | group_mod = createAllGroupMod(test_group_id, ports=[onu_port, onu_port2]) |
| 514 | self.controller.message_send(group_mod) |
| 515 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 516 | verify_no_errors(self.controller) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 517 | |
Admin | 09b5cc6 | 2015-10-11 13:53:59 -0700 | [diff] [blame] | 518 | # It takes some time for flows to propagate down to the data plane |
Admin | dcb1bc7 | 2015-11-12 18:24:56 -0800 | [diff] [blame] | 519 | time.sleep(10) |
Admin | 09b5cc6 | 2015-10-11 13:53:59 -0700 | [diff] [blame] | 520 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 521 | self.dataplane.send(olt_port, str(inPkt)) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 522 | verify_packet(self, outPkt, onu_port2) |
Admin | dcb1bc7 | 2015-11-12 18:24:56 -0800 | [diff] [blame] | 523 | verify_packet(self, outPkt, onu_port) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 524 | # verify_packets(self, outPkt, [onu_port,onu_port2]) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 525 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 526 | # clean up the test |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 527 | request = ofp.message.flow_delete(table_id=test_param_get("table", 0)) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 528 | self.controller.message_send(request) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 529 | group_delete = ofp.message.group_delete(xid=2, group_id=test_group_id) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 530 | self.controller.message_send(group_delete) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 531 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 532 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 533 | verify_no_errors(self.controller) |
| 534 | |
Admin | dcb1bc7 | 2015-11-12 18:24:56 -0800 | [diff] [blame] | 535 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 536 | class TestGroupModForwarding(OltBaseTest): |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 537 | |
Admin | dcb1bc7 | 2015-11-12 18:24:56 -0800 | [diff] [blame] | 538 | def runTest(self): |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 539 | logging.info("Running datapath forwarding tests for group mod") |
Admin | dcb1bc7 | 2015-11-12 18:24:56 -0800 | [diff] [blame] | 540 | delete_all_flows(self.controller) |
| 541 | delete_all_groups(self.controller) |
| 542 | |
| 543 | vlan_id = 201 |
| 544 | |
| 545 | # Create a group |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 546 | test_group_id = 1 |
Admin | dcb1bc7 | 2015-11-12 18:24:56 -0800 | [diff] [blame] | 547 | group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2]) |
| 548 | |
| 549 | self.controller.message_send(group_add) |
| 550 | do_barrier(self.controller) |
| 551 | verify_no_errors(self.controller) |
| 552 | |
| 553 | # Create a flow rule matching olt port and vlan id |
| 554 | match = ofp.match() |
| 555 | match.oxm_list.append(ofp.oxm.in_port(olt_port)) |
| 556 | match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id)) |
| 557 | |
| 558 | request = ofp.message.flow_add( |
| 559 | table_id=test_param_get("table", 0), |
| 560 | cookie=43, |
| 561 | match=match, |
| 562 | instructions=[ |
| 563 | ofp.instruction.apply_actions( |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 564 | actions=[ofp.action.group(group_id=test_group_id)]), |
| 565 | ], |
| 566 | buffer_id=ofp.OFP_NO_BUFFER, priority=1000) |
Admin | dcb1bc7 | 2015-11-12 18:24:56 -0800 | [diff] [blame] | 567 | |
| 568 | self.controller.message_send(request) |
| 569 | do_barrier(self.controller) |
| 570 | verify_no_errors(self.controller) |
| 571 | |
| 572 | # It takes some time for flows to propagate down to the data plane |
| 573 | time.sleep(10) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 574 | |
| 575 | inPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True, |
Admin | dcb1bc7 | 2015-11-12 18:24:56 -0800 | [diff] [blame] | 576 | vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0, eth_dst="01:01:11:12:11:12") |
| 577 | outPkt = inPkt |
| 578 | self.dataplane.send(olt_port, str(inPkt)) |
| 579 | verify_packet(self, outPkt, onu_port) |
Admin | 99c2a27 | 2016-03-01 12:56:39 -0800 | [diff] [blame] | 580 | verify_packet(self, outPkt, onu_port2) |
Admin | dcb1bc7 | 2015-11-12 18:24:56 -0800 | [diff] [blame] | 581 | |
| 582 | # Now remove onu port 1 from the group and test that the input packet is no longer forwarded to onu port 1 |
| 583 | group_mod = createAllGroupMod(test_group_id, ports=[onu_port2]) |
| 584 | self.controller.message_send(group_mod) |
| 585 | do_barrier(self.controller) |
| 586 | verify_no_errors(self.controller) |
| 587 | |
| 588 | time.sleep(10) |
| 589 | self.dataplane.send(olt_port, str(inPkt)) |
| 590 | verify_no_packet(self, outPkt, onu_port) |
| 591 | verify_packet(self, outPkt, onu_port2) |
| 592 | |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 593 | # Now remove all ports in the group and test that the input packet is no longer forwarded to any port |
Admin | dcb1bc7 | 2015-11-12 18:24:56 -0800 | [diff] [blame] | 594 | group_mod = createAllGroupMod(test_group_id, ports=[]) |
| 595 | self.controller.message_send(group_mod) |
| 596 | do_barrier(self.controller) |
| 597 | verify_no_errors(self.controller) |
| 598 | time.sleep(10) |
| 599 | self.dataplane.send(olt_port, str(inPkt)) |
| 600 | verify_packets(self, outPkt, []) |
| 601 | |
| 602 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 603 | class TransparentVlanTest(OltBaseTest): |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 604 | |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 605 | def runTest(self): |
| 606 | logging.info("Running transparent vlan tests") |
Admin | 09b5cc6 | 2015-10-11 13:53:59 -0700 | [diff] [blame] | 607 | delete_all_flows(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 608 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 609 | vlan_id = 201 |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 610 | match = ofp.match() |
| 611 | match.oxm_list.append(ofp.oxm.in_port(onu_port)) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 612 | match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id)) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 613 | |
| 614 | request = ofp.message.flow_add( |
| 615 | table_id=test_param_get("table", 0), |
| 616 | cookie=42, |
| 617 | match=match, |
| 618 | instructions=[ |
| 619 | ofp.instruction.apply_actions( |
| 620 | actions=[ |
| 621 | ofp.action.output(port=olt_port)]), |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 622 | ], |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 623 | buffer_id=ofp.OFP_NO_BUFFER, |
| 624 | priority=1000) |
| 625 | |
| 626 | self.controller.message_send(request) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 627 | |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 628 | match = ofp.match() |
| 629 | match.oxm_list.append(ofp.oxm.in_port(olt_port)) |
| 630 | match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id)) |
| 631 | |
| 632 | request = ofp.message.flow_add( |
| 633 | table_id=test_param_get("table", 0), |
| 634 | cookie=43, |
| 635 | match=match, |
| 636 | instructions=[ |
| 637 | ofp.instruction.apply_actions( |
| 638 | actions=[ |
| 639 | ofp.action.output(port=onu_port)]), |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 640 | ], |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 641 | buffer_id=ofp.OFP_NO_BUFFER, |
| 642 | priority=1000) |
| 643 | |
| 644 | self.controller.message_send(request) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 645 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 646 | verify_no_errors(self.controller) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 647 | |
Admin | 09b5cc6 | 2015-10-11 13:53:59 -0700 | [diff] [blame] | 648 | # It takes some time for flows to propagate down to the data plane |
| 649 | time.sleep(2) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 650 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 651 | inPkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=vlan_id, vlan_pcp=0) |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 652 | |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 653 | # upstream |
| 654 | self.dataplane.send(onu_port, str(inPkt)) |
| 655 | verify_packet(self, inPkt, olt_port) |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 656 | |
Admin | 99c2a27 | 2016-03-01 12:56:39 -0800 | [diff] [blame] | 657 | # downstream |
| 658 | self.dataplane.send(olt_port, str(inPkt)) |
| 659 | verify_packet(self, inPkt, onu_port) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 660 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 661 | # clean up the test |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 662 | delete_all_flows(self.controller) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 663 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 664 | verify_no_errors(self.controller) |
| 665 | |
alshabib | ed97b5f | 2016-03-01 23:46:53 -0800 | [diff] [blame] | 666 | class TestMulticastForwarding(IGMPPacketIn): |
| 667 | |
| 668 | def runTest(self): |
| 669 | delete_all_groups(self.controller) |
| 670 | # send igmp join packet |
| 671 | super(TestMulticastForwarding, self).runTest() |
| 672 | |
| 673 | vlan_id = 201 |
| 674 | |
alshabib | c49e69c | 2016-03-01 23:49:25 -0800 | [diff] [blame] | 675 | group = createAllGroupAdd(1, [onu_port]) |
alshabib | ed97b5f | 2016-03-01 23:46:53 -0800 | [diff] [blame] | 676 | |
alshabib | 23f0e37 | 2016-03-01 23:50:37 -0800 | [diff] [blame] | 677 | self.controller.message_send(group) |
alshabib | ed97b5f | 2016-03-01 23:46:53 -0800 | [diff] [blame] | 678 | do_barrier(self.controller) |
| 679 | verify_no_errors(self.controller) |
| 680 | |
| 681 | # Create a flow rule matching olt port and vlan id |
| 682 | match = ofp.match() |
| 683 | match.oxm_list.append(ofp.oxm.in_port(olt_port)) |
| 684 | match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id)) |
| 685 | |
| 686 | request = ofp.message.flow_add( |
| 687 | table_id=test_param_get("table", 0), |
| 688 | cookie=43, |
| 689 | match=match, |
| 690 | instructions=[ |
| 691 | ofp.instruction.apply_actions( |
| 692 | actions=[ofp.action.group(group_id=1)]), |
| 693 | ], |
| 694 | buffer_id=ofp.OFP_NO_BUFFER, priority=1000) |
| 695 | |
| 696 | self.controller.message_send(request) |
| 697 | do_barrier(self.controller) |
| 698 | verify_no_errors(self.controller) |
| 699 | |
| 700 | # It takes some time for flows to propagate down to the data plane |
| 701 | time.sleep(5) |
| 702 | |
| 703 | pkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=vlan_id, vlan_pcp=0, \ |
Admin | 99a3ed9 | 2016-03-02 17:22:50 -0800 | [diff] [blame] | 704 | eth_dst = "01:00:5e:0a:14:1e", ip_dst = "229.10.20.30") |
alshabib | ed97b5f | 2016-03-01 23:46:53 -0800 | [diff] [blame] | 705 | |
| 706 | # downstream |
| 707 | self.dataplane.send(olt_port, str(pkt)) |
| 708 | verify_packet(self, pkt, onu_port) |
| 709 | |
| 710 | # clean up the test |
| 711 | delete_all_flows(self.controller) |
| 712 | do_barrier(self.controller) |
| 713 | verify_no_errors(self.controller) |
| 714 | delete_all_groups(self.controller) |
| 715 | |
| 716 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 717 | class RemoveRuleTest(OltBaseTest): |
alshabib | 28c03c3 | 2016-03-01 20:33:51 -0800 | [diff] [blame] | 718 | |
| 719 | def runTest(self): |
| 720 | logging.info("Testing Rule removal") |
alshabib | e165af2 | 2016-03-01 21:42:17 -0800 | [diff] [blame] | 721 | delete_all_flows(self.controller) |
Zsolt Haraszti | 5b8b39c | 2016-03-02 22:25:51 -0800 | [diff] [blame] | 722 | self.installEapolRule(onu_port) |
alshabib | e165af2 | 2016-03-01 21:42:17 -0800 | [diff] [blame] | 723 | |
alshabib | 9929a15 | 2016-03-01 21:25:18 -0800 | [diff] [blame] | 724 | #wait for the rule to settle |
| 725 | time.sleep(3) |
| 726 | |
Admin | 44f754e | 2016-03-01 23:00:46 -0800 | [diff] [blame] | 727 | self.installDoubleTaggingRules(1, 2) |
alshabib | e165af2 | 2016-03-01 21:42:17 -0800 | [diff] [blame] | 728 | |
alshabib | 9929a15 | 2016-03-01 21:25:18 -0800 | [diff] [blame] | 729 | #wait for the rules to settle |
| 730 | time.sleep(3) |
| 731 | |
| 732 | stats = get_flow_stats(self, ofp.match()) |
| 733 | |
Admin | 53e10b6 | 2016-03-01 21:52:18 -0800 | [diff] [blame] | 734 | self.assertTrue(len(stats) == 5, \ |
| 735 | "Wrong number of rules reports; reported %s, expected 5\n\n %s" % (len(stats), stats)) |
alshabib | 9929a15 | 2016-03-01 21:25:18 -0800 | [diff] [blame] | 736 | |
Zsolt Haraszti | 5b8b39c | 2016-03-02 22:25:51 -0800 | [diff] [blame] | 737 | self.installEapolRule(onu_port, install=False) |
alshabib | 9929a15 | 2016-03-01 21:25:18 -0800 | [diff] [blame] | 738 | time.sleep(3) |
| 739 | |
| 740 | stats = get_flow_stats(self, ofp.match()) |
| 741 | |
Admin | 53e10b6 | 2016-03-01 21:52:18 -0800 | [diff] [blame] | 742 | self.assertTrue(len(stats) == 4, \ |
| 743 | "Wrong number of rules reports; reported %s, expected 4\n\n %s" % (len(stats), stats)) |
alshabib | 9929a15 | 2016-03-01 21:25:18 -0800 | [diff] [blame] | 744 | |
alshabib | d6be76e | 2016-03-01 22:21:00 -0800 | [diff] [blame] | 745 | eapol = ofp.oxm.eth_type(0x888e) |
| 746 | found = False |
| 747 | for fe in stats: |
| 748 | if eapol in fe.match.oxm_list: |
| 749 | found = True |
| 750 | |
| 751 | self.assertFalse(found, "Removed incorrect flow rule") |
alshabib | 28c03c3 | 2016-03-01 20:33:51 -0800 | [diff] [blame] | 752 | |
| 753 | |
alshabib | b5a09bc | 2016-03-02 13:26:43 -0800 | [diff] [blame] | 754 | class MultipleDoubleTaggingForwarding(OltBaseTest): |
alshabib | 28c03c3 | 2016-03-01 20:33:51 -0800 | [diff] [blame] | 755 | |
alshabib | 5d53c48 | 2016-03-01 23:25:39 -0800 | [diff] [blame] | 756 | def runTest(self): |
alshabib | 28c03c3 | 2016-03-01 20:33:51 -0800 | [diff] [blame] | 757 | logging.info("Testing multiple Q-in-Q rules") |
Admin | b3bae67 | 2016-03-02 13:00:08 -0800 | [diff] [blame] | 758 | delete_all_flows(self.controller) |
alshabib | 3f3da0e | 2016-03-01 23:23:45 -0800 | [diff] [blame] | 759 | |
Zsolt Haraszti | 5b8b39c | 2016-03-02 22:25:51 -0800 | [diff] [blame] | 760 | self.installEapolRule(onu_port) |
alshabib | 57a536a | 2016-03-02 13:21:28 -0800 | [diff] [blame] | 761 | |
| 762 | time.sleep(1) |
| 763 | |
Zsolt Haraszti | d057140 | 2016-03-02 18:40:50 -0800 | [diff] [blame] | 764 | self.installDoubleTaggingRules(10, 5, cookie=42, onu=onu_port) |
alshabib | 3f3da0e | 2016-03-01 23:23:45 -0800 | [diff] [blame] | 765 | |
Admin | b3bae67 | 2016-03-02 13:00:08 -0800 | [diff] [blame] | 766 | time.sleep(1) |
alshabib | 3f3da0e | 2016-03-01 23:23:45 -0800 | [diff] [blame] | 767 | |
Zsolt Haraszti | d057140 | 2016-03-02 18:40:50 -0800 | [diff] [blame] | 768 | self.installDoubleTaggingRules(10, 30, cookie=50, onu=onu_port2) |
alshabib | 3f3da0e | 2016-03-01 23:23:45 -0800 | [diff] [blame] | 769 | |
Admin | b3bae67 | 2016-03-02 13:00:08 -0800 | [diff] [blame] | 770 | time.sleep(1) |
alshabib | 3f3da0e | 2016-03-01 23:23:45 -0800 | [diff] [blame] | 771 | |
| 772 | self.testPacketFlow(10, 5, onu=onu_port) |
Admin | b3bae67 | 2016-03-02 13:00:08 -0800 | [diff] [blame] | 773 | self.testPacketFlow(10, 30, onu=onu_port2) |
alshabib | 3f3da0e | 2016-03-01 23:23:45 -0800 | [diff] [blame] | 774 | |
Admin | b3bae67 | 2016-03-02 13:00:08 -0800 | [diff] [blame] | 775 | delete_all_flows(self.controller) |
alshabib | 28c03c3 | 2016-03-01 20:33:51 -0800 | [diff] [blame] | 776 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 777 | |
alshabib | d6be76e | 2016-03-01 22:21:00 -0800 | [diff] [blame] | 778 | class DoubleVlanTest(OltBaseTest): |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 779 | |
Admin | b17b166 | 2015-10-19 15:50:53 -0700 | [diff] [blame] | 780 | def runTest(self): |
| 781 | logging.info("Running double vlan tests") |
| 782 | delete_all_flows(self.controller) |
| 783 | |
| 784 | c_vlan_id = 100 |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 785 | s_vlan_id = 102 |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 786 | |
alshabib | d6be76e | 2016-03-01 22:21:00 -0800 | [diff] [blame] | 787 | self.installDoubleTaggingRules(s_vlan_id, c_vlan_id) |
Admin | b17b166 | 2015-10-19 15:50:53 -0700 | [diff] [blame] | 788 | |
Admin | b17b166 | 2015-10-19 15:50:53 -0700 | [diff] [blame] | 789 | # It takes some time for flows to propagate down to the data plane |
| 790 | time.sleep(10) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 791 | |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 792 | # Test packet flows |
alshabib | 3f3da0e | 2016-03-01 23:23:45 -0800 | [diff] [blame] | 793 | self.testPacketFlow(s_vlan_id, c_vlan_id) |
Admin | b17b166 | 2015-10-19 15:50:53 -0700 | [diff] [blame] | 794 | |
| 795 | # clean up the test |
| 796 | delete_all_flows(self.controller) |
| 797 | do_barrier(self.controller) |
| 798 | verify_no_errors(self.controller) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 799 | |
| 800 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 801 | class TestCyclingDoubleVlan(OltBaseTest): |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 802 | """Cycle through vlans and test traffic flow""" |
| 803 | |
| 804 | def runTest(self): |
| 805 | logging.info("Running cycling vlan test") |
| 806 | |
alshabib | 2ecca69 | 2016-03-01 15:10:38 -0800 | [diff] [blame] | 807 | for stag in xrange(2, 4000, 100): |
| 808 | for ctag in xrange(2, 4000, 100): |
alshabib | f1f07dd | 2016-03-01 15:50:35 -0800 | [diff] [blame] | 809 | delete_all_flows(self.controller) |
| 810 | time.sleep(5) |
Admin | 44f754e | 2016-03-01 23:00:46 -0800 | [diff] [blame] | 811 | self.installDoubleTaggingRules(stag, ctag) |
alshabib | f1f07dd | 2016-03-01 15:50:35 -0800 | [diff] [blame] | 812 | time.sleep(5) |
alshabib | 3f3da0e | 2016-03-01 23:23:45 -0800 | [diff] [blame] | 813 | self.testPacketFlow(stag, ctag) |