tests: add smoke test for systemd-nspawn#4378
Conversation
bb7e479 to
49cd41a
Compare
test/TEST-13-NSPAWN-SMOKE/test.sh
Outdated
|
|
||
| # check cgroup namespaces | ||
| is_cgns_supported=no | ||
| if unshare -C /bin/sh -c ':'; then |
There was a problem hiding this comment.
This requires util-linux >= 2.28
But:
$ uname -a
Linux ubuntu-xenial 4.4.0-43-generic #63-Ubuntu SMP Wed Oct 12 13:48:03 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$ dpkg -l 'util-linux'
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-=============================================-===========================-===========================-===============================================================================================
ii util-linux 2.27.1-6ubuntu3.1 amd64 miscellaneous system utilities
$ sudo unshare -C
unshare: invalid option -- 'C'
I guess we can ignore this for now. @martinpitt ?
There was a problem hiding this comment.
Well, I think I should check the /proc/1/ns/cgroup. Will fix
49cd41a to
c31a33e
Compare
|
One of the combinations (SYSTEMD_NSPAWN_USE_CGNS=yes -U --private-network) does not work for me here, so I added a patch to skip that test. After all outstanding pull requests go in, it should be fixed and we can enable it again. I also reworked the code a bit to make it easier understand what failed, when something fails. |
test/TEST-13-NSPAWN-SMOKE/test.sh
Outdated
| run no yes | ||
| run yes yes | ||
| systemd-run -E UNIFIED_CGROUP_HIERARCHY=$1 -E SYSTEMD_NSPAWN_USE_CGNS=$2 -E SYSTEMD_LOG_LEVEL=debug \ | ||
| --wait systemd-nspawn --quiet --register=no -M container -b --private-network |
There was a problem hiding this comment.
Convert to use systemd-run
to have each case as a separate unit in the journal
This totally breaks journalctl -D ... -u testsuite.service
| mkdir "$root/bin" | ||
| if [[ -d "$root" ]]; then | ||
| echo "$root already exists" | ||
| exit 0 |
There was a problem hiding this comment.
Also sligthly simplify things by not creating separate chroot for each test
run, the same one can be reused over and over
Well, the behaviour of the -U-option depends on the $root's uid and gid. I think we should create a separate root to really test -U
test/TEST-13-NSPAWN-SMOKE/test.sh
Outdated
| set -x | ||
| # Call sleep before each container to make the logs easier to parse | ||
| systemd-run -E UNIFIED_CGROUP_HIERARCHY=$1 -E SYSTEMD_NSPAWN_USE_CGNS=$2 -E SYSTEMD_LOG_LEVEL=debug \ | ||
| --wait systemd-nspawn --quiet --register=no -M container -b |
There was a problem hiding this comment.
Why? Actually, this -x helps to understand what is going on.
I guess we can
UNIFIED_CGROUP_HIERARCHY=$1 SYSTEMD_NSPAWN_USE_CGNS=$2 systemd-nspawn --register=no -D "$_root" -b
instead of the
export ..
export ..
systemd-nspawn
unset
unset
...
This fixes:
When anything fails, it is very hard to locate the failure, when everything
is run from the same script one after another.
No?
There was a problem hiding this comment.
Anyway, systemd-run is a complex thing. systemd-run --wait is a complex thing. And I really want to test systemd-nspawn (not systemd-run, not machined (this is why --register=no)).
test/TEST-13-NSPAWN-SMOKE/test.sh
Outdated
| run yes yes | ||
| systemd-run -E UNIFIED_CGROUP_HIERARCHY=$1 -E SYSTEMD_NSPAWN_USE_CGNS=$2 -E SYSTEMD_LOG_LEVEL=debug \ | ||
| --wait systemd-nspawn --quiet --register=no -M container -b --private-network | ||
| sleep 0.5 |
There was a problem hiding this comment.
Also insert short sleeps between the cases
Well, I think this sleep prevents (maybe, potentially) the testing of the cleanup phase of the nspawn
|
In my testing of your original patch, not all logs ended up in the journal. At some point the output from the script was cut off. Maybe it's a bug, but it's not central to the problem at hand. OK, so you don't like my changes. Can you repush with just my documentation patch, and incorporate the missing return fix into your patch? |
|
... and maybe also the last patch which disables the failing test. It'll probably look different, but I think we need something like this to have the CI pass. |
I think we should disable those cases: #4352
This looks like #2913
OK. I guess we should add |
|
#2913 is different — I was not seeing the messages at all. But it's possible I messed something up. I'll retest when you push a new version... |
Oh, looks like #1812 (comment)
Maybe, again |
Basically, this test runs:
```
systemd-nspawn --register=no -D "$_root" -b
systemd-nspawn --register=no -D "$_root" --private-network -b
systemd-nspawn --register=no -D "$_root" -U -b
systemd-nspawn --register=no -D "$_root" --private-network -U -b
```
and exports the `UNIFIED_CGROUP_HIERARCHY=[yes|no]`, `SYSTEMD_NSPAWN_USE_CGNS=[yes|no]`
Inspired by
* systemd#3589 (comment)
* systemd#4372 (comment)
* systemd#4223 (comment)
* systemd#1555
and so on :-)
1612edb to
a2fc3d8
Compare
|
@keszybz , updated I've tested on:
@martinpitt , if ! (cd $t; TEST_BASE_DIR=../ INITRD=/initrd.img ./test.sh --$op); thenWhy not if ! (cd $t; make $op INITRD=/initrd.img); then? |
And we don't need |
Because this should work on an unbuilt tree as well (for testing distro packages), and then there simply is no
Thanks! Pushed: https://anonscm.debian.org/cgit/pkg-systemd/systemd.git/commit/?id=068efe4aac |
Oh, indeed, thanks! So, I can
Is it OK? |
I don't see a rule in I guess that's why you asked about running this through |
Actually not -- I committed https://anonscm.debian.org/cgit/pkg-systemd/systemd.git/commit/?id=f142ef34c for now, as this is conceptually cleaner than replicating the logic from the Makefile, and if you agree, we can remove the
Yes, that's fine too. I'll restart the failed tests, as with running this through Also, please let me know if/where you want/need tests on Ubuntu 16.10 (I can only start them manually for now, if we want to do this permanently we need to ask @zonque to reconfigure the web hooks). |
|
I also started an amd64 test on 16.10, as you requested in the description. |
I think we don't need
Yes (if
Thanks!
Updated the PR description. |
I believe we need tests on Ubuntu 16.10 (Ubuntu 16.04 and CentOS 7 don't support the unified cgroup hierarchy for example, so, we don't really touch the "unified" hierarchy code paths) |
Can we add |
|
Test deps added (https://anonscm.debian.org/cgit/pkg-systemd/systemd.git/commit/?id=5fc1668) and tests restarted. |
I'm not sure why "make: cc: Command not found"
Well, #4310 isn't working now (we should bump to
|
|
xenial-i386> this is still the previous run before I added the gcc/make test deps, retried. yakkety-amd64 is expected (nspawn failure) as you said. As long as we don't regularly run tests on 16.10, this PR is fine then -- but I figure we should soon clean that up as we actually want to run tests on 16.10 soon to test cgroups v2 on a current kernel? |
Oh, I was wrong. There is no
Yes, we should fix #4352. (or we should use |
Right, it's just a teensy busybox one; I'd like to keep this as we shouldn't make too many assumptions on what is in a container. We can also test a full OS container if we can get an image easily (like downloading the standard LXD ones). |
IIUC, the hybrid hierarchy will break older systemd releases and probably other code which only supports legacy. So I think we have no choice to do hybrid only when we can detect that the container system supports it. |
|
FWIW, I think we should merge this, even if some hacks are required to tests pass, and do incremental improvements later. We have too many unmerged patches which touch the same area and it's just hard to follow. |
|
No objection from me either -- the packaging has been fixed, so tests succeed on xenial, i. e. this won't break other PRs. |
Sorry, I asked the wrong question. I mean, why do we mount the systemd hierarchy at all if there is no
This is true, of course. Can I press the merge button? :-) |
Basically, this test runs:
and exports the
UNIFIED_CGROUP_HIERARCHY=[yes|no],SYSTEMD_NSPAWN_USE_CGNS=[yes|no]Inspired by
and so on :-)
@martinpitt , this test
should fail on Yaketty-testbeds (I've added an expected failure check: https://github.com/systemd/systemd/pull/4378/files#diff-16c7d2b78656b2bcbee324db72cd948fR97UNIFIED_CGROUP_HIERARCHY=no SYSTEMD_NSPAWN_USE_CGNS=yes systemd-nspawn --register=no -D /var/lib/machines/unified-no-cgns-yes -U -b)