diff --git a/test/README.md b/test/README.md index f880a984f1..6e625bf2b3 100644 --- a/test/README.md +++ b/test/README.md @@ -151,6 +151,10 @@ that make use of `run_testcases`. `TEST_SKIP_TESTCASE=testcase`: takes a space separated list of testcases to skip. +`TEST_JOURNAL_USE_TMP=1`: Write test journal to `/tmp` while the test is in +progress and only move the journal to its final location in the build directory +(`$BUILD_DIR/test/journal`) when the test is finished. + ### SELinux AVCs To have `TEST-06-SELINUX` check for SELinux denials, write the following to diff --git a/test/fmf/integration-tests/test.sh b/test/fmf/integration-tests/test.sh index d1e43b1d7d..f82961f959 100755 --- a/test/fmf/integration-tests/test.sh +++ b/test/fmf/integration-tests/test.sh @@ -13,6 +13,10 @@ lsmem echo "Clock source: $(cat /sys/devices/system/clocksource/clocksource0/current_clocksource)" +# Bump inotify limits so nspawn containers don't run out of inotify file descriptors. +sysctl fs.inotify.max_user_watches=65536 +sysctl fs.inotify.max_user_instances=1024 + # Allow running the integration tests downstream in dist-git with something like # the following snippet which makes the dist-git sources available in $TMT_SOURCE_DIR: # @@ -112,6 +116,18 @@ if [[ ! -e /dev/kvm ]]; then export TEST_NO_QEMU=1 fi +NPROC="$(nproc)" +if [[ "$NPROC" -ge 10 ]]; then + export TEST_JOURNAL_USE_TMP=1 + NPROC="$((NPROC / 3))" +else + NPROC="$((NPROC - 1))" +fi + +# This test is only really useful if we're building with sanitizers and takes a long time, so let's skip it +# for now. +export TEST_SKIP="TEST-21-DFUZZER" + # Create missing mountpoint for mkosi sandbox. mkdir -p /etc/pacman.d/gnupg @@ -127,7 +143,7 @@ mkosi -f sandbox \ --suite integration-tests \ --print-errorlogs \ --no-stdsplit \ - --num-processes "$(($(nproc) - 1))" && EC=0 || EC=$? + --num-processes "$NPROC" && EC=0 || EC=$? find build/meson-logs -type f -exec mv {} "$TMT_TEST_DATA" \; find build/test/journal -type f -exec mv {} "$TMT_TEST_DATA" \; diff --git a/test/integration-test-wrapper.py b/test/integration-test-wrapper.py index d9d92fcba3..610c34c903 100755 --- a/test/integration-test-wrapper.py +++ b/test/integration-test-wrapper.py @@ -10,6 +10,7 @@ import json import os import re import shlex +import shutil import subprocess import sys import tempfile @@ -441,7 +442,11 @@ def main() -> None: """ ) - journal_file = (args.meson_build_dir / (f'test/journal/{name}.journal')).absolute() + if os.getenv('TEST_JOURNAL_USE_TMP', '0') == '1': + journal_file = Path(f'/tmp/systemd-integration-tests/journal/{name.journal}') + else: + journal_file = (args.meson_build_dir / f'test/journal/{name}.journal').absolute() + journal_file.unlink(missing_ok=True) if not sys.stderr.isatty(): @@ -465,6 +470,7 @@ def main() -> None: [Service] ExecStartPre=/usr/lib/systemd/tests/testdata/integration-test-setup.sh setup ExecStopPost=/usr/lib/systemd/tests/testdata/integration-test-setup.sh finalize + StateDirectory=%N """ ) @@ -511,7 +517,7 @@ def main() -> None: ] ), '--credential', f"journal.storage={'persistent' if sys.stderr.isatty() else args.storage}", - *(['--runtime-build-sources=no'] if not sys.stderr.isatty() else []), + *(['--runtime-build-sources=no', '--register=no'] if not sys.stderr.isatty() else []), 'vm' if args.vm or os.getuid() != 0 or os.getenv('TEST_PREFER_QEMU', '0') == '1' else 'boot', ] # fmt: skip @@ -551,6 +557,11 @@ def main() -> None: ): journal_file.unlink(missing_ok=True) + if os.getenv('TEST_JOURNAL_USE_TMP', '0') == '1': + dst = args.meson_build_dir / f'test/journal/{name}.journal' + dst.parent.mkdir(parents=True, exist_ok=True) + shutil.move(journal_file, dst) + if shell or (result.returncode in (args.exit_code, 77) and not coredumps and not sanitizer): exit(0 if shell or result.returncode == args.exit_code else 77) diff --git a/test/test.service.in b/test/test.service.in index 75f703698f..790c513da4 100644 --- a/test/test.service.in +++ b/test/test.service.in @@ -10,4 +10,3 @@ ExecStartPre=rm -f /failed /testok ExecStart=@command@ Type=oneshot MemoryAccounting=@memory-accounting@ -StateDirectory=%N