Skip to main content

Test harness for testing XDP programs.

Project description

XDP test harness

A test harness that can be used to test the implementation of XDP and XDP programs.

Requirements

Python 3.5, bcc, Pyroute2, Scapy

Usage

Running

To start the test harness, run python3 -m xdp_test_harness.runner in a folder containing tests as a superuser. There are three commands that can be used:

client

Start a client, running tests using network interfaces to process packets by XDP program. One can further specify which tests to run, using unittest's format. That is modules, classes and methods separated by dots, for example python3 -m xdp_test_harness.runner client test_general.ReturnValuesBasic.

bptr

Similar to the client command, but uses the BPF_PROG_TEST_RUN syscall command instead of a server to process packets by an XDP program.

server

Starts a server, used by client command to send packets.

Configuration

Configuration of interfaces to be used for testing is done in the config.py file. In the configuration file there are two variables:

local_server_ctx

A variable specifying the interface of the server, used for testing, and the interface of the server used for communication with a client.

local_server_ctx = ContextServer(
    ContextLocal("enp0s31f6"),
    ContextCommunication("192.168.0.106", 6555),
)

remote_server_ctxs

List of contexts specifying one physical testing interface and one virtual testing interface. Elements of the list are either ContextClient objects, for physical interfaces, or objects created by new_virtual_ctx function, for virtual interfaces.

remote_server_ctxs = ContextClientList([
    ContextClient(
        ContextLocal("enp0s31f6", xdp_mode=XDPFlag.SKB_MODE),
        ContextCommunication("192.168.0.107", 6555)
    ),
    new_virtual_ctx(
        ContextLocal("a_to_b", xdp_mode=XDPFlag.DRV_MODE),
        ContextCommunication("192.168.1.1"),
        "test_b",
        ContextLocal("b_to_a", xdp_mode=XDPFlag.DRV_MODE),
        ContextCommunication("192.168.1.2", 6000),
    ),
])

Creating new tests

To create a new test, create a class inheriting from XDPCase. This class should be located in a file named with a test_ prefix and placed in the tests folder. Each method of this class, that should be run while testing, has to be named with a test_ prefix.

Each test should either call both load_bpf and attach_xdp methods in this order, before calling send_packets, or be decorated with usingCustomLoader and attach own XDP program to the interface. After attaching attaching an XDP program, calling send_packets, returns a SendResult object, containing lists of packets that arrived to each interface engaged in testing.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xdp-test-harness-0.1.4.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xdp_test_harness-0.1.4-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

File details

Details for the file xdp-test-harness-0.1.4.tar.gz.

File metadata

  • Download URL: xdp-test-harness-0.1.4.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.9

File hashes

Hashes for xdp-test-harness-0.1.4.tar.gz
Algorithm Hash digest
SHA256 b32ce257679e806ac872563e60a5ba44ec69a88f920ad6041ad8163171b871e8
MD5 a3e14af12b843bb4b4ebfcb52aa83c6e
BLAKE2b-256 6eae351ced60cc62c0acf1eef593e6ca08d3ca8912f7c8a3a7206a878a110e48

See more details on using hashes here.

File details

Details for the file xdp_test_harness-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: xdp_test_harness-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 27.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.9

File hashes

Hashes for xdp_test_harness-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 697580c10ec5191a8471a9941ada4d9c9cd19909b9a5065213693ba664b346e8
MD5 83b5039a05cf955a80c7982d0de1e69a
BLAKE2b-256 4843fe72db9c35eda8e229ab117a803f3e23305c81a247bebd84fd81e8d7b6e5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page