X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fsanity-quota.sh;h=d548db42ec586e6d17d4482206a9993d149a3ba7;hb=1f0cc0be3202a2d129ca0ba0d01a363bd5bc308a;hp=09184c96e972306d1fb776a57a06c25397cdfe87;hpb=7d3ca089df3483440fc35964361e77773be4daf8;p=fs%2Flustre-release.git diff --git a/lustre/tests/sanity-quota.sh b/lustre/tests/sanity-quota.sh index 09184c9..d548db4 100644 --- a/lustre/tests/sanity-quota.sh +++ b/lustre/tests/sanity-quota.sh @@ -16,16 +16,8 @@ fi SRCDIR=`dirname $0` export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/../utils:$PATH:/sbin -if [ "$1" == "9_10" ]; then - echo "only run for test9 and test10" - shift - TEST_9_10=1 - ONLY="9 10" -else - TEST_9_10=0 -fi ONLY=${ONLY:-"$*"} -ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-""} +ALWAYS_EXCEPT="$SANITY_QUOTA_EXCEPT" # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT! case `uname -r` in @@ -56,99 +48,17 @@ ITUNE_SZ=${ITUNE_SZ:-5} # default 50% of IUNIT_SZ MAX_DQ_TIME=604800 MAX_IQ_TIME=604800 -log() { - echo "$*" - $LCTL mark "$*" 2> /dev/null || true -} - -trace() { - log "STARTING: $*" - strace -o $TMP/$1.strace -ttt $* - RC=$? - log "FINISHED: $*: rc $RC" - return 1 -} TRACE=${TRACE:-""} +LUSTRE=${LUSTRE:-`dirname $0`/..} +. $LUSTRE/tests/test-framework.sh +init_test_env $@ +. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh} -run_one() { - BEFORE=`date +%s` - log "== test $1: $2= `date +%H:%M:%S` ($BEFORE)" - export TESTNAME=test_$1 - test_$1 || error "exit with rc=$?" - unset TESTNAME - pass "($((`date +%s` - $BEFORE))s)" - cd $SAVE_PWD -} - -build_test_filter() { - [ "$ALWAYS_EXCEPT$EXCEPT$SANITY_EXCEPT" ] && \ - echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT $SANITY_QUOTA_EXCEPT`" - - for O in $ONLY; do - eval ONLY_${O}=true - done - for E in $EXCEPT $ALWAYS_EXCEPT $SANITY_QUOTA_EXCEPT; do - eval EXCEPT_${E}=true - done - # turn on/off quota tests must be included - eval ONLY_0=true - eval ONLY_99=true -} - -_basetest() { - echo $* -} - -basetest() { - IFS=abcdefghijklmnopqrstuvwxyz _basetest $1 -} - -run_test() { - base=`basetest $1` - if [ "$ONLY" ]; then - testname=ONLY_$1 - if [ ${!testname}x != x ]; then - run_one $1 "$2" - return $? - fi - testname=ONLY_$base - if [ ${!testname}x != x ]; then - run_one $1 "$2" - return $? - fi - echo -n "." - return 0 - fi - testname=EXCEPT_$1 - if [ ${!testname}x != x ]; then - echo "skipping excluded test $1" - return 0 - fi - testname=EXCEPT_$base - if [ ${!testname}x != x ]; then - echo "skipping excluded test $1 (base $base)" - return 0 - fi - run_one $1 "$2" - return $? -} +QUOTALOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log} +FAIL_ON_ERROR=false [ "$QUOTALOG" ] && rm -f $QUOTALOG || true -error() { - sysctl -w lustre.fail_loc=0 - log "FAIL: $TESTNAME $@" - if [ "$QUOTALOG" ]; then - echo "FAIL: $TESTNAME $@" >> $QUOTALOG - else - exit 1 - fi -} - -pass() { - echo PASS $@ -} - mounted_lustre_filesystems() { awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts | sed -n ${1}p } @@ -158,9 +68,7 @@ MOUNT_HINT=$MOUNT MOUNT_HINT2=$MOUNT_2 MOUNT="`mounted_lustre_filesystems 1`" MOUNT_2="`mounted_lustre_filesystems 2`" -if [ $TEST_9_10 -eq 1 -a "$MOUNT" ]; then - echo "test9 and test10 will run on $MOUNT" -elif [ "$MOUNT" -a "$MOUNT_2" ]; then +if [ "$MOUNT" -a "$MOUNT_2" ]; then echo "testing on $MOUNT and $MOUNT_2" elif [ "$MOUNT" -o "$MOUNT_2" ]; then error "test needs two mounts, only found $MOUNT $MOUNT_2!" @@ -183,13 +91,8 @@ DIR=${DIR:-$MOUNT} [ -z "`echo $DIR | grep $MOUNT`" ] && echo "$DIR not in $MOUNT" && exit 99 DIR2=${DIR2:-$MOUNT_2} -LPROC=/proc/fs/lustre LOVNAME=`cat $LPROC/llite/*/lov/common_name | tail -n 1` -if [ $TEST_9_10 -eq 1 ]; then - OSTCOUNT=2 -else - OSTCOUNT=`cat $LPROC/lov/$LOVNAME/numobd` -fi +OSTCOUNT=`cat $LPROC/lov/$LOVNAME/numobd` STRIPECOUNT=`cat $LPROC/lov/$LOVNAME/stripecount` STRIPESIZE=`cat $LPROC/lov/$LOVNAME/stripesize` ORIGFREE=`cat $LPROC/lov/$LOVNAME/kbytesavail` @@ -203,6 +106,8 @@ SHOW_QUOTA_INFO="$LFS quota -t $MOUNT" build_test_filter +eval ONLY_0=true +eval ONLY_99=true # set_blk_tunables(btune_sz) set_blk_tunesz() { @@ -263,9 +168,7 @@ pre_test() { set_file_unitsz $IUNIT_SZ fi } -if [ $TEST_9_10 -eq 0 ]; then - pre_test -fi +pre_test post_test() { if [ -z "$NOSETUP" ]; then @@ -613,7 +516,7 @@ run_test 5 "Chown & chgrp successfully even out of block/file quota ===" # block quota acquire & release test_6() { if [ $OSTCOUNT -lt 2 ]; then - echo "WARN: too few osts, skip this test." + skip "$OSTCOUNT < 2, too few osts" return 0; fi @@ -674,10 +577,7 @@ run_test 6 "Block quota acquire & release =========" # quota recovery (block quota only by now) test_7() { - if [ -z "`lsmod|grep mds`" ]; then - echo "WARN: no local mds, skip this test" - return 0 - fi + remote_mds && skip "remote mds" LIMIT=$(( $BUNIT_SZ * $(($OSTCOUNT + 1)) * 10)) # 10 bunits each sever TESTFILE="$TSTDIR/quota_tst70" @@ -712,8 +612,8 @@ test_7() [ $TOTAL_LIMIT -eq $LIMIT ] || error "total limits not recovery!" echo " total limits = $TOTAL_LIMIT" - OST0_UUID=`$LCTL dl | awk '$3 ~ /obdfilter/ { print $5 }'| head -n1` - [ -z "$OST0_UUID" ] && OST0_UUID=`$LCTL dl | awk '$3 ~ /obdfilter/ { print $5 }'|head -n1` + OST0_UUID=`do_facet ost1 "$LCTL dl | grep -m1 obdfilter" | awk '{print $((NF-1))}'` + [ -z "$OST0_UUID" ] && OST0_UUID=`do_facet ost1 "$LCTL dl | grep -m1 obdfilter" | awk '{print $((NF-1))}'` OST0_LIMIT="`$LFS quota -o $OST0_UUID -u $TSTUSR $MOUNT | awk '/^.*[[:digit:]+][[:space:]+]/ { print $3 }'`" [ $OST0_LIMIT -eq $BUNIT_SZ ] || error "high limits not released!" echo " limits on $OST0_UUID = $OST0_LIMIT" @@ -729,7 +629,7 @@ test_8() { FILE_LIMIT=1000000 DBENCH_LIB=${DBENCH_LIB:-/usr/lib/dbench} - [ ! -d $DBENCH_LIB ] && echo "dbench not installed, skip this test" && return 0 + [ ! -d $DBENCH_LIB ] && skip "dbench not installed" && return 0 echo " Set enough high limit for user: $TSTUSR" $LFS setquota -u $TSTUSR 0 $BLK_LIMIT 0 $FILE_LIMIT $MOUNT @@ -760,23 +660,25 @@ test_9() { size_file=$((1024 * 1024 * 9 / 2 * $OSTCOUNT)) echo "lustrefs_size:$lustrefs_size size_file:$size_file" if [ $lustrefs_size -lt $size_file ]; then - echo "WARN: less than $size_file free, skip this test." + skip "less than $size_file free" return 0; fi + set_blk_unitsz $((1024 * 100)) + set_blk_tunesz $((1024 * 50)) + # set the D_QUOTA flag - DBG_SAVE="`sysctl -n lnet.debug`" - sysctl -w lnet.debug="$DBG_SAVE quota" + debugsave + sysctl -w lnet.debug="+quota" TESTFILE="$TSTDIR/quota_tst90" - echo " Set block limit $LIMIT kbytes to $TSTUSR.$TSTUSR" BLK_LIMIT=$((100 * 1024 * 1024)) # 100G FILE_LIMIT=1000000 - echo " Set enough high limit for user: $TSTUSR" + echo " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for user: $TSTUSR" $LFS setquota -u $TSTUSR 0 $BLK_LIMIT 0 $FILE_LIMIT $MOUNT - echo " Set enough high limit for group: $TSTUSR" + echo " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for group: $TSTUSR" $LFS setquota -g $TSTUSR 0 $BLK_LIMIT 0 $FILE_LIMIT $MOUNT echo " Set stripe" @@ -784,12 +686,21 @@ test_9() { touch $TESTFILE chown $TSTUSR.$TSTUSR $TESTFILE + $SHOW_QUOTA_USER + $SHOW_QUOTA_GROUP + echo " Write the big file of $(($OSTCOUNT * 9 / 2 ))G ..." $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$size_file || error "(usr) write $((9 / 2 * $OSTCOUNT))G file failure, but expect success" + $SHOW_QUOTA_USER + $SHOW_QUOTA_GROUP + echo " delete the big file of $(($OSTCOUNT * 9 / 2))G..." $RUNAS rm -f $TESTFILE + $SHOW_QUOTA_USER + $SHOW_QUOTA_GROUP + echo " write the big file of 2G..." $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$((1024 * 1024 * 2)) || error "(usr) write $((9 / 2 * $OSTCOUNT))G file failure, but expect seccess" @@ -797,7 +708,10 @@ test_9() { $RUNAS rm -f $TESTFILE RC=$? - sysctl -w lnet.debug="$DBG_SAVE" + set_blk_tunesz $BTUNE_SZ + set_blk_unitsz $BUNIT_SZ + + debugrestore return $RC } run_test 9 "run for fixing bug10707(64bit) ===========" @@ -808,36 +722,35 @@ test_10() { size_file=$((1024 * 1024 * 9 / 2 * $OSTCOUNT)) echo "lustrefs_size:$lustrefs_size size_file:$size_file" if [ $lustrefs_size -lt $size_file ]; then - echo "WARN: less than $size_file free, skip this test." + skip "less than $size_file free" return 0; fi if [ ! -d /proc/fs/lustre/ost/ -o ! -d /proc/fs/lustre/mds ]; then - echo "WARN: mds or ost isn't local, skip this test." + skip "mds or ost isn't local" return 0; fi sync; sleep 10; sync; - # set the D_QUOTA flag - set_flag=0 - if [ -z "`sysctl lnet.debug | grep quota`" ]; then - sysctl -w lnet.debug="+quota" - set_flag=1 - fi + set_blk_unitsz $((1024 * 100)) + set_blk_tunesz $((1024 * 50)) + # set the D_QUOTA flag + debugsave + sysctl -w lnet.debug="+quota" + # make qd_count 32 bit sysctl -w lustre.fail_loc=0xA00 TESTFILE="$TSTDIR/quota_tst100" - echo " Set block limit $LIMIT kbytes to $TSTUSR.$TSTUSR" BLK_LIMIT=$((100 * 1024 * 1024)) # 100G FILE_LIMIT=1000000 - echo " Set enough high limit for user: $TSTUSR" + echo " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for user: $TSTUSR" $LFS setquota -u $TSTUSR 0 $BLK_LIMIT 0 $FILE_LIMIT $MOUNT - echo " Set enough high limit for group: $TSTUSR" + echo " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for group: $TSTUSR" $LFS setquota -g $TSTUSR 0 $BLK_LIMIT 0 $FILE_LIMIT $MOUNT echo " Set stripe" @@ -845,12 +758,21 @@ test_10() { touch $TESTFILE chown $TSTUSR.$TSTUSR $TESTFILE + $SHOW_QUOTA_USER + $SHOW_QUOTA_GROUP + echo " Write the big file of $(($OSTCOUNT * 9 / 2 ))G ..." $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$size_file || error "(usr) write $((9 / 2 * $OSTCOUNT))G file failure, but expect success" + $SHOW_QUOTA_USER + $SHOW_QUOTA_GROUP + echo " delete the big file of $(($OSTCOUNT * 9 / 2))G..." $RUNAS rm -f $TESTFILE + $SHOW_QUOTA_USER + $SHOW_QUOTA_GROUP + echo " write the big file of 2G..." $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$((1024 * 1024 * 2)) || error "(usr) write $((9 / 2 * $OSTCOUNT))G file failure, but expect success" @@ -860,13 +782,14 @@ test_10() { RC=$? # clear the flage - if [ $set_flag -eq 1 ]; then - sysctl -w lnet.debug="-quota" - fi + debugrestore # make qd_count 64 bit sysctl -w lustre.fail_loc=0 + set_blk_tunesz $BTUNE_SZ + set_blk_unitsz $BUNIT_SZ + return $RC } run_test 10 "run for fixing bug10707(32bit) ===========" @@ -1050,6 +973,56 @@ test_13() { } run_test 13 "test multiple clients write block quota ===" +check_if_quota_zero(){ + line=`$LFS quota -$1 $2 $MOUNT | wc -l` + for i in `seq 3 $line`; do + for j in 3 4 6 7; do + tmp=`$LFS quota -$1 $2 $MOUNT | sed -n ${i}p | + awk '{print $'"$j"'}'` + [ -n "$tmp" ] && [ $tmp -ne 0 ] && $LFS quota -$1 $2 $MOUNT && \ + error "quota on $1 isn't clean" + done + done + echo "pass check_if_quota_zero" +} + +# test setting quota on root, b=12223 +test_13(){ + TESTFILE="$TSTDIR/quota_tst13" + + # reboot the lustre + cd $T_PWD; sh llmountcleanup.sh || error "llmountcleanup failed" + sh llmount.sh + pre_test + setup + run_test 0 "reboot lustre" + + # out of root's file and block quota + $LFS setquota -u root 10 10 10 10 $MOUNT + createmany -m ${TESTFILE} 20 || \ + error "unexpected: user(root) create files failly!" + dd if=/dev/zero of=$TESTFILE bs=4k count=4096 || \ + error "unexpected: user(root) write files failly!" + chmod 666 $TESTFILE + $RUNAS dd if=/dev/zero of=${TESTFILE} seek=4096 bs=4k count=4096 && \ + error "unexpected: user(quota_usr) write a file successfully!" + + # trigger the llog + chmod 777 $MOUNT + for i in `seq 1 10`; do $RUNAS touch ${TESTFILE}a_$i; done + for i in `seq 1 10`; do $RUNAS rm -f ${TESTFILE}a_$i; done + + # do the check + dmesg | tail | grep "\-122" |grep llog_obd_origin_add && error "test_13 failed." + $LFS setquota -u root 0 0 0 0 $MOUNT + #check_if_quota_zero u root + + # clean + unlinkmany ${TESTFILE} 15 + rm -f $TESTFILE +} +run_test 13 "test setting quota on root ===" + # turn off quota test_99() { @@ -1062,9 +1035,7 @@ run_test 99 "Quota off ===============================" log "cleanup: ======================================================" if [ "`mount | grep ^$NAME`" ]; then rm -fr $TSTDIR - if [ $TEST_9_10 -eq 0 ]; then post_test - fi # delete test user and group userdel "$TSTUSR" userdel "$TSTUSR2" @@ -1074,5 +1045,5 @@ if [ "`mount | grep ^$NAME`" ]; then fi echo '=========================== finished ===============================' -[ -f "$QUOTALOG" ] && cat $QUOTALOG && exit 1 +[ -f "$QUOTALOG" ] && cat $QUOTALOG && grep -q FAIL $QUOTALOG && exit 1 || true echo "$0: completed"