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")] |
Zsolt Haraszti | ecf8945 | 2016-03-01 22:38:13 -0800 | [diff] [blame] | 62 | pkt = IGMPv3.fixup( scapy.Ether(src='00:00:00:00:be:ef') / scapy.IP() / igmp ) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 63 | pkt = pkt / ("0" * (100 - len(pkt))) |
| 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 |
Admin | d521278 | 2015-12-09 17:17:57 -0800 | [diff] [blame] | 75 | pkt = buildIgmp(igmp) |
| 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 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 276 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 277 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 278 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 279 | class TestGroupAdd(OltBaseTest): |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 280 | |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 281 | def runTest(self): |
| 282 | logging.info("Running Group tests") |
| 283 | delete_all_flows(self.controller) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 284 | delete_all_groups(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 285 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 286 | test_group_id = 1 |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 287 | |
| 288 | # output to two ONU |
| 289 | group_add = createAllGroupAdd(test_group_id, ports=[onu_port, onu_port2]) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 290 | |
| 291 | self.controller.message_send(group_add) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 292 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 293 | verify_no_errors(self.controller) |
| 294 | |
| 295 | # Remove the group and then readd it. |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 296 | group_delete = ofp.message.group_delete(group_id=test_group_id) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 297 | self.controller.message_send(group_delete) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 298 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 299 | verify_no_errors(self.controller) |
| 300 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 301 | group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2]) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 302 | self.controller.message_send(group_add) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 303 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 304 | verify_no_errors(self.controller) |
| 305 | |
| 306 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 307 | # clean up the test |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 308 | group_delete = ofp.message.group_delete(group_id=test_group_id) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 309 | self.controller.message_send(group_delete) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 310 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 311 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 312 | verify_no_errors(self.controller) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 313 | |
| 314 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 315 | class TestGroupMod(OltBaseTest): |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 316 | |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 317 | def runTest(self): |
| 318 | logging.info("Running Group tests") |
| 319 | delete_all_flows(self.controller) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 320 | delete_all_groups(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 321 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 322 | test_group_id = 1 |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 323 | |
| 324 | group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2]) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 325 | |
| 326 | self.controller.message_send(group_add) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 327 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 328 | verify_no_errors(self.controller) |
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 | # Modifying the group |
| 331 | group_mod = createAllGroupMod(test_group_id, [onu_port2]) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 332 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 333 | self.controller.message_send(group_mod) |
| 334 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 335 | verify_no_errors(self.controller) |
| 336 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 337 | # Add a bucket into the group |
| 338 | group_mod = createAllGroupMod(test_group_id, [onu_port, onu_port2]) |
| 339 | self.controller.message_send(group_mod) |
| 340 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 341 | verify_no_errors(self.controller) |
| 342 | |
| 343 | # Modifying a non-existing group |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 344 | group_mod = createAllGroupMod(777, [onu_port2]) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 345 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 346 | self.controller.message_send(group_mod) |
| 347 | do_barrier(self.controller) |
| 348 | errorExperienced = 0 |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 349 | try: |
| 350 | verify_no_errors(self.controller) |
| 351 | except AssertionError as e: |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 352 | errorExperienced = 1 |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 353 | if (not (e.message == "unexpected error type=6 code=8")): |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 354 | raise AssertionError("Incorrect error type: %s" % e.message) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 355 | if not errorExperienced: |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 356 | raise AssertionError("An error message is expected, but not shown.") |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 357 | |
| 358 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 359 | # clean up the test |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 360 | group_delete = ofp.message.group_delete(xid=2, group_id=test_group_id) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 361 | self.controller.message_send(group_delete) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 362 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 363 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 364 | verify_no_errors(self.controller) |
| 365 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 366 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 367 | class TestDuplicateGroup(OltBaseTest): |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 368 | |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 369 | def runTest(self): |
| 370 | logging.info("Running Group tests") |
| 371 | delete_all_flows(self.controller) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 372 | delete_all_groups(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 373 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 374 | test_group_id = 1 |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 375 | group_add = createAllGroupAdd(test_group_id, ports=[onu_port]) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 376 | |
| 377 | self.controller.message_send(group_add) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 378 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 379 | verify_no_errors(self.controller) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 380 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 381 | # Add the same group id |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 382 | duplicate_group_fail = 0 |
| 383 | |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 384 | self.controller.message_send(group_add) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 385 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 386 | try: |
| 387 | verify_no_errors(self.controller) |
| 388 | except AssertionError as e: |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 389 | duplicate_group_fail = 1 |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 390 | if (not e.message == "unexpected error type=6 code=0"): |
| 391 | raise AssertionError("Incorrect error type: %s" % e.message) |
| 392 | if not duplicate_group_fail: |
| 393 | raise AssertionError("Adding duplicate groups didn't raise an error.") |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 394 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 395 | # clean up the test |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 396 | group_delete = ofp.message.group_delete(xid=2, group_id=test_group_id) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 397 | self.controller.message_send(group_delete) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 398 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 399 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 400 | verify_no_errors(self.controller) |
| 401 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 402 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 403 | class TestGroupAndFlow(OltBaseTest): |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 404 | |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 405 | def runTest(self): |
| 406 | logging.info("Running Group tests") |
| 407 | delete_all_flows(self.controller) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 408 | delete_all_groups(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 409 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 410 | # Create a group |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 411 | test_group_id = 1 |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 412 | group_add = createAllGroupAdd(test_group_id, ports=[onu_port]) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 413 | |
| 414 | self.controller.message_send(group_add) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 415 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 416 | verify_no_errors(self.controller) |
| 417 | |
| 418 | # Create a flow rule matching olt port and vlan id |
| 419 | match = ofp.match() |
| 420 | match.oxm_list.append(ofp.oxm.in_port(olt_port)) |
| 421 | match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | 201)) |
| 422 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 423 | flow_pointing_to_group = ofp.message.flow_add( |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 424 | table_id=test_param_get("table", 0), |
| 425 | cookie=43, |
| 426 | match=match, |
| 427 | instructions=[ |
| 428 | ofp.instruction.apply_actions( |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 429 | actions=[ofp.action.group(group_id=test_group_id)])], |
| 430 | buffer_id=ofp.OFP_NO_BUFFER, priority=1000) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 431 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 432 | self.controller.message_send(flow_pointing_to_group) |
| 433 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 434 | verify_no_errors(self.controller) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 435 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 436 | # After letting a flow rule point to the group, test we can do group_mod |
| 437 | group_mod = createAllGroupMod(test_group_id, ports=[onu_port2]) |
| 438 | self.controller.message_send(group_mod) |
| 439 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 440 | verify_no_errors(self.controller) |
| 441 | |
| 442 | # Test we can remove flows and then remove group |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 443 | 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] | 444 | self.controller.message_send(flow_delete) |
| 445 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 446 | verify_no_errors(self.controller) |
| 447 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 448 | group_delete = ofp.message.group_delete(xid=3, group_id=test_group_id) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 449 | self.controller.message_send(group_delete) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 450 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 451 | verify_no_errors(self.controller) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 452 | |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 453 | # 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] | 454 | '''group_add = createAllGroupAdd(test_group_id, ports=[onu_port]) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 455 | self.controller.message_send(group_add) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 456 | |
| 457 | self.controller.message_send(flow_pointing_to_group) |
| 458 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 459 | verify_no_errors(self.controller) |
| 460 | |
| 461 | group_delete = ofp.message.group_delete(xid = 4, group_id = test_group_id) |
Admin | dcb1bc7 | 2015-11-12 18:24:56 -0800 | [diff] [blame] | 462 | self.controller.message_send(group_delete)''' |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 463 | |
| 464 | self.controller.message_send(flow_delete) |
| 465 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 466 | verify_no_errors(self.controller) |
| 467 | |
| 468 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 469 | class TestGroupForwarding(OltBaseTest): |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 470 | |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 471 | def runTest(self): |
| 472 | logging.info("Running Group datapath forwarding tests") |
| 473 | delete_all_flows(self.controller) |
Admin | 99c2a27 | 2016-03-01 12:56:39 -0800 | [diff] [blame] | 474 | delete_all_groups(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 475 | |
Admin | 09b5cc6 | 2015-10-11 13:53:59 -0700 | [diff] [blame] | 476 | vlan_id = 201 |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 477 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 478 | # Create a group |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 479 | test_group_id = 1 |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 480 | group_add = createAllGroupAdd(test_group_id, [onu_port]) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 481 | |
| 482 | self.controller.message_send(group_add) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 483 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 484 | verify_no_errors(self.controller) |
| 485 | |
| 486 | # Create a flow rule matching olt port and vlan id |
| 487 | match = ofp.match() |
| 488 | match.oxm_list.append(ofp.oxm.in_port(olt_port)) |
| 489 | match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id)) |
| 490 | |
| 491 | request = ofp.message.flow_add( |
| 492 | table_id=test_param_get("table", 0), |
| 493 | cookie=43, |
| 494 | match=match, |
| 495 | instructions=[ |
| 496 | ofp.instruction.apply_actions( |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 497 | actions=[ofp.action.group(group_id=test_group_id)]), |
| 498 | ], |
| 499 | buffer_id=ofp.OFP_NO_BUFFER, priority=1000) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 500 | |
| 501 | self.controller.message_send(request) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 502 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 503 | verify_no_errors(self.controller) |
Admin | 09b5cc6 | 2015-10-11 13:53:59 -0700 | [diff] [blame] | 504 | |
| 505 | # It takes some time for flows to propagate down to the data plane |
Admin | dcb1bc7 | 2015-11-12 18:24:56 -0800 | [diff] [blame] | 506 | time.sleep(10) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 507 | |
| 508 | inPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True, |
Admin | dcb1bc7 | 2015-11-12 18:24:56 -0800 | [diff] [blame] | 509 | 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] | 510 | outPkt = inPkt |
| 511 | self.dataplane.send(olt_port, str(inPkt)) |
| 512 | verify_packet(self, outPkt, onu_port) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 513 | |
Admin | dcb1bc7 | 2015-11-12 18:24:56 -0800 | [diff] [blame] | 514 | |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 515 | # 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] | 516 | # duplicated out both ports |
| 517 | group_mod = createAllGroupMod(test_group_id, ports=[onu_port, onu_port2]) |
| 518 | self.controller.message_send(group_mod) |
| 519 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 520 | verify_no_errors(self.controller) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 521 | |
Admin | 09b5cc6 | 2015-10-11 13:53:59 -0700 | [diff] [blame] | 522 | # It takes some time for flows to propagate down to the data plane |
Admin | dcb1bc7 | 2015-11-12 18:24:56 -0800 | [diff] [blame] | 523 | time.sleep(10) |
Admin | 09b5cc6 | 2015-10-11 13:53:59 -0700 | [diff] [blame] | 524 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 525 | self.dataplane.send(olt_port, str(inPkt)) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 526 | verify_packet(self, outPkt, onu_port2) |
Admin | dcb1bc7 | 2015-11-12 18:24:56 -0800 | [diff] [blame] | 527 | verify_packet(self, outPkt, onu_port) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 528 | # verify_packets(self, outPkt, [onu_port,onu_port2]) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 529 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 530 | # clean up the test |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 531 | request = ofp.message.flow_delete(table_id=test_param_get("table", 0)) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 532 | self.controller.message_send(request) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 533 | group_delete = ofp.message.group_delete(xid=2, group_id=test_group_id) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 534 | self.controller.message_send(group_delete) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 535 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 536 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 537 | verify_no_errors(self.controller) |
| 538 | |
Admin | dcb1bc7 | 2015-11-12 18:24:56 -0800 | [diff] [blame] | 539 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 540 | class TestGroupModForwarding(OltBaseTest): |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 541 | |
Admin | dcb1bc7 | 2015-11-12 18:24:56 -0800 | [diff] [blame] | 542 | def runTest(self): |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 543 | logging.info("Running datapath forwarding tests for group mod") |
Admin | dcb1bc7 | 2015-11-12 18:24:56 -0800 | [diff] [blame] | 544 | delete_all_flows(self.controller) |
| 545 | delete_all_groups(self.controller) |
| 546 | |
| 547 | vlan_id = 201 |
| 548 | |
| 549 | # Create a group |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 550 | test_group_id = 1 |
Admin | dcb1bc7 | 2015-11-12 18:24:56 -0800 | [diff] [blame] | 551 | group_add = createAllGroupAdd(test_group_id, [onu_port, onu_port2]) |
| 552 | |
| 553 | self.controller.message_send(group_add) |
| 554 | do_barrier(self.controller) |
| 555 | verify_no_errors(self.controller) |
| 556 | |
| 557 | # Create a flow rule matching olt port and vlan id |
| 558 | match = ofp.match() |
| 559 | match.oxm_list.append(ofp.oxm.in_port(olt_port)) |
| 560 | match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id)) |
| 561 | |
| 562 | request = ofp.message.flow_add( |
| 563 | table_id=test_param_get("table", 0), |
| 564 | cookie=43, |
| 565 | match=match, |
| 566 | instructions=[ |
| 567 | ofp.instruction.apply_actions( |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 568 | actions=[ofp.action.group(group_id=test_group_id)]), |
| 569 | ], |
| 570 | buffer_id=ofp.OFP_NO_BUFFER, priority=1000) |
Admin | dcb1bc7 | 2015-11-12 18:24:56 -0800 | [diff] [blame] | 571 | |
| 572 | self.controller.message_send(request) |
| 573 | do_barrier(self.controller) |
| 574 | verify_no_errors(self.controller) |
| 575 | |
| 576 | # It takes some time for flows to propagate down to the data plane |
| 577 | time.sleep(10) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 578 | |
| 579 | inPkt = simple_udp_packet(pktlen=104, dl_vlan_enable=True, |
Admin | dcb1bc7 | 2015-11-12 18:24:56 -0800 | [diff] [blame] | 580 | vlan_vid=vlan_id, vlan_pcp=0, dl_vlan_cfi=0, eth_dst="01:01:11:12:11:12") |
| 581 | outPkt = inPkt |
| 582 | self.dataplane.send(olt_port, str(inPkt)) |
| 583 | verify_packet(self, outPkt, onu_port) |
Admin | 99c2a27 | 2016-03-01 12:56:39 -0800 | [diff] [blame] | 584 | verify_packet(self, outPkt, onu_port2) |
Admin | dcb1bc7 | 2015-11-12 18:24:56 -0800 | [diff] [blame] | 585 | |
| 586 | # Now remove onu port 1 from the group and test that the input packet is no longer forwarded to onu port 1 |
| 587 | group_mod = createAllGroupMod(test_group_id, ports=[onu_port2]) |
| 588 | self.controller.message_send(group_mod) |
| 589 | do_barrier(self.controller) |
| 590 | verify_no_errors(self.controller) |
| 591 | |
| 592 | time.sleep(10) |
| 593 | self.dataplane.send(olt_port, str(inPkt)) |
| 594 | verify_no_packet(self, outPkt, onu_port) |
| 595 | verify_packet(self, outPkt, onu_port2) |
| 596 | |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 597 | # 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] | 598 | group_mod = createAllGroupMod(test_group_id, ports=[]) |
| 599 | self.controller.message_send(group_mod) |
| 600 | do_barrier(self.controller) |
| 601 | verify_no_errors(self.controller) |
| 602 | time.sleep(10) |
| 603 | self.dataplane.send(olt_port, str(inPkt)) |
| 604 | verify_packets(self, outPkt, []) |
| 605 | |
| 606 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 607 | class TransparentVlanTest(OltBaseTest): |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 608 | |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 609 | def runTest(self): |
| 610 | logging.info("Running transparent vlan tests") |
Admin | 09b5cc6 | 2015-10-11 13:53:59 -0700 | [diff] [blame] | 611 | delete_all_flows(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 612 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 613 | vlan_id = 201 |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 614 | match = ofp.match() |
| 615 | match.oxm_list.append(ofp.oxm.in_port(onu_port)) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 616 | match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id)) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 617 | |
| 618 | request = ofp.message.flow_add( |
| 619 | table_id=test_param_get("table", 0), |
| 620 | cookie=42, |
| 621 | match=match, |
| 622 | instructions=[ |
| 623 | ofp.instruction.apply_actions( |
| 624 | actions=[ |
| 625 | ofp.action.output(port=olt_port)]), |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 626 | ], |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 627 | buffer_id=ofp.OFP_NO_BUFFER, |
| 628 | priority=1000) |
| 629 | |
| 630 | self.controller.message_send(request) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 631 | |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 632 | match = ofp.match() |
| 633 | match.oxm_list.append(ofp.oxm.in_port(olt_port)) |
| 634 | match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id)) |
| 635 | |
| 636 | request = ofp.message.flow_add( |
| 637 | table_id=test_param_get("table", 0), |
| 638 | cookie=43, |
| 639 | match=match, |
| 640 | instructions=[ |
| 641 | ofp.instruction.apply_actions( |
| 642 | actions=[ |
| 643 | ofp.action.output(port=onu_port)]), |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 644 | ], |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 645 | buffer_id=ofp.OFP_NO_BUFFER, |
| 646 | priority=1000) |
| 647 | |
| 648 | self.controller.message_send(request) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 649 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 650 | verify_no_errors(self.controller) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 651 | |
Admin | 09b5cc6 | 2015-10-11 13:53:59 -0700 | [diff] [blame] | 652 | # It takes some time for flows to propagate down to the data plane |
| 653 | time.sleep(2) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 654 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 655 | 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] | 656 | |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 657 | # upstream |
| 658 | self.dataplane.send(onu_port, str(inPkt)) |
| 659 | verify_packet(self, inPkt, olt_port) |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 660 | |
Admin | 99c2a27 | 2016-03-01 12:56:39 -0800 | [diff] [blame] | 661 | # downstream |
| 662 | self.dataplane.send(olt_port, str(inPkt)) |
| 663 | verify_packet(self, inPkt, onu_port) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 664 | |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 665 | # clean up the test |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 666 | delete_all_flows(self.controller) |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 667 | do_barrier(self.controller) |
Admin | 02d052c | 2015-10-10 19:08:26 -0700 | [diff] [blame] | 668 | verify_no_errors(self.controller) |
| 669 | |
alshabib | ed97b5f | 2016-03-01 23:46:53 -0800 | [diff] [blame] | 670 | class TestMulticastForwarding(IGMPPacketIn): |
| 671 | |
| 672 | def runTest(self): |
| 673 | delete_all_groups(self.controller) |
| 674 | # send igmp join packet |
| 675 | super(TestMulticastForwarding, self).runTest() |
| 676 | |
| 677 | vlan_id = 201 |
| 678 | |
alshabib | c49e69c | 2016-03-01 23:49:25 -0800 | [diff] [blame] | 679 | group = createAllGroupAdd(1, [onu_port]) |
alshabib | ed97b5f | 2016-03-01 23:46:53 -0800 | [diff] [blame] | 680 | |
alshabib | 23f0e37 | 2016-03-01 23:50:37 -0800 | [diff] [blame^] | 681 | self.controller.message_send(group) |
alshabib | ed97b5f | 2016-03-01 23:46:53 -0800 | [diff] [blame] | 682 | do_barrier(self.controller) |
| 683 | verify_no_errors(self.controller) |
| 684 | |
| 685 | # Create a flow rule matching olt port and vlan id |
| 686 | match = ofp.match() |
| 687 | match.oxm_list.append(ofp.oxm.in_port(olt_port)) |
| 688 | match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan_id)) |
| 689 | |
| 690 | request = ofp.message.flow_add( |
| 691 | table_id=test_param_get("table", 0), |
| 692 | cookie=43, |
| 693 | match=match, |
| 694 | instructions=[ |
| 695 | ofp.instruction.apply_actions( |
| 696 | actions=[ofp.action.group(group_id=1)]), |
| 697 | ], |
| 698 | buffer_id=ofp.OFP_NO_BUFFER, priority=1000) |
| 699 | |
| 700 | self.controller.message_send(request) |
| 701 | do_barrier(self.controller) |
| 702 | verify_no_errors(self.controller) |
| 703 | |
| 704 | # It takes some time for flows to propagate down to the data plane |
| 705 | time.sleep(5) |
| 706 | |
| 707 | pkt = simple_udp_packet(dl_vlan_enable=True, vlan_vid=vlan_id, vlan_pcp=0, \ |
| 708 | eth_dst = "01:00:5E:00:00:01", ip_dst = "229.10.20.30") |
| 709 | |
| 710 | # downstream |
| 711 | self.dataplane.send(olt_port, str(pkt)) |
| 712 | verify_packet(self, pkt, onu_port) |
| 713 | |
| 714 | # clean up the test |
| 715 | delete_all_flows(self.controller) |
| 716 | do_barrier(self.controller) |
| 717 | verify_no_errors(self.controller) |
| 718 | delete_all_groups(self.controller) |
| 719 | |
| 720 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 721 | class RemoveRuleTest(OltBaseTest): |
alshabib | 28c03c3 | 2016-03-01 20:33:51 -0800 | [diff] [blame] | 722 | |
| 723 | def runTest(self): |
| 724 | logging.info("Testing Rule removal") |
alshabib | e165af2 | 2016-03-01 21:42:17 -0800 | [diff] [blame] | 725 | delete_all_flows(self.controller) |
Admin | 44f754e | 2016-03-01 23:00:46 -0800 | [diff] [blame] | 726 | self.processEapolRule(onu_port) |
alshabib | e165af2 | 2016-03-01 21:42:17 -0800 | [diff] [blame] | 727 | |
alshabib | 9929a15 | 2016-03-01 21:25:18 -0800 | [diff] [blame] | 728 | #wait for the rule to settle |
| 729 | time.sleep(3) |
| 730 | |
Admin | 44f754e | 2016-03-01 23:00:46 -0800 | [diff] [blame] | 731 | self.installDoubleTaggingRules(1, 2) |
alshabib | e165af2 | 2016-03-01 21:42:17 -0800 | [diff] [blame] | 732 | |
alshabib | 9929a15 | 2016-03-01 21:25:18 -0800 | [diff] [blame] | 733 | #wait for the rules to settle |
| 734 | time.sleep(3) |
| 735 | |
| 736 | stats = get_flow_stats(self, ofp.match()) |
| 737 | |
Admin | 53e10b6 | 2016-03-01 21:52:18 -0800 | [diff] [blame] | 738 | self.assertTrue(len(stats) == 5, \ |
| 739 | "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] | 740 | |
Admin | 44f754e | 2016-03-01 23:00:46 -0800 | [diff] [blame] | 741 | self.processEapolRule(onu_port, install = False) |
alshabib | 9929a15 | 2016-03-01 21:25:18 -0800 | [diff] [blame] | 742 | time.sleep(3) |
| 743 | |
| 744 | stats = get_flow_stats(self, ofp.match()) |
| 745 | |
Admin | 53e10b6 | 2016-03-01 21:52:18 -0800 | [diff] [blame] | 746 | self.assertTrue(len(stats) == 4, \ |
| 747 | "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] | 748 | |
alshabib | d6be76e | 2016-03-01 22:21:00 -0800 | [diff] [blame] | 749 | eapol = ofp.oxm.eth_type(0x888e) |
| 750 | found = False |
| 751 | for fe in stats: |
| 752 | if eapol in fe.match.oxm_list: |
| 753 | found = True |
| 754 | |
| 755 | self.assertFalse(found, "Removed incorrect flow rule") |
alshabib | 28c03c3 | 2016-03-01 20:33:51 -0800 | [diff] [blame] | 756 | |
| 757 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 758 | class MultipleDoubleTaggingForwarding(OltBaseTest): |
alshabib | 28c03c3 | 2016-03-01 20:33:51 -0800 | [diff] [blame] | 759 | |
alshabib | 5d53c48 | 2016-03-01 23:25:39 -0800 | [diff] [blame] | 760 | def runTest(self): |
alshabib | 28c03c3 | 2016-03-01 20:33:51 -0800 | [diff] [blame] | 761 | logging.info("Testing multiple Q-in-Q rules") |
alshabib | 3f3da0e | 2016-03-01 23:23:45 -0800 | [diff] [blame] | 762 | |
| 763 | self.installDoubleTaggingRules(10, 5, cookie=42, onu = onu_port) |
| 764 | |
| 765 | time.sleep(5) |
| 766 | |
| 767 | self.installDoubleTaggingRules(20, 10, cookie=50, onu = onu_port2) |
| 768 | |
| 769 | time.sleep(5) |
| 770 | |
| 771 | self.testPacketFlow(10, 5, onu=onu_port) |
| 772 | self.testPacketFlow(20, 10, onu=onu_port2) |
| 773 | |
alshabib | 28c03c3 | 2016-03-01 20:33:51 -0800 | [diff] [blame] | 774 | pass |
| 775 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 776 | |
alshabib | d6be76e | 2016-03-01 22:21:00 -0800 | [diff] [blame] | 777 | class DoubleVlanTest(OltBaseTest): |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 778 | |
Admin | b17b166 | 2015-10-19 15:50:53 -0700 | [diff] [blame] | 779 | def runTest(self): |
| 780 | logging.info("Running double vlan tests") |
| 781 | delete_all_flows(self.controller) |
| 782 | |
| 783 | c_vlan_id = 100 |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 784 | s_vlan_id = 102 |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 785 | |
alshabib | d6be76e | 2016-03-01 22:21:00 -0800 | [diff] [blame] | 786 | self.installDoubleTaggingRules(s_vlan_id, c_vlan_id) |
Admin | b17b166 | 2015-10-19 15:50:53 -0700 | [diff] [blame] | 787 | |
Admin | b17b166 | 2015-10-19 15:50:53 -0700 | [diff] [blame] | 788 | # It takes some time for flows to propagate down to the data plane |
| 789 | time.sleep(10) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 790 | |
Zsolt Haraszti | fe52550 | 2016-03-02 05:18:52 +0000 | [diff] [blame] | 791 | # Test packet flows |
alshabib | 3f3da0e | 2016-03-01 23:23:45 -0800 | [diff] [blame] | 792 | self.testPacketFlow(s_vlan_id, c_vlan_id) |
Admin | b17b166 | 2015-10-19 15:50:53 -0700 | [diff] [blame] | 793 | |
| 794 | # clean up the test |
| 795 | delete_all_flows(self.controller) |
| 796 | do_barrier(self.controller) |
| 797 | verify_no_errors(self.controller) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 798 | |
| 799 | |
alshabib | cde318b | 2016-03-01 22:49:13 -0800 | [diff] [blame] | 800 | class TestCyclingDoubleVlan(OltBaseTest): |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 801 | """Cycle through vlans and test traffic flow""" |
| 802 | |
| 803 | def runTest(self): |
| 804 | logging.info("Running cycling vlan test") |
| 805 | |
alshabib | 2ecca69 | 2016-03-01 15:10:38 -0800 | [diff] [blame] | 806 | for stag in xrange(2, 4000, 100): |
| 807 | for ctag in xrange(2, 4000, 100): |
alshabib | f1f07dd | 2016-03-01 15:50:35 -0800 | [diff] [blame] | 808 | delete_all_flows(self.controller) |
| 809 | time.sleep(5) |
Admin | 44f754e | 2016-03-01 23:00:46 -0800 | [diff] [blame] | 810 | self.installDoubleTaggingRules(stag, ctag) |
alshabib | f1f07dd | 2016-03-01 15:50:35 -0800 | [diff] [blame] | 811 | time.sleep(5) |
alshabib | 3f3da0e | 2016-03-01 23:23:45 -0800 | [diff] [blame] | 812 | self.testPacketFlow(stag, ctag) |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 813 | |
alshabib | 9929a15 | 2016-03-01 21:25:18 -0800 | [diff] [blame] | 814 | |
alshabib | b9b39a7 | 2016-03-01 15:52:03 -0800 | [diff] [blame] | 815 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 816 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 817 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 818 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 819 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 820 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 821 | |
alshabib | b9d4ee8 | 2016-03-01 14:12:42 -0800 | [diff] [blame] | 822 | |