passt/test
David Gibson c2f248588b test: Integration of old-style pane execution and new context execution
We're creating a system for tests to more reliably execute commands in
various contexts (e.g. host, guest, namespace).  That transition is going
to happen over a number of steps though, so in the meantime we need to deal
with both the old-style issuing of commands via typing into and screen
scraping tmux panels, and the new-style system for executing commands in
context.

Introduce some transitional helpers which will issue a command via context
if the requested context is initialized, but will otherwise fall back to
the old style tmux panel based method.  Re-implement the various test DSL
commands in terms of these new helpers.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2022-09-13 05:32:00 +02:00
..
build test: Split cppcheck and clang-tidy tests into different files 2022-08-20 19:07:12 +02:00
demo contrib, test: Rebase Podman patch, enable three-way merge on git am in demo 2022-08-01 12:45:05 +02:00
dhcp test: Only select a single interface or gateway in tests 2022-08-20 19:07:12 +02:00
distro test: Wait for systemd-resolved to be ready on Ubuntu 22.04 for s390x 2022-09-05 14:32:14 +02:00
env LICENSES: Add license text files, add missing notices, fix SPDX tags 2021-10-20 08:29:30 +02:00
icmp tests: Explicitly list test files in test/run, remove "onlyfor" support 2022-07-14 01:32:42 +02:00
lib test: Integration of old-style pane execution and new context execution 2022-09-13 05:32:00 +02:00
ndp test: Only select a single interface or gateway in tests 2022-08-20 19:07:12 +02:00
perf test: Rewrite test_iperf3 2022-09-07 11:01:22 +02:00
shutdown test: Use shutdown test for pasta 2022-08-20 19:07:12 +02:00
tcp test: Correctly match "background" with "wait" commands 2022-09-13 05:32:00 +02:00
two_guests Separately locate external interfaces for IPv4 and IPv6 2022-07-30 21:57:50 +02:00
udp test: Correctly match "background" with "wait" commands 2022-09-13 05:32:00 +02:00
.gitignore test: Ignore video processing temporary files 2022-08-20 19:07:12 +02:00
ci test: Add CI/demo scripts 2021-09-27 15:10:35 +02:00
find-arm64-firmware.sh tests: Search multiple places for aarch64 EDK2 bios image 2022-07-14 01:32:42 +02:00
Makefile tests: Prepare distro images during asset build phase 2022-07-14 01:36:02 +02:00
passt.mbuto tests: Use socat instead of netcat 2022-07-22 19:41:42 +02:00
prepare-distro-img.sh Makefile: Ugly hack to get a "plain" Markdown version of README 2022-08-20 19:07:12 +02:00
README.md test/README: Requirements for socket buffer sizes and hardware performance events 2022-09-02 17:06:46 +02:00
run test: Integration of old-style pane execution and new context execution 2022-09-13 05:32:00 +02:00
run_demo test: Add CI/demo scripts 2021-09-27 15:10:35 +02:00
valgrind.supp test, seccomp, Makefile: Switch to valgrind runs for passt functional tests 2022-03-29 15:35:38 +02:00

Scope

This directory contains test cases for passt and pasta and a simple POSIX shell-based framework to define them, and run them as a suite.

These tests can be run as part of a continuous integration workflow, and are also used to provide short usage demos, with video recording, for passt and pasta basic use cases.

Run

Dependencies

Packages

The tests require some package dependencies commonly available in Linux distributions. If some packages are not available, the test groups that need them will be selectively skipped.

This is a non-exhaustive list of packages that might not commonly be installed on a system, i.e. common utilities such as a shell are not included here.

Example for Debian, and possibly most Debian-based distributions:

build-essential git jq strace iperf3 qemu-system-x86 tmux sipcalc bc
clang-tidy cppcheck isc-dhcp-common psmisc linux-cpupower socat
netcat-openbsd fakeroot lz4 lm-sensors qemu-system-arm qemu-system-ppc
qemu-system-misc qemu-system-x86 valgrind

Other tools

Test measuring request-response and connect-request-response latencies use neper, which is not commonly packaged by distributions and needs to be built and installed manually:

git clone https://github.com/google/neper
cd neper; make
cp tcp_crr tcp_rr udp_rr /usr/local/bin

Virtual machine images are built during test executions using mbuto, the shell script is sourced via git as needed, so there's no need to actually install it.

Kernel parameters

Performance tests use iperf3 with rather large TCP receiving and sending windows, to decrease the likelihood of iperf3 itself becoming the bottleneck. These values need to be allowed by the kernel of the host running the tests. Example for /etc/sysctl.conf:

net.core.rmem_max = 134217728 net.core.wmem_max = 134217728

Further, the passt demo uses perf(1), relying on hardware events for performance counters, to display syscall overhead. The kernel needs to allow unprivileged users to access these events. Suggested entry for /etc/sysctl.conf:

kernel.perf_event_paranoid = -1

Special requirements for continuous integration and demo modes

Running the test suite as continuous integration or demo modes will record the terminal with the steps being executed, using asciinema(1), and create binary packages.

The following additional packages are commonly needed:

alien asciinema linux-perf tshark

Regular test

Just issue:

./run

from the test directory. Elevated privileges are not needed. Environment variable settings: DEBUG=1 enables debugging messages, TRACE=1 enables tracing (further debugging messages), PCAP=1 enables packet captures. Example:

PCAP=1 TRACE=1 ./run

Continuous integration

Issuing:

./ci

will run the whole test suite while recording the execution, and it will also build JavaScript fragments used on http://passt.top/ for performance data tables and links to specific offsets in the captures.

Demo mode

Issuing:

./demo

will run the demo cases under demo, with terminal captures as well.

Framework

The implementation of the testing framework is under lib, and it provides facilities for terminal and tmux session management, interpretation of test directives, video recording, and suchlike. Test cases are organised in the remaining directories.

Test cases can be implemented as POSIX shell scripts, or as a set of directives, which are not formally documented here, but should be clear enough from the existing cases. The entry point for interpretation of test directives is implemented in lib/test.