rpm-ostree/Makefile-tests.am
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

104 lines
3.4 KiB
Plaintext

BASE_TESTS_ENVIRONMENT = \
builddir=$(abs_builddir) \
topsrcdir=$(abs_top_srcdir) \
commondir=$(abs_top_srcdir)/tests/common
AM_TESTS_ENVIRONMENT = \
UNINSTALLEDTESTS=1 \
$(BASE_TESTS_ENVIRONMENT)
# we consume libdnf as a submodule, but we may not have installed it yet (and we
# don't want it to fall back to the system libhif if it's also installed)
AM_TESTS_ENVIRONMENT += \
LD_LIBRARY_PATH=$(abs_builddir)/libdnf-build/libdnf:$$(cd $(top_builddir)/.libs && pwd)$${LD_LIBRARY_PATH:+:$${LD_LIBRARY_PATH}} \
GI_TYPELIB_PATH=$$(cd $(top_builddir) && pwd)$${GI_TYPELIB_PATH:+:$$GI_TYPELIB_PATH} \
$(NULL)
if BUILDOPT_ASAN
AM_TESTS_ENVIRONMENT += BUILDOPT_ASAN=yes ASAN_OPTIONS=detect_leaks=false
endif
GITIGNOREFILES += ssh-config ansible-inventory.yml vmcheck-logs/ test-compose-logs/ tests/vmcheck/image.qcow2
testbin_cppflags = $(AM_CPPFLAGS) -I $(srcdir)/src/lib -I $(srcdir)/src/libpriv -I $(srcdir)/libglnx -I $(srcdir)/tests/common
testbin_cflags = $(AM_CFLAGS) -fvisibility=hidden $(PKGDEP_RPMOSTREE_CFLAGS)
testbin_ldadd = $(PKGDEP_RPMOSTREE_LIBS) librpmostree-1.la librpmostreepriv.la
noinst_LTLIBRARIES += libtest.la
libtest_la_SOURCES = tests/common/libtest.c
libtest_la_CPPFLAGS = $(testbin_cppflags)
libtest_la_CFLAGS = $(testbin_cflags)
libtest_la_LIBADD = $(testbin_ldadd)
tests_check_jsonutil_CPPFLAGS = $(testbin_cppflags)
tests_check_jsonutil_CFLAGS = $(testbin_cflags)
tests_check_jsonutil_LDADD = $(testbin_ldadd) libtest.la
tests_check_postprocess_CPPFLAGS = $(testbin_cppflags)
tests_check_postprocess_CFLAGS = $(testbin_cflags)
tests_check_postprocess_LDADD = $(testbin_ldadd) libtest.la
tests_check_test_utils_CPPFLAGS = $(testbin_cppflags)
tests_check_test_utils_CFLAGS = $(testbin_cflags)
tests_check_test_utils_LDADD = $(testbin_ldadd) libtest.la
tests_check_test_sysusers_CPPFLAGS = $(testbin_cppflags)
tests_check_test_sysusers_CFLAGS = $(testbin_cflags)
tests_check_test_sysusers_LDADD = $(testbin_ldadd) libtest.la
uninstalled_test_programs = \
tests/check/jsonutil \
tests/check/postprocess \
tests/check/test-utils \
tests/check/test-sysusers \
$(NULL)
uninstalled_test_scripts = \
tests/check/test-lib-introspection.sh \
tests/check/test-ucontainer.sh \
$(NULL)
uninstalled_test_extra_programs = \
dbus-run-session \
$(NULL)
dbus_run_session_SOURCES = tests/utils/dbus-run-session.c
check-local:
@echo " *** NOTE ***"
@echo " *** NOTE ***"
@echo " \"make check\" only runs a subset of rpm-ostree's tests."
@echo " Use \"make vmcheck\" to run remaining tests in a VM."
@echo " *** NOTE ***"
@echo " *** NOTE ***"
.PHONY: vmsync vmoverlay vmcheck testenv
vmsync:
@set -e; if [ -z "$(SKIP_INSTALL)" ]; then \
env $(BASE_TESTS_ENVIRONMENT) ./tests/vmcheck/install.sh; \
fi; \
env $(BASE_TESTS_ENVIRONMENT) ./tests/vmcheck/sync.sh
vmoverlay:
@set -e; \
if [ -z "$(SKIP_INSTALL)" ] && [ -z "$(SKIP_VMOVERLAY)" ]; then \
env $(BASE_TESTS_ENVIRONMENT) ./tests/vmcheck/install.sh; \
fi; \
env $(BASE_TESTS_ENVIRONMENT) ./tests/vmcheck/overlay.sh;
# One can run the vmcheck.sh script directly. The make target is useful for local
# development so that e.g. we automatically overlay.
vmcheck: vmoverlay
@tests/vmcheck.sh
testenv:
@echo "===== ENTERING TESTENV ====="
test_tmpdir=$$(mktemp -d test.XXXXXX) && \
cd $$test_tmpdir && \
env $(BASE_TESTS_ENVIRONMENT) PATH=$(abs_builddir):$$PATH TESTENV=1 \
sh ../tests/utils/setup-session.sh bash && \
cd .. && \
rm -rf $$test_tmpdir
@echo "===== LEAVING TESTENV ====="