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
1diff --git a/debian/patches/series b/debian/patches/series
2index 48bcae4..8b267f5 100644
3--- a/debian/patches/series
4+++ b/debian/patches/series
5@@ -59,3 +59,4 @@ Revert-network-if-sys-is-rw-then-udev-should-be-around.patch
6 riscv64-seccomp.patch
7 dhcp-Allow-setting-request-options-again.patch
8 lp1860926-network-Change-IgnoreCarrierLoss-default-to-value-of.patch
9+test-Skip-test-boot-timestamps-on-permission-denied.patch
10diff --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
11new file mode 100644
12index 0000000..1acfe77
13--- /dev/null
14+++ b/debian/patches/test-Skip-test-boot-timestamps-on-permission-denied.patch
15@@ -0,0 +1,41 @@
16+From: Balint Reczey <balint.reczey@canonical.com>
17+Date: Tue, 5 May 2020 21:24:53 +0200
18+Subject: test: Skip test-boot-timestamps on permission denied
19+Forwarded: https://github.com/systemd/systemd/pull/15728
20+
21+In containers even root can be denied to access the needed files.
22+---
23+ src/test/test-boot-timestamps.c | 6 +++---
24+ 1 file changed, 3 insertions(+), 3 deletions(-)
25+
26+diff --git a/src/test/test-boot-timestamps.c b/src/test/test-boot-timestamps.c
27+index 3c7f7a9..29074ec 100644
28+--- a/src/test/test-boot-timestamps.c
29++++ b/src/test/test-boot-timestamps.c
30+@@ -17,7 +17,7 @@ static int test_acpi_fpdt(void) {
31+
32+ r = acpi_get_boot_usec(&loader_start, &loader_exit);
33+ if (r < 0) {
34+- bool ok = r == -ENOENT || (getuid() != 0 && r == -EACCES) || r == -ENODATA;
35++ bool ok = r == -ENOENT || r == -EACCES || r == -ENODATA;
36+
37+ log_full_errno(ok ? LOG_DEBUG : LOG_ERR, r, "Failed to read ACPI FPDT: %m");
38+ return ok ? 0 : r;
39+@@ -37,7 +37,7 @@ static int test_efi_loader(void) {
40+
41+ r = efi_loader_get_boot_usec(&loader_start, &loader_exit);
42+ if (r < 0) {
43+- bool ok = r == -ENOENT || (getuid() != 0 && r == -EACCES) || r == -EOPNOTSUPP;
44++ bool ok = r == -ENOENT || r == -EACCES || r == -EOPNOTSUPP;
45+
46+ log_full_errno(ok ? LOG_DEBUG : LOG_ERR, r, "Failed to read EFI loader data: %m");
47+ return ok ? 0 : r;
48+@@ -59,7 +59,7 @@ static int test_boot_timestamps(void) {
49+
50+ r = boot_timestamps(NULL, &fw, &l);
51+ if (r < 0) {
52+- bool ok = r == -ENOENT || (getuid() != 0 && r == -EACCES) || r == -EOPNOTSUPP;
53++ bool ok = r == -ENOENT || r == -EACCES || r == -EOPNOTSUPP;
54+
55+ log_full_errno(ok ? LOG_DEBUG : LOG_ERR, r, "Failed to read variables: %m");
56+ return ok ? 0 : r;
57diff --git a/debian/tests/control b/debian/tests/control
58index c6aef85..febf6a9 100644
59--- a/debian/tests/control
60+++ b/debian/tests/control
61@@ -120,6 +120,15 @@ Depends: systemd-tests,
62 dbus-user-session,
63 Restrictions: needs-root, allow-stderr, isolation-container, breaks-testbed
64
65+Tests: tests-in-lxd
66+Depends: systemd-tests,
67+ udev,
68+ libpam-systemd,
69+ autopkgtest,
70+ lsb-release,
71+ lxd
72+Restrictions: needs-root, allow-stderr, isolation-machine, breaks-testbed, skip-not-installable
73+
74 Tests: upstream
75 Depends: libsystemd-dev,
76 tree,
77diff --git a/debian/tests/root-unittests b/debian/tests/root-unittests
78index 96416e2..bf8202a 100644
79--- a/debian/tests/root-unittests
80+++ b/debian/tests/root-unittests
81@@ -8,6 +8,8 @@ for t in /usr/lib/systemd/tests/test-*; do
82 tname=$(basename $t)
83 # test-udev needs special prep and has its own test
84 [ "$tname" != test-udev ] || continue
85+ # test-execute fails in LXC LP: XXX
86+ [ "$tname" != test-execute ] || ! systemd-detect-virt -c -q || continue
87 echo "====== $tname ======="
88 # exit code 77 means "skip"
89 rc=0
90diff --git a/debian/tests/tests-in-lxd b/debian/tests/tests-in-lxd
91new file mode 100644
92index 0000000..1eba27d
93--- /dev/null
94+++ b/debian/tests/tests-in-lxd
95@@ -0,0 +1,40 @@
96+#!/bin/sh
97+
98+# run root-unittests in lxd
99+
100+set -eu
101+
102+lxd init --auto
103+
104+IMAGE=autopkgtest/ubuntu/$(lsb_release -cs)/$(dpkg --print-architecture)
105+
106+autopkgtest-build-lxd ubuntu-daily:$(lsb_release -cs)
107+
108+# push local apt configuration to match pinning
109+lxc launch $IMAGE systemd-lxc
110+lxc file push -r /etc/apt systemd-lxc/etc/
111+lxc exec systemd-lxc -- sed -i 's|/tmp/autopkgtest.[^/]*/|/root/|' /etc/apt/sources.list.d/autopkgtest.list || true
112+
113+cd /tmp/autopkgtest.*/build.*/src
114+
115+# push potential locally built packages
116+if [ -d ../../binaries ]; then
117+ lxc file push -r ../../binaries systemd-lxc/root/
118+fi
119+
120+# fix failing systemd-remount-fs.service LP: #1877078
121+lxc file delete systemd-lxc/etc/fstab
122+lxc exec systemd-lxc touch /etc/fstab
123+
124+lxc stop systemd-lxc
125+lxc publish systemd-lxc --alias $IMAGE
126+
127+for t in root-unittests boot-and-services; do
128+ autopkgtest -U -B . --test-name=$t -- lxd $IMAGE || [ $? = 2 ] # see Debian's #960267
129+done
130+
131+# also check tests in privileged containers
132+lxc profile set default security.privileged "true"
133+for t in root-unittests boot-and-services; do
134+ autopkgtest -U -B . --test-name=$t -- lxd $IMAGE || [ $? = 2 ] # see Debian's #960267
135+done

Subscribers

People subscribed via source and target branches