Whamcloud - gitweb
1ae6256b812695b76a838579ec27b8eba0f36261
[fs/lustre-release.git] / lustre / tests / replay-ost-single.sh
1 #!/bin/bash
2
3 set -e
4
5 PTLDEBUG=${PTLDEBUG:--1}
6 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
7 SETUP=${SETUP:-""}
8 CLEANUP=${CLEANUP:-""}
9 . $LUSTRE/tests/test-framework.sh
10 init_test_env $@
11 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
12
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
17
18 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
19
20 if [ "$FAILURE_MODE" = "HARD" ] && mixed_ost_devs; then
21     skip "$0: Several ost services on one ost node are used with FAILURE_MODE=$FAILURE_MODE. "
22     exit 0
23 fi
24
25 # Tests that fail on uml
26 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
27 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT 6"
28
29 # Skip these tests
30 # BUG NUMBER: 
31 ALWAYS_EXCEPT="$REPLAY_OST_SINGLE_EXCEPT"
32
33 #                                       
34 [ "$SLOW" = "no" ] && EXCEPT_SLOW="5"
35
36 build_test_filter
37
38 check_and_setup_lustre
39 assert_DIR
40 rm -rf $DIR/[df][0-9]*
41
42 TDIR=$DIR/d0.${TESTSUITE}
43 mkdir -p $TDIR
44 $LFS setstripe $TDIR -i 0 -c 1
45 $LFS getstripe $TDIR
46
47 test_0a() {
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"
53 }
54 run_test 0a "target handle mismatch (bug 5317) `date +%H:%M:%S`"
55
56 test_0b() {
57     fail ost1
58     cp /etc/profile  $TDIR/$tfile
59     sync
60     diff /etc/profile $TDIR/$tfile
61     rm -f $TDIR/$tfile
62 }
63 run_test 0b "empty replay"
64
65 test_1() {
66     date > $TDIR/$tfile || error "error creating $TDIR/$tfile"
67     fail ost1
68     $CHECKSTAT -t file $TDIR/$tfile || return 1
69     rm -f $TDIR/$tfile
70 }
71 run_test 1 "touch"
72
73 test_2() {
74     for i in `seq 10`; do
75         echo "tag-$i" > $TDIR/$tfile-$i || error "create $TDIR/$tfile-$i"
76     done 
77     fail ost1
78     for i in `seq 10`; do
79       grep -q "tag-$i" $TDIR/$tfile-$i || error "grep $TDIR/$tfile-$i"
80     done 
81     rm -f $TDIR/$tfile-*
82 }
83 run_test 2 "|x| 10 open(O_CREAT)s"
84
85 test_3() {
86     verify=$ROOT/tmp/verify-$$
87     dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $TDIR/$tfile &
88     ddpid=$!
89     sync &
90     fail ost1
91     wait $ddpid || return 1
92     cmp $verify $TDIR/$tfile || return 2
93     rm -f $verify $TDIR/$tfile
94 }
95 run_test 3 "Fail OST during write, with verification"
96
97 test_4() {
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
101     cancel_lru_locks osc
102     cmp $verify $TDIR/$tfile &
103     cmppid=$!
104     fail ost1
105     wait $cmppid || return 1
106     rm -f $verify $TDIR/$tfile
107 }
108 run_test 4 "Fail OST during read, with verification"
109
110 test_5() {
111     [ -z "`which iozone 2> /dev/null`" ] && skip "iozone missing" && return 0
112     FREE=`df -P $TDIR | tail -n 1 | awk '{ print $4/2 }'`
113     GB=1048576  # 1048576KB == 1GB
114     if (( FREE > GB )); then
115         FREE=$GB
116     fi
117     IOZONE_OPTS="-i 0 -i 1 -i 2 -+d -r 4 -s $FREE"
118     iozone $IOZONE_OPTS -f $TDIR/$tfile &
119     PID=$!
120     
121     sleep 8
122     fail ost1
123     wait $PID
124     RC=$?
125     log "iozone rc=$RC"
126     rm -f $TDIR/$tfile
127     [ $RC -ne 0 ] && return $RC || true
128 }
129 run_test 5 "Fail OST during iozone"
130
131 kbytesfree() {
132    calc_osc_kbytes kbytesfree
133 }
134
135 test_6() {
136     remote_mds_nodsh && skip "remote MDS with nodsh" && return 0
137
138     f=$TDIR/$tfile
139     rm -f $f
140     sync && sleep 2 && sync     # wait for delete thread
141     before=`kbytesfree`
142     dd if=/dev/urandom bs=4096 count=1280 of=$f || return 28
143     lfs getstripe $f
144     sync
145     sleep 2                                     # ensure we have a fresh statfs
146     sync
147 #define OBD_FAIL_MDS_REINT_NET_REP       0x119
148     do_facet mds "lctl set_param fail_loc=0x80000119"
149     after_dd=`kbytesfree`
150     log "before: $before after_dd: $after_dd"
151     (( $before > $after_dd )) || return 1
152     rm -f $f
153     fail ost1
154     $CHECKSTAT -t file $f && return 2 || true
155     sync
156     # let the delete happen
157     sleep 5
158     after=`kbytesfree`
159     log "before: $before after: $after"
160     (( $before <= $after + 40 )) || return 3    # take OST logs into account
161 }
162 run_test 6 "Fail OST before obd_destroy"
163
164 test_7() {
165     f=$TDIR/$tfile
166     rm -f $f
167     sync && sleep 5 && sync     # wait for delete thread
168     before=`kbytesfree`
169     dd if=/dev/urandom bs=4096 count=1280 of=$f || return 4
170     sync
171     sleep 2                                     # ensure we have a fresh statfs
172     sync
173     after_dd=`kbytesfree`
174     log "before: $before after_dd: $after_dd"
175     (( $before > $after_dd )) || return 1
176     replay_barrier ost1
177     rm -f $f
178     fail ost1
179     $CHECKSTAT -t file $f && return 2 || true
180     sync
181     # let the delete happen
182     sleep 5
183     after=`kbytesfree`
184     log "before: $before after: $after"
185     (( $before <= $after + 40 )) || return 3    # take OST logs into account
186 }
187 run_test 7 "Fail OST before obd_destroy"
188
189 equals_msg `basename $0`: test complete, cleaning up
190 check_and_cleanup_lustre
191 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG || true