Home | History | Annotate | Download | only in tc-testing
      1 tdc - Linux Traffic Control (tc) unit testing suite
      2 
      3 Author: Lucas Bates - lucasb (a] mojatatu.com
      4 
      5 tdc is a Python script to load tc unit tests from a separate JSON file and
      6 execute them inside a network namespace dedicated to the task.
      7 
      8 
      9 REQUIREMENTS
     10 ------------
     11 
     12 *  Minimum Python version of 3.4. Earlier 3.X versions may work but are not
     13    guaranteed.
     14 
     15 *  The kernel must have network namespace support
     16 
     17 *   The kernel must have veth support available, as a veth pair is created
     18    prior to running the tests.
     19 
     20 *  All tc-related features must be built in or available as modules.
     21    To check what is required in current setup run:
     22    ./tdc.py -c
     23 
     24    Note:
     25    In the current release, tdc run will abort due to a failure in setup or
     26    teardown commands - which includes not being able to run a test simply
     27    because the kernel did not support a specific feature. (This will be
     28    handled in a future version - the current workaround is to run the tests
     29    on specific test categories that your kernel supports)
     30 
     31 
     32 BEFORE YOU RUN
     33 --------------
     34 
     35 The path to the tc executable that will be most commonly tested can be defined
     36 in the tdc_config.py file. Find the 'TC' entry in the NAMES dictionary and
     37 define the path.
     38 
     39 If you need to test a different tc executable on the fly, you can do so by
     40 using the -p option when running tdc:
     41 	./tdc.py -p /path/to/tc
     42 
     43 
     44 RUNNING TDC
     45 -----------
     46 
     47 To use tdc, root privileges are required. tdc will not run otherwise.
     48 
     49 All tests are executed inside a network namespace to prevent conflicts
     50 within the host.
     51 
     52 Running tdc without any arguments will run all tests. Refer to the section
     53 on command line arguments for more information, or run:
     54 	./tdc.py -h
     55 
     56 tdc will list the test names as they are being run, and print a summary in
     57 TAP (Test Anything Protocol) format when they are done. If tests fail,
     58 output captured from the failing test will be printed immediately following
     59 the failed test in the TAP output.
     60 
     61 
     62 USER-DEFINED CONSTANTS
     63 ----------------------
     64 
     65 The tdc_config.py file contains multiple values that can be altered to suit
     66 your needs. Any value in the NAMES dictionary can be altered without affecting
     67 the tests to be run. These values are used in the tc commands that will be
     68 executed as part of the test. More will be added as test cases require.
     69 
     70 Example:
     71 	$TC qdisc add dev $DEV1 ingress
     72 
     73 
     74 COMMAND LINE ARGUMENTS
     75 ----------------------
     76 
     77 Run tdc.py -h to see the full list of available arguments.
     78 
     79 -p PATH           Specify the tc executable located at PATH to be used on this
     80                   test run
     81 -c                Show the available test case categories in this test file
     82 -c CATEGORY       Run only tests that belong to CATEGORY
     83 -f FILE           Read test cases from the JSON file named FILE
     84 -l [CATEGORY]     List all test cases in the JSON file. If CATEGORY is
     85                   specified, list test cases matching that category.
     86 -s ID             Show the test case matching ID
     87 -e ID             Execute the test case identified by ID
     88 -i                Generate unique ID numbers for test cases with no existing
     89                   ID number
     90 
     91 
     92 ACKNOWLEDGEMENTS
     93 ----------------
     94 
     95 Thanks to:
     96 
     97 Jamal Hadi Salim, for providing valuable test cases
     98 Keara Leibovitz, who wrote the CLI test driver that I used as a base for the
     99    first version of the tc testing suite. This work was presented at
    100    Netdev 1.2 Tokyo in October 2016.
    101 Samir Hussain, for providing help while I dove into Python for the first time
    102     and being a second eye for this code.
    103