Package: ifupdown Version: 0.8.10 Severity: wishlist Tags: patch Hello,
The attached git-formatted patch adds an autopkgtest to ifupdown to provide integration testing for "allow-hotplug" interfaces. We used to have that in systemd, but as all the logic and units are in ifupdown now, it makes more sense to have the test there too. Feel free to extend them for more scenarios, of course. :-) I didn't commit myself, as I'm never sure when to add debian/changelog or not. Do you use git-dch or something similar? (I'm not familiar with that, I usually edit debian/changelog in the actual commits and use debcommit -ae). Thanks for considering, Martin -- Martin Pitt | http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)
From d8cdea572797a571266d9815ab237e366d2e4e85 Mon Sep 17 00:00:00 2001 From: Martin Pitt <[email protected]> Date: Wed, 10 Feb 2016 09:10:32 +0100 Subject: [PATCH] Add autopkgtest for "allow-hotplug" interfaces Add an integration test to check that hotplugging an "allow-hotplug" interface correctly brings this up. If running under systemd, check the [email protected] instance as well. --- debian/tests/control | 5 +++++ debian/tests/hotplug | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 debian/tests/control create mode 100755 debian/tests/hotplug diff --git a/debian/tests/control b/debian/tests/control new file mode 100644 index 0000000..7b3f584 --- /dev/null +++ b/debian/tests/control @@ -0,0 +1,5 @@ +Tests: hotplug +Depends: ifupdown +# requires udev, thus does not work in containers +Restrictions: needs-root, isolation-machine + diff --git a/debian/tests/hotplug b/debian/tests/hotplug new file mode 100755 index 0000000..93993fb --- /dev/null +++ b/debian/tests/hotplug @@ -0,0 +1,60 @@ +#!/bin/sh +# check behaviour of "allow-hotplug" interface +set -e + +IFACE=sdtest42 + +if [ -e /sys/class/net/$IFACE ]; then + echo "SKIP: network interface $IFACE already exists" + exit 0 +fi + +# different kinds of installs/images have different conventions; e. g. +# cloud-init sources *.cfg, a Debian desktop sources only prefix-less files +if grep -q 'source-directory .*interfaces.d' /etc/network/interfaces; then + IFACE_CFG=/etc/network/interfaces.d/${IFACE} +elif grep -q 'source .*interfaces.d.*cfg' /etc/network/interfaces; then + IFACE_CFG=/etc/network/interfaces.d/${IFACE}.cfg +else + echo "SKIP: /etc/network/interfaces does not include interfaces.d/" + exit 0 +fi + +cat <<EOF > $IFACE_CFG +allow-hotplug $IFACE +iface $IFACE inet static + address 192.168.234.129 + netmask 255.255.255.0 +EOF + +# these should trigger uevents and [email protected] +ip link add name $IFACE type veth peer name v$IFACE +trap "ip link del dev $IFACE; rm $IFACE_CFG" EXIT INT QUIT PIPE + +sleep 3 + +# $IFACE is configured in ifupdown, should succeed and be up +ifquery --state $IFACE +if [ -d /run/systemd/system ]; then + systemctl status -l ifup@${IFACE}.service +fi + +OUT=$(ip a show dev $IFACE) +if ! echo "$OUT" | grep -q 'inet 192.168.234.129/24'; then + echo "interface $IFACE not configured" >&2 + echo "$OUT" >&2 + exit 1 +fi + +# v$IFACE is not configured in ifupdown, should be down +! ifquery --state v$IFACE +if [ -d /run/systemd/system ]; then + ! systemctl status -l ifup@v${IFACE}.service +fi + +OUT=$(ip a show dev v$IFACE) +if echo "$OUT" | grep -q 'inet'; then + echo "interface $IFACE unexpectedly configured" >&2 + echo "$OUT" >&2 + exit 1 +fi -- 2.7.0
signature.asc
Description: Digital signature

