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