diff options
author | Jeff Darcy <jdarcy@redhat.com> | 2016-04-14 12:38:50 -0400 |
---|---|---|
committer | Jeff Darcy <jdarcy@redhat.com> | 2016-07-11 06:33:38 -0700 |
commit | c341a95bd3e6ae81cf32620950bac33b27c1e033 (patch) | |
tree | 3c620ceda86fc4fffca8da7320bcd64099924b28 /tests | |
parent | f4757d256e3e00132ef204c01ed61f78f705ad6b (diff) |
tests: miscellaneous improvements
This is a combination of three previous low-impact changes, combined to
reduce patch-pushing burden.
((( GF_INTERACTIVE )))
To use this, just define GF_INTERACTIVE (value doesn't matter as long as
the length is non-zero) before running your test. It replaces the TEST
alias with one that will prompt you before executing that line. You can
answer:
'y' to execute the line
'q' to exit the test immediately
anything else to skip this line and continue
This is particularly useful to inspect state in another window while a
test is paused, or to do manual experimentation in the (often complex)
configuration created during a test.
((( CLEANUP.SH )))
tests: add cleanup.sh
Often, a developer might want to run a test up to some point, then bail
out and poke around manually. That leaves state that needs to be
cleaned up before the next test can run properly. This patch adds a
trivial script to invoke that cleanup machinery.
Along the way, code in include.rc to find env.rc was changed to be more
robust across arbitrarily deep (or shallow) directory hierarchies.
((( REPLACE EXISTING TAR FILES INSTEAD OF APPENDING )))
We currently use "tar rf" to collect log files from each test. This
*appends* the new data to whatever's there already, which has two bad
effects when a test is run repeatedly.
* Ever-increasing size of the tar file.
* Ever-increasing time to extract logs from the tar file, with each
copy completely overwriting any previous.
This doesn't seem to be a problem in our regression tests, because the
entire directory is nuked during package removal and reinstallation.
However, when running a test repeatedly during a debug session, the
effects can be quite severe. This is particularly evident with JBR,
because the "logs" that get archived include large journal files.
Certain other translators, such as changelog and CTR, might be prone to
similar effects.
There's no point to having multiple copies of the logs in each tar file.
As far as I know, nobody ever takes advantage of that. Therefore, use
"tar cf" to overwrite any existing archive instead of appending. This
change also handles excluding other .tar files in a portable way.
Change-Id: Iebf77d496a71976c321bbacb49776338a9da586f
Signed-off-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-on: http://review.gluster.org/14874
Smoke: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cleanup.sh | 4 | ||||
-rw-r--r-- | tests/include.rc | 50 |
2 files changed, 44 insertions, 10 deletions
diff --git a/tests/cleanup.sh b/tests/cleanup.sh new file mode 100644 index 00000000000..29fd6929fac --- /dev/null +++ b/tests/cleanup.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +. $(dirname $0)/include.rc +cleanup diff --git a/tests/include.rc b/tests/include.rc index e122a0ed627..61dd6ba59f9 100644 --- a/tests/include.rc +++ b/tests/include.rc @@ -18,13 +18,19 @@ META_MNT=${META_MNT:=/var/run/gluster/shared_storage}; # Mount point of shared g CC=cc OSTYPE=$(uname -s) -ENV_RC=$(dirname $0)/../env.rc -if [ ! -f $ENV_RC ]; then - ENV_RC=$(dirname $0)/../../env.rc - if [ ! -f $ENV_RC ]; then - ENV_RC=$(dirname $0)/../../../env.rc - fi -fi +env_dir=$(dirname $0) +while true; do + ENV_RC=${env_dir}/env.rc + if [ -f ${ENV_RC} ]; then + break + fi + new_dir=$(dirname $env_dir) + if [ x"$new_dir" = x"$old_dir" ]; then + ENV_RC="/not/found" + break + fi + env_dir=$new_dir +done if [ ! -f $ENV_RC ]; then echo "Aborting." | tee /dev/stderr @@ -556,8 +562,13 @@ function cleanup() if [ -n "$LOGDIR" -a -z "$STOP_WASTING_SPACE" ] then tarname=$(basename $0 .t) - tar -rf ${LOGDIR}/${tarname}.tar ${LOGDIR}/* \ - --exclude="*.tar" \ + # Can't use --exclude here because NetBSD doesn't have it. + # However, both it and Linux have -X to take patterns from + # a file, so use that. + (echo '*.tar'; echo .notar) > ${LOGDIR}/.notar \ + && \ + tar -cf ${LOGDIR}/${tarname}.tar -X ${LOGDIR}/.notar \ + ${LOGDIR}/* 2> /dev/null \ && \ find $LOGDIR/* -maxdepth 0 -name '*.tar' -prune \ -o -exec rm -rf '{}' ';' @@ -802,9 +813,28 @@ useradd --help 2>/dev/null | grep -q -- '--no-create-home' || { } } +DBG_TEST () { + read -p "execute \"$*\"? " x; + case $x in + 'y') + _TEST "$@" + ;; + 'q') + exit 0 + ;; + *) + echo "skipping" + ;; + esac +} + alias EXPECT='_EXPECT $LINENO' alias EXPECT_NOT='_EXPECT_NOT $LINENO' -alias TEST='_TEST $LINENO' +if [ -n "$GF_INTERACTIVE" ]; then + alias TEST='DBG_TEST $LINENO' +else + alias TEST='_TEST $LINENO' +fi alias EXPECT_WITHIN='_EXPECT_WITHIN $LINENO' alias EXPECT_KEYWORD='_EXPECT_KEYWORD $LINENO' alias TEST_IN_LOOP='_TEST_IN_LOOP $LINENO' |