rpm-ostree/Makefile-tests.am
Colin Walters 95e9aa4284 Introduce ex livefs
There are a few different use cases here. First, for layering new packages,
there's no good reason for us to force a reboot. Second, we want some support
for cherry-picking security updates and allowing admins to restart services.  Finally,
at some point we should offer support for entirely replacing the running tree
if that's what the user wants.

Until now we've been very conservative, but there's a spectrum here. In
particular, this patch changes things so we push a rollback before we start
doing anything live. I think in practice, many use cases would be totally fine
with doing most changes live, and falling back to the rollback if something went
wrong.

This initial code drop *only* supports live layering of new packages.  However,
a lot of the base infrastructure is laid for future work.

For now, this will be classified as an experimental feature, hence `ex livefs`.

Part of: https://github.com/projectatomic/rpm-ostree/issues/639

Closes: #652
Approved by: jlebon
2017-05-12 15:00:59 +00:00

149 lines
5.1 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 \
$(NULL)
if BUILDOPT_ASAN
AM_TESTS_ENVIRONMENT += ASAN_OPTIONS=detect_leaks=false
endif
CLEANFILES += \
tests/common/compose/yum/repo \
tests/common/compose/test-repo.repo \
$(NULL)
testpackages = \
tests/common/compose/yum/repo/packages/x86_64/empty-1.0-1.x86_64.rpm \
tests/common/compose/yum/repo/packages/x86_64/foo-1.0-1.x86_64.rpm \
tests/common/compose/yum/repo/packages/x86_64/bar-1.0-1.x86_64.rpm \
tests/common/compose/yum/repo/packages/x86_64/scriptpkg1-1.0-1.x86_64.rpm \
tests/common/compose/yum/repo/packages/x86_64/nonrootcap-1.0-1.x86_64.rpm \
tests/common/compose/yum/repo/packages/x86_64/test-post-rofiles-violation-1.0-1.x86_64.rpm \
tests/common/compose/yum/repo/packages/x86_64/test-opt-1.0-1.x86_64.rpm \
tests/common/compose/yum/repo/packages/x86_64/test-livefs-with-etc-1.0-1.x86_64.rpm \
$(NULL)
# Create a rule for each testpkg with their respective spec file as dep.
# The static pattern feature is almost a fit for this, but does not allow string
# substitutions and wildcards in the patterns to allow rpm-filename -->
# spec-filename without also encoding the arch, release, and rev.
define testpkgbuild_template =
$(1): tests/common/compose/yum/$(2).spec
(cd tests/common/compose/yum && \
rm -rf .build && \
rpmbuild -ba $$$$(basename $$<) \
--define "_sourcedir $$$$PWD" \
--define "_specdir $$$$PWD" \
--define "_builddir $$$$PWD/.build" \
--define "_srcrpmdir $$$$PWD" \
--define "_rpmdir $$$$PWD/repo/packages" \
--define "_buildrootdir $$$$PWD" && \
rm -rf .build && \
rm -f *.src.rpm)
endef
$(foreach pkg,$(testpackages),$(eval $(call testpkgbuild_template,$(pkg),$(shell basename $(pkg) | sed -e 's,-1\.0.*,,'))))
tests/common/compose/yum/repo/repodata/repomd.xml: $(testpackages)
(cd tests/common/compose/yum/repo && \
createrepo_c --no-database $$PWD)
tests/common/compose/test-repo.repo: tests/common/compose/test-repo.repo.in \
tests/common/compose/yum/repo/repodata/repomd.xml
cat $< | sed -e "s|%WHERE%|$(abs_top_srcdir)|" > $@
CLEANFILES += \
tests/common/compose/test-repo-local.repo \
$(NULL)
testbin_cppflags = $(AM_CPPFLAGS) -I $(srcdir)/src/libpriv -I $(srcdir)/libglnx
testbin_cflags = $(AM_CFLAGS) $(PKGDEP_RPMOSTREE_CFLAGS)
testbin_ldadd = $(PKGDEP_RPMOSTREE_LIBS) librpmostree-1.la librpmostreepriv.la
tests_check_jsonutil_CPPFLAGS = $(testbin_cppflags)
tests_check_jsonutil_CFLAGS = $(testbin_cflags)
tests_check_jsonutil_LDADD = $(testbin_ldadd)
tests_check_cache_branch_to_nevra_CPPFLAGS = $(testbin_cppflags)
tests_check_cache_branch_to_nevra_CFLAGS = $(testbin_cflags)
tests_check_cache_branch_to_nevra_LDADD = $(testbin_ldadd)
tests_check_postprocess_CPPFLAGS = $(testbin_cppflags)
tests_check_postprocess_CFLAGS = $(testbin_cflags)
tests_check_postprocess_LDADD = $(testbin_ldadd)
tests_check_test_utils_CPPFLAGS = $(testbin_cppflags)
tests_check_test_utils_CFLAGS = $(testbin_cflags)
tests_check_test_utils_LDADD = $(testbin_ldadd)
tests/check/test-compose.sh: tests/common/compose/test-repo.repo
tests/check/test-ucontainer.sh: tests/common/compose/test-repo.repo
uninstalled_test_programs = \
tests/check/jsonutil \
tests/check/cache_branch_to_nevra \
tests/check/postprocess \
tests/check/test-utils \
$(NULL)
uninstalled_test_scripts = \
tests/check/test-basic.sh \
tests/check/test-compose.sh \
tests/check/test-ucontainer.sh \
$(NULL)
uninstalled_test_extra_programs = dbus-run-session
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 vmshell vmcheck testenv
vmsync:
@env $(BASE_TESTS_ENVIRONMENT) ./tests/vmcheck/sync.sh
HOSTS := "vmcheck"
vmoverlay:
@if [ -z "$(SKIP_VMOVERLAY)" ]; then \
rm -rf $(abs_top_srcdir)/insttree; \
echo -n "$(HOSTS)" | xargs -P 0 -n 1 -d ' ' -I {} \
env $(BASE_TESTS_ENVIRONMENT) VM={} \
./tests/vmcheck/overlay.sh; \
fi
vmshell: vmsync
ssh -F ssh-config vmcheck
# set up test environment to somewhat resemble uninstalled tests
vmcheck: vmoverlay tests/common/compose/yum/repo/repodata/repomd.xml
@env VMTESTS=1 $(BASE_TESTS_ENVIRONMENT) PYTHONUNBUFFERED=1 \
tests/vmcheck/multitest.py $(HOSTS)
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 ====="