c7a9c3b1dd
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`).
61 lines
1.6 KiB
Bash
Executable File
61 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
dn=$(cd "$(dirname "$0")" && pwd)
|
|
topsrcdir=$(cd "$dn/.." && pwd)
|
|
commondir=$(cd "$dn/common" && pwd)
|
|
export topsrcdir commondir
|
|
|
|
# https://github.com/coreos/coreos-assembler/pull/632
|
|
ncpus() {
|
|
if ! grep -q kubepods /proc/1/cgroup; then
|
|
# this might be a developer laptop; leave one cpu free to be nice
|
|
echo $(($(nproc) - 1))
|
|
return 0
|
|
fi
|
|
|
|
quota=$(cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us)
|
|
period=$(cat /sys/fs/cgroup/cpu/cpu.cfs_period_us)
|
|
if [[ ${quota} != -1 ]] && [[ ${period} -gt 0 ]]; then
|
|
echo $(("${quota}" / "${period}"))
|
|
fi
|
|
|
|
# just fallback to 1
|
|
echo 1
|
|
}
|
|
|
|
# Just match 1:1 the number of processing units available. Ideally, we'd also
|
|
# cap based on memory available to us, but that's notoriously difficult to do
|
|
# for containers (see:
|
|
# https://fabiokung.com/2014/03/13/memory-inside-linux-containers/). We make an
|
|
# assumption here that we have at least 1G of RAM we can use per CPU available
|
|
# to us.
|
|
nhosts=${NHOSTS:-$(ncpus)}
|
|
|
|
nselected=0
|
|
ntotal=0
|
|
tests=()
|
|
for tf in $(find "${topsrcdir}/tests/vmcheck/" -name 'test-*.sh' | sort); do
|
|
ntotal=$((ntotal + 1))
|
|
|
|
tfbn=$(basename "$tf" .sh)
|
|
tfbn=" ${tfbn#test-} "
|
|
if [ -n "${TESTS+ }" ]; then
|
|
if [[ " $TESTS " != *$tfbn* ]]; then
|
|
continue
|
|
fi
|
|
fi
|
|
|
|
nselected=$((nselected + 1))
|
|
tests+=(${tfbn})
|
|
done
|
|
|
|
echo "Running ${nselected} out of ${ntotal} tests ${nhosts} at a time"
|
|
|
|
outputdir="${topsrcdir}/vmcheck-logs"
|
|
echo "Test results outputting to ${outputdir}/"
|
|
if [ "${#tests[*]}" -gt 0 ]; then
|
|
echo -n "${tests[*]}" | parallel -d' ' -j "${nhosts}" --line-buffer \
|
|
"${topsrcdir}/tests/vmcheck/runtest.sh" "${outputdir}"
|
|
fi
|