Merge ~rbalint/ubuntu/+source/systemd:tests-in-lxd into ~ubuntu-core-dev/ubuntu/+source/systemd:ubuntu-groovy

Proposed by Balint Reczey
Status: Merged
Merge reported by: Balint Reczey
Merged at revision: adcd2657f1dbf848fc8a1ed711553ba45a24fd8d
Proposed branch: ~rbalint/ubuntu/+source/systemd:tests-in-lxd
Merge into: ~ubuntu-core-dev/ubuntu/+source/systemd:ubuntu-groovy
Diff against target: 135 lines (+93/-0)
5 files modified
debian/patches/series (+1/-0)
debian/patches/test-Skip-test-boot-timestamps-on-permission-denied.patch (+41/-0)
debian/tests/control (+9/-0)
debian/tests/root-unittests (+2/-0)
debian/tests/tests-in-lxd (+40/-0)
Reviewer Review Type Date Requested Status
Dan Streetman Approve
Dimitri John Ledkov Pending
Review via email: mp+383501@code.launchpad.net

Description of the change

New upstream releases keep breaking tests (and functionality) in LXD containers, this test helps detecting such breakages earlier.
I'd like to make the test part of the upstream test-suite later, when it supports locally built binary packages.

To post a comment you must log in.
Revision history for this message
Balint Reczey (rbalint) wrote :

There is one more unittest failing, i need to patch that, too, before this can be merged.

Revision history for this message
Balint Reczey (rbalint) wrote :

OK, now this passes locally in lxd.

Revision history for this message
Dan Streetman (ddstreet) wrote :

LGTM with just minor comments inline below.

Revision history for this message
Dan Streetman (ddstreet) :
review: Approve
Revision history for this message
Balint Reczey (rbalint) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/debian/patches/series b/debian/patches/series
index 48bcae4..8b267f5 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -59,3 +59,4 @@ Revert-network-if-sys-is-rw-then-udev-should-be-around.patch
59riscv64-seccomp.patch59riscv64-seccomp.patch
60dhcp-Allow-setting-request-options-again.patch60dhcp-Allow-setting-request-options-again.patch
61lp1860926-network-Change-IgnoreCarrierLoss-default-to-value-of.patch61lp1860926-network-Change-IgnoreCarrierLoss-default-to-value-of.patch
62test-Skip-test-boot-timestamps-on-permission-denied.patch
diff --git a/debian/patches/test-Skip-test-boot-timestamps-on-permission-denied.patch b/debian/patches/test-Skip-test-boot-timestamps-on-permission-denied.patch
62new file mode 10064463new file mode 100644
index 0000000..1acfe77
--- /dev/null
+++ b/debian/patches/test-Skip-test-boot-timestamps-on-permission-denied.patch
@@ -0,0 +1,41 @@
1From: Balint Reczey <balint.reczey@canonical.com>
2Date: Tue, 5 May 2020 21:24:53 +0200
3Subject: test: Skip test-boot-timestamps on permission denied
4Forwarded: https://github.com/systemd/systemd/pull/15728
5
6In containers even root can be denied to access the needed files.
7---
8 src/test/test-boot-timestamps.c | 6 +++---
9 1 file changed, 3 insertions(+), 3 deletions(-)
10
11diff --git a/src/test/test-boot-timestamps.c b/src/test/test-boot-timestamps.c
12index 3c7f7a9..29074ec 100644
13--- a/src/test/test-boot-timestamps.c
14+++ b/src/test/test-boot-timestamps.c
15@@ -17,7 +17,7 @@ static int test_acpi_fpdt(void) {
16
17 r = acpi_get_boot_usec(&loader_start, &loader_exit);
18 if (r < 0) {
19- bool ok = r == -ENOENT || (getuid() != 0 && r == -EACCES) || r == -ENODATA;
20+ bool ok = r == -ENOENT || r == -EACCES || r == -ENODATA;
21
22 log_full_errno(ok ? LOG_DEBUG : LOG_ERR, r, "Failed to read ACPI FPDT: %m");
23 return ok ? 0 : r;
24@@ -37,7 +37,7 @@ static int test_efi_loader(void) {
25
26 r = efi_loader_get_boot_usec(&loader_start, &loader_exit);
27 if (r < 0) {
28- bool ok = r == -ENOENT || (getuid() != 0 && r == -EACCES) || r == -EOPNOTSUPP;
29+ bool ok = r == -ENOENT || r == -EACCES || r == -EOPNOTSUPP;
30
31 log_full_errno(ok ? LOG_DEBUG : LOG_ERR, r, "Failed to read EFI loader data: %m");
32 return ok ? 0 : r;
33@@ -59,7 +59,7 @@ static int test_boot_timestamps(void) {
34
35 r = boot_timestamps(NULL, &fw, &l);
36 if (r < 0) {
37- bool ok = r == -ENOENT || (getuid() != 0 && r == -EACCES) || r == -EOPNOTSUPP;
38+ bool ok = r == -ENOENT || r == -EACCES || r == -EOPNOTSUPP;
39
40 log_full_errno(ok ? LOG_DEBUG : LOG_ERR, r, "Failed to read variables: %m");
41 return ok ? 0 : r;
diff --git a/debian/tests/control b/debian/tests/control
index c6aef85..febf6a9 100644
--- a/debian/tests/control
+++ b/debian/tests/control
@@ -120,6 +120,15 @@ Depends: systemd-tests,
120 dbus-user-session,120 dbus-user-session,
121Restrictions: needs-root, allow-stderr, isolation-container, breaks-testbed121Restrictions: needs-root, allow-stderr, isolation-container, breaks-testbed
122122
123Tests: tests-in-lxd
124Depends: systemd-tests,
125 udev,
126 libpam-systemd,
127 autopkgtest,
128 lsb-release,
129 lxd
130Restrictions: needs-root, allow-stderr, isolation-machine, breaks-testbed, skip-not-installable
131
123Tests: upstream132Tests: upstream
124Depends: libsystemd-dev,133Depends: libsystemd-dev,
125 tree,134 tree,
diff --git a/debian/tests/root-unittests b/debian/tests/root-unittests
index 96416e2..bf8202a 100644
--- a/debian/tests/root-unittests
+++ b/debian/tests/root-unittests
@@ -8,6 +8,8 @@ for t in /usr/lib/systemd/tests/test-*; do
8 tname=$(basename $t)8 tname=$(basename $t)
9 # test-udev needs special prep and has its own test9 # test-udev needs special prep and has its own test
10 [ "$tname" != test-udev ] || continue10 [ "$tname" != test-udev ] || continue
11 # test-execute fails in LXC LP: XXX
12 [ "$tname" != test-execute ] || ! systemd-detect-virt -c -q || continue
11 echo "====== $tname ======="13 echo "====== $tname ======="
12 # exit code 77 means "skip"14 # exit code 77 means "skip"
13 rc=015 rc=0
diff --git a/debian/tests/tests-in-lxd b/debian/tests/tests-in-lxd
14new file mode 10064416new file mode 100644
index 0000000..1eba27d
--- /dev/null
+++ b/debian/tests/tests-in-lxd
@@ -0,0 +1,40 @@
1#!/bin/sh
2
3# run root-unittests in lxd
4
5set -eu
6
7lxd init --auto
8
9IMAGE=autopkgtest/ubuntu/$(lsb_release -cs)/$(dpkg --print-architecture)
10
11autopkgtest-build-lxd ubuntu-daily:$(lsb_release -cs)
12
13# push local apt configuration to match pinning
14lxc launch $IMAGE systemd-lxc
15lxc file push -r /etc/apt systemd-lxc/etc/
16lxc exec systemd-lxc -- sed -i 's|/tmp/autopkgtest.[^/]*/|/root/|' /etc/apt/sources.list.d/autopkgtest.list || true
17
18cd /tmp/autopkgtest.*/build.*/src
19
20# push potential locally built packages
21if [ -d ../../binaries ]; then
22 lxc file push -r ../../binaries systemd-lxc/root/
23fi
24
25# fix failing systemd-remount-fs.service LP: #1877078
26lxc file delete systemd-lxc/etc/fstab
27lxc exec systemd-lxc touch /etc/fstab
28
29lxc stop systemd-lxc
30lxc publish systemd-lxc --alias $IMAGE
31
32for t in root-unittests boot-and-services; do
33 autopkgtest -U -B . --test-name=$t -- lxd $IMAGE || [ $? = 2 ] # see Debian's #960267
34done
35
36# also check tests in privileged containers
37lxc profile set default security.privileged "true"
38for t in root-unittests boot-and-services; do
39 autopkgtest -U -B . --test-name=$t -- lxd $IMAGE || [ $? = 2 ] # see Debian's #960267
40done

Subscribers

People subscribed via source and target branches