From: Colin Patrick McCabe Date: Fri, 22 Oct 2010 18:48:35 +0000 (-0700) Subject: test_lost.sh: put common functions in test_common X-Git-Tag: v0.23~118 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=242b5992f3075ee073bf53e7a88b16f028879c8e;p=ceph.git test_lost.sh: put common functions in test_common Signed-off-by: Colin McCabe --- diff --git a/src/test/test_common.sh b/src/test/test_common.sh new file mode 100755 index 000000000000..0df86b3404f0 --- /dev/null +++ b/src/test/test_common.sh @@ -0,0 +1,38 @@ +#!/bin/bash -x + +# +# test_common.sh +# +# Common routines for tests +# + +# Functions +cleanup() { + rm -rf "${TEMPDIR}" +} + +setup_tempdir() { + TEMPDIR=`mktemp -d` + trap cleanup INT TERM EXIT +} + +die() { + echo $@ + exit 1 +} + +stop_osd() { + osd_index=$1 + pidfile="out/osd.$osd_index.pid" + if [ -e $pidfile ]; then + kill `cat $pidfile` && return 0 + else + echo "cosd process $osd_index is not running" + fi + return 1 +} + +restart_osd() { + osd_index=$1 + ./cosd -i $osd_index -c ceph.conf & +} diff --git a/src/test/test_lost.sh b/src/test/test_lost.sh index f66344b9192c..baba361435bf 100755 --- a/src/test/test_lost.sh +++ b/src/test/test_lost.sh @@ -4,44 +4,15 @@ # Simple test of recovery logic # +# Includes +dir=`dirname $0` +source $dir/test_common.sh +setup_tempdir +cd $dir/.. + # Constants MAX_OBJS=50 OBJ_SIZE=1000000 -TEMPDIR=`mktemp -d` -SDIR=`dirname $0`/.. - -# Initialization -cd $SDIR -[ -e "/dev/urandom" ] || die "need /dev/urandom" -trap cleanup INT TERM EXIT -rm -rf $TEMPDIR -mkdir -p $TEMPDIR || die "failed to make tempdir" - -# Functions -cleanup() { - rm -rf "${TEMPDIR}" -} - -die() { - echo $@ - exit 1 -} - -stop_osd() { - osd_index=$1 - pidfile="out/osd.$osd_index.pid" - if [ -e $pidfile ]; then - kill `cat $pidfile` && return 0 - else - echo "cosd process $osd_index is not running" - fi - return 1 -} - -restart_osd() { - osd_index=$1 - ./cosd -i $osd_index -c ceph.conf & -} write_objects() { start_ver=$1