diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index 9f75d8c2168925a26da190a514557c18cda268ff..eefca63022af4252f97d11f6effaee572fb2923b 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -37,6 +37,8 @@ OSTSIZE=40000 # [ "$SLOW" = "no" ] && EXCEPT_SLOW="0 1 2 3 6 7 15 18 24b 25 30 31 32 33 34a " +assert_DIR + reformat() { formatall } diff --git a/lustre/tests/recovery-small.sh b/lustre/tests/recovery-small.sh index dda094d6b4d0bb6421627b30ca84fe1c73851bcc..a7eaa84574c1ecea68e45d14998a926b1aed3e3a 100755 --- a/lustre/tests/recovery-small.sh +++ b/lustre/tests/recovery-small.sh @@ -23,6 +23,7 @@ SETUP=${SETUP:-""} CLEANUP=${CLEANUP:-""} cleanup_and_setup_lustre +assert_DIR rm -rf $DIR/[df][0-9]* test_1() { @@ -750,6 +751,7 @@ test_51() { run_test 51 "failover MDS during recovery" test_52_guts() { + do_facet client "mkdir -p $DIR/$tdir" do_facet client "writemany -q -a $DIR/$tdir/$tfile 300 5" & CLIENT_PID=$! echo writemany pid $CLIENT_PID diff --git a/lustre/tests/replay-dual.sh b/lustre/tests/replay-dual.sh index dd087a39717c05b73911770161a56a8a80f4c501..cf397cba533eec9bed547560eb73988790bf91db 100755 --- a/lustre/tests/replay-dual.sh +++ b/lustre/tests/replay-dual.sh @@ -23,6 +23,7 @@ init_test_env $@ build_test_filter cleanup_and_setup_lustre +assert_DIR rm -rf $DIR/[df][0-9]* [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE diff --git a/lustre/tests/replay-ost-single.sh b/lustre/tests/replay-ost-single.sh index b652b0f216fb045b042e8b7189f3415cce5c4e31..128f020e26137f87882473a1d9d0b1b03f7167ed 100755 --- a/lustre/tests/replay-ost-single.sh +++ b/lustre/tests/replay-ost-single.sh @@ -30,6 +30,7 @@ OSTCOUNT=1 build_test_filter REFORMAT=--reformat cleanup_and_setup_lustre +assert_DIR rm -rf $DIR/[df][0-9]* test_0a() { diff --git a/lustre/tests/replay-single.sh b/lustre/tests/replay-single.sh index 2902b8c592d4921eb68f50fc0eb4c28d8545996b..baab91dc2f345331084ee17a10cfd30347216e3d 100755 --- a/lustre/tests/replay-single.sh +++ b/lustre/tests/replay-single.sh @@ -29,6 +29,7 @@ cleanup_and_setup_lustre mkdir -p $DIR +assert_DIR rm -rf $DIR/[df][0-9]* test_0a() { # was test_0 @@ -147,7 +148,8 @@ test_5() { run_test 5 "|x| 220 open(O_CREAT)" -test_6a() { # was test_6a +test_6a() { # was test_6 + mkdir -p $DIR/$tdir replay_barrier mds mcreate $DIR/$tdir/$tfile fail mds @@ -159,6 +161,7 @@ test_6a() { # was test_6a run_test 6a "mkdir + contained create" test_6b() { + mkdir -p $DIR/$tdir replay_barrier mds rm -rf $DIR/$tdir fail mds @@ -167,6 +170,7 @@ test_6b() { run_test 6b "|X| rmdir" test_7() { + mkdir -p $DIR/$tdir replay_barrier mds mcreate $DIR/$tdir/$tfile fail mds @@ -1242,6 +1246,7 @@ run_test 57 "test recovery from llog for setattr op" #recovery many mds-ost setattr from llog test_58() { + mkdir -p $DIR/$tdir #define OBD_FAIL_MDS_OST_SETATTR 0x12c do_facet mds "lctl set_param fail_loc=0x8000012c" createmany -o $DIR/$tdir/$tfile-%d 2500 @@ -1258,6 +1263,7 @@ run_test 58 "test recovery from llog for setattr op (test llog_gen_rec)" # log_commit_thread vs filter_destroy race used to lead to import use after free # bug 11658 test_59() { + mkdir -p $DIR/$tdir createmany -o $DIR/$tdir/$tfile-%d 200 sync unlinkmany $DIR/$tdir/$tfile-%d 200 @@ -1274,6 +1280,7 @@ run_test 59 "test log_commit_thread vs filter_destroy race" # race between add unlink llog vs cat log init in post_recovery (only for b1_6) # bug 12086: should no oops and No ctxt error for this test test_60() { + mkdir -p $DIR/$tdir createmany -o $DIR/$tdir/$tfile-%d 200 replay_barrier mds unlinkmany $DIR/$tdir/$tfile-%d 0 100 @@ -1286,6 +1293,7 @@ run_test 60 "test llog post recovery init vs llog unlink" #test race llog recovery thread vs llog cleanup test_61a() { + mkdir -p $DIR/$tdir createmany -o $DIR/$tdir/$tfile-%d 800 replay_barrier ost1 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221 @@ -1324,6 +1332,7 @@ test_61c() { run_test 61c "test race mds llog sync vs llog cleanup" test_62() { # Bug 15756 - don't mis-drop resent replay + mkdir -p $DIR/$tdir replay_barrier mds createmany -o $DIR/$tdir/$tfile- 25 #define OBD_FAIL_TGT_REPLAY_DROP 0x707 diff --git a/lustre/tests/sanity-quota.sh b/lustre/tests/sanity-quota.sh index 7e2a9a2b75aa8ebdc5c3be319cf7edd743279471..e62a20f67c80bf6f4902b32576f2dacad134f901 100644 --- a/lustre/tests/sanity-quota.sh +++ b/lustre/tests/sanity-quota.sh @@ -156,6 +156,7 @@ run_test 0 "Set quota =============================" # test for specific quota limitation, qunit, qtune $1=block_quota_limit test_1_sub() { LIMIT=$1 + mkdir -p $DIR/$tdir chmod 0777 $DIR/$tdir TESTFILE="$DIR/$tdir/$tfile-0" @@ -244,6 +245,7 @@ run_test 1 "Block hard limit (normal use and out of quota) ===" # test for specific quota limitation, qunit, qtune $1=block_quota_limit test_2_sub() { LIMIT=$1 + mkdir -p $DIR/$tdir chmod 0777 $DIR/$tdir TESTFILE="$DIR/$tdir/$tfile-0" @@ -387,6 +389,7 @@ test_block_soft() { # block soft limit (start timer, timer goes off, stop timer) test_3() { + mkdir -p $DIR/$tdir chmod 0777 $DIR/$tdir # 1 bunit on mds and 1 bunit on every ost @@ -471,6 +474,7 @@ test_file_soft() { # file soft limit (start timer, timer goes off, stop timer) test_4a() { # was test_4 + mkdir -p $DIR/$tdir chmod 0777 $DIR/$tdir LIMIT=$(($IUNIT_SZ * 10)) # 10 iunits on mds TESTFILE=$DIR/$tdir/$tfile-0 @@ -530,6 +534,7 @@ run_test 4b "Grace time strings handling ===" # chown & chgrp (chown & chgrp successfully even out of block/file quota) test_5() { + mkdir -p $DIR/$tdir BLIMIT=$(( $BUNIT_SZ * $((OSTCOUNT + 1)) * 10)) # 10 bunits on each server ILIMIT=$(( $IUNIT_SZ * 10 )) # 10 iunits on mds @@ -570,6 +575,7 @@ test_6() { wait_delete_completed + mkdir -p $DIR/$tdir chmod 0777 $DIR/$tdir LIMIT=$((BUNIT_SZ * (OSTCOUNT + 1) * 5)) # 5 bunits per server @@ -631,6 +637,7 @@ run_test 6 "Block quota acquire & release =========" # quota recovery (block quota only by now) test_7() { + mkdir -p $DIR/$tdir chmod 0777 $DIR/$tdir remote_mds && skip "remote mds" && return 0 @@ -682,6 +689,7 @@ run_test 7 "Quota recovery (only block limit) ======" # run dbench with quota enabled test_8() { + mkdir -p $DIR/$tdir BLK_LIMIT=$((100 * 1024 * 1024)) # 100G FILE_LIMIT=1000000 DBENCH_LIB=${DBENCH_LIB:-/usr/lib/dbench} @@ -746,6 +754,7 @@ test_9() { set_blk_tunesz 512 set_blk_unitsz 1024 + mkdir -p $DIR/$tdir chmod 0777 $DIR/$tdir TESTFILE="$DIR/$tdir/$tfile-0" @@ -791,6 +800,7 @@ run_test 9 "run for fixing bug10707(64bit) ===========" # run for fixing bug10707, it need a big room. test for 32bit test_10() { + mkdir -p $DIR/$tdir chmod 0777 $DIR/$tdir check_whether_skip && return 0 @@ -871,12 +881,12 @@ test_11() { local i=1 while [ $i -le $REPS ]; do echo "test: cycle($i of $REPS) start at $(date)" - mkdir -p $DIR/$tdir && chmod 777 $DIR/$tdir + mkdir -p $TESTDIR && chmod 777 $TESTDIR echo -n " create a file for uid " for j in `seq 1 30`; do echo -n "$j " # 30MB per dd for a total of 900MB (if space even permits) - runas -u $j dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$blksize count=15 > /dev/null 2>&1 & + runas -u $j dd if=/dev/zero of=$TESTDIR/$tfile bs=$blksize count=15 > /dev/null 2>&1 & done echo "" PROCS=$(ps -ef | grep -v grep | grep "dd if /dev/zero of $TESTDIR" | wc -l) @@ -885,11 +895,11 @@ test_11() { sleep 20 SECS=$((SECS + sleep)) PROCS=$(ps -ef | grep -v grep | grep "dd if /dev/zero of $TESTDIR" | wc -l) - USED=$(du -s $DIR/$tdir | awk '{print $1}') + USED=$(du -s $TESTDIR | awk '{print $1}') PCT=$(($USED * 100 / $block_limit)) echo "${i}/${REPS} ${PCT}% p${PROCS} t${SECS} " if [ $USED -le $LAST_USED ]; then - kill -9 $(ps -ef | grep "dd if /dev/zero of $DIR/$tdir" | grep -v grep | awk '{ print $2 }') + kill -9 $(ps -ef | grep "dd if /dev/zero of $TESTDIR" | grep -v grep | awk '{ print $2 }') i=$REPS RV=2 break @@ -897,7 +907,7 @@ test_11() { LAST_USED=$USED done echo " removing the test files..." - rm -f $DIR/$tdir/$tfile + rm -f $TESTDIR/$tfile echo "cycle $i done at $(date)" i=$[$i+1] done @@ -918,6 +928,7 @@ run_test 11 "run for fixing bug10912 ===========" # test a deadlock between quota and journal b=11693 test_12() { + mkdir -p $DIR/$tdir chmod 0777 $DIR/$tdir [ "$(grep $DIR2 /proc/mounts)" ] || mount_client $DIR2 || \ @@ -988,7 +999,8 @@ run_test 12 "test a deadlock between quota and journal ===" # test multiple clients write block quota b=11693 test_13() { - wait_delete_completed + mkdir -p $DIR/$tdir + wait_delete_completed # one OST * 10 + (mds + other OSTs) LIMIT=$((BUNIT_SZ * 10 + (BUNIT_SZ * OSTCOUNT))) @@ -1078,6 +1090,7 @@ pre_test_14 test_14a() { # was test_14 b=12223 -- setting quota on root TESTFILE="$DIR/$tdir/$tfile" + mkdir -p $DIR/$tdir # out of root's file and block quota $LFS setquota -u root 10 10 10 10 $DIR @@ -1186,6 +1199,7 @@ run_test 15 "set block quota more than 4T ===" test_16_tub() { LIMIT=$(( $BUNIT_SZ * $(($OSTCOUNT + 1)) * 4)) TESTFILE="$DIR/$tdir/$tfile" + mkdir -p $DIR/$tdir wait_delete_completed @@ -1254,6 +1268,7 @@ test_17() { TESTFILE="$DIR/$tdir/$tfile-a" TESTFILE2="$DIR/$tdir/$tfile-b" + mkdir -p $DIR/$tdir BLK_LIMIT=$((100 * 1024)) # 100M @@ -1303,6 +1318,7 @@ run_test 17 "run for fixing bug14526 ===========" test_18() { LIMIT=$((100 * 1024 * 1024)) # 100G TESTFILE="$DIR/$tdir/$tfile" + mkdir -p $DIR/$tdir wait_delete_completed @@ -1358,6 +1374,7 @@ run_test 18 "run for fixing bug14840 ===========" test_18a() { LIMIT=$((100 * 1024 * 1024)) # 100G TESTFILE="$DIR/$tdir/$tfile-a" + mkdir -p $DIR/$tdir wait_delete_completed @@ -1414,6 +1431,7 @@ test_19() { # 1 Mb bunit per each MDS/OSS LIMIT=$((($OSTCOUNT + 1) * 1024)) TESTFILE="$DIR/$tdir/$tfile" + mkdir -p $DIR/$tdir wait_delete_completed diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index cd09890d6f7035a379331fafbdba0f8d3a1b6f31..d03c71f76f40e7f01a8b277d953901f69a56492c 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -106,7 +106,7 @@ fi check_and_setup_lustre DIR=${DIR:-$MOUNT} -[ -z "`echo $DIR | grep $MOUNT`" ] && echo "$DIR not in $MOUNT" && exit 99 +assert_DIR LOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1` OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd` @@ -493,6 +493,7 @@ run_test 21 "write to dangling link ============================" test_22() { WDIR=$DIR/$tdir + mkdir -p $WDIR chown $RUNAS_ID $WDIR (cd $WDIR || error "cd $WDIR failed"; $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \ @@ -759,6 +760,7 @@ run_test 26e "unlink multiple component recursive symlink ======" # recursive symlinks (bug 7022) test_26f() { + mkdir -p $DIR/$tdir mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed" cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed" mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed" @@ -1768,6 +1770,7 @@ test_42d() { run_test 42d "test complete truncate of file with cached dirty data" test_43() { + mkdir -p $DIR/$tdir cp -p /bin/ls $DIR/$tdir/$tfile multiop $DIR/$tdir/$tfile Ow_c & pid=$! @@ -2797,7 +2800,7 @@ run_test 66 "update inode blocks count on client ===============" test_67a() { # was test_67 bug 3285 - supplementary group fails on MDS, passes on client [ "$RUNAS_ID" = "$UID" ] && skip "RUNAS_ID = UID = $UID -- skipping" && return check_kernel_version 35 || return 0 - mkdir $DIR/$tdir + mkdir -p $DIR/$tdir chmod 771 $DIR/$tdir chgrp $RUNAS_ID $DIR/$tdir $RUNAS -u $RUNAS_ID -g $(($RUNAS_ID + 1)) -G1,2,$RUNAS_ID ls $DIR/$tdir @@ -3946,6 +3949,7 @@ test_105c() { run_test 105c "lockf when mounted without -o flock test ========" test_106() { #bug 10921 + mkdir -p $DIR/$tdir $DIR/$tdir && error "exec $DIR/$tdir succeeded" chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed" } @@ -4502,6 +4506,7 @@ test_119c() # bug 13099 run_test 119c "Testing for direct read hitting hole" test_120a() { + mkdir -p $DIR/$tdir [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \ skip "no early lock cancel on server" && return 0 lru_resize_disable mdc @@ -4521,6 +4526,7 @@ test_120a() { run_test 120a "Early Lock Cancel: mkdir test ===================" test_120b() { + mkdir -p $DIR/$tdir [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \ skip "no early lock cancel on server" && return 0 lru_resize_disable mdc @@ -4540,6 +4546,7 @@ test_120b() { run_test 120b "Early Lock Cancel: create test ==================" test_120c() { + mkdir -p $DIR/$tdir [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \ skip "no early lock cancel on server" && return 0 lru_resize_disable mdc @@ -4561,6 +4568,7 @@ test_120c() { run_test 120c "Early Lock Cancel: link test ====================" test_120d() { + mkdir -p $DIR/$tdir [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \ skip "no early lock cancel on server" && return 0 lru_resize_disable mdc @@ -4581,6 +4589,7 @@ test_120d() { run_test 120d "Early Lock Cancel: setattr test =================" test_120e() { + mkdir -p $DIR/$tdir [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \ skip "no early lock cancel on server" && return 0 lru_resize_disable mdc @@ -4605,6 +4614,7 @@ run_test 120e "Early Lock Cancel: unlink test ==================" test_120f() { [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \ skip "no early lock cancel on server" && return 0 + mkdir -p $DIR/$tdir lru_resize_disable mdc lru_resize_disable osc mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2 diff --git a/lustre/tests/sanityN.sh b/lustre/tests/sanityN.sh index 627ef82c0e22fb5b07f307cc1838906b78807af5..16c1e14839c872c895fffdcc4a59474f8bb9dfd8 100644 --- a/lustre/tests/sanityN.sh +++ b/lustre/tests/sanityN.sh @@ -60,6 +60,7 @@ LPROC=/proc/fs/lustre LOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1` OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd` +assert_DIR rm -rf $DIR1/[df][0-9]* $DIR1/lnk # $RUNAS_ID may get set incorrectly somewhere else @@ -158,11 +159,9 @@ test_6() { run_test 6 "remove of open file on other node ==================" test_7() { - # run_one creates uniq $tdir (bug 13798) - # opendirunlink failes if it exists - rmdir $DIR1/$tdir || true - opendirunlink $DIR1/$tdir $DIR2/$tdir || \ - error "opendirunlink $DIR1/$tdir $DIR2/$tdir" + local dir=d7 + opendirunlink $DIR1/$dir $DIR2/$dir || \ + error "opendirunlink $DIR1/$dir $DIR2/$dir" } run_test 7 "remove of open directory on other node =============" @@ -477,6 +476,7 @@ test_25() { [ `lctl get_param -n mdc.*-mdc-*.connect_flags | grep -c acl` -lt 2 ] && \ skip "must have acl, skipping" && return + mkdir -p $DIR1/$tdir touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1" chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1" @@ -571,6 +571,7 @@ test_29() { # bug 10999 run_test 29 "lock put race between glimpse and enqueue =========" test_30() { #bug #11110 + mkdir -p $DIR1/$tdir cp -f /bin/bash $DIR1/$tdir/bash /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' & err=$($DIR1/$tdir/bash -c 'sleep 2; openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?') diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 4cab5544ec0839f27ef03a20606ea199b4acd08a..74fb073af1a3faf2f8c835cf99aadfba2bd32adb 100644 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -24,6 +24,18 @@ assert_env() { [ $failed ] && exit 1 || true } +assert_DIR () { + local failed="" + [ -z "`echo :$DIR: | grep :$MOUNT:`" ] && \ + failed=1 && echo "DIR not in $MOUNT. Aborting." + [ -z "`echo :$DIR1: | grep :$MOUNT1:`" ] && \ + failed=1 && echo "DIR1 not in $MOUNT1. Aborting." + [ -z "`echo :$DIR2: | grep :$MOUNT2:`" ] && \ + failed=1 && echo "DIR2 not in $MOUNT2. Aborting" + + [ -n "$failed" ] && exit 99 || true +} + usage() { echo "usage: $0 [-r] [-f cfgfile]" echo " -r: reformat" @@ -1179,6 +1191,8 @@ basetest() { } run_test() { + assert_DIR + export base=`basetest $1` if [ ! -z "$ONLY" ]; then testname=ONLY_$1 @@ -1282,7 +1296,6 @@ run_one() { export tdir=d0.${TESTSUITE}/d${base} local SAVE_UMASK=`umask` umask 0022 - mkdir -p $DIR/$tdir BEFORE=`date +%s` log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)" @@ -1297,7 +1310,6 @@ run_one() { error "LBUG/LASSERT detected" ps auxww | grep -v grep | grep -q multiop && error "multiop still running" pass "($((`date +%s` - $BEFORE))s)" - rmdir ${DIR}/$tdir >/dev/null 2>&1 || true unset TESTNAME unset tdir umask $SAVE_UMASK