test: introduce TEST_PARALLELIZE to support running tests in parallel

Support running tests in parallel by switching to copying of the
base image instead of symlinking it..

This still requires some setup steps, like running `make setup` on tests
which have unique $IMAGE_NAME beforehand (and sequentially), otherwise
they'll all try to create the same base image when started in parallel,
leading to nasty issues. However, as running the integration tests in
parallel is such an unusual use case it should be good enough, for now.
This commit is contained in:
Frantisek Sumsal 2020-05-17 10:48:16 +02:00
parent e89450921f
commit 7a57256c73
1 changed files with 6 additions and 1 deletions

View File

@ -18,6 +18,7 @@ EFI_MOUNT="${EFI_MOUNT:-$(bootctl -x 2>/dev/null || echo /boot)}"
QEMU_MEM="${QEMU_MEM:-512M}"
IMAGE_NAME=${IMAGE_NAME:-default}
TEST_REQUIRE_INSTALL_TESTS="${TEST_REQUIRE_INSTALL_TESTS:-1}"
TEST_PARALLELIZE="${TEST_PARALLELIZE:-0}"
LOOPDEV=
# Decide if we can (and want to) run QEMU with KVM acceleration.
@ -2006,7 +2007,11 @@ test_setup() {
mount_initdir
elif [ -e "$IMAGE_PUBLIC" ]; then
echo "Reusing existing cached image $IMAGE_PUBLIC → $(realpath $IMAGE_PUBLIC)"
ln -s "$(realpath $IMAGE_PUBLIC)" "$IMAGE_PRIVATE"
if [ ${TEST_PARALLELIZE} -ne 0 ]; then
cp -v "$(realpath $IMAGE_PUBLIC)" "$IMAGE_PRIVATE"
else
ln -sv "$(realpath $IMAGE_PUBLIC)" "$IMAGE_PRIVATE"
fi
mount_initdir
else
test_create_image