From fbdbddb3d4b36acbc37a0f1606d5809033a583b0 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 5 Apr 2017 21:51:37 -0400 Subject: [PATCH] vmcheck: Support a VMCHECK_DEBUG to not reset the system I want to be able to debug a test by sshing in with the same setup; right now the suite resets and reboots by default. This also required fixing how we deal with `/etc/yum.repos.d`, since at the start of the test it could be either pristine or not. Closes: #578 Approved by: jlebon --- tests/vmcheck/test.sh | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/tests/vmcheck/test.sh b/tests/vmcheck/test.sh index d4eafa60..1142e0de 100755 --- a/tests/vmcheck/test.sh +++ b/tests/vmcheck/test.sh @@ -47,8 +47,18 @@ vm_cmd ostree refs vmcheck_tmp --delete # comes with the distro to help speed up rpm-ostree metadata fetching since we # don't cache it (e.g. on Fedora, it takes *forever* to fetch metadata, which we # have to do dozens of times throughout the suite) -vm_cmd mv /etc/yum.repos.d{,.bak} -vm_cmd mkdir /etc/yum.repos.d +if ! vm_cmd test -f /etc/yum.repos.d/.vmcheck; then + echo "Neutering /etc/yum.repos.d" + # Move the current one to .bak + vm_cmd mv /etc/yum.repos.d{,.bak} + # And create a new one with a .vmcheck as a stamp file so we recognize it + vm_cmd rm /etc/yum.repos.d.tmp -rf + vm_cmd mkdir /etc/yum.repos.d.tmp + vm_cmd touch /etc/yum.repos.d.tmp/.vmcheck + vm_cmd mv /etc/yum.repos.d{.tmp,} +else + echo "Keeping existing vmcheck /etc/yum.repos.d" +fi origdir=$(pwd) echo -n '' > ${LOG} @@ -119,6 +129,10 @@ for tf in $(find . -name 'test-*.sh' | sort); do fi vm_cmd logger "vmcheck: finished $bn..." + if test -n "${VMCHECK_DEBUG:-}"; then + echo "VMCHECK_DEBUG is set, skipping restoration of original deployment" + break + fi # go back to the original vmcheck deployment if needed csum_cur=$(vm_get_booted_csum) @@ -136,9 +150,15 @@ for tf in $(find . -name 'test-*.sh' | sort); do done + # put back the original yum repos -vm_cmd rm -rf /etc/yum.repos.d -vm_cmd mv /etc/yum.repos.d{.bak,} +if test -z "${VMCHECK_DEBUG:-}"; then + if vm_cmd test -f /etc/yum.repos.d/.vmcheck; then + echo "Restoring original /etc/yum.repos.d" + vm_cmd rm -rf /etc/yum.repos.d + vm_cmd mv /etc/yum.repos.d{.bak,} + fi +fi # Gather post-failure system logs if necessary ALL_LOGS=$LOG