X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fsanity-benchmark.sh;h=a56dc845d12c36588a1698078a6212a75932924e;hb=7bba9569f40f2f81913cd6a0ff1b9b8523b686c4;hp=cfce8761bfdba83bb24b7adccac8ec904c3b0b5c;hpb=1d8a6a2525fa786a1bf03d6e77a0522b5a0f6304;p=fs%2Flustre-release.git diff --git a/lustre/tests/sanity-benchmark.sh b/lustre/tests/sanity-benchmark.sh index cfce876..a56dc84 100644 --- a/lustre/tests/sanity-benchmark.sh +++ b/lustre/tests/sanity-benchmark.sh @@ -6,10 +6,16 @@ set -e +ONLY=${ONLY:-"$*"} + LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)} . $LUSTRE/tests/test-framework.sh init_test_env $@ . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh} +init_logging + +# bug number: +ALWAYS_EXCEPT="$SANITY_BENCHMARK_EXCEPT" MAX_THREADS=${MAX_THREADS:-20} RAMKB=`awk '/MemTotal:/ { print $2 }' /proc/meminfo` @@ -23,6 +29,7 @@ RSIZE=${RSIZE:-512} DEBUG_LVL=${DEBUG_LVL:-0} DEBUG_OFF=${DEBUG_OFF:-"eval lctl set_param debug=\"$DEBUG_LVL\""} DEBUG_ON=${DEBUG_ON:-"eval lctl set_param debug=0x33f0484"} +DIRECTIO=${DIRECTIO:-directio} PIOSBIN=${PIOSBIN:-$(which pios 2> /dev/null || true)} @@ -48,7 +55,7 @@ test_dbench() { return fi - DBENCHDIR=$MOUNT/d0.$HOSTNAME + local DBENCHDIR=$DIR/d0.$HOSTNAME mkdir -p $DBENCHDIR local SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'` DB_THREADS=$((SPACE / 50000)) @@ -56,9 +63,11 @@ test_dbench() { $DEBUG_OFF myUID=$RUNAS_ID + myGID=$RUNAS_GID myRUNAS=$RUNAS - FAIL_ON_ERROR=false check_runas_id_ret $myUID $myUID $myRUNAS || { myRUNAS="" && myUID=$UID; } - chown $myUID:$myUID $DBENCHDIR + FAIL_ON_ERROR=false check_runas_id_ret $myUID $myGID $myRUNAS || \ + { myRUNAS="" && myUID=$UID && myGID=`id -g $USER`; } + chown $myUID:$myGID $DBENCHDIR local duration="" [ "$SLOW" = "no" ] && duration=" -t 120" if [ "$SLOW" != "no" -o $DB_THREADS -eq 1 ]; then @@ -79,7 +88,7 @@ test_bonnie() { skip_env "No bonnie++ installed" return 0 fi - BONDIR=$MOUNT/d0.bonnie + local BONDIR=$DIR/d0.bonnie mkdir -p $BONDIR $LFS setstripe -c -1 $BONDIR sync @@ -89,10 +98,12 @@ test_bonnie() { log "min OST has ${MIN}kB available, using ${SIZE}kB file size" $DEBUG_OFF myUID=$RUNAS_ID + myGID=$RUNAS_GID myRUNAS=$RUNAS - FAIL_ON_ERROR=false check_runas_id_ret $myUID $myUID $myRUNAS || { myRUNAS="" && myUID=$UID; } - chown $myUID:$myUID $BONDIR - $myRUNAS bonnie++ -f -r 0 -s$((SIZE / 1024)) -n 10 -u$myUID:$myUID -d$BONDIR + FAIL_ON_ERROR=false check_runas_id_ret $myUID $myGID $myRUNAS || \ + { myRUNAS="" && myUID=$UID && myGID=`id -$USER`; } + chown $myUID:$myGID $BONDIR + $myRUNAS bonnie++ -f -r 0 -s$((SIZE / 1024)) -n 10 -u$myUID:$myGID -d$BONDIR $DEBUG_ON } run_test bonnie "bonnie++" @@ -105,7 +116,7 @@ test_iozone() { export O_DIRECT - IOZDIR=$MOUNT/d0.iozone + local IOZDIR=$DIR/d0.iozone mkdir -p $IOZDIR $LFS setstripe -c -1 $IOZDIR sync @@ -119,9 +130,11 @@ test_iozone() { # $SPACE was calculated with all OSTs $DEBUG_OFF myUID=$RUNAS_ID + myGID=$RUNAS_GID myRUNAS=$RUNAS - FAIL_ON_ERROR=false check_runas_id_ret $myUID $myUID $myRUNAS || { myRUNAS="" && myUID=$UID; } - chown $myUID:$myUID $IOZDIR + FAIL_ON_ERROR=false check_runas_id_ret $myUID $myGID $myRUNAS || \ + { myRUNAS="" && myUID=$UID && myGID=`id -g $USER`; } + chown $myUID:$myGID $IOZDIR $myRUNAS iozone $IOZONE_OPTS -s $SIZE -f $IOZFILE 2>&1 | tee $IOZLOG tail -1 $IOZLOG | grep -q complete || \ { error "iozone (1) failed" && return 1; } @@ -130,12 +143,12 @@ test_iozone() { # check if O_DIRECT support is implemented in kernel if [ -z "$O_DIRECT" ]; then - touch $MOUNT/f.iozone - if ! ./directio write $MOUNT/f.iozone 0 1; then + touch $DIR/f.iozone + if ! $DIRECTIO write $DIR/f.iozone 0 1; then log "SKIP iozone DIRECT IO test" O_DIRECT=no fi - rm -f $MOUNT/f.iozone + rm -f $DIR/f.iozone fi if [ "$O_DIRECT" != "no" -a "$IOZONE_DIR" != "no" ]; then $DEBUG_OFF @@ -172,17 +185,20 @@ test_iozone() { run_test iozone "iozone" test_fsx() { + local testfile=$DIR/f0.fsxfile FSX_SIZE=$SIZE FSX_COUNT=1000 local SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'` [ $SPACE -lt $FSX_SIZE ] && FSX_SIZE=$((SPACE * 3 / 4)) $DEBUG_OFF FSX_SEED=${FSX_SEED:-$RANDOM} - rm -f $MOUNT/fsxfile - $LFS setstripe -c -1 $MOUNT/fsxfile - echo Using FSX_SEED=$FSX_SEED FSX_SIZE=$FSX_SIZE FSX_COUNT=$FSX_COUNT - fsx -c 50 -p 1000 -S $FSX_SEED -P $TMP -l $FSX_SIZE \ - -N $(($FSX_COUNT * 100)) $MOUNT/fsxfile + rm -f $testfile + $LFS setstripe -c -1 $testfile + CMD="fsx -c 50 -p 1000 -S $FSX_SEED -P $TMP -l $FSX_SIZE \ + -N $((FSX_COUNT * 100)) $FSXOPT $testfile" + echo "Using: $CMD" + $CMD || error "fsx failed" + rm -f $testfile $DEBUG_ON } run_test fsx "fsx" @@ -205,22 +221,45 @@ iterpr_KMGT () { echo $num } -space_check () { - # space estimation +pios_file_size () { + # pios.c: check_device_size () # /* Adding 10% to total test size for filesystem overhead */ - # size = size + (double)(size) * (double) (0.1); - # - # total_test_size = runarg->stream[n - 1].max_offset + - # runarg->regionsize; + # size = size + (double)(size) * (double) (0.1); + # pios.c: set_actual_streams () + # total_test_size = runarg->regioncount * runarg->regionsize - local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }') local size=$(($(iterpr_KMGT $pios_REGIONCOUNT) * \ - $(iterpr_KMGT $pios_OFFSET) + \ $(iterpr_KMGT $pios_REGIONSIZE) )) + echo $size +} + +space_check () { + local testdir=$DIR/$tdir + local stripe=$($LFS getstripe -c $testdir) + + # if stripe_count = 1 the size should be less than min ost size, bug 24294 + local space=$(lfs_df $testdir | grep "summary" | awk '{print $4}') + [ $stripe -eq 1 ] && space=$(min_ost_size) + + local size=$(pios_file_size) size=$(( size + size / 10 )) - if [ $((space * 1024)) -le $size ]; then - echo "Need free space atleast $size, have $((space * 1024))" - return 10 + # we can not use pios --cleanup|-x because we need the files exist for pios --verify, + # so, we need space available for each of pios_THREADCOUNT value run + local num_runs=$(echo ${pios_THREADCOUNT//,/ } | wc -w) + size=$(( size * $num_runs)) + space=$((space * 1024)) + echo size=$size space=$space + if [ $space -le $size ]; then + local ratio=$(( size / space + 1 )) + echo "Need free space atleast $size, available $space, ratio=$ratio" + local rgcount=$(( pios_REGIONCOUNT / ratio )) + echo "reducing pios_REGIONCOUNT=$pios_REGIONCOUNT on $ratio" + if [ $rgcount -eq 0 ]; then + echo "fs is too small, reduced pios_REGIONCOUNT=$rgcount" + return 10 + fi + pios_REGIONCOUNT=$(( pios_REGIONCOUNT / ratio )) + echo using pios_REGIONCOUNT=$pios_REGIONCOUNT size=$(pios_file_size) fi } @@ -231,20 +270,24 @@ pios_setup() { stripes=1 [ "$1" == "--stripe" ] && stripes=-1 $LFS setstripe $testdir -c $stripes - echo "Test directory stripe count: $stripes" + echo "Test directory $testdir stripe count: $stripes" } pios_cleanup() { - local rc=$1 + local rc=${1:-0} local testdir=$DIR/$tdir - [ $rc = 0 ] && rm -rf $testdir + if [ $rc -eq 0 ]; then + echo cleanup: testdir=$testdir rc=$rc + rm -rf $testdir + wait_delete_completed || true + fi } run_pios () { local testdir=$DIR/$tdir local cmd="$PIOSBIN -t $pios_THREADCOUNT -n $pios_REGIONCOUNT \ -c $pios_CHUNKSIZE -s $pios_REGIONSIZE \ - -o $pios_OFFSET $@ -p $testdir" + -o $pios_OFFSET $@ -p $testdir" if [ ! -d $testdir ]; then error "No test directory created, setup_pios must have failed" @@ -267,8 +310,12 @@ test_pios_ssf() { fi local rc=0 - space_check || { skip_env "not enough space" && return 0; } pios_setup --stripe || return + if ! space_check; then + skip_env "not enough space" + pios_cleanup + return 0 + fi run_pios || return run_pios --verify || rc=$? pios_cleanup $rc @@ -283,8 +330,12 @@ test_pios_fpp() { fi local rc=0 - space_check || { skip_env "not enough space" && return 0; } pios_setup || return + if ! space_check; then + skip_env "not enough space" + pios_cleanup + return 0 + fi run_pios -L fpp || return run_pios -L fpp --verify || rc=$? pios_cleanup $rc @@ -292,6 +343,6 @@ test_pios_fpp() { } run_test pios_fpp "pios file per process" -equals_msg `basename $0`: test complete, cleaning up +complete $SECONDS check_and_cleanup_lustre -[ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true +exit_status