@@ -32,3 +32,105 @@ freebsd_build_task:
check_script:
- gmake -j8 check TESTSUITEFLAGS=-j8 RECHECK=yes
|| { cat ./tests/testsuite.log; exit 1; }
+
+# This tests both the upstream OVS Debian packaging recipe and executes all the
+# system testsuites on Ubuntu.
+ubuntu_autopkgtest_latest_task:
+
+ compute_engine_instance:
+ image_project: ubuntu-os-cloud
+ image: family/ubuntu-2304-amd64
+ platform: linux
+ cpu: 4
+ memory: 4G
+
+ env:
+ DEPENDENCIES: |
+ build-essential fakeroot dpkg-dev devscripts equivs autopkgtest autodep8
+ libbpf-dev libxdp-dev
+ DPDK: shared
+ matrix:
+ TEST_NAME: afxdp
+ TEST_NAME: dpdk
+ TEST_NAME: kmod
+ # Pending resolution of https://launchpad.net/bugs/2020677
+ # TEST_NAME: offloads
+ TEST_NAME: userspace
+
+ prepare_script: |
+ apt-get update
+ if [ "${DPDK}" = no ]; then
+ echo "Skipping DPDK dependency."
+ else
+ apt-get -y install libdpdk-dev
+ fi
+ apt-get --yes install linux-headers-$(uname -r) ${DEPENDENCIES}
+
+ configure_script: |
+ ./boot.sh
+ ./configure \
+ --prefix=/usr \
+ --localstatedir=/var \
+ --sysconfdir=/etc \
+ --with-dpdk=${DPDK}
+
+ build_script:
+ - make debian-source
+
+ check_script: |
+ if [ "${DPDK}" = "no" ]; then
+ deb_dpdk_build_opt="nodpdk"
+ else
+ deb_dpdk_build_opt=""
+ fi
+ autopkgtest \
+ --env DEB_BUILD_OPTIONS="nocheck parallel=8 ${deb_dpdk_build_opt}" \
+ --test-name $TEST_NAME \
+ *.dsc \
+ -- null
+
+ubuntu_autopkgtest_lts_task:
+
+ compute_engine_instance:
+ image_project: ubuntu-os-cloud
+ image: family/ubuntu-2204-lts
+ platform: linux
+ cpu: 4
+ memory: 4G
+
+ env:
+ DEPENDENCIES: |
+ build-essential fakeroot dpkg-dev devscripts equivs autopkgtest autodep8
+ DPDK: no
+ matrix:
+ TEST_NAME: kmod
+ # Pending resolution of https://launchpad.net/bugs/2020677
+ # TEST_NAME: offloads
+ TEST_NAME: userspace
+
+ prepare_script: |
+ apt-get update
+ apt-get --yes install linux-headers-$(uname -r) ${DEPENDENCIES}
+
+ configure_script: |
+ ./boot.sh
+ ./configure \
+ --prefix=/usr \
+ --localstatedir=/var \
+ --sysconfdir=/etc \
+ --with-dpdk=${DPDK}
+
+ build_script:
+ - make debian-source
+
+ check_script: |
+ if [ "${DPDK}" = "no" ]; then
+ deb_dpdk_build_opt="nodpdk"
+ else
+ deb_dpdk_build_opt=""
+ fi
+ autopkgtest \
+ --env DEB_BUILD_OPTIONS="nocheck parallel=8 ${deb_dpdk_build_opt}" \
+ --test-name $TEST_NAME \
+ *.dsc \
+ -- null
@@ -75,6 +75,7 @@ OvsDpInterface.h
testsuite.tmp.orig
/rpm/
/openvswitch*.tar.gz
+/openvswitch*.dsc
/tests/lcov/
/Documentation/_build
/.venv
@@ -85,17 +85,34 @@ You do not need to be the superuser to build the Debian packages.
$ ./boot.sh && ./configure --disable-afxdp && make debian
+ If you want to build a source package you need to set path arguments that
+ match the package recipe::
+
+ $ ./boot.sh && \
+ ./configure \
+ --prefix=/usr \
+ --localstatedir=/var \
+ --sysconfdir=/etc &&\
+ make debian-source
+
Check your work by running ``dpkg-checkbuilddeps`` in the top level of your OVS
directory. If you've installed all the dependencies properly,
``dpkg-checkbuilddeps`` will exit without printing anything. If you forgot to
install some dependencies, it will tell you which ones.
-5. Build the package::
+5. Build the package.
+
+ If you want binary packages execute the following command::
$ make debian-deb
-5. The generated .deb files will be in the parent directory of the Open vSwitch
- source distribution.
+ If you want a source package execute the following command::
+
+ $ make debian-source
+
+6. The generated binary .deb files will be in the parent directory of the
+ Open vSwitch source distribution. If you built a source package it will
+ be located in the top level Open vSwitch source directory.
Installing .deb Packages
------------------------
@@ -61,10 +61,13 @@ EXTRA_DIST += \
debian/rules \
debian/source/format \
debian/source/lintian-overrides \
+ debian/tests/afxdp \
debian/tests/control \
debian/tests/dpdk \
- debian/tests/openflow.py \
- debian/tests/vanilla \
+ debian/tests/kmod \
+ debian/tests/offloads \
+ debian/tests/run-tests.sh \
+ debian/tests/userspace \
debian/watch
check-debian-changelog-version:
@@ -131,7 +134,6 @@ CLEANFILES += debian/control
debian: debian/copyright debian/control
.PHONY: debian
-
debian-deb: debian
@if test X"$(srcdir)" != X"$(top_builddir)"; then \
echo "Debian packages should be built from $(abs_srcdir)/"; \
@@ -147,3 +149,28 @@ debian-deb: debian
$(AM_V_GEN) fakeroot debian/rules clean
$(AM_V_GEN) DEB_BUILD_OPTIONS="$(DEB_BUILD_OPTIONS)" \
fakeroot debian/rules binary
+
+debian-source: debian
+ @if test X"$(srcdir)" != X"$(top_builddir)"; then \
+ echo "Debian packages should be built from $(abs_srcdir)/"; \
+ exit 1; \
+ fi
+ cp $(srcdir)/debian/control.in $(srcdir)/debian/control
+ $(update_deb_copyright)
+ ## Order is significant here as we are modifying the file in-place and
+ ## a DPDK enabled binary may support both DPDK and AFXDP.
+ $(update_deb_control_dpdk)
+ $(update_deb_control_afxdp)
+ $(AM_V_GEN) $(MAKE) distdir
+ cp $(srcdir)/debian/control $(srcdir)/debian/copyright \
+ $(distdir)/debian/
+ $(AM_V_GEN) tardir=$(distdir) && $(am__tar) | \
+ eval GZIP= gzip $(GZIP_ENV) \
+ -c >$(PACKAGE_NAME)_$(PACKAGE_VERSION).orig.tar.gz
+ cd $(distdir); \
+ $(AM_V_GEN) dpkg-source --compression=gzip -b .
+ $(am__post_remove_distdir)
+
+DISTCLEANFILES += $(PACKAGE_NAME)_$(PACKAGE_VERSION)-1.debian.tar.gz \
+ $(PACKAGE_NAME)_$(PACKAGE_VERSION).orig.tar.gz \
+ $(PACKAGE_NAME)_$(PACKAGE_VERSION)-1.dsc
@@ -95,6 +95,11 @@ endif
execute_before_dh_auto_clean:
find . -name "*.pyc" -delete
+ test -f debian/control && cp debian/control debian/control.save.$(PPID)
+
+execute_after_dh_auto_clean:
+ test -f debian/control.save.$(PPID) && \
+ mv debian/control.save.$(PPID) debian/control
override_dh_auto_install:
dh_auto_install --sourcedirectory=_debian
new file mode 120000
@@ -0,0 +1 @@
+run-tests.sh
\ No newline at end of file
@@ -1,8 +1,35 @@
-Tests: vanilla dpdk
+Tests: afxdp, kmod, offloads, userspace
Depends:
- iperf,
- mininet (>= 2.2.0~),
- openvswitch-switch,
- openvswitch-switch-dpdk [amd64 i386],
- openvswitch-testcontroller,
-Restrictions: needs-root rw-build-tree isolation-machine
+ @,
+ devscripts,
+ equivs,
+ conntrack,
+ net-tools,
+ netcat-openbsd,
+ python3-pyftpdlib,
+ tcpdump,
+Restrictions:
+ allow-stderr,
+ isolation-machine,
+ needs-root,
+ rw-build-tree,
+
+# The dpdk tests are marked `skippable`, because they have environment specific
+# requirements which may or may not be available at runtime (hugepages setup).
+Tests: dpdk
+Depends:
+ @,
+ conntrack,
+ devscripts,
+ dpdk-dev [amd64 i386 ppc64el arm64 riscv64],
+ equivs,
+ net-tools,
+ netcat-openbsd,
+ python3-pyftpdlib,
+ tcpdump,
+Restrictions:
+ allow-stderr,
+ isolation-machine,
+ needs-root,
+ rw-build-tree,
+ skippable,
deleted file mode 100755
@@ -1,45 +0,0 @@
-#!/bin/sh
-
-set -e
-
-if [ ! -x /usr/lib/openvswitch-switch-dpdk/ovs-vswitchd-dpdk ]; then
- echo "DPDK enabled binary not detected - skipping"
- exit 0
-fi
-
-sse3flag=$(sed -n "/^flags.*sse3/p" < /proc/cpuinfo | wc -l)
-if [ "${sse3flag}" -eq 0 ]; then
- echo "sse3 not available in test environment"
- echo "for adt-virt-qemu please consider adding --qemu-options='-cpu qemu64,+ssse3'"
- echo "SKIPPING"
- exit 0
-fi
-
-update-alternatives --set ovs-vswitchd \
- /usr/lib/openvswitch-switch-dpdk/ovs-vswitchd-dpdk
-service openvswitch-switch restart
-
-modprobe openvswitch || true
-
-echo "kernel modules loaded: "
-# Check that ovs loaded
-lsmod | grep "openvswitch"
-echo "OK"
-
-echo "Checking daemons: "
-pgrep ovs-vswitchd
-pgrep ovsdb-server
-echo "OK"
-
-echo "stop conflicting openvswitch testcontroller"
-systemctl stop openvswitch-testcontroller || true
-
-if dpkg --compare-versions "$(dpkg-query --showformat '${Version}\n' --show mininet)" ge "2.3.0-1"; then
- PYCMD="python3"
-else
- PYCMD="python2"
-fi
-
-printf "running openflow tests using mininet"
-${PYCMD} `dirname $0`/openflow.py 2>&1
-echo "OK"
new file mode 120000
@@ -0,0 +1 @@
+run-tests.sh
\ No newline at end of file
new file mode 120000
@@ -0,0 +1 @@
+run-tests.sh
\ No newline at end of file
new file mode 120000
@@ -0,0 +1 @@
+run-tests.sh
\ No newline at end of file
deleted file mode 100755
@@ -1,66 +0,0 @@
-import unittest
-import logging
-from mininet.net import Mininet
-import mininet.log as log
-from mininet.node import OVSController, OVSKernelSwitch
-
-Switch = OVSKernelSwitch
-Controller = OVSController
-logging.basicConfig(level=logging.DEBUG)
-log.setLogLevel('info')
-
-
-class BasicOpenflowTest(unittest.TestCase):
-
- def addHost(self, N):
- logging.debug("Creating host h%s and add to net.", N)
- name = 'h%d' % N
- ip = '10.0.0.%d' % N
- return self.net.addHost(name, ip=ip)
-
- def setUp(self):
- self.net = Mininet(controller=Controller, switch=Switch)
-
- logging.info("Creating controllers")
- self.net.addController('c1', command='ovs-testcontroller')
-
- logging.info("Creating switches")
- s1 = self.net.addSwitch('s1', protocols="OpenFlow10")
- s2 = self.net.addSwitch('s2', protocols="OpenFlow10")
-
- logging.info("Creating hosts (7 on each switch)")
- hosts1 = [self.addHost(n) for n in (1, 2, 3, 4, 5, 6, 7)]
- hosts2 = [self.addHost(n) for n in (8, 9, 10, 11, 12, 13, 14)]
-
- logging.info("Creating links")
- for h in hosts1:
- self.net.addLink(s1, h)
- for h in hosts2:
- self.net.addLink(s2, h)
- self.net.addLink(s1, s2)
-
- logging.info("Starting network")
- self.net.start()
-
- def testPingAll(self):
- logging.info("Testing network")
- packetLoss = self.net.pingAll()
- self.assertTrue(
- packetLoss == 0,
- "Packet loss during ping test %s" %
- packetLoss)
-
- def testIPerfTCP(self):
- logging.info("Running TCP performance test")
- self.net.iperf()
-
- def testIPerfUDP(self):
- logging.info("Running UDP performance test")
- self.net.iperf(l4Type='UDP')
-
- def tearDown(self):
- logging.info("Stopping network")
- self.net.stop()
-
-if __name__ == '__main__':
- unittest.main()
new file mode 100755
@@ -0,0 +1,183 @@
+#!/bin/bash
+
+set -ex
+
+PROGRAM=`basename $0`
+TARGET=${PROGRAM}
+
+# The autopkgtests are run in throwaway environments, let's be good citizens
+# regardless, and attempt to clean up any environment modifications.
+function cleanup {
+ rc=$?
+
+ set +e
+
+ # Dump the log to console on error
+ if [ $rc -ne 0 ]; then
+ for logfile in $(ls -1 _debian/tests/system-*-testsuite.log); do
+ printf "%s:\n" $(basename $logfile)
+ cat $logfile
+ done
+ fi
+
+ # The DPDK test requires post-test cleanup steps.
+ if [ "$PROGRAM" = "dpdk" ]; then
+ mv /etc/dpdk/dpdk.conf.bak /etc/dpdk/dpdk.conf
+ systemctl restart dpdk
+
+ update-alternatives \
+ --set ovs-vswitchd \
+ /usr/lib/openvswitch-switch/ovs-vswitchd
+
+ if dirs +1 > /dev/null 2>&1; then
+ popd
+ umount ${BIND_MOUNT_DIR}
+ rmdir ${BIND_MOUNT_DIR}
+ fi
+ fi
+
+ exit $rc
+}
+trap cleanup EXIT
+
+# The DPDK test requires preparing steps.
+if [ "$PROGRAM" = "dpdk" ]; then
+ if [ ! -x /usr/lib/openvswitch-switch-dpdk/ovs-vswitchd-dpdk ]; then
+ echo "DPDK enabled binary not detected, SKIP test"
+ exit 77
+ fi
+ ARCH=$(dpkg --print-architecture)
+ echo "Check required features on arch: ${ARCH}"
+ case "${ARCH}" in
+ amd64)
+ # For amd64 the OVS DPDK support works with ssse3
+ # https://github.com/openvswitch/ovs/blob/8045c0f8de5192355ca438ed7eef77457c3c1625/acinclude.m4#LL441C52-L441C52
+ if ! grep -q '^flags.*sse3' /proc/cpuinfo; then
+ echo "Missing ssse3 on ${ARCH} - not supported, SKIP test"
+ exit 77
+ fi
+ ;;
+ arm64)
+ if ! grep -q '^Features.*crc32' /proc/cpuinfo; then
+ echo "Missing crc32 on ${ARCH} - not supported, SKIP test"
+ exit 77
+ fi
+ ;;
+ esac
+ echo "no known missing feature on ${ARCH}, continue test"
+
+ # Allocate hugepages, use 2M pages when possible because of higher
+ # probability of successful allocation at runtime and smaller test
+ # footprint in CI virtual machines.
+ #
+ # If the tests are to be run on real physical hardware, you may need
+ # to adjust these variables depending on CPU architecture and topology.
+ numa_node=$(lscpu | awk '/NUMA node\(s\)/{print$3}')
+ if [ -z "$numa_node" -o "$numa_node" -eq 0 ]; then
+ numa_node=1
+ fi
+ DPDK_NR_1G_PAGES=${DPDK_NR_1G_PAGES:-0}
+ DPDK_NR_2M_PAGES=${DPDK_NR_2M_PAGES:-$((${numa_node} * (2667 + 512) / 2))}
+
+ printf "Determine hugepage allocation for %s NUMA Node(s) on arch: %s\n" \
+ ${numa_node} ${ARCH}
+ echo "DPDK_NR_2M_PAGES=${DPDK_NR_2M_PAGES}"
+ echo "DPDK_NR_1G_PAGES=${DPDK_NR_1G_PAGES}"
+
+ mv /etc/dpdk/dpdk.conf /etc/dpdk/dpdk.conf.bak
+ cat << EOF > /etc/dpdk/dpdk.conf
+NR_1G_PAGES=${DPDK_NR_1G_PAGES}
+NR_2M_PAGES=${DPDK_NR_2M_PAGES}
+DROPCACHE_BEFORE_HP_ALLOC=1
+EOF
+ systemctl restart dpdk
+ realhp_2m=$(cat /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages)
+ realhp_1g=$(cat /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages)
+ if [ "$realhp_2m" != "$DPDK_NR_2M_PAGES" -o \
+ "$realhp_1g" != "$DPDK_NR_1G_PAGES" ]; then
+ echo "Unable to allocate huge pages required for the test, SKIP test"
+ exit 77
+ fi
+
+ # Point `ovs-vswitchd` at the DPDK enabled binary.
+ update-alternatives \
+ --set ovs-vswitchd \
+ /usr/lib/openvswitch-switch-dpdk/ovs-vswitchd-dpdk
+
+ # Long log messages from DPDK library overflow and is written as multiple
+ # lines. This does not play well with the OVS testsuite assertions. Even
+ # a tmp directory in /tmp will make the paths too long.
+ #
+ # Realpaths from build will be embedded in testsuite artifacts, so we do
+ # this before the build, and use a bind mount to avoid copying data around
+ # (using a symlink would not be sufficient).
+ #
+ # Ensure we use a short path for running the testsuite (LP:# 2019069).
+ BIND_MOUNT_DIR=$(mktemp -d /XXX)
+ mount --bind . ${BIND_MOUNT_DIR}
+ pushd ${BIND_MOUNT_DIR}
+fi
+
+# A built source tree is required in order to make use of the system level
+# testsuites. Autopkgtest may be run against both already built and source
+# packages, so we perform this step in either case to ensure the required
+# artifacts are available.
+#
+# We build it here instead of using the `build-needed` Restriction field,
+# because we need to pass in additional environment variables in order to
+# avoid running the build time checks yet another time (they would have just
+# run as part of the package under test build process anyway).
+mk-build-deps \
+ --install \
+ --tool "apt-get -o Debug::pkgProblemResolver=yes \
+ --no-install-recommends --yes" \
+ --remove \
+ debian/control
+
+export DEB_BUILD_OPTIONS="nocheck $DEB_BUILD_OPTIONS"
+debian/rules build
+
+apt-get --yes autoremove openvswitch-build-deps
+
+# Ensure none of the Open vSwitch daemons are running.
+systemctl stop \
+ openvswitch-ipsec \
+ openvswitch-testcontroller \
+ ovs-vswitchd \
+ ovsdb-server
+
+# List of tests to run, an empty list means run all tests.
+TEST_LIST=""
+
+# Run the testsuite.
+#
+# By not having paths from build directory in AUTOTEST_PATH, apart from
+# `tests`, will ensure binaries are executed from system PATH, i.e. from the
+# binary package under test, and not the built source tree.
+#
+# Note that the built testsuite artifacts are put under tests/ in the top level
+# source directory regardless of the use of `make -C ...` in the package
+# source. The testsuite's configuration (atlocal) is however placed in
+# relation to the value of `-C`.
+#
+# We also cannot use `make` to invoke the testsuite, as we have removed the
+# build dependencies, and `make` will notice the missing sytem headers.
+#
+# The sum of this leads to the invocation method below.
+case "${TARGET}" in
+ dpdk)
+ # Check that the conditional build of debian/control works properly by
+ # including both DPDK and AFXDP tests for the DPDK enabled package.
+ testsuites="afxdp ${TARGET}"
+ ;;
+ *)
+ testsuites=${TARGET}
+ ;;
+esac
+for testsuite in ${testsuites}; do
+ set /bin/bash tests/system-${testsuite}-testsuite \
+ -C _debian/tests \
+ -j1 \
+ AUTOTEST_PATH=$(realpath ./tests):$(realpath ./_debian/tests)
+ $@ ${TEST_LIST} || $@ --recheck
+done
new file mode 120000
@@ -0,0 +1 @@
+run-tests.sh
\ No newline at end of file
deleted file mode 100755
@@ -1,29 +0,0 @@
-#!/bin/sh
-
-set -e
-
-echo "Checking service status right after install: "
-# for transparency we want to see all status and then fail if one is inactive
-systemctl status ovsdb-server.service || true
-systemctl status ovs-vswitchd.service || true
-systemctl status openvswitch-switch.service || true
-systemctl is-active ovs-vswitchd.service ovsdb-server.service openvswitch-switch.service
-echo "OK"
-
-echo "Checking daemon pids to exist: "
-pgrep ovs-vswitchd
-pgrep ovsdb-server
-echo "OK"
-
-echo "stop conflicting openvswitch testcontroller"
-systemctl stop openvswitch-testcontroller || true
-
-if dpkg --compare-versions "$(dpkg-query --showformat '${Version}\n' --show mininet)" ge "2.3.0-1"; then
- PYCMD="python3"
-else
- PYCMD="python2"
-fi
-
-printf "running openflow tests using mininet"
-${PYCMD} `dirname $0`/openflow.py 2>&1
-echo "OK"
The autopkgtests [0][1] are relevant in an upstream context because an Open vSwitch contributor may want to have a quick way of running the upstream system testsuites on recent Debian/Ubuntu releases in an automated and contained manner. During the Debian/Ubuntu/upstream package source sync work [2], a relatively naive autopkgtest was added. It had been around since Open vSwitch was initially packaged many years ago. Replace the autopkgtest with a test that runs all the upstream system testsuites instead. To run the autopkgtest, take a look at [1] for prerequisites then: ./boot.sh && \ ./configure \ --prefix=/usr \ --localstatedir=/var \ --sysconfdir=/etc \ --with-dpdk=shared && \ make debian-source autopkgtest \ --env DEB_BUILD_OPTIONS="nocheck parallel=32" \ openvswitch_3.1.90-1.dsc \ -- qemu \ --cpus 32 \ --ram-size 8129 \ autopkgtest-mantic-amd64.img This patch also adds Cirrus CI jobs that run these tests. 0: https://wiki.debian.org/ContinuousIntegration/autopkgtest 1: https://packaging.ubuntu.com/html/auto-pkg-test.html 2: https://mail.openvswitch.org/pipermail/ovs-dev/2022-July/396219.html Signed-off-by: Frode Nordahl <frode.nordahl@canonical.com> --- .cirrus.yml | 102 ++++++++++++++ .gitignore | 1 + Documentation/intro/install/debian.rst | 23 +++- debian/automake.mk | 33 ++++- debian/rules | 5 + debian/tests/afxdp | 1 + debian/tests/control | 41 +++++- debian/tests/dpdk | 46 +------ debian/tests/kmod | 1 + debian/tests/offloads | 1 + debian/tests/openflow.py | 66 --------- debian/tests/run-tests.sh | 183 +++++++++++++++++++++++++ debian/tests/userspace | 1 + debian/tests/vanilla | 29 ---- 14 files changed, 380 insertions(+), 153 deletions(-) create mode 120000 debian/tests/afxdp mode change 100755 => 120000 debian/tests/dpdk create mode 120000 debian/tests/kmod create mode 120000 debian/tests/offloads delete mode 100755 debian/tests/openflow.py create mode 100755 debian/tests/run-tests.sh create mode 120000 debian/tests/userspace delete mode 100755 debian/tests/vanilla