blob: 04a005af22a575b6e011feddf4104d1f34516666 [file] [log] [blame]
Dan Talaycof7dae842010-02-19 11:50:02 -08001OpenFlow Testing Framework
Dan Talayco79f36082010-03-11 16:53:53 -08002March, 2010
Dan Talaycof7dae842010-02-19 11:50:02 -08003
4Warning
5+++++++
6
7This is still experimental and it requires root privilege to
8control the dataplane ports. As a consequence, there are
9some serious risks to the machine on which this is running.
10Use caution.
11
Dan Talayco1ddefbf2010-03-07 21:56:47 -080012This is still preliminary work and there are bugs in the
13framework that need to be ironed out. Please report any issues
14to dtalayco@stanford.edu.
15
Dan Talaycof7dae842010-02-19 11:50:02 -080016Quick Start
17+++++++++++
Dan Talaycoa85e5662010-04-16 09:35:30 -070018
19 Make sure your switch is running and trying to connect to a
20 controller on the machine where you're running oft (normally port
21 6633). (We plan to add a script for the simple case of the SW
22 switch running on the same host.)
23
24 Currently, switches must be running version 1.0 of OpenFlow.
25
26 git clone yuba:/usr/local/git/openflow-projects/oftest
27 cd <oftest>/tools/munger
28 make install
29 cd ../../tests
30 <start your OF switch to test>
31 ./oft --list
32 sudo ./oft --verbose --log-file=""
33 sudo ./oft --test-spec=<mod> --debug=info --platform=remote --host=...
Dan Talayco1ddefbf2010-03-07 21:56:47 -080034
35Longer Start
36++++++++++++
Dan Talaycof7dae842010-02-19 11:50:02 -080037
38 1. Pre-requisites:
Dan Talaycoa85e5662010-04-16 09:35:30 -070039 * An OF switch instance to test (see 4 below)
Dan Talayco1ddefbf2010-03-07 21:56:47 -080040 * Root privilege on host
Dan Talaycod2ca1032010-03-10 14:40:26 -080041 * Python 2.5. You can run platforms using eth interfaces with
42 Python 2.4.
Dan Talaycoa85e5662010-04-16 09:35:30 -070043 * oftest checked out (to a directory called <oftest> here)
Dan Talaycof7dae842010-02-19 11:50:02 -080044 * scapy installed: http://www.secdev.org/projects/scapy/
Dan Talaycoa85e5662010-04-16 09:35:30 -070045 * tcpdump installed (optional, but scapy will complain if it's
46 not there)
Dan Talaycof7dae842010-02-19 11:50:02 -080047 * Doxygen and doxypy for document generation (optional)
48 * lint for source checking (optional)
49
50 2. Build the OpenFlow Python message classes
Dan Talaycoc4747962010-02-19 12:29:17 -080051
52 Important: The OF version used by the controller is based on
53 the file in <oftest>/tools/pylibopenflow/include/openflow.h
54 This is currently the 1.0 release file.
55
Dan Talaycoa85e5662010-04-16 09:35:30 -070056 cd <oftest>/tools/munger
57 make install
Dan Talayco1ddefbf2010-03-07 21:56:47 -080058 This places files in <oftest>/src/python/oftest/src and then
59 calls setuptools to install on the local host
Dan Talaycof7dae842010-02-19 11:50:02 -080060
Dan Talayco1ddefbf2010-03-07 21:56:47 -080061 3. Edit configuration if necessary
62 Local platforms work with veth interface pairs and default to
63 four ports. You can adjust this a bit with the command line
64 parameters port_count, base_of_port and base_if_index.
65
Dan Talayco673e0852010-03-06 23:09:23 -080066 Starting from remote.py as a simple example, you can add your
67 own <platform>.py file and then have it imported with
68 --platform=<platform> on the command line.
Dan Talaycof7dae842010-02-19 11:50:02 -080069
Dan Talayco1ddefbf2010-03-07 21:56:47 -080070 4. Start the switch to test
Dan Talaycof7dae842010-02-19 11:50:02 -080071 The switch must be running and actively attempting to
72 connect to the controller at the host/port specified above.
73
Dan Talaycoa85e5662010-04-16 09:35:30 -070074 If you're new to the test environment and want to check its
75 sanity, you can do the following. This requires that
76 your host kernel supports virtual ethernet interfaces. This
77 is best done in a window separate from where you will run oft.
78
79 4A. Check out openflow (preferably at the same level as oftest):
80 git clone git://openflowswitch.org/openflow.git
81 4B. cd openflow; ./boot.sh; ./configure; make
82 4C. cd ../oftest/tests
83 4D. Run the switch startup script:
84 sudo ./run_switch.py; Now you can run oft (see below).
85 4F. Use --help to see command line switches. Make sure you
86 use the same port for the switch as for oft.
87 4E. Use control-C to terminate the switch daemons.
88 4F. To clean up the virtual ethernet interfaces, use
89 sudo rmmod veth
90
Dan Talayco1ddefbf2010-03-07 21:56:47 -080091 5. Run oft
Dan Talayco673e0852010-03-06 23:09:23 -080092 See Warning above; requires sudo to control the dataplane
Dan Talaycoa85e5662010-04-16 09:35:30 -070093 cd <oftest>/tests
94 sudo ./oft --help
95
96OFT Command Line Options
97++++++++++++++++++++++++
98
99 Here is a summary of the oft command line options. Use --help to see
100 the long and short command option names.
101
102 platform : String identifying the target platform
103 controller_host : Host on which test controller is running (for sockets)
104 controller_port : Port on which test controller listens for switch cxn
105 port_count : Number of ports in dataplane
106 base_of_port : Base OpenFlow port number in dataplane
107 base_if_index : Base OS network interface for dataplane
108 test_dir : Directory to search for test files (default .)
109 test_spec : Specification of test(s) to run
110 log_file : Filename for test logging
111 list : Boolean: List all tests and exit
112 debug : String giving debug level (info, warning, error...)
113 verbose : Same as debug=verbose
Dan Talaycof7dae842010-02-19 11:50:02 -0800114
115Overview
116++++++++
117
118 The directory structure is currently:
119
120 <oftest>
121 `
122 |-- doc
123 |-- src
124 | `-- python
125 | `-- oftest
126 |-- tests
Dan Talayco1ddefbf2010-03-07 21:56:47 -0800127 | `-- oft and files with test cases
Dan Talaycof7dae842010-02-19 11:50:02 -0800128 `-- tools
129 |-- munger
130 `-- pylibopenflow
131
132 The tools directory is what processes the OpenFlow header
133 files to produce Python classes representing OpenFlow messages.
134 The results are placed in src/python/oftest and currently
135 include:
136
137 message.py: The main API providing OF message classes
138 error.py: Subclasses for error messages
139 action.py: Subclasses for action specification
140 cstruct.py: Direct representation of C structures in Python
141 class_maps.py: Addition info about C structures
142
143 In addition, the following Python files are present in
144 src/python/oftest:
145
Dan Talaycof7dae842010-02-19 11:50:02 -0800146 controller.py: The controller representation
147 dataplane.py: The dataplane representation
148 action_list.py: Action list class
149 netutils.py: e.g., set promisc on sockets
150 ofutils.py: Utilities related to OpenFlow messages
Dan Talayco60a8d7a2010-03-03 15:20:59 -0800151 oft_assert.py: Test framework level assertion
Dan Talaycof7dae842010-02-19 11:50:02 -0800152
Dan Talayco60a8d7a2010-03-03 15:20:59 -0800153 Tests are run from the tests directory. The file oft is the
154 top level entry point for tests. Try ./oft --help for some more.
Dan Talaycof7dae842010-02-19 11:50:02 -0800155
Dan Talayco1ddefbf2010-03-07 21:56:47 -0800156Important Notes
157+++++++++++++++
158
159 1. If you edit any of the files in src/python/oftest or any of the
160 scripts in tools/munger/scripts, you MUST re-run make install. This
161 is easy to forget.
162
163 2. If your running into issues with transactions, and it appears that
164 OpenFlow messages aren't quite right, start by looking at any length
165 fields in the packets. With the local platform, you can use wireshark
166 on the loopback interface as well as the dataplane veth interfaces.
167
168Adding Your Own Test Cases
169++++++++++++++++++++++++++
170
171 You can:
172
173 * Add cases to an existing file
174 * Add a new file
175
176 If you add cases to an existing file, each case should be its own
177 class. It must inherit from unittest.TestCase or one of its
178 derivatives and define runTest (that's how test cases are discovered).
179
180 If you add a new file, it must implement a top level function called
181 test_set_init which takes a configuration dictionary. See basic.py
182 for an example. The main point of this is to pass the port map
183 object to the test cases. But you can access any configuration
184 parameters this way. Each test case in the new file must derive
185 from unittest.TestCase.
Dan Talaycof7dae842010-02-19 11:50:02 -0800186
Dan Talayco79f36082010-03-11 16:53:53 -0800187 CONVENTIONS:
188
189 The first line of the doc string for a file and for a test class is
190 displayed in the list command. Please keep it clear and under 50
191 characters.
192
Dan Talaycod2ca1032010-03-10 14:40:26 -0800193
194Using CentOS/RHEL
195+++++++++++++++++
196
197 CentOS/RHEL have two challenges: they are very tied to Python 2.4
198 (and Scapy requires Python 2.5 for its latest version) and they
199 require a kernel upgrade to use veth pairs for local platform
200 testing.
201
202 If you only need to control eth interfaces for a remote platform,
Dan Talaycofa16d592010-03-12 10:01:43 -0800203 you can use CentOS/RHEL without major disruption. The key is to
204 download scapy-1.2 from the following link:
Dan Talaycod2ca1032010-03-10 14:40:26 -0800205
206 wget http://hg.secdev.org/scapy/raw-file/v1.2.0.2/scapy.py
207
208 See: http://www.dirk-loss.de/scapy-doc/installation.html#installing-scapy-v1-2
209 for more info.
210
211 Copy scapy.py to /usr/lib/python2.4/site-packages
212
213 If you hit an error related to importing scapy.all, you just need
214 to change the import to refer to scapy (not scapy.all). See
215 examples in parse.py for example.
216
217
Dan Talaycof7dae842010-02-19 11:50:02 -0800218Other Info
219++++++++++
220
221 * Build doc with
222 + cd <oftest>/tools/munger
223 + make doc
224 Places the results in <oftest>/doc/html
225
226 * Run lint on sources
227 + cd <oftest>/tools/munger
228 + make lint
229 Places results in <oftest>/lint/*.log
230 The file controller.log currently has some errors indicated
231
232
233To Do
234+++++
235
Dan Talayco60a8d7a2010-03-03 15:20:59 -0800236 * Need to have an overview of the components of the test, how they
237 connect and how they are managed by the test framework.
Dan Talaycof7dae842010-02-19 11:50:02 -0800238 * See the Regression Test component on trac:
239 http://www.openflowswitch.org/bugs/openflow
240 http://www.openflowswitch.org/bugs/openflow/query?component=Regression+test+suite
241
Dan Talaycoc4747962010-02-19 12:29:17 -0800242 * Make the framework work with OF versions other than 1.0?
243