Whamcloud - gitweb
b=24410 exit with error if NFSCLIENT is set, but no nfs export found
[fs/lustre-release.git] / lustre / tests / replay-ost-single.sh
1 #!/bin/bash
2
3 set -e
4
5 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
6 SETUP=${SETUP:-""}
7 CLEANUP=${CLEANUP:-""}
8 . $LUSTRE/tests/test-framework.sh
9 init_test_env $@
10 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
11
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
16
17 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
18
19 # Tests that fail on uml
20 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
21 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT 6"
22
23 # Skip these tests
24 # BUG NUMBER: 
25 ALWAYS_EXCEPT="$REPLAY_OST_SINGLE_EXCEPT"
26
27 #                                       
28 [ "$SLOW" = "no" ] && EXCEPT_SLOW="5"
29
30 build_test_filter
31
32 check_and_setup_lustre
33 assert_DIR
34 rm -rf $DIR/[df][0-9]*
35
36 TDIR=$DIR/d0.${TESTSUITE}
37 mkdir -p $TDIR 
38 $LFS setstripe $TDIR -i 0 -c 1
39 $LFS getstripe $TDIR
40
41 test_0a() {
42     zconf_umount `hostname` $MOUNT -f
43     # needs to run during initial client->OST connection
44     #define OBD_FAIL_OST_ALL_REPLY_NET       0x211
45     do_facet ost1 "lctl set_param fail_loc=0x80000211"
46     zconf_mount `hostname` $MOUNT && df $MOUNT || error "0a mount fail"
47 }
48 run_test 0a "target handle mismatch (bug 5317) `date +%H:%M:%S`"
49
50 test_0b() {
51     fail ost1
52     cp /etc/profile  $TDIR/$tfile
53     sync
54     diff /etc/profile $TDIR/$tfile
55     rm -f $TDIR/$tfile
56 }
57 run_test 0b "empty replay"
58
59 test_1() {
60     date > $TDIR/$tfile
61     fail ost1
62     $CHECKSTAT -t file $TDIR/$tfile || return 1
63     rm -f $TDIR/$tfile
64 }
65 run_test 1 "touch"
66
67 test_2() {
68     for i in `seq 10`; do
69         echo "tag-$i" > $TDIR/$tfile-$i
70     done 
71     fail ost1
72     for i in `seq 10`; do
73       grep -q "tag-$i" $TDIR/$tfile-$i || error "f2-$i"
74     done 
75     rm -f $TDIR/$tfile-*
76 }
77 run_test 2 "|x| 10 open(O_CREAT)s"
78
79 test_3() {
80     verify=$ROOT/tmp/verify-$$
81     dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $TDIR/$tfile &
82     ddpid=$!
83     sync &
84     fail ost1
85     wait $ddpid || return 1
86     cmp $verify $TDIR/$tfile || return 2
87     rm -f $verify $TDIR/$tfile
88 }
89 run_test 3 "Fail OST during write, with verification"
90
91 test_4() {
92     verify=$ROOT/tmp/verify-$$
93     dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $TDIR/$tfile
94     # invalidate cache, so that we're reading over the wire
95     cancel_lru_locks osc
96     cmp $verify $TDIR/$tfile &
97     cmppid=$!
98     fail ost1
99     wait $cmppid || return 1
100     rm -f $verify $TDIR/$tfile
101 }
102 run_test 4 "Fail OST during read, with verification"
103
104 iozone_bg () {
105     local args=$@
106
107     local tmppipe=$TMP/${TESTSUITE}.${TESTNAME}.pipe
108     mkfifo $tmppipe
109
110     echo "+ iozone $args"
111     iozone $args > $tmppipe &
112
113     local pid=$!
114
115     echo "tmppipe=$tmppipe"
116     echo iozone pid=$pid
117
118     # iozone exit code is 0 even if iozone is not completed
119     # need to check iozone output  on "complete"
120     local iozonelog=$TMP/${TESTSUITE}.iozone.log
121     rm -f $iozonelog
122     cat $tmppipe | while read line ; do
123         echo "$line"
124         echo "$line" >>$iozonelog
125     done;
126
127     local rc=0
128     wait $pid
129     rc=$?
130     if ! $(tail -1 $iozonelog | grep -q complete); then
131         echo iozone failed!
132         rc=1
133     fi
134     rm -f $tmppipe
135     rm -f $iozonelog
136     return $rc
137 }
138
139 test_5() {
140     [ -z "`which iozone 2> /dev/null`" ] && skip_env "iozone missing" && return 0
141
142     # striping is -c 1, get min of available
143     local minavail=$(lctl get_param -n osc.*[oO][sS][cC][-_]*.kbytesavail | sort -n | head -1)
144     local size=$(( minavail * 3/4 ))
145     local GB=1048576  # 1048576KB == 1GB
146
147     if (( size > GB )); then
148         size=$GB
149     fi
150     local iozone_opts="-i 0 -i 1 -i 2 -+d -r 4 -s $size -f $TDIR/$tfile"
151
152     iozone_bg $iozone_opts &
153     local pid=$!
154
155     echo iozone bg pid=$pid
156
157     sleep 8
158     fail ost1
159     local rc=0
160     wait $pid
161     rc=$?
162     log "iozone rc=$rc"
163     rm -f $TDIR/$tfile
164     [ $rc -eq 0 ] || error "iozone failed"
165     return $rc
166 }
167 run_test 5 "Fail OST during iozone"
168
169 kbytesfree() {
170    calc_osc_kbytes kbytesfree
171 }
172
173 test_6() {
174     remote_mds_nodsh && skip "remote MDS with nodsh" && return 0
175
176     f=$TDIR/$tfile
177     rm -f $f
178     sync && sleep 2 && sync     # wait for delete thread
179     before=`kbytesfree`
180     dd if=/dev/urandom bs=4096 count=1280 of=$f || return 28
181     lfs getstripe $f
182     get_stripe_info client $f
183
184     sync
185     sleep 2 # ensure we have a fresh statfs
186     sync
187 #define OBD_FAIL_MDS_REINT_NET_REP       0x119
188     do_facet mds "lctl set_param fail_loc=0x80000119"
189     after_dd=`kbytesfree`
190     log "before: $before after_dd: $after_dd"
191     (( $before > $after_dd )) || return 1
192     rm -f $f
193     fail ost$((stripe_index + 1))
194     wait_recovery_complete ost$((stripe_index + 1)) || error "OST recovery isn't done"
195     $CHECKSTAT -t file $f && return 2 || true
196     sync
197     # let the delete happen
198     wait_mds_ost_sync || return 4
199     wait_destroy_complete || return 5
200     after=`kbytesfree`
201     log "before: $before after: $after"
202     (( $before <= $after + 40 )) || return 3    # take OST logs into account
203 }
204 run_test 6 "Fail OST before obd_destroy"
205
206 test_7() {
207     f=$TDIR/$tfile
208     rm -f $f
209     sync && sleep 2 && sync     # wait for delete thread
210     before=`kbytesfree`
211     dd if=/dev/urandom bs=4096 count=1280 of=$f || return 4
212     sync
213     sleep 2 # ensure we have a fresh statfs
214     sync
215     after_dd=`kbytesfree`
216     log "before: $before after_dd: $after_dd"
217     (( $before > $after_dd )) || return 1
218     replay_barrier ost1
219     rm -f $f
220     fail ost1
221     wait_recovery_complete ost1 || error "OST recovery isn't done"
222     $CHECKSTAT -t file $f && return 2 || true
223     sync
224     # let the delete happen
225     wait_mds_ost_sync || return 4
226     wait_destroy_complete || return 5
227     after=`kbytesfree`
228     log "before: $before after: $after"
229     (( $before <= $after + 40 )) || return 3 # take OST logs into account
230 }
231 run_test 7 "Fail OST before obd_destroy"
232
233 complete $(basename $0) $SECONDS
234 check_and_cleanup_lustre
235 exit_status