Whamcloud - gitweb
LU-2524 test: Clean up replay-ost-single test suite
[fs/lustre-release.git] / lustre / tests / replay-ost-single.sh
index 74d0d24..26da7d6 100755 (executable)
@@ -1,6 +1,4 @@
 #!/bin/bash
-# -*- mode: Bash; tab-width: 4; indent-tabs-mode: t; -*-
-# vim:shiftwidth=4:softtabstop=4:tabstop=4:
 
 set -e
 
@@ -19,11 +17,11 @@ init_logging
 
 require_dsh_ost || exit 0
 
-# Skip these tests
-# BUG NUMBER: 
+# bug number for skipped test:
 ALWAYS_EXCEPT="$REPLAY_OST_SINGLE_EXCEPT"
+# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
-#                                      
+# bug number for SLOW test:
 [ "$SLOW" = "no" ] && EXCEPT_SLOW="5"
 
 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
@@ -41,69 +39,71 @@ rm -rf $DIR/[df][0-9]*
 
 TDIR=$DIR/d0.${TESTSUITE}
 mkdir -p $TDIR
-$LFS setstripe $TDIR -i 0 -c 1
-$LFS getstripe $TDIR
+$SETSTRIPE $TDIR -i 0 -c 1
+$GETSTRIPE $TDIR
 
 test_0a() {
-    zconf_umount `hostname` $MOUNT -f
-    # needs to run during initial client->OST connection
-    #define OBD_FAIL_OST_ALL_REPLY_NET       0x211
-    do_facet ost1 "lctl set_param fail_loc=0x80000211"
-    zconf_mount `hostname` $MOUNT && df $MOUNT || error "0a mount fail"
+       zconf_umount $(hostname) $MOUNT -f
+       # needs to run during initial client->OST connection
+       #define OBD_FAIL_OST_ALL_REPLY_NET       0x211
+       do_facet ost1 "lctl set_param fail_loc=0x80000211"
+       zconf_mount $(hostname) $MOUNT && df $MOUNT || error "0a mount fail"
 }
-run_test 0a "target handle mismatch (bug 5317) `date +%H:%M:%S`"
+run_test 0a "target handle mismatch (bug 5317)"
 
 test_0b() {
-    fail ost1
-    cp /etc/profile  $TDIR/$tfile
-    sync
-    diff /etc/profile $TDIR/$tfile
-    rm -f $TDIR/$tfile
+       fail ost1
+       cp /etc/profile  $TDIR/$tfile
+       sync
+       diff /etc/profile $TDIR/$tfile
+       rm -f $TDIR/$tfile
 }
 run_test 0b "empty replay"
 
 test_1() {
-    date > $TDIR/$tfile || error "error creating $TDIR/$tfile"
-    fail ost1
-    $CHECKSTAT -t file $TDIR/$tfile || return 1
-    rm -f $TDIR/$tfile
+       date > $TDIR/$tfile || error "error creating $TDIR/$tfile"
+       fail ost1
+       $CHECKSTAT -t file $TDIR/$tfile || error "check for file failed"
+       rm -f $TDIR/$tfile
 }
 run_test 1 "touch"
 
 test_2() {
-    for i in `seq 10`; do
-        echo "tag-$i" > $TDIR/$tfile-$i || error "create $TDIR/$tfile-$i"
-    done 
-    fail ost1
-    for i in `seq 10`; do
-      grep -q "tag-$i" $TDIR/$tfile-$i || error "grep $TDIR/$tfile-$i"
-    done 
-    rm -f $TDIR/$tfile-*
+       for i in $(seq 10); do
+               echo "tag-$i" > $TDIR/$tfile-$i ||
+                       error "create $TDIR/$tfile-$i failed"
+       done
+       fail ost1
+       for i in $(seq 10); do
+               grep -q "tag-$i" $TDIR/$tfile-$i ||
+                       error "grep $TDIR/$tfile-$i failed"
+       done
+       rm -f $TDIR/$tfile-*
 }
 run_test 2 "|x| 10 open(O_CREAT)s"
 
 test_3() {
-    verify=$ROOT/tmp/verify-$$
-    dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $TDIR/$tfile &
-    ddpid=$!
-    sync &
-    fail ost1
-    wait $ddpid || return 1
-    cmp $verify $TDIR/$tfile || return 2
-    rm -f $verify $TDIR/$tfile
+       verify=$ROOT/tmp/verify-$$
+       dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $TDIR/$tfile &
+       ddpid=$!
+       sync &
+       fail ost1
+       wait $ddpid || error "wait for dd failed"
+       cmp $verify $TDIR/$tfile || error "compare $verify $TDIR/$tfile failed"
+       rm -f $verify $TDIR/$tfile
 }
 run_test 3 "Fail OST during write, with verification"
 
 test_4() {
-    verify=$ROOT/tmp/verify-$$
-    dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $TDIR/$tfile
-    # invalidate cache, so that we're reading over the wire
-    cancel_lru_locks osc
-    cmp $verify $TDIR/$tfile &
-    cmppid=$!
-    fail ost1
-    wait $cmppid || return 1
-    rm -f $verify $TDIR/$tfile
+       verify=$ROOT/tmp/verify-$$
+       dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $TDIR/$tfile
+       # invalidate cache, so that we're reading over the wire
+       cancel_lru_locks osc
+       cmp $verify $TDIR/$tfile &
+       cmppid=$!
+       fail ost1
+       wait $cmppid || error "wait on cmp failed"
+       rm -f $verify $TDIR/$tfile
 }
 run_test 4 "Fail OST during read, with verification"
 
@@ -143,7 +143,7 @@ iozone_bg () {
 }
 
 test_5() {
-       if [ -z "`which iozone 2> /dev/null`" ]; then
+       if [ -z "$(which iozone 2> /dev/null)" ]; then
                skip_env "iozone missing"
                return 0
        fi
@@ -167,7 +167,7 @@ test_5() {
        sleep 8
        fail ost1
        local rc=0
-       wait $pid
+       wait $pid || error "wait on iozone failed"
        rc=$?
        log "iozone rc=$rc"
        rm -f $TDIR/$tfile
@@ -185,17 +185,16 @@ test_6() {
        remote_mds_nodsh && skip "remote MDS with nodsh" && return 0
 
        local f=$TDIR/$tfile
-       rm -f $f
        sync && sleep 5 && sync  # wait for delete thread
 
        # wait till space is returned, following
        # (( $before > $after_dd)) test counting on that
-       wait_mds_ost_sync || return 4
-       wait_destroy_complete || return 5
+       wait_mds_ost_sync || error "first wait_mds_ost_sync failed"
+       wait_destroy_complete || error "first wait_destroy_complete failed"
 
        local before=$(kbytesfree)
-       dd if=/dev/urandom bs=4096 count=1280 of=$f || return 28
-       lfs getstripe $f
+       dd if=/dev/urandom bs=4096 count=1280 of=$f || error "dd failed"
+       $GETSTRIPE $f || error "$GETSTRIPE $f failed"
        local stripe_index=$(lfs getstripe -i $f)
 
        sync
@@ -225,8 +224,8 @@ test_6() {
        $CHECKSTAT -t file $f && return 2 || true
        sync
        # let the delete happen
-       wait_mds_ost_sync || return 4
-       wait_delete_completed || return 5
+       wait_mds_ost_sync || error "second wait_mds_ost_sync failed"
+       wait_delete_completed || error "second wait_delete_completed failed"
        local after=$(kbytesfree)
        log "before: $before after: $after"
        (( $before <= $after + $(fs_log_size) )) ||
@@ -236,16 +235,16 @@ run_test 6 "Fail OST before obd_destroy"
 
 test_7() {
        local f=$TDIR/$tfile
-       rm -f $f
        sync && sleep 5 && sync # wait for delete thread
 
        # wait till space is returned, following
        # (( $before > $after_dd)) test counting on that
-       wait_mds_ost_sync || return 4
-       wait_destroy_complete || return 5
+       wait_mds_ost_sync || error "wait_mds_ost_sync failed"
+       wait_destroy_complete || error "wait_destroy_complete failed"
 
        local before=$(kbytesfree)
-       dd if=/dev/urandom bs=4096 count=1280 of=$f || error "dd to file failed: $?"
+       dd if=/dev/urandom bs=4096 count=1280 of=$f ||
+               error "dd to file failed: $?"
 
        sync
        local after_dd=$(kbytesfree)
@@ -267,8 +266,8 @@ test_7() {
        $CHECKSTAT -t file $f && return 2 || true
        sync
        # let the delete happen
-       wait_mds_ost_sync || return 4
-       wait_delete_completed || return 5
+       wait_mds_ost_sync || error "wait_mds_ost_sync failed"
+       wait_delete_completed || error "wait_delete_completed failed"
        local after=$(kbytesfree)
        log "before: $before after: $after"
        (( $before <= $after + $(fs_log_size) )) ||
@@ -281,22 +280,21 @@ test_8a() {
                { skip "Need MDS version at least 2.3.0"; return; }
        verify=$ROOT/tmp/verify-$$
        dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
-               error "Create verify file failed"
-#define OBD_FAIL_OST_DQACQ_NET 0x230
+               error "Create verify file failed"
+       #define OBD_FAIL_OST_DQACQ_NET 0x230
        do_facet ost1 "lctl set_param fail_loc=0x230"
        dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
        ddpid=$!
        sleep $TIMEOUT  # wait for the io to become redo io
        if ! ps -p $ddpid  > /dev/null 2>&1; then
                error "redo io finished incorrectly"
-               return 1
        fi
        do_facet ost1 "lctl set_param fail_loc=0"
        wait $ddpid || true
        cancel_lru_locks osc
-       cmp $verify $TDIR/$tfile || return 2
+       cmp $verify $TDIR/$tfile || error "compare $verify $TDIR/$tfile failed"
        rm -f $verify $TDIR/$tfile
-       message=`dmesg | grep "redo for recoverable error -115"`
+       message=$(dmesg | grep "redo for recoverable error -115")
        [ -z "$message" ] || error "redo error messages found in dmesg"
 }
 run_test 8a "Verify redo io: redo io when get -EINPROGRESS error"
@@ -306,17 +304,17 @@ test_8b() {
                { skip "Need MDS version at least 2.3.0"; return; }
        verify=$ROOT/tmp/verify-$$
        dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
-               error "Create verify file failed"
-#define OBD_FAIL_OST_DQACQ_NET 0x230
+               error "Create verify file failed"
+       #define OBD_FAIL_OST_DQACQ_NET 0x230
        do_facet ost1 "lctl set_param fail_loc=0x230"
        dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
        ddpid=$!
        sleep $TIMEOUT  # wait for the io to become redo io
        fail ost1
        do_facet ost1 "lctl set_param fail_loc=0"
-       wait $ddpid || return 1
+       wait $ddpid || error "dd did not complete"
        cancel_lru_locks osc
-       cmp $verify $TDIR/$tfile || return 2
+       cmp $verify $TDIR/$tfile || error "compare $verify $TDIR/$tfile failed"
        rm -f $verify $TDIR/$tfile
 }
 run_test 8b "Verify redo io: redo io should success after recovery"
@@ -327,7 +325,7 @@ test_8c() {
        verify=$ROOT/tmp/verify-$$
        dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
                error "Create verify file failed"
-#define OBD_FAIL_OST_DQACQ_NET 0x230
+       #define OBD_FAIL_OST_DQACQ_NET 0x230
        do_facet ost1 "lctl set_param fail_loc=0x230"
        dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
        ddpid=$!
@@ -338,7 +336,7 @@ test_8c() {
        do_facet ost1 "lctl set_param fail_loc=0"
        wait $ddpid
        cancel_lru_locks osc
-       cmp $verify $TDIR/$tfile && return 2
+       cmp $verify $TDIR/$tfile && error "compare files should fail"
        rm -f $verify $TDIR/$tfile
 }
 run_test 8c "Verify redo io: redo io should fail after eviction"
@@ -346,7 +344,7 @@ run_test 8c "Verify redo io: redo io should fail after eviction"
 test_8d() {
        [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
                { skip "Need MDS version at least 2.3.0"; return; }
-#define OBD_FAIL_MDS_DQACQ_NET 0x187
+       #define OBD_FAIL_MDS_DQACQ_NET 0x187
        do_facet $SINGLEMDS "lctl set_param fail_loc=0x187"
        # test the non-intent create path
        mcreate $TDIR/$tfile &
@@ -354,15 +352,14 @@ test_8d() {
        sleep $TIMEOUT
        if ! ps -p $cpid  > /dev/null 2>&1; then
                error "mknod finished incorrectly"
-               return 1
        fi
        do_facet $SINGLEMDS "lctl set_param fail_loc=0"
-       wait $cpid || return 2
+       wait $cpid || error "mcreate did not complete"
        stat $TDIR/$tfile || error "mknod failed"
 
        rm $TDIR/$tfile
 
-#define OBD_FAIL_MDS_DQACQ_NET 0x187
+       #define OBD_FAIL_MDS_DQACQ_NET 0x187
        do_facet $SINGLEMDS "lctl set_param fail_loc=0x187"
        # test the intent create path
        openfile -f O_RDWR:O_CREAT $TDIR/$tfile &
@@ -370,10 +367,9 @@ test_8d() {
        sleep $TIMEOUT
        if ! ps -p $cpid > /dev/null 2>&1; then
                error "open finished incorrectly"
-               return 3
        fi
        do_facet $SINGLEMDS "lctl set_param fail_loc=0"
-       wait $cpid || return 4
+       wait $cpid || error "openfile failed"
        stat $TDIR/$tfile || error "open failed"
 }
 run_test 8d "Verify redo creation on -EINPROGRESS"
@@ -382,7 +378,7 @@ test_8e() {
        [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
                { skip "Need MDS version at least 2.3.0"; return; }
        sleep 1 # ensure we have a fresh statfs
-#define OBD_FAIL_OST_STATFS_EINPROGRESS 0x231
+       #define OBD_FAIL_OST_STATFS_EINPROGRESS 0x231
        do_facet ost1 "lctl set_param fail_loc=0x231"
        df $MOUNT &
        dfpid=$!
@@ -390,16 +386,14 @@ test_8e() {
        if ! ps -p $dfpid  > /dev/null 2>&1; then
                        do_facet ost1 "lctl set_param fail_loc=0"
                        error "df shouldn't have completed!"
-                       return 1
        fi
-       do_facet ost1 "lctl set_param fail_loc=0"
 }
 run_test 8e "Verify that ptlrpc resends request on -EINPROGRESS"
 
 test_9() {
        [ $(lustre_version_code ost1) -ge $(version_code 2.6.54) ] ||
                { skip "Need OST version at least 2.6.54"; return; }
-       $SETSTRIPE -i 0 -c 1 $DIR/$tfile
+       $SETSTRIPE -i 0 -c 1 $DIR/$tfile || "setstripe failed"
        replay_barrier ost1
        # do IO
        dd if=/dev/zero of=$DIR/$tfile count=1 bs=1M > /dev/null ||
@@ -410,7 +404,7 @@ test_9() {
        do_facet ost1 $LCTL set_param fail_val=$TIMEOUT
        fail ost1
        do_facet ost1 $LCTL set_param fail_loc=0
-       do_facet ost1 "dmesg | tail -n 100" |\
+       do_facet ost1 "dmesg | tail -n 100" |
                sed -n '/no req deadline/,$ p' | grep -q 'Already past' &&
                return 1
        return 0