On Tue, Jun 20, 2023 at 10:08 AM Frode Nordahl
<[email protected]> wrote:
>
> 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="afxdp nocheck parallel=32" \
>         openvswitch_3.1.90-1.dsc \
>         -- qemu \
>             --cpus 32 \
>             --ram-size 8129 \
>             autopkgtest-mantic-amd64.img
>
> 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 <[email protected]>

Reworked this a bit since v1 and also removed the skip lists, as that
is a downstream thing.

Result of a complete run of the tests can be viewed here:
https://gist.githubusercontent.com/fnordahl/8c08b6857ef85d27d6e055d7cce25dca/raw/85b0f70d5347a5a4060b815f689ee60aab2ffe2a/output.txt

There is a failing test in the offloads suite, but that is most likely a
real up- or down-stream issue, and not an issue with this patch.

-- 
Frode Nordahl

> ---
>  .gitignore                    |   1 +
>  debian/automake.mk            |  31 ++++++-
>  debian/rules                  |   5 ++
>  debian/tests/afxdp            |   1 +
>  debian/tests/control          |  38 ++++++--
>  debian/tests/dpdk             |  46 +---------
>  debian/tests/kernel           |   1 +
>  debian/tests/offloads         |   1 +
>  debian/tests/openflow.py      |  66 --------------
>  debian/tests/run-tests.sh     | 160 ++++++++++++++++++++++++++++++++++
>  debian/tests/system-userspace |   1 +
>  debian/tests/vanilla          |  29 ------
>  12 files changed, 230 insertions(+), 150 deletions(-)
>  create mode 120000 debian/tests/afxdp
>  mode change 100755 => 120000 debian/tests/dpdk
>  create mode 120000 debian/tests/kernel
>  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/system-userspace
>  delete mode 100755 debian/tests/vanilla
>
> diff --git a/.gitignore b/.gitignore
> index 26ed8d3d0..3d4f17b8a 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -75,6 +75,7 @@ OvsDpInterface.h
>  testsuite.tmp.orig
>  /rpm/
>  /openvswitch*.tar.gz
> +/openvswitch*.dsc
>  /tests/lcov/
>  /Documentation/_build
>  /.venv
> diff --git a/debian/automake.mk b/debian/automake.mk
> index 3195964c9..3e0a38edd 100644
> --- a/debian/automake.mk
> +++ b/debian/automake.mk
> @@ -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/kernel \
> +       debian/tests/offloads \
> +       debian/tests/run-tests.sh \
> +       debian/tests/system-userspace \
>         debian/watch
>
>  check-debian-changelog-version:
> @@ -125,7 +128,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)/";   
>   \
> @@ -144,3 +146,26 @@ else
>         $(AM_V_GEN) DEB_BUILD_OPTIONS="nocheck parallel=`nproc` nodpdk" \
>                 fakeroot debian/rules binary
>  endif
> +
> +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)
> +       $(update_deb_control_afxdp)
> +       $(update_deb_control_dpdk)
> +       $(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
> diff --git a/debian/rules b/debian/rules
> index 8ed19db70..aa80737ad 100755
> --- a/debian/rules
> +++ b/debian/rules
> @@ -97,6 +97,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
> diff --git a/debian/tests/afxdp b/debian/tests/afxdp
> new file mode 120000
> index 000000000..7080a3249
> --- /dev/null
> +++ b/debian/tests/afxdp
> @@ -0,0 +1 @@
> +run-tests.sh
> \ No newline at end of file
> diff --git a/debian/tests/control b/debian/tests/control
> index b481ed53c..29a65fb12 100644
> --- a/debian/tests/control
> +++ b/debian/tests/control
> @@ -1,8 +1,32 @@
> -Tests: vanilla dpdk
> +Tests: afxdp, kernel, offloads, system-userspace
>  Depends:
> - iperf,
> - mininet (>= 2.2.0~),
> - openvswitch-switch,
> - openvswitch-switch-dpdk [amd64 i386],
> - openvswitch-testcontroller,
> -Restrictions: needs-root rw-build-tree isolation-machine
> + @,
> + @builddeps@,
> + conntrack,
> + net-tools,
> + netcat-openbsd,
> + tcpdump,
> + python3-pyftpdlib,
> +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:
> + @,
> + @builddeps@,
> + conntrack,
> + dpdk-dev [amd64 i386 ppc64el arm64 riscv64],
> + net-tools,
> + netcat-openbsd,
> + tcpdump,
> + python3-pyftpdlib,
> +Restrictions:
> + allow-stderr,
> + isolation-machine,
> + needs-root,
> + skippable,
> diff --git a/debian/tests/dpdk b/debian/tests/dpdk
> deleted file mode 100755
> index 2aabae050..000000000
> --- a/debian/tests/dpdk
> +++ /dev/null
> @@ -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"
> diff --git a/debian/tests/dpdk b/debian/tests/dpdk
> new file mode 120000
> index 000000000..7080a3249
> --- /dev/null
> +++ b/debian/tests/dpdk
> @@ -0,0 +1 @@
> +run-tests.sh
> \ No newline at end of file
> diff --git a/debian/tests/kernel b/debian/tests/kernel
> new file mode 120000
> index 000000000..7080a3249
> --- /dev/null
> +++ b/debian/tests/kernel
> @@ -0,0 +1 @@
> +run-tests.sh
> \ No newline at end of file
> diff --git a/debian/tests/offloads b/debian/tests/offloads
> new file mode 120000
> index 000000000..7080a3249
> --- /dev/null
> +++ b/debian/tests/offloads
> @@ -0,0 +1 @@
> +run-tests.sh
> \ No newline at end of file
> diff --git a/debian/tests/openflow.py b/debian/tests/openflow.py
> deleted file mode 100755
> index 216b57cf4..000000000
> --- a/debian/tests/openflow.py
> +++ /dev/null
> @@ -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()
> diff --git a/debian/tests/run-tests.sh b/debian/tests/run-tests.sh
> new file mode 100755
> index 000000000..356e1a77f
> --- /dev/null
> +++ b/debian/tests/run-tests.sh
> @@ -0,0 +1,160 @@
> +#!/bin/bash
> +
> +set -ex
> +
> +PROGRAM=`basename $0`
> +TARGET=check-${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
> +        case "${PROGRAM}" in
> +            kernel)
> +                # For historical reasons the log for the system kernel
> +                # datapath testsuite has a deviant name.
> +                logname="kmod"
> +            ;;
> +            *)
> +                logname="${PROGRAM}"
> +            ;;
> +        esac
> +        if [ -f _debian/tests/system-${logname}-testsuite.log ]; then
> +            cat _debian/tests/system-${logname}-testsuite.log
> +        fi
> +    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.
> +#
> +# 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).
> +export DEB_BUILD_OPTIONS="nocheck $DEB_BUILD_OPTIONS"
> +debian/rules build
> +
> +# 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.
> +make \
> +    -C _debian \
> +    ${TARGET} \
> +    AUTOTEST_PATH=tests \
> +    TESTSUITEFLAGS="-j1 ${TEST_LIST}" \
> +    RECHECK=yes
> diff --git a/debian/tests/system-userspace b/debian/tests/system-userspace
> new file mode 120000
> index 000000000..7080a3249
> --- /dev/null
> +++ b/debian/tests/system-userspace
> @@ -0,0 +1 @@
> +run-tests.sh
> \ No newline at end of file
> diff --git a/debian/tests/vanilla b/debian/tests/vanilla
> deleted file mode 100755
> index 80304f4df..000000000
> --- a/debian/tests/vanilla
> +++ /dev/null
> @@ -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"
> --
> 2.40.1
>
> _______________________________________________
> dev mailing list
> [email protected]
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to