From: Mykola Golub Date: Tue, 30 Dec 2014 09:59:31 +0000 (+0200) Subject: qa: refactor 'ceph -w' magic in test_mon_misc by introducing helper X-Git-Tag: v0.92~63^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3b4e021cdcee8e1802228ad8c4c7eea6617bd902;p=ceph.git qa: refactor 'ceph -w' magic in test_mon_misc by introducing helper functions ceph_watch_start and ceph_watch_wait so they can be reused in other tests. Signed-off-by: Mykola Golub --- diff --git a/qa/workunits/cephtool/test.sh b/qa/workunits/cephtool/test.sh index 0aad890b8443..7b9f756fbdc0 100755 --- a/qa/workunits/cephtool/test.sh +++ b/qa/workunits/cephtool/test.sh @@ -155,6 +155,37 @@ function expect_config_value() fi } +function ceph_watch_start() +{ + local whatch_opt=--watch + + if [ -n "$1" ]; then + whatch_opt=--watch-$1 + fi + + CEPH_WATCH_FILE=${TMPDIR}/CEPH_WATCH_$$ + ceph $whatch_opt > $CEPH_WATCH_FILE & + CEPH_WATCH_PID=$! +} + +function ceph_watch_wait() +{ + local regexp=$1 + local timeout=30 + + if [ -n "$2" ]; then + timeout=$2 + fi + + for i in `seq ${timeout}`; do + sleep 1 + grep -q "$regexp" $CEPH_WATCH_FILE && break + done + + kill $CEPH_WATCH_PID + grep "$regexp" $CEPH_WATCH_FILE +} + function test_mon_injectargs() { CEPH_ARGS='--mon_debug_dump_location the.dump' ceph tell osd.0 injectargs --no-osd_debug_op_order >& $TMPFILE || return 1 @@ -495,20 +526,12 @@ function test_mon_misc() ceph health --format json-pretty ceph health detail --format xml-pretty - ceph -w > $TMPDIR/$$ & - wpid="$!" + ceph_watch_start mymsg="this is a test log message $$.$(date)" ceph log "$mymsg" - sleep 3 - if ! grep "$mymsg" $TMPDIR/$$; then - # in case it is very slow (mon thrashing or something) - sleep 30 - grep "$mymsg" $TMPDIR/$$ - fi - kill $wpid + ceph_watch_wait "$mymsg" } - function check_mds_active() { ceph mds dump | grep active