Matteo Scandolo | a229eca | 2017-08-08 13:05:28 -0700 | [diff] [blame] | 1 | |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | |
macauley_cheng | c249052 | 2015-09-02 17:57:53 +0800 | [diff] [blame] | 17 | """
|
| 18 | Basic test cases
|
| 19 |
|
| 20 | Test cases in other modules depend on this functionality.
|
| 21 | """
|
| 22 |
|
| 23 | import logging
|
| 24 |
|
| 25 | from oftest import config
|
| 26 | import oftest.base_tests as base_tests
|
| 27 | import ofp
|
| 28 | import time
|
| 29 | from oftest.testutils import *
|
| 30 | from accton_util import *
|
| 31 |
|
| 32 | class case1(base_tests.SimpleDataPlane):
|
| 33 | """
|
| 34 | pakcet from port 1 (tag/untag) ouptut to port 2 with vlan 10
|
| 35 | """
|
| 36 | def runTest(self):
|
| 37 | delete_all_flows(self.controller)
|
| 38 | delete_all_groups(self.controller)
|
| 39 |
|
| 40 | in_port = config["port_map"].keys()[0]
|
| 41 | out_port=config["port_map"].keys()[1]
|
| 42 |
|
| 43 | add_one_vlan_table_flow(self.controller, in_port, vlan_id=1, vrf=0, flag=VLAN_TABLE_FLAG_ONLY_BOTH, send_barrier=False)
|
castroflavio | dd17147 | 2015-12-08 13:55:58 -0500 | [diff] [blame] | 44 | add_one_l2_interface_group(self.controller, out_port, 10, True, False)
|
macauley_cheng | c249052 | 2015-09-02 17:57:53 +0800 | [diff] [blame] | 45 | msg=add_l2_rewrite_group(self.controller, out_port, 10, 1, None, None)
|
| 46 |
|
| 47 | match = ofp.match()
|
| 48 | match.oxm_list.append(ofp.oxm.in_port(in_port))
|
| 49 |
|
| 50 | request = ofp.message.flow_add(
|
| 51 | table_id=60,
|
| 52 | cookie=42,
|
| 53 | match=match,
|
| 54 | instructions=[
|
| 55 | ofp.instruction.write_actions(
|
| 56 | actions=[
|
| 57 | ofp.action.group(msg.group_id)])
|
| 58 | ],
|
| 59 | buffer_id=ofp.OFP_NO_BUFFER,
|
| 60 | priority=1000)
|
| 61 |
|
| 62 | self.controller.message_send(request)
|
| 63 |
|
| 64 | parsed_pkt = simple_tcp_packet(pktlen=100)
|
| 65 | pkt = str(parsed_pkt)
|
| 66 | self.dataplane.send(in_port, pkt)
|
| 67 |
|
| 68 | parsed_pkt = simple_tcp_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=10)
|
| 69 | verify_packet(self, str(parsed_pkt), out_port) |