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