blob: e5ff539822a820847bded6e3185979e5560dee9d [file] [log] [blame]
Dan Talaycof7dae842010-02-19 11:50:02 -08001OpenFlow Testing Framework
2February, 2010
3
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 Talaycof7dae842010-02-19 11:50:02 -080030 * Python 2.5 (or so)
31 * oftest checked out (called <oftest> here)
32 * scapy installed: http://www.secdev.org/projects/scapy/
33 * Doxygen and doxypy for document generation (optional)
34 * lint for source checking (optional)
35
36 2. Build the OpenFlow Python message classes
Dan Talaycoc4747962010-02-19 12:29:17 -080037
38 Important: The OF version used by the controller is based on
39 the file in <oftest>/tools/pylibopenflow/include/openflow.h
40 This is currently the 1.0 release file.
41
Dan Talaycof7dae842010-02-19 11:50:02 -080042 * cd <oftest>/tools/munger
Dan Talayco673e0852010-03-06 23:09:23 -080043 * make install
Dan Talayco1ddefbf2010-03-07 21:56:47 -080044 This places files in <oftest>/src/python/oftest/src and then
45 calls setuptools to install on the local host
Dan Talaycof7dae842010-02-19 11:50:02 -080046
Dan Talayco1ddefbf2010-03-07 21:56:47 -080047 3. Edit configuration if necessary
48 Local platforms work with veth interface pairs and default to
49 four ports. You can adjust this a bit with the command line
50 parameters port_count, base_of_port and base_if_index.
51
Dan Talayco673e0852010-03-06 23:09:23 -080052 Starting from remote.py as a simple example, you can add your
53 own <platform>.py file and then have it imported with
54 --platform=<platform> on the command line.
Dan Talaycof7dae842010-02-19 11:50:02 -080055
Dan Talayco1ddefbf2010-03-07 21:56:47 -080056 4. Start the switch to test
Dan Talaycof7dae842010-02-19 11:50:02 -080057 The switch must be running and actively attempting to
58 connect to the controller at the host/port specified above.
59
Dan Talayco1ddefbf2010-03-07 21:56:47 -080060 5. Run oft
Dan Talayco673e0852010-03-06 23:09:23 -080061 See Warning above; requires sudo to control the dataplane
Dan Talaycof7dae842010-02-19 11:50:02 -080062 * cd <oftest>/tests
Dan Talayco673e0852010-03-06 23:09:23 -080063 * sudo ./oft --help
Dan Talaycof7dae842010-02-19 11:50:02 -080064
65Overview
66++++++++
67
68 The directory structure is currently:
69
70 <oftest>
71 `
72 |-- doc
73 |-- src
74 | `-- python
75 | `-- oftest
76 |-- tests
Dan Talayco1ddefbf2010-03-07 21:56:47 -080077 | `-- oft and files with test cases
Dan Talaycof7dae842010-02-19 11:50:02 -080078 `-- tools
79 |-- munger
80 `-- pylibopenflow
81
82 The tools directory is what processes the OpenFlow header
83 files to produce Python classes representing OpenFlow messages.
84 The results are placed in src/python/oftest and currently
85 include:
86
87 message.py: The main API providing OF message classes
88 error.py: Subclasses for error messages
89 action.py: Subclasses for action specification
90 cstruct.py: Direct representation of C structures in Python
91 class_maps.py: Addition info about C structures
92
93 In addition, the following Python files are present in
94 src/python/oftest:
95
Dan Talaycof7dae842010-02-19 11:50:02 -080096 controller.py: The controller representation
97 dataplane.py: The dataplane representation
98 action_list.py: Action list class
99 netutils.py: e.g., set promisc on sockets
100 ofutils.py: Utilities related to OpenFlow messages
Dan Talayco60a8d7a2010-03-03 15:20:59 -0800101 oft_assert.py: Test framework level assertion
Dan Talaycof7dae842010-02-19 11:50:02 -0800102
Dan Talayco60a8d7a2010-03-03 15:20:59 -0800103 Tests are run from the tests directory. The file oft is the
104 top level entry point for tests. Try ./oft --help for some more.
Dan Talaycof7dae842010-02-19 11:50:02 -0800105
Dan Talayco1ddefbf2010-03-07 21:56:47 -0800106Important Notes
107+++++++++++++++
108
109 1. If you edit any of the files in src/python/oftest or any of the
110 scripts in tools/munger/scripts, you MUST re-run make install. This
111 is easy to forget.
112
113 2. If your running into issues with transactions, and it appears that
114 OpenFlow messages aren't quite right, start by looking at any length
115 fields in the packets. With the local platform, you can use wireshark
116 on the loopback interface as well as the dataplane veth interfaces.
117
118Adding Your Own Test Cases
119++++++++++++++++++++++++++
120
121 You can:
122
123 * Add cases to an existing file
124 * Add a new file
125
126 If you add cases to an existing file, each case should be its own
127 class. It must inherit from unittest.TestCase or one of its
128 derivatives and define runTest (that's how test cases are discovered).
129
130 If you add a new file, it must implement a top level function called
131 test_set_init which takes a configuration dictionary. See basic.py
132 for an example. The main point of this is to pass the port map
133 object to the test cases. But you can access any configuration
134 parameters this way. Each test case in the new file must derive
135 from unittest.TestCase.
Dan Talaycof7dae842010-02-19 11:50:02 -0800136
137Other Info
138++++++++++
139
140 * Build doc with
141 + cd <oftest>/tools/munger
142 + make doc
143 Places the results in <oftest>/doc/html
144
145 * Run lint on sources
146 + cd <oftest>/tools/munger
147 + make lint
148 Places results in <oftest>/lint/*.log
149 The file controller.log currently has some errors indicated
150
151
152To Do
153+++++
154
Dan Talayco60a8d7a2010-03-03 15:20:59 -0800155 * Need to have an overview of the components of the test, how they
156 connect and how they are managed by the test framework.
Dan Talaycof7dae842010-02-19 11:50:02 -0800157 * See the Regression Test component on trac:
158 http://www.openflowswitch.org/bugs/openflow
159 http://www.openflowswitch.org/bugs/openflow/query?component=Regression+test+suite
160
Dan Talaycoc4747962010-02-19 12:29:17 -0800161 * Make the framework work with OF versions other than 1.0?
162