blob: b27ad5b17c96bca1f3efb933817b9c40b5e12c1a [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 Talayco1ddefbf2010-03-07 21:56:47 -080018 # cd <oftest>/tools/munger
19 # make install
20 # cd <oftest>/tests
21 # ./oft --list
22 # ./oft
23 # ./oft --test-spec=<mod> --debug=info --platform=remote --host=...
24
25Longer Start
26++++++++++++
Dan Talaycof7dae842010-02-19 11:50:02 -080027
28 1. Pre-requisites:
Dan Talayco1ddefbf2010-03-07 21:56:47 -080029 * Root privilege on host
Dan Talaycod2ca1032010-03-10 14:40:26 -080030 * Python 2.5. You can run platforms using eth interfaces with
31 Python 2.4.
Dan Talaycof7dae842010-02-19 11:50:02 -080032 * oftest checked out (called <oftest> here)
33 * scapy installed: http://www.secdev.org/projects/scapy/
34 * Doxygen and doxypy for document generation (optional)
35 * lint for source checking (optional)
36
37 2. Build the OpenFlow Python message classes
Dan Talaycoc4747962010-02-19 12:29:17 -080038
39 Important: The OF version used by the controller is based on
40 the file in <oftest>/tools/pylibopenflow/include/openflow.h
41 This is currently the 1.0 release file.
42
Dan Talaycof7dae842010-02-19 11:50:02 -080043 * cd <oftest>/tools/munger
Dan Talayco673e0852010-03-06 23:09:23 -080044 * make install
Dan Talayco1ddefbf2010-03-07 21:56:47 -080045 This places files in <oftest>/src/python/oftest/src and then
46 calls setuptools to install on the local host
Dan Talaycof7dae842010-02-19 11:50:02 -080047
Dan Talayco1ddefbf2010-03-07 21:56:47 -080048 3. Edit configuration if necessary
49 Local platforms work with veth interface pairs and default to
50 four ports. You can adjust this a bit with the command line
51 parameters port_count, base_of_port and base_if_index.
52
Dan Talayco673e0852010-03-06 23:09:23 -080053 Starting from remote.py as a simple example, you can add your
54 own <platform>.py file and then have it imported with
55 --platform=<platform> on the command line.
Dan Talaycof7dae842010-02-19 11:50:02 -080056
Dan Talayco1ddefbf2010-03-07 21:56:47 -080057 4. Start the switch to test
Dan Talaycof7dae842010-02-19 11:50:02 -080058 The switch must be running and actively attempting to
59 connect to the controller at the host/port specified above.
60
Dan Talayco1ddefbf2010-03-07 21:56:47 -080061 5. Run oft
Dan Talayco673e0852010-03-06 23:09:23 -080062 See Warning above; requires sudo to control the dataplane
Dan Talaycof7dae842010-02-19 11:50:02 -080063 * cd <oftest>/tests
Dan Talayco673e0852010-03-06 23:09:23 -080064 * sudo ./oft --help
Dan Talaycof7dae842010-02-19 11:50:02 -080065
66Overview
67++++++++
68
69 The directory structure is currently:
70
71 <oftest>
72 `
73 |-- doc
74 |-- src
75 | `-- python
76 | `-- oftest
77 |-- tests
Dan Talayco1ddefbf2010-03-07 21:56:47 -080078 | `-- oft and files with test cases
Dan Talaycof7dae842010-02-19 11:50:02 -080079 `-- tools
80 |-- munger
81 `-- pylibopenflow
82
83 The tools directory is what processes the OpenFlow header
84 files to produce Python classes representing OpenFlow messages.
85 The results are placed in src/python/oftest and currently
86 include:
87
88 message.py: The main API providing OF message classes
89 error.py: Subclasses for error messages
90 action.py: Subclasses for action specification
91 cstruct.py: Direct representation of C structures in Python
92 class_maps.py: Addition info about C structures
93
94 In addition, the following Python files are present in
95 src/python/oftest:
96
Dan Talaycof7dae842010-02-19 11:50:02 -080097 controller.py: The controller representation
98 dataplane.py: The dataplane representation
99 action_list.py: Action list class
100 netutils.py: e.g., set promisc on sockets
101 ofutils.py: Utilities related to OpenFlow messages
Dan Talayco60a8d7a2010-03-03 15:20:59 -0800102 oft_assert.py: Test framework level assertion
Dan Talaycof7dae842010-02-19 11:50:02 -0800103
Dan Talayco60a8d7a2010-03-03 15:20:59 -0800104 Tests are run from the tests directory. The file oft is the
105 top level entry point for tests. Try ./oft --help for some more.
Dan Talaycof7dae842010-02-19 11:50:02 -0800106
Dan Talayco1ddefbf2010-03-07 21:56:47 -0800107Important Notes
108+++++++++++++++
109
110 1. If you edit any of the files in src/python/oftest or any of the
111 scripts in tools/munger/scripts, you MUST re-run make install. This
112 is easy to forget.
113
114 2. If your running into issues with transactions, and it appears that
115 OpenFlow messages aren't quite right, start by looking at any length
116 fields in the packets. With the local platform, you can use wireshark
117 on the loopback interface as well as the dataplane veth interfaces.
118
119Adding Your Own Test Cases
120++++++++++++++++++++++++++
121
122 You can:
123
124 * Add cases to an existing file
125 * Add a new file
126
127 If you add cases to an existing file, each case should be its own
128 class. It must inherit from unittest.TestCase or one of its
129 derivatives and define runTest (that's how test cases are discovered).
130
131 If you add a new file, it must implement a top level function called
132 test_set_init which takes a configuration dictionary. See basic.py
133 for an example. The main point of this is to pass the port map
134 object to the test cases. But you can access any configuration
135 parameters this way. Each test case in the new file must derive
136 from unittest.TestCase.
Dan Talaycof7dae842010-02-19 11:50:02 -0800137
Dan Talayco79f36082010-03-11 16:53:53 -0800138 CONVENTIONS:
139
140 The first line of the doc string for a file and for a test class is
141 displayed in the list command. Please keep it clear and under 50
142 characters.
143
Dan Talaycod2ca1032010-03-10 14:40:26 -0800144
145Using CentOS/RHEL
146+++++++++++++++++
147
148 CentOS/RHEL have two challenges: they are very tied to Python 2.4
149 (and Scapy requires Python 2.5 for its latest version) and they
150 require a kernel upgrade to use veth pairs for local platform
151 testing.
152
153 If you only need to control eth interfaces for a remote platform,
154 you can use CentOS/RHEL. The key is to download scapy-1.2 from
155 the following link:
156
157 wget http://hg.secdev.org/scapy/raw-file/v1.2.0.2/scapy.py
158
159 See: http://www.dirk-loss.de/scapy-doc/installation.html#installing-scapy-v1-2
160 for more info.
161
162 Copy scapy.py to /usr/lib/python2.4/site-packages
163
164 If you hit an error related to importing scapy.all, you just need
165 to change the import to refer to scapy (not scapy.all). See
166 examples in parse.py for example.
167
168
Dan Talaycof7dae842010-02-19 11:50:02 -0800169Other Info
170++++++++++
171
172 * Build doc with
173 + cd <oftest>/tools/munger
174 + make doc
175 Places the results in <oftest>/doc/html
176
177 * Run lint on sources
178 + cd <oftest>/tools/munger
179 + make lint
180 Places results in <oftest>/lint/*.log
181 The file controller.log currently has some errors indicated
182
183
184To Do
185+++++
186
Dan Talayco60a8d7a2010-03-03 15:20:59 -0800187 * Need to have an overview of the components of the test, how they
188 connect and how they are managed by the test framework.
Dan Talaycof7dae842010-02-19 11:50:02 -0800189 * See the Regression Test component on trac:
190 http://www.openflowswitch.org/bugs/openflow
191 http://www.openflowswitch.org/bugs/openflow/query?component=Regression+test+suite
192
Dan Talaycoc4747962010-02-19 12:29:17 -0800193 * Make the framework work with OF versions other than 1.0?
194