5 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
8 . $LUSTRE/tests/test-framework.sh
10 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
13 # While we do not use OSTCOUNT=1 setup anymore,
14 # ost1failover_HOST is used
15 #ostfailover_HOST=${ostfailover_HOST:-$ost_HOST}
16 #failover= must be defined in OST_MKFS_OPTIONS if ostfailover_HOST != ost_HOST
18 require_dsh_ost || exit 0
20 if [ "$FAILURE_MODE" = "HARD" ] && mixed_ost_devs; then
21 skip_env "$0: Several ost services on one ost node are used with FAILURE_MODE=$FAILURE_MODE. "
25 # Tests that fail on uml
26 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
27 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT 6"
31 ALWAYS_EXCEPT="$REPLAY_OST_SINGLE_EXCEPT"
34 [ "$SLOW" = "no" ] && EXCEPT_SLOW="5"
38 check_and_setup_lustre
40 rm -rf $DIR/[df][0-9]*
42 TDIR=$DIR/d0.${TESTSUITE}
44 $LFS setstripe $TDIR -i 0 -c 1
48 zconf_umount `hostname` $MOUNT -f
49 # needs to run during initial client->OST connection
50 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
51 do_facet ost1 "lctl set_param fail_loc=0x80000211"
52 zconf_mount `hostname` $MOUNT && df $MOUNT || error "0a mount fail"
54 run_test 0a "target handle mismatch (bug 5317) `date +%H:%M:%S`"
58 cp /etc/profile $TDIR/$tfile
60 diff /etc/profile $TDIR/$tfile
63 run_test 0b "empty replay"
66 date > $TDIR/$tfile || error "error creating $TDIR/$tfile"
68 $CHECKSTAT -t file $TDIR/$tfile || return 1
75 echo "tag-$i" > $TDIR/$tfile-$i || error "create $TDIR/$tfile-$i"
79 grep -q "tag-$i" $TDIR/$tfile-$i || error "grep $TDIR/$tfile-$i"
83 run_test 2 "|x| 10 open(O_CREAT)s"
86 verify=$ROOT/tmp/verify-$$
87 dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $TDIR/$tfile &
91 wait $ddpid || return 1
92 cmp $verify $TDIR/$tfile || return 2
93 rm -f $verify $TDIR/$tfile
95 run_test 3 "Fail OST during write, with verification"
98 verify=$ROOT/tmp/verify-$$
99 dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $TDIR/$tfile
100 # invalidate cache, so that we're reading over the wire
102 cmp $verify $TDIR/$tfile &
105 wait $cmppid || return 1
106 rm -f $verify $TDIR/$tfile
108 run_test 4 "Fail OST during read, with verification"
113 local tmppipe=$TMP/${TESTSUITE}.${TESTNAME}.pipe
116 echo "+ iozone $args"
117 iozone $args > $tmppipe &
121 echo "tmppipe=$tmppipe"
124 # iozone exit code is 0 even if iozone is not completed
125 # need to check iozone output on "complete"
126 local iozonelog=$TMP/${TESTSUITE}.iozone.log
128 cat $tmppipe | while read line ; do
130 echo "$line" >>$iozonelog
136 if ! $(tail -1 $iozonelog | grep -q complete); then
146 [ -z "`which iozone 2> /dev/null`" ] && skip_env "iozone missing" && return 0
148 # striping is -c 1, get min of available
149 local minavail=$(lctl get_param -n osc.*[oO][sS][cC][-_]*.kbytesavail | sort -n | head -1)
150 local size=$(( minavail * 3/4 ))
151 local GB=1048576 # 1048576KB == 1GB
153 if (( size > GB )); then
156 local iozone_opts="-i 0 -i 1 -i 2 -+d -r 4 -s $size -f $TDIR/$tfile"
158 iozone_bg $iozone_opts &
161 echo iozone bg pid=$pid
170 [ $rc -eq 0 ] || error "iozone failed"
173 run_test 5 "Fail OST during iozone"
176 calc_osc_kbytes kbytesfree
180 remote_mds_nodsh && skip "remote MDS with nodsh" && return 0
184 sync && sleep 2 && sync # wait for delete thread
186 dd if=/dev/urandom bs=4096 count=1280 of=$f || return 28
188 get_stripe_info client $f
191 sleep 2 # ensure we have a fresh statfs
193 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
194 do_facet mds "lctl set_param fail_loc=0x80000119"
195 after_dd=`kbytesfree`
196 log "before: $before after_dd: $after_dd"
197 (( $before > $after_dd )) || return 1
199 fail ost$((stripe_index + 1))
200 wait_recovery_complete ost$((stripe_index + 1)) || error "OST recovery not done"
201 $CHECKSTAT -t file $f && return 2 || true
203 # let the delete happen
204 wait_mds_ost_sync || return 4
205 wait_destroy_complete || return 5
207 log "before: $before after: $after"
208 (( $before <= $after + 40 )) || return 3 # take OST logs into account
210 run_test 6 "Fail OST before obd_destroy"
215 sync && sleep 5 && sync # wait for delete thread
217 dd if=/dev/urandom bs=4096 count=1280 of=$f || return 4
219 sleep 2 # ensure we have a fresh statfs
221 after_dd=`kbytesfree`
222 log "before: $before after_dd: $after_dd"
223 (( $before > $after_dd )) || return 1
227 wait_recovery_complete ost1 || error "OST recovery not done"
228 $CHECKSTAT -t file $f && return 2 || true
230 # let the delete happen
231 wait_mds_ost_sync || return 4
232 wait_destroy_complete || return 5
234 log "before: $before after: $after"
235 (( $before <= $after + 40 )) || return 3 # take OST logs into account
237 run_test 7 "Fail OST before obd_destroy"
239 equals_msg `basename $0`: test complete, cleaning up
240 check_and_cleanup_lustre
241 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true