Dan Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 1 | OpenFlow Testing Framework |
Dan Talayco | 79f3608 | 2010-03-11 16:53:53 -0800 | [diff] [blame] | 2 | March, 2010 |
Dan Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 3 | |
| 4 | Warning |
| 5 | +++++++ |
| 6 | |
| 7 | This is still experimental and it requires root privilege to |
| 8 | control the dataplane ports. As a consequence, there are |
| 9 | some serious risks to the machine on which this is running. |
| 10 | Use caution. |
| 11 | |
Dan Talayco | 1ddefbf | 2010-03-07 21:56:47 -0800 | [diff] [blame] | 12 | This is still preliminary work and there are bugs in the |
| 13 | framework that need to be ironed out. Please report any issues |
| 14 | to dtalayco@stanford.edu. |
| 15 | |
Dan Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 16 | Quick Start |
| 17 | +++++++++++ |
Dan Talayco | 1ddefbf | 2010-03-07 21:56:47 -0800 | [diff] [blame] | 18 | # 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 | |
| 25 | Longer Start |
| 26 | ++++++++++++ |
Dan Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 27 | |
| 28 | 1. Pre-requisites: |
Dan Talayco | 1ddefbf | 2010-03-07 21:56:47 -0800 | [diff] [blame] | 29 | * Root privilege on host |
Dan Talayco | d2ca103 | 2010-03-10 14:40:26 -0800 | [diff] [blame] | 30 | * Python 2.5. You can run platforms using eth interfaces with |
| 31 | Python 2.4. |
Dan Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 32 | * 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 Talayco | c474796 | 2010-02-19 12:29:17 -0800 | [diff] [blame] | 38 | |
| 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 Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 43 | * cd <oftest>/tools/munger |
Dan Talayco | 673e085 | 2010-03-06 23:09:23 -0800 | [diff] [blame] | 44 | * make install |
Dan Talayco | 1ddefbf | 2010-03-07 21:56:47 -0800 | [diff] [blame] | 45 | This places files in <oftest>/src/python/oftest/src and then |
| 46 | calls setuptools to install on the local host |
Dan Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 47 | |
Dan Talayco | 1ddefbf | 2010-03-07 21:56:47 -0800 | [diff] [blame] | 48 | 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 Talayco | 673e085 | 2010-03-06 23:09:23 -0800 | [diff] [blame] | 53 | 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 Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 56 | |
Dan Talayco | 1ddefbf | 2010-03-07 21:56:47 -0800 | [diff] [blame] | 57 | 4. Start the switch to test |
Dan Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 58 | The switch must be running and actively attempting to |
| 59 | connect to the controller at the host/port specified above. |
| 60 | |
Dan Talayco | 1ddefbf | 2010-03-07 21:56:47 -0800 | [diff] [blame] | 61 | 5. Run oft |
Dan Talayco | 673e085 | 2010-03-06 23:09:23 -0800 | [diff] [blame] | 62 | See Warning above; requires sudo to control the dataplane |
Dan Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 63 | * cd <oftest>/tests |
Dan Talayco | 673e085 | 2010-03-06 23:09:23 -0800 | [diff] [blame] | 64 | * sudo ./oft --help |
Dan Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 65 | |
| 66 | Overview |
| 67 | ++++++++ |
| 68 | |
| 69 | The directory structure is currently: |
| 70 | |
| 71 | <oftest> |
| 72 | ` |
| 73 | |-- doc |
| 74 | |-- src |
| 75 | | `-- python |
| 76 | | `-- oftest |
| 77 | |-- tests |
Dan Talayco | 1ddefbf | 2010-03-07 21:56:47 -0800 | [diff] [blame] | 78 | | `-- oft and files with test cases |
Dan Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 79 | `-- 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 Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 97 | 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 Talayco | 60a8d7a | 2010-03-03 15:20:59 -0800 | [diff] [blame] | 102 | oft_assert.py: Test framework level assertion |
Dan Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 103 | |
Dan Talayco | 60a8d7a | 2010-03-03 15:20:59 -0800 | [diff] [blame] | 104 | 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 Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 106 | |
Dan Talayco | 1ddefbf | 2010-03-07 21:56:47 -0800 | [diff] [blame] | 107 | Important 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 | |
| 119 | Adding 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 Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 137 | |
Dan Talayco | 79f3608 | 2010-03-11 16:53:53 -0800 | [diff] [blame] | 138 | 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 Talayco | d2ca103 | 2010-03-10 14:40:26 -0800 | [diff] [blame] | 144 | |
| 145 | Using 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, |
Dan Talayco | fa16d59 | 2010-03-12 10:01:43 -0800 | [diff] [blame] | 154 | you can use CentOS/RHEL without major disruption. The key is to |
| 155 | download scapy-1.2 from the following link: |
Dan Talayco | d2ca103 | 2010-03-10 14:40:26 -0800 | [diff] [blame] | 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 Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 169 | Other 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 | |
| 184 | To Do |
| 185 | +++++ |
| 186 | |
Dan Talayco | 60a8d7a | 2010-03-03 15:20:59 -0800 | [diff] [blame] | 187 | * 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 Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 189 | * 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 Talayco | c474796 | 2010-02-19 12:29:17 -0800 | [diff] [blame] | 193 | * Make the framework work with OF versions other than 1.0? |
| 194 | |