5 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
8 . $LUSTRE/tests/test-framework.sh
10 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
12 # While we do not use OSTCOUNT=1 setup anymore,
13 # ost1failover_HOST is used
14 #ostfailover_HOST=${ostfailover_HOST:-$ost_HOST}
15 #failover= must be defined in OST_MKFS_OPTIONS if ostfailover_HOST != ost_HOST
17 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
19 if [ "$FAILURE_MODE" = "HARD" ] && mixed_ost_devs; then
20 skip "$0: Several ost services on one ost node are used with FAILURE_MODE=$FAILURE_MODE. "
24 # Tests that fail on uml
25 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
26 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT 6"
30 ALWAYS_EXCEPT="$REPLAY_OST_SINGLE_EXCEPT"
33 [ "$SLOW" = "no" ] && EXCEPT_SLOW="5"
37 check_and_setup_lustre
39 rm -rf $DIR/[df][0-9]*
41 TDIR=$DIR/d0.${TESTSUITE}
43 $LFS setstripe $TDIR -i 0 -c 1
47 zconf_umount `hostname` $MOUNT -f
48 # needs to run during initial client->OST connection
49 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
50 do_facet ost1 "lctl set_param fail_loc=0x80000211"
51 zconf_mount `hostname` $MOUNT && df $MOUNT || error "0a mount fail"
53 run_test 0a "target handle mismatch (bug 5317) `date +%H:%M:%S`"
57 cp /etc/profile $TDIR/$tfile
59 diff /etc/profile $TDIR/$tfile
62 run_test 0b "empty replay"
65 date > $TDIR/$tfile || error "error creating $TDIR/$tfile"
67 $CHECKSTAT -t file $TDIR/$tfile || return 1
74 echo "tag-$i" > $TDIR/$tfile-$i || error "create $TDIR/$tfile-$i"
78 grep -q "tag-$i" $TDIR/$tfile-$i || error "grep $TDIR/$tfile-$i"
82 run_test 2 "|x| 10 open(O_CREAT)s"
85 verify=$ROOT/tmp/verify-$$
86 dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $TDIR/$tfile &
90 wait $ddpid || return 1
91 cmp $verify $TDIR/$tfile || return 2
92 rm -f $verify $TDIR/$tfile
94 run_test 3 "Fail OST during write, with verification"
97 verify=$ROOT/tmp/verify-$$
98 dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $TDIR/$tfile
99 # invalidate cache, so that we're reading over the wire
101 cmp $verify $TDIR/$tfile &
104 wait $cmppid || return 1
105 rm -f $verify $TDIR/$tfile
107 run_test 4 "Fail OST during read, with verification"
112 local tmppipe=$TMP/${TESTSUITE}.${TESTNAME}.pipe
115 echo "+ iozone $args"
116 iozone $args > $tmppipe &
120 echo "tmppipe=$tmppipe"
123 # iozone exit code is 0 even if iozone is not completed
124 # need to check iozone output on "complete"
125 local iozonelog=$TMP/${TESTSUITE}.iozone.log
127 cat $tmppipe | while read line ; do
129 echo "$line" >>$iozonelog
135 if ! $(tail -1 $iozonelog | grep -q complete); then
145 [ -z "`which iozone 2> /dev/null`" ] && skip "iozone missing" && return 0
147 # striping is -c 1, get min of available
148 local minavail=$(lctl get_param -n osc.*[oO][sS][cC][-_]*.kbytesavail | sort -n | head -1)
149 local size=$(( minavail * 3/4 ))
150 local GB=1048576 # 1048576KB == 1GB
152 if (( size > GB )); then
155 local iozone_opts="-i 0 -i 1 -i 2 -+d -r 4 -s $size -f $TDIR/$tfile"
157 iozone_bg $iozone_opts &
160 echo iozone bg pid=$pid
169 [ $rc -eq 0 ] || error "iozone failed"
172 run_test 5 "Fail OST during iozone"
175 calc_osc_kbytes kbytesfree
179 remote_mds_nodsh && skip "remote MDS with nodsh" && return 0
183 sync && sleep 2 && sync # wait for delete thread
185 dd if=/dev/urandom bs=4096 count=1280 of=$f || return 28
187 get_stripe_info client $f
190 sleep 2 # ensure we have a fresh statfs
192 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
193 do_facet mds "lctl set_param fail_loc=0x80000119"
194 after_dd=`kbytesfree`
195 log "before: $before after_dd: $after_dd"
196 (( $before > $after_dd )) || return 1
198 fail ost$((stripe_index + 1))
199 $CHECKSTAT -t file $f && return 2 || true
201 # let the delete happen
204 log "before: $before after: $after"
205 (( $before <= $after + 40 )) || return 3 # take OST logs into account
207 run_test 6 "Fail OST before obd_destroy"
212 sync && sleep 5 && sync # wait for delete thread
214 dd if=/dev/urandom bs=4096 count=1280 of=$f || return 4
216 sleep 2 # ensure we have a fresh statfs
218 after_dd=`kbytesfree`
219 log "before: $before after_dd: $after_dd"
220 (( $before > $after_dd )) || return 1
224 $CHECKSTAT -t file $f && return 2 || true
226 # let the delete happen
229 log "before: $before after: $after"
230 (( $before <= $after + 40 )) || return 3 # take OST logs into account
232 run_test 7 "Fail OST before obd_destroy"
234 equals_msg `basename $0`: test complete, cleaning up
235 check_and_cleanup_lustre
236 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true