Dan Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 1 | OpenFlow Testing Framework |
| 2 | February, 2010 |
| 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 | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 30 | * 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 Talayco | c474796 | 2010-02-19 12:29:17 -0800 | [diff] [blame] | 37 | |
| 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 Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 42 | * cd <oftest>/tools/munger |
Dan Talayco | 673e085 | 2010-03-06 23:09:23 -0800 | [diff] [blame] | 43 | * make install |
Dan Talayco | 1ddefbf | 2010-03-07 21:56:47 -0800 | [diff] [blame] | 44 | This places files in <oftest>/src/python/oftest/src and then |
| 45 | calls setuptools to install on the local host |
Dan Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 46 | |
Dan Talayco | 1ddefbf | 2010-03-07 21:56:47 -0800 | [diff] [blame] | 47 | 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 Talayco | 673e085 | 2010-03-06 23:09:23 -0800 | [diff] [blame] | 52 | 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 Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 55 | |
Dan Talayco | 1ddefbf | 2010-03-07 21:56:47 -0800 | [diff] [blame] | 56 | 4. Start the switch to test |
Dan Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 57 | The switch must be running and actively attempting to |
| 58 | connect to the controller at the host/port specified above. |
| 59 | |
Dan Talayco | 1ddefbf | 2010-03-07 21:56:47 -0800 | [diff] [blame] | 60 | 5. Run oft |
Dan Talayco | 673e085 | 2010-03-06 23:09:23 -0800 | [diff] [blame] | 61 | See Warning above; requires sudo to control the dataplane |
Dan Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 62 | * cd <oftest>/tests |
Dan Talayco | 673e085 | 2010-03-06 23:09:23 -0800 | [diff] [blame] | 63 | * sudo ./oft --help |
Dan Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 64 | |
| 65 | Overview |
| 66 | ++++++++ |
| 67 | |
| 68 | The directory structure is currently: |
| 69 | |
| 70 | <oftest> |
| 71 | ` |
| 72 | |-- doc |
| 73 | |-- src |
| 74 | | `-- python |
| 75 | | `-- oftest |
| 76 | |-- tests |
Dan Talayco | 1ddefbf | 2010-03-07 21:56:47 -0800 | [diff] [blame] | 77 | | `-- oft and files with test cases |
Dan Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 78 | `-- 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 Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 96 | 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 Talayco | 60a8d7a | 2010-03-03 15:20:59 -0800 | [diff] [blame] | 101 | oft_assert.py: Test framework level assertion |
Dan Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 102 | |
Dan Talayco | 60a8d7a | 2010-03-03 15:20:59 -0800 | [diff] [blame] | 103 | 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 Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 105 | |
Dan Talayco | 1ddefbf | 2010-03-07 21:56:47 -0800 | [diff] [blame] | 106 | Important 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 | |
| 118 | Adding 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 Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 136 | |
| 137 | Other 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 | |
| 152 | To Do |
| 153 | +++++ |
| 154 | |
Dan Talayco | 60a8d7a | 2010-03-03 15:20:59 -0800 | [diff] [blame] | 155 | * 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 Talayco | f7dae84 | 2010-02-19 11:50:02 -0800 | [diff] [blame] | 157 | * 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 Talayco | c474796 | 2010-02-19 12:29:17 -0800 | [diff] [blame] | 161 | * Make the framework work with OF versions other than 1.0? |
| 162 | |