From 52b325970d1f8577810a7aa9e5f4ff87d1b824d2 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Fri, 15 Jul 2016 13:34:47 -0400 Subject: [PATCH] vmcheck: move vmbuild and vmoverlay to scripts That way we can make use of libvm instead of relying on vagrant. Closes: #394 Approved by: cgwalters --- Makefile-tests.am | 37 +++++++++++++++---------------------- tests/utils/vmbuild.sh | 15 +++++++++++++++ tests/utils/vmoverlay.sh | 16 ++++++++++++++++ 3 files changed, 46 insertions(+), 22 deletions(-) create mode 100755 tests/utils/vmbuild.sh create mode 100755 tests/utils/vmoverlay.sh diff --git a/Makefile-tests.am b/Makefile-tests.am index 1b5455ec..78b3ecb6 100644 --- a/Makefile-tests.am +++ b/Makefile-tests.am @@ -1,11 +1,15 @@ include $(top_srcdir)/buildutil/glib-tap.mk -AM_TESTS_ENVIRONMENT = \ - UNINSTALLEDTESTS=1 \ +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 libhif 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 += \ @@ -90,39 +94,28 @@ check-local: vmbuild: @if [ -z "$(SKIP_VMBUILD)" ]; then \ - vagrant up && \ - ( [ -z "$(VMCLEAN)" ] || vagrant ssh -c "rm -rf sync" ) && \ - vagrant rsync && \ - vagrant ssh -c "cd sync/vagrant && \ - make install VERSION=$$(git describe)" && \ - ( vagrant ssh -c "sudo systemctl reboot" || : ) && \ - sleep 2; \ + env $(BASE_TESTS_ENVIRONMENT) \ + tests/utils/vmbuild.sh; \ fi vmoverlay: - vagrant up && \ - ( [ -z "$(VMCLEAN)" ] || vagrant ssh -c "rm -rf sync" ) && \ - vagrant rsync && \ - vagrant ssh -c "cd sync/vagrant && make ofsinstall" && \ - vagrant ssh -c "systemctl daemon-reload && \ - systemctl restart rpm-ostreed" + @env $(BASE_TESTS_ENVIRONMENT) \ + tests/utils/vmoverlay.sh vmshell: vmbuild - vagrant ssh + sleep 2 + ssh -F ssh-config vmcheck # set up test environment to somewhat resemble uninstalled tests vmcheck: vmbuild tests/common/compose/yum/repo/repodata/repomd.xml - @env VMTESTS=1 \ - builddir="$(abs_builddir)" \ - topsrcdir="$(abs_top_srcdir)" \ - commondir="$(abs_top_srcdir)/tests/common" \ - sh tests/vmcheck/test.sh + @env VMTESTS=1 $(BASE_TESTS_ENVIRONMENT) \ + sh tests/vmcheck/test.sh testenv: @echo "===== ENTERING TESTENV =====" test_tmpdir=$$(mktemp -d test.XXXXXX) && \ cd $$test_tmpdir && \ - env $(AM_TESTS_ENVIRONMENT) TESTENV=1 \ + env $(BASE_TESTS_ENVIRONMENT) TESTENV=1 \ sh ../tests/utils/setup-session.sh bash && \ cd .. && \ rm -rf $$test_tmpdir diff --git a/tests/utils/vmbuild.sh b/tests/utils/vmbuild.sh new file mode 100755 index 00000000..ce052975 --- /dev/null +++ b/tests/utils/vmbuild.sh @@ -0,0 +1,15 @@ +#!/bin/bash +set -euo pipefail + +source ${commondir}/libvm.sh + +# create ssh-config if needed and export cmds +vm_setup + +if [ -n "${VMCLEAN:-}" ]; then + vm_cmd rm -rf sync +fi + +vm_rsync +vm_cmd make -C sync/vagrant install VERSION=$(git describe) +vm_reboot diff --git a/tests/utils/vmoverlay.sh b/tests/utils/vmoverlay.sh new file mode 100755 index 00000000..4d76905e --- /dev/null +++ b/tests/utils/vmoverlay.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -euo pipefail + +source ${commondir}/libvm.sh + +# create ssh-config if needed and export cmds +vm_setup + +if [ -n "${VMCLEAN:-}" ]; then + vm_cmd rm -rf sync +fi + +vm_rsync +vm_cmd make -C sync/vagrant ofsinstall +vm_cmd systemctl daemon-reload +vm_cmd systemctl restart rpm-ostreed