rpm-ostree/tests/vmcheck/runtest.sh
Jonathan Lebon c7a9c3b1dd Rework vmcheck to use kola spawn, move off of PAPR
There's a lot going on here, but essentially:

1. We change the `vmcheck` model so that it always operates on an
   immutable base image. It takes that image and dynamically launches a
   separate VM for each test using `kola spawn`. This means we can drop
   a lot of hacks around re-using the same VMs.
2. Following from 1., `vmoverlay` now takes as input a base image,
   overlays the built rpm-ostree bits, then creates a new base image. Of
   course, we don't have to do this in CI, because we build FCOS with
   the freshly built RPMs (so it uses `SKIP_VMOVERLAY=1`). `vmoverlay`
   then will be more for the developer case where one doesn't want to
   iterate via `cosa build` to test rpm-ostree changes. I say "will"
   because the functionality doesn't exist yet; I'd like to enhance
   `cosa dev-overlay` to do this. (Note `vmsync` should still works just
   as before too.)
3. `vmcheck` can be run without building the tree first, as
   `tests/vmcheck.sh`. The `make vmcheck` target still exists though for
   finger compatibility and better meshing with `vmoverlay` in the
   developer case.

What's really nice about using kola spawn is that it takes care of a lot
of things for us, such as the qemu command, journal and console
gathering, and SSH.

Similarly to the compose testsuites, we're using parallel here to run
multiple vmcheck tests at once. (On developer laptops, we cap
parallelism at `$(nproc) - 1`).
2019-12-13 19:18:30 +01:00

57 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
if [ -n "${V:-}" ]; then
set -x
fi
outputdir=$1; shift
testname=$1; shift
outputdir="${outputdir}/${testname}"
rm -rf ${outputdir}/*
mkdir -p "${outputdir}"
# keep original stdout around; this propagates to the terminal
exec 3>&1
# but redirect everything else to a log file
exec 1>"${outputdir}/output.log"
exec 2>&1
# seed output log with current date
date
if [ -n "${V:-}" ]; then
setpriv --pdeathsig SIGKILL -- tail -f "${outputdir}/output.log" >&3 &
fi
# this will cause libtest.sh to allocate a tmpdir and cd to it
export VMTESTS=1
echo "EXEC: ${testname}" >&3
runtest() {
. ${commondir}/libtest.sh
. ${commondir}/libvm.sh
vm_kola_spawn "${outputdir}/kola"
"${topsrcdir}/tests/vmcheck/test-${testname}.sh"
}
if runtest; then
echo "PASS: ${testname}" >&3
else
echo "FAIL: ${testname}" >&3
if [ -z "${V:-}" ]; then
tail -n10 "${outputdir}/output.log" | sed "s/^/ ${testname}: /g" >&3
fi
if [ -n "${VMCHECK_DEBUG:-}" ]; then
echo "--- VMCHECK_DEBUG ---" >&3
echo "To try SSH:" "SSH_AUTH_SOCK=$(realpath ${SSH_AUTH_SOCK})" ${SSH:-} >&3
echo "Sleeping..." >&3
sleep infinity
fi
exit 1
fi