Whamcloud - gitweb
1accb1597aa1b5891f922fbdef848b0e19713602
[fs/lustre-release.git] / lustre / tests / replay-ost-single.sh
1 #!/bin/sh
2
3 set -e
4
5 PTLDEBUG=${PTLDEBUG:--1}
6 LUSTRE=${LUSTRE:-`dirname $0`/..}
7 . $LUSTRE/tests/test-framework.sh
8 init_test_env $@
9 . ${CONFIG:=$LUSTRE/tests/cfg/lmv.sh}
10
11 ostfailover_HOST=${ostfailover_HOST:-$ost_HOST}
12 #failover= must be defined in OST_MKFS_OPTIONS if ostfailover_HOST != ost_HOST
13
14 # Tests that fail on uml
15 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
16 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT 6"
17
18 # Skip these tests
19 # BUG NUMBER: 
20 ALWAYS_EXCEPT="$REPLAY_OST_SINGLE_EXCEPT"
21
22 # It is replay-ost-single, after all
23 OSTCOUNT=1
24
25 gen_config() {
26     formatall
27 }
28
29 cleanup() {
30     cleanupall
31 }
32
33 if [ "$ONLY" == "cleanup" ]; then
34     cleanup
35     exit
36 fi
37
38 build_test_filter
39
40 SETUP=${SETUP:-"setup"}
41 CLEANUP=${CLEANUP:-"cleanup"}
42
43 setup() {
44     gen_config
45     start mds $MDSDEV $MDS_MOUNT_OPTS
46     start ost1 `ostdevname 1` $OST_MOUNT_OPTS
47     [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
48
49     if [ -z "`grep " $MOUNT " /proc/mounts`" ]; then
50         # test "-1" needed during initial client->OST connection
51         log "== test 00: target handle mismatch (bug 5317) === `date +%H:%M:%S`"
52         #define OBD_FAIL_OST_ALL_REPLY_NET       0x211
53         do_facet ost1 "sysctl -w lustre.fail_loc=0x80000211"
54         zconf_mount `hostname` $MOUNT && df $MOUNT && pass || error "mount fail"
55     fi
56 }
57
58 mkdir -p $DIR
59
60 $SETUP
61
62 test_0() {
63     fail ost1
64     cp /etc/profile  $DIR/$tfile
65     sync
66     diff /etc/profile $DIR/$tfile
67     rm -f $DIR/$tfile
68 }
69 run_test 0 "empty replay"
70
71 test_1() {
72     date > $DIR/$tfile
73     fail ost1
74     $CHECKSTAT -t file $DIR/$tfile || return 1
75     rm -f $DIR/$tfile
76 }
77 run_test 1 "touch"
78
79 test_2() {
80     for i in `seq 10`; do
81         echo "tag-$i" > $DIR/$tfile-$i
82     done 
83     fail ost1
84     for i in `seq 10`; do
85       grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
86     done 
87     rm -f $DIR/$tfile-*
88 }
89 run_test 2 "|x| 10 open(O_CREAT)s"
90
91 test_3() {
92     verify=$ROOT/tmp/verify-$$
93     dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $DIR/$tfile &
94     ddpid=$!
95     sync &
96     fail ost1
97     wait $ddpid || return 1
98     cmp $verify $DIR/$tfile || return 2
99     rm -f $verify $DIR/$tfile
100 }
101 run_test 3 "Fail OST during write, with verification"
102
103 test_4() {
104     verify=$ROOT/tmp/verify-$$
105     dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $DIR/$tfile
106     # invalidate cache, so that we're reading over the wire
107     for i in /proc/fs/lustre/ldlm/namespaces/*-osc-*; do
108         echo -n clear > $i/lru_size
109     done
110     cmp $verify $DIR/$tfile &
111     cmppid=$!
112     fail ost1
113     wait $cmppid || return 1
114     rm -f $verify $DIR/$tfile
115 }
116 run_test 4 "Fail OST during read, with verification"
117
118 test_5() {
119     [ -z "`which iozone 2> /dev/null`" ] && log "iozone missing" && return
120     FREE=`df -P -h $DIR | tail -n 1 | awk '{ print $3 }'`
121     case $FREE in
122     *T|*G) FREE=1G;;
123     esac
124     IOZONE_OPTS="-i 0 -i 1 -i 2 -+d -r 4 -s $FREE"
125     iozone $IOZONE_OPTS -f $DIR/$tfile &
126     PID=$!
127     
128     sleep 8
129     fail ost1
130     wait $PID || return 1
131     rm -f $DIR/$tfile
132 }
133 run_test 5 "Fail OST during iozone"
134
135 kbytesfree() {
136    awk '{total+=$1} END {print total}' /proc/fs/lustre/osc/*-osc-*/kbytesfree
137 }
138
139 test_6() {
140     f=$DIR/$tfile
141     rm -f $f
142     sync && sleep 2 && sync     # wait for delete thread
143     before=`kbytesfree`
144     dd if=/dev/urandom bs=4096 count=1280 of=$f || return 28
145     lfs getstripe $f
146 #define OBD_FAIL_MDS_REINT_NET_REP       0x119
147     do_facet mds "sysctl -w lustre.fail_loc=0x80000119"
148     sync
149     sleep 1                                     # ensure we have a fresh statfs
150     sync
151     after_dd=`kbytesfree`
152     log "before: $before after_dd: $after_dd"
153     (( $before > $after_dd )) || return 1
154     rm -f $f
155     fail ost1
156     $CHECKSTAT -t file $f && return 2 || true
157     sync
158     # let the delete happen
159     sleep 5
160     after=`kbytesfree`
161     log "before: $before after: $after"
162     (( $before <= $after + 40 )) || return 3    # take OST logs into account
163 }
164 run_test 6 "Fail OST before obd_destroy"
165
166 test_7() {
167     f=$DIR/$tfile
168     rm -f $f
169     sync && sleep 2 && sync     # wait for delete thread
170     before=`kbytesfree`
171     dd if=/dev/urandom bs=4096 count=1280 of=$f
172     sync
173     sleep 1                                     # ensure we have a fresh statfs
174     after_dd=`kbytesfree`
175     log "before: $before after_dd: $after_dd"
176     (( $before > $after_dd )) || return 1
177     replay_barrier ost1
178     rm -f $f
179     fail ost1
180     $CHECKSTAT -t file $f && return 2 || true
181     sync
182     # let the delete happen
183     sleep 2
184     after=`kbytesfree`
185     log "before: $before after: $after"
186     (( $before <= $after + 40 )) || return 3    # take OST logs into account
187 }
188 run_test 7 "Fail OST before obd_destroy"
189
190 equals_msg test complete, cleaning up
191 $CLEANUP