Whamcloud - gitweb
LU-15474 test: facet_failover() should mount all facets concurrently
[fs/lustre-release.git] / lustre / tests / sanity-benchmark.sh
index 46aa92f..35a58fc 100644 (file)
@@ -8,14 +8,18 @@ set -e
 
 ONLY=${ONLY:-"$*"}
 
-LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
+LUSTRE=${LUSTRE:-$(dirname $0)/..}
 . $LUSTRE/tests/test-framework.sh
 init_test_env $@
-. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
 init_logging
 
+ALWAYS_EXCEPT="$SANITY_BENCHMARK_EXCEPT"
+[ "$SLOW" = "no" ] && EXCEPT_SLOW="iozone"
+
+build_test_filter
+
 MAX_THREADS=${MAX_THREADS:-20}
-RAMKB=`awk '/MemTotal:/ { print $2 }' /proc/meminfo`
+RAMKB=$(awk '/MemTotal:/ { print $2 }' /proc/meminfo)
 if [ -z "$THREADS" ]; then
        THREADS=$((RAMKB / 16384))
        [ $THREADS -gt $MAX_THREADS ] && THREADS=$MAX_THREADS
@@ -26,20 +30,8 @@ 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)}
-
-pios_THREADCOUNT=${pios_THREADCOUNT:-"1,8,40"}
-[ "$SLOW" = "no" ] && pios_THREADCOUNT=8
-
-pios_REGIONCOUNT=${pios_REGIONCOUNT:-1024}
-pios_CHUNKSIZE=${pios_CHUNKSIZE:-1M}
-pios_REGIONSIZE=${pios_REGIONSIZE:-8M}
-pios_OFFSET=${pios_OFFSET:-16M}
-
-[ "$SLOW" = "no" ] && EXCEPT_SLOW="iozone"
-
-build_test_filter
 check_and_setup_lustre
 
 assert_DIR
@@ -59,9 +51,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
@@ -92,10 +86,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++"
@@ -109,6 +105,7 @@ test_iozone() {
     export O_DIRECT
     
     local IOZDIR=$DIR/d0.iozone
+    wait_delete_completed || true
     mkdir -p $IOZDIR
     $LFS setstripe -c -1 $IOZDIR
     sync
@@ -122,23 +119,27 @@ 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; }
     rm -f $IOZLOG
+    wait_delete_completed || true
     $DEBUG_ON
     
     # check if O_DIRECT support is implemented in kernel
     if [ -z "$O_DIRECT" ]; then
        touch $DIR/f.iozone
-       if ! ./directio write $DIR/f.iozone 0 1; then
+       if ! $DIRECTIO write $DIR/f.iozone 0 1; then
            log "SKIP iozone DIRECT IO test"
            O_DIRECT=no
        fi
        rm -f $DIR/f.iozone
+       wait_delete_completed || true
     fi
     if [ "$O_DIRECT" != "no" -a "$IOZONE_DIR" != "no" ]; then
        $DEBUG_OFF
@@ -146,6 +147,7 @@ test_iozone() {
        tail -1 $IOZLOG | grep -q complete || \
            { error "iozone (2) failed" && return 1; }
        rm -f $IOZLOG
+       wait_delete_completed || true
        $DEBUG_ON
     fi
 
@@ -166,6 +168,7 @@ test_iozone() {
        tail -1 $IOZLOG | grep -q complete || \
            { error "iozone (3) failed" && return 1; }
        rm -f $IOZLOG
+       wait_delete_completed || true
        $DEBUG_ON
     elif [ $IOZVER -lt 3145 ]; then
        VER=`iozone -v | awk '/Revision:/ { print $3 }'`
@@ -175,127 +178,52 @@ 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 $testfile
-    $LFS setstripe -c -1 $testfile
-    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)) $DIR/fsxfile
-    $DEBUG_ON
-}
-run_test fsx "fsx"
-
+       local testfile=$DIR/f0.fsxfile
+       FSX_SIZE=$SIZE
+       FSX_COUNT=1000
+       local SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
 
-############################################################
-# PIOS
-#
+       check_set_fallocate
 
-iterpr_KMGT () {
-    local str=$1
-    local num=${str:0:${#str}-1}
-    case ${str:${#str}-1} in
-        k|K ) num=$((num << 10));; #
-        m|M ) num=$((num << 20));; # emacs is confsued by the <<  and
-        g|G ) num=$((num << 30));; # these comments help it out.
-        t|T ) num=$((num << 40));; #
-          * ) num=$str;;
-    esac
-    echo $num
-}
-
-space_check () {
-    # space estimation
-    # /* 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;
-
-    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) ))
-    size=$(( size + size / 10 ))
-    if [ $((space * 1024)) -le $size ]; then 
-        echo "Need free space atleast $size, have $((space * 1024))"
-        return 10
-    fi
-}
-
-pios_setup() { 
-    local testdir=$DIR/$tdir
-    mkdir -p $testdir
-
-    stripes=1
-    [ "$1" == "--stripe" ] && stripes=-1
-    $LFS setstripe $testdir -c $stripes
-    echo "Test directory stripe count: $stripes"
-}
-
-pios_cleanup() {
-    local rc=$1
-    local testdir=$DIR/$tdir
-    [ $rc = 0 ] && rm -rf $testdir
-}
-
-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"
-    
-    if [ ! -d $testdir ]; then  
-        error "No test directory created, setup_pios must have failed"
-        return 20
-    fi
-
-    log "$cmd"
-
-    local rc=0
-    eval $cmd
-    rc=$?
-
-    return $rc
-}
-
-test_pios_ssf() {
-    if  [ -z "$PIOSBIN" ]; then
-        skip_env "$0 : pios not found PIOSBIN=$PIOSBIN"
-       return
-    fi
-
-    local rc=0
-    space_check || { skip_env "not enough space" && return 0; }
-    pios_setup --stripe || return
-    run_pios || return
-    run_pios  --verify || rc=$? 
-    pios_cleanup $rc
-    return $rc
+       [ $SPACE -lt $FSX_SIZE ] && FSX_SIZE=$((SPACE * 3 / 4))
+       $DEBUG_OFF
+       FSX_SEED=${FSX_SEED:-$RANDOM}
+       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 pios_ssf "pios shared single file"
-
-test_pios_fpp() {
-    if  [ -z "$PIOSBIN" ]; then
-        skip_env "pios not found PIOSBIN=$PIOSBIN"
-        return
-    fi
+run_test fsx "fsx"
 
-    local rc=0
-    space_check || { skip_env "not enough space" && return 0; }
-    pios_setup || return
-    run_pios -L fpp || return
-    run_pios -L fpp --verify || rc=$?
-    pios_cleanup $rc
-    return $rc
+test_fsx_partial_punch() {
+       local fsx_count=100000
+       local testfile=$DIR/f0.fsxfile
+       local fsx_size=5407677 # upper bound file size
+       local fsx_seed=7919
+
+       check_set_fallocate
+
+       rm -f $testfile
+       $LFS setstripe -c -1 $testfile
+
+       #
+       # $fsx_seed, $fsx_count and $fsx_size combination almost
+       # always reproduces the LASSERT under LU-14640. Therefore these
+       # constants are used as reproducer vs using a random value and
+       # hoping it hits the error condition
+       #
+       CMD="$FSX -c 50 -p 1000 -S $fsx_seed -P $TMP -l $fsx_size \
+            -N $fsx_count $testfile"
+       echo "Using: $CMD"
+       $CMD || error "fsx failed"
+       rm -f $testfile
 }
-run_test pios_fpp "pios file per process"
+run_test fsx_partial_punch "Verify fsx with partial punch via fallocate"
 
-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