Whamcloud - gitweb
LU-13019 tests: replace usleep in test scripts
[fs/lustre-release.git] / lustre / tests / replay-dual.sh
index b8e5094..8aa6de8 100755 (executable)
@@ -2,37 +2,40 @@
 
 set -e
 
-# bug number:  LU-2012 10124
-ALWAYS_EXCEPT="14b     15c   $REPLAY_DUAL_EXCEPT"
-
-SAVE_PWD=$PWD
 PTLDEBUG=${PTLDEBUG:--1}
-LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
-SETUP=${SETUP:-""}
-CLEANUP=${CLEANUP:-""}
 MOUNT_2=${MOUNT_2:-"yes"}
-export MULTIOP=${MULTIOP:-multiop}
-. $LUSTRE/tests/test-framework.sh
 
+LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
+. $LUSTRE/tests/test-framework.sh
 init_test_env $@
-. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
 init_logging
 
 remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
 
-[ "$SLOW" = "no" ] && EXCEPT_SLOW="21b"
+ALWAYS_EXCEPT="$REPLAY_DUAL_EXCEPT "
+# bug number for skipped test:  LU-2012 LU-8333 LU-7372
+ALWAYS_EXCEPT+="                14b     21b     26 "
+# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
-[[ $(facet_fstype $SINGLEMDS) == zfs ]] &&
-# bug number for skipped test:       LU-2230
+[[ "$mds1_FSTYPE" == zfs ]] &&
+# bug number for skipped test:        LU-2230
        ALWAYS_EXCEPT="$ALWAYS_EXCEPT 21b"
 
-build_test_filter
+if $SHARED_KEY; then
+# bug number for skipped tests:  LU-9795 LU-9795
+       ALWAYS_EXCEPT+="         0a      0b "
+fi
 
+#                                   7  (min)"
+[ "$SLOW" = "no" ] && EXCEPT_SLOW="21b "
+
+build_test_filter
 check_and_setup_lustre
+
 MOUNTED=$(mounted_lustre_filesystems)
 if ! $(echo $MOUNTED' ' | grep -w -q $MOUNT2' '); then
-    zconf_mount $HOSTNAME $MOUNT2
-    MOUNTED2=yes
+       zconf_mount $HOSTNAME $MOUNT2
+       MOUNTED2=yes
 fi
 
 assert_DIR
@@ -326,14 +329,14 @@ test_14b() {
        wait_mds_ost_sync
        wait_delete_completed
 
-       local BEFOREUSED=$(df -P $DIR | tail -1 | awk '{ print $3 }')
+       local beforeused=$(df -P $DIR | tail -1 | awk '{ print $3 }')
 
        mkdir -p $MOUNT1/$tdir
-       $SETSTRIPE -i 0 $MOUNT1/$tdir
+       $LFS setstripe -i 0 $MOUNT1/$tdir
        replay_barrier $SINGLEMDS
        createmany -o $MOUNT1/$tdir/$tfile- 5
 
-       $SETSTRIPE -i 0 $MOUNT2/$tfile-2
+       $LFS setstripe -i 0 $MOUNT2/$tfile-2
        dd if=/dev/zero of=$MOUNT2/$tfile-2 bs=1M count=5
        createmany -o $MOUNT1/$tdir/$tfile-3- 5
        umount $MOUNT2
@@ -351,11 +354,11 @@ test_14b() {
        wait_mds_ost_sync || error "wait_mds_ost_sync failed"
        wait_delete_completed || error "wait_delete_complete failed"
 
-       local AFTERUSED=$(df -P $DIR | tail -1 | awk '{ print $3 }')
-       log "before $BEFOREUSED, after $AFTERUSED"
+       local afterused=$(df -P $DIR | tail -1 | awk '{ print $3 }')
+       log "before $beforeused, after $afterused"
        # leave some margin for some files/dirs to be modified (OI, llog, etc)
-       [ $AFTERUSED -gt $((BEFOREUSED + 128)) ] &&
-               error "after $AFTERUSED > before $BEFOREUSED" || true
+       [ $afterused -le $((beforeused + $(fs_log_size))) ] ||
+               error "after $afterused > before $beforeused"
 }
 run_test 14b "delete ost orphans if gap occured in objids due to VBR"
 
@@ -437,18 +440,18 @@ test_18() { # bug 3822 - evicting client with enqueued lock
        local DLMTRACE=$(do_facet $SINGLEMDS lctl get_param debug)
        do_facet $SINGLEMDS lctl set_param debug=+dlmtrace
        mkdir -p $MOUNT1/$tdir || error "mkdir $MOUNT1/$tdir failed"
-       touch $MOUNT1/$tdir/$tfile
-       #define OBD_FAIL_LDLM_ENQUEUE_BLOCKED    0x30b
-       statmany -s $MOUNT1/$tdir/f 1 500 &
+       touch $MOUNT1/$tdir/${tfile}0 || error "touch file failed"
+       statmany -s $MOUNT1/$tdir/$tfile 1 500 &
        OPENPID=$!
-       NOW=$(date +%s)
+       NOW=$SECONDS
+       #define OBD_FAIL_LDLM_ENQUEUE_BLOCKED    0x30b
        do_facet $SINGLEMDS lctl set_param fail_loc=0x8000030b  # hold enqueue
        sleep 1
        #define OBD_FAIL_LDLM_BL_CALLBACK_NET                   0x305
        do_facet client lctl set_param ldlm.namespaces.*.early_lock_cancel=0
        do_facet client lctl set_param fail_loc=0x80000305  # drop cb, evict
        cancel_lru_locks mdc
-       usleep 500 # wait to ensure first client is one that will be evicted
+       sleep 0.1 # wait to ensure first client is one that will be evicted
        openfile -f O_RDONLY $MOUNT2/$tdir/$tfile
        wait $OPENPID
        do_facet client lctl set_param ldlm.namespaces.*.early_lock_cancel=1
@@ -461,7 +464,7 @@ run_test 18 "ldlm_handle_enqueue succeeds on evicted export (3822)"
 
 test_19() { # Bug 10991 - resend of open request does not fail assertion.
     replay_barrier $SINGLEMDS
-    drop_ldlm_reply "createmany -o $DIR/$tfile 1" || return 1
+    drop_mdt_ldlm_reply "createmany -o $DIR/$tfile 1" || return 1
     fail $SINGLEMDS
     checkstat $DIR2/${tfile}0 || return 2
     rm $DIR/${tfile}0 || return 3
@@ -491,9 +494,9 @@ test_20() { #16389
        zconf_mount $HOSTNAME $DIR2 || error "mount $DIR2 fail"
        local tier2=$((SECONDS - before))
 
-       # timeout is more than 2.25x original timeout
-       ((tier2 < tier1 * 9 / 4)) ||
-               error "recovery time $tier2 >= 2.25x original time $tier1"
+       # timeout is more than 1.5x original timeout
+       ((tier2 < tier1 * 6 / 4)) ||
+               error "recovery time $tier2 >= 1.5x original time $tier1"
 }
 run_test 20 "recovery time is not increasing"
 
@@ -566,7 +569,7 @@ test_21b() {
 
        local param_file=$TMP/$tfile-params
 
-       local mdtidx=$($LFS getstripe -M $MOUNT1)
+       local mdtidx=$($LFS getstripe -m $MOUNT1)
        local facet=mds$((mdtidx + 1))
 
        save_lustre_params $facet "mdt.*.commit_on_sharing" > $param_file
@@ -577,15 +580,15 @@ test_21b() {
 
        test_21b_sub $facet || error "Not all renames are replayed. COS=$COS"
 
-       # COS disabled (should fail)
-       COS=0
-       do_facet $facet lctl set_param mdt.*.commit_on_sharing=$COS
-
        # there is still a window when transactions may be written to disk
        # before the mds device is set R/O. To avoid such a rare test failure,
        # the check is repeated several times.
+       COS=0
        local n_attempts=1
        while true; do
+               # COS disabled (should fail)
+               do_facet $facet lctl set_param mdt.*.commit_on_sharing=$COS
+
                test_21b_sub $facet || break
                n_attempts=$((n_attempts + 1))
                [ $n_attempts -gt 3 ] &&
@@ -631,6 +634,7 @@ test_22a () {
        do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
        do_node $CLIENT1 $LFS mkdir -i $MDTIDX $MOUNT1/$remote_dir &
        CLIENT_PID=$!
+       sleep 1
 
        fail mds$((MDTIDX + 1))
        wait $CLIENT_PID || error "lfs mkdir failed"
@@ -657,6 +661,7 @@ test_22b () {
        do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
        do_node $CLIENT1 $LFS mkdir -i $MDTIDX $MOUNT1/$remote_dir &
        CLIENT_PID=$!
+       sleep 1
 
        fail mds${MDTIDX},mds$((MDTIDX + 1))
        wait $CLIENT_PID || error "lfs mkdir failed"
@@ -683,10 +688,11 @@ test_22c () {
 
        do_node $CLIENT1 mkdir -p $MOUNT1/${tdir}
 
-       # OBD_FAIL_UPDATE_OBJ_NET_REP    0x1701
+       # OBD_FAIL_OUT_UPDATE_NET_REP    0x1701
        do_facet mds$MDTIDX lctl set_param fail_loc=0x1701
        do_node $CLIENT1 $LFS mkdir -i $MDTIDX $MOUNT1/$remote_dir &
        CLIENT_PID=$!
+       sleep 1
        do_facet mds$MDTIDX lctl set_param fail_loc=0
 
        fail mds$MDTIDX
@@ -710,10 +716,11 @@ test_22d () {
 
        do_node $CLIENT1 mkdir -p $MOUNT1/${tdir}
 
-       # OBD_FAIL_UPDATE_OBJ_NET_REP    0x1701
+       # OBD_FAIL_OUT_UPDATE_NET_REP    0x1701
        do_facet mds$MDTIDX lctl set_param fail_loc=0x1701
        do_node $CLIENT1 $LFS mkdir -i $MDTIDX $MOUNT1/$remote_dir &
        CLIENT_PID=$!
+       sleep 1
        do_facet mds$MDTIDX lctl set_param fail_loc=0
 
        fail mds${MDTIDX},mds$((MDTIDX + 1))
@@ -758,6 +765,7 @@ test_23a () {
        do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
        do_node $CLIENT1 rmdir $MOUNT1/$remote_dir &
        local CLIENT_PID=$!
+       sleep 1
        do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0
 
        fail mds$((MDTIDX + 1))
@@ -787,6 +795,7 @@ test_23b () {
        do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
        do_node $CLIENT1 rmdir $MOUNT1/$remote_dir &
        local CLIENT_PID=$!
+       sleep 1
        do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0
 
        fail mds${MDTIDX},mds$((MDTIDX + 1))
@@ -817,10 +826,11 @@ test_23c () {
        do_node $CLIENT1 $LFS mkdir -i $MDTIDX $MOUNT1/$remote_dir ||
                        error "lfs mkdir failed"
 
-       # OBD_FAIL_UPDATE_OBJ_NET_REP    0x1701
+       # OBD_FAIL_OUT_UPDATE_NET_REP    0x1701
        do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
        do_node $CLIENT1 rmdir $MOUNT1/$remote_dir &
        CLIENT_PID=$!
+       sleep 1
        do_facet mds${MDTIDX} lctl set_param fail_loc=0
 
        fail mds${MDTIDX}
@@ -850,6 +860,7 @@ test_23d () {
        do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
        do_node $CLIENT1 rmdir $MOUNT1/$remote_dir &
        CLIENT_PID=$!
+       sleep 1
        do_facet mds${MDTIDX} lctl set_param fail_loc=0
 
        fail mds${MDTIDX},mds$((MDTIDX + 1))
@@ -867,8 +878,8 @@ test_23d () {
 run_test 23d "c1 rmdir d1, M0 drop update reply and fail M0/M1, c2 mkdir d1"
 
 test_24 () {
-       [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.5.2) ]] ||
-               { skip "Need MDS version newer than 2.5.2"; return 0; }
+       [[ "$MDS1_VERSION" -gt $(version_code 2.5.2) ]] ||
+               skip "Need MDS version newer than 2.5.2"
 
        touch $MOUNT/$tfile
        stat $MOUNT/$tfile >&/dev/null
@@ -891,7 +902,7 @@ run_test 24 "reconstruct on non-existing object"
 test_25() {
        cancel_lru_locks osc
 
-       $SETSTRIPE -i 0 -c 1 $DIR/$tfile
+       $LFS setstripe -i 0 -c 1 $DIR/$tfile
 
        # get lock for the 1st client
        dd if=/dev/zero of=$DIR/$tfile count=1 >/dev/null ||
@@ -901,9 +912,15 @@ test_25() {
        drop_ldlm_cancel "multiop $DIR2/$tfile Ow512" &
        sleep 1
 
-#define OBD_FAIL_OST_LDLM_REPLY_NET      0x213
        # failover, replay and resend replayed waiting locks
-       do_facet ost1 lctl set_param fail_loc=0x80000213
+       if [ "$OST1_VERSION" -ge $(version_code 2.6.90) ]; then
+               #define OBD_FAIL_LDLM_SRV_CP_AST      0x325
+               do_facet ost1 lctl set_param fail_loc=0x80000325
+       else
+               #define OBD_FAIL_OST_LDLM_REPLY_NET     0x213
+               do_facet ost1 lctl set_param fail_loc=0x80000213
+       fi
+
        fail ost1
 
        # multiop does not finish because CP AST is skipped;
@@ -914,8 +931,142 @@ test_25() {
 }
 run_test 25 "replay|resend"
 
+cleanup_26() {
+       trap 0
+       kill -9 $tar_26_pid
+       kill -9 $dbench_26_pid
+       killall -9 dbench
+}
+
+test_26() {
+       local clients=${CLIENTS:-$HOSTNAME}
+
+       zconf_mount_clients $clients $MOUNT
+
+       local duration=600
+       [ "$SLOW" = "no" ] && duration=200
+       # set duration to 900 because it takes some time to boot node
+       [ "$FAILURE_MODE" = HARD ] && duration=900
+
+       local start_ts=$SECONDS
+       local rc=0
+
+       trap cleanup_26 EXIT
+       (
+               local tar_dir=$DIR/$tdir/run_tar
+               while true; do
+                       test_mkdir -p -c$MDSCOUNT $tar_dir || break
+                       if [ $MDSCOUNT -ge 2 ]; then
+                               $LFS setdirstripe -D -c$MDSCOUNT $tar_dir ||
+                                       error "set default dirstripe failed"
+                       fi
+                       cd $tar_dir || break
+                       tar cf - /etc | tar xf - || error "tar failed"
+                       cd $DIR/$tdir || break
+                       rm -rf $tar_dir || break
+               done
+       )&
+       tar_26_pid=$!
+       echo "Started tar $tar_26_pid"
+
+       (
+               local dbench_dir=$DIR2/$tdir/run_dbench
+               while true; do
+                       test_mkdir -p -c$MDSCOUNT $dbench_dir || break
+                       if [ $MDSCOUNT -ge 2 ]; then
+                               $LFS setdirstripe -D -c$MDSCOUNT $dbench_dir ||
+                                       error "set default dirstripe failed"
+                       fi
+                       cd $dbench_dir || break
+                       rundbench 1 -D $dbench_dir -t 100 &>/dev/null || break
+                       cd $DIR/$tdir || break
+                       rm -rf $dbench_dir || break
+               done
+       )&
+       dbench_26_pid=$!
+       echo "Started dbench $dbench_26_pid"
+
+       local num_failovers=0
+       local fail_index=1
+       while [ $((SECONDS - start_ts)) -lt $duration ]; do
+               kill -0 $tar_26_pid || error "tar $tar_26_pid missing"
+               kill -0 $dbench_26_pid || error "dbench $dbench_26_pid missing"
+               sleep 2
+               replay_barrier mds$fail_index
+               sleep 2 # give clients a time to do operations
+               # Increment the number of failovers
+               num_failovers=$((num_failovers + 1))
+               log "$TESTNAME fail mds$fail_index $num_failovers times"
+               fail mds$fail_index
+               if [ $fail_index -ge $MDSCOUNT ]; then
+                       fail_index=1
+               else
+                       fail_index=$((fail_index + 1))
+               fi
+       done
+       # stop the client loads
+       kill -0 $tar_26_pid || error "tar $tar_26_pid stopped"
+       kill -0 $dbench_26_pid || error "dbench $dbench_26_pid stopped"
+       cleanup_26 || true
+}
+run_test 26 "dbench and tar with mds failover"
+
+test_28() {
+       $LFS setstripe -i 0 -c 1 $DIR2/$tfile
+       dd if=/dev/zero of=$DIR2/$tfile bs=4096 count=1
+
+       #define OBD_FAIL_LDLM_SRV_BL_AST         0x324
+       do_facet ost1 $LCTL set_param fail_loc=0x80000324
+
+       dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 &
+       local pid=$!
+       sleep 2
+
+       #define OBD_FAIL_LDLM_GRANT_CHECK        0x32a
+       do_facet ost1 $LCTL set_param fail_loc=0x32a
+
+       fail ost1
+
+       sleep 2
+       cancel_lru_locks OST0000-osc
+       wait $pid || error "dd failed"
+}
+run_test 28 "lock replay should be ordered: waiting after granted"
+
+test_29() {
+       local dir0=$DIR/$tdir/d0
+       local dir1=$DIR/$tdir/d1
+
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
+       [ $CLIENTCOUNT -lt 2 ] && skip "needs >= 2 clients" && return 0
+       [ "$CLIENT1" == "$CLIENT2" ] &&
+               skip "clients must be on different nodes" && return 0
+
+       mkdir -p $DIR/$tdir
+       $LFS mkdir -i0 $dir0
+       $LFS mkdir -i1 $dir1
+       sync
+
+       replay_barrier mds2
+       # create a remote dir, drop reply
+       #define OBD_FAIL_PTLRPC_ROUND_XID 0x530
+       $LCTL set_param fail_loc=0x530 fail_val=36
+       #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
+       do_facet mds2 $LCTL set_param fail_loc=0x8000015a
+       echo make remote dir d0 for $dir0
+       $LFS mkdir -i1 -c1 $dir0/d3 &
+       sleep 1
+
+       echo make local dir d1 for $dir1
+       do_node $CLIENT2 $LCTL set_param fail_loc=0x530 fail_val=36
+       do_node $CLIENT2 mkdir $dir1/d4
+
+       fail mds2
+}
+run_test 29 "replay vs update with the same xid"
+
 complete $SECONDS
-SLEEP=$((`date +%s` - $NOW))
+SLEEP=$((SECONDS - $NOW))
 [ $SLEEP -lt $TIMEOUT ] && sleep $SLEEP
 [ "$MOUNTED2" = yes ] && zconf_umount $HOSTNAME $MOUNT2 || true
 check_and_cleanup_lustre