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