Whamcloud - gitweb
b=16551 (att 19784)
[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 ostfailover_HOST=${ostfailover_HOST:-$ost_HOST}
14 #failover= must be defined in OST_MKFS_OPTIONS if ostfailover_HOST != ost_HOST
15
16 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
17
18 # Tests that fail on uml
19 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
20 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT 6"
21
22 # Skip these tests
23 # BUG NUMBER: 
24 ALWAYS_EXCEPT="$REPLAY_OST_SINGLE_EXCEPT"
25
26 #                                       
27 [ "$SLOW" = "no" ] && EXCEPT_SLOW="5"
28
29 # It is replay-ost-single, after all
30 OSTCOUNT=1
31
32 build_test_filter
33
34 REFORMAT=--reformat cleanup_and_setup_lustre
35 assert_DIR
36 rm -rf $DIR/[df][0-9]*
37
38 test_0a() {
39     zconf_umount `hostname` $MOUNT -f
40     # needs to run during initial client->OST connection
41     #define OBD_FAIL_OST_ALL_REPLY_NET       0x211
42     do_facet ost "lctl set_param fail_loc=0x80000211"
43     zconf_mount `hostname` $MOUNT && df $MOUNT || error "0a mount fail"
44 }
45 run_test 0a "target handle mismatch (bug 5317) `date +%H:%M:%S`"
46
47 test_0b() {
48     fail ost1
49     cp /etc/profile  $DIR/$tfile
50     sync
51     diff /etc/profile $DIR/$tfile
52     rm -f $DIR/$tfile
53 }
54 run_test 0b "empty replay"
55
56 test_1() {
57     date > $DIR/$tfile || error "error creating $DIR/$tfile"
58     fail ost1
59     $CHECKSTAT -t file $DIR/$tfile || return 1
60     rm -f $DIR/$tfile
61 }
62 run_test 1 "touch"
63
64 test_2() {
65     for i in `seq 10`; do
66         echo "tag-$i" > $DIR/$tfile-$i || error "create $DIR/$tfile-$i"
67     done 
68     fail ost1
69     for i in `seq 10`; do
70       grep -q "tag-$i" $DIR/$tfile-$i || error "grep $DIR/$tfile-$i"
71     done 
72     rm -f $DIR/$tfile-*
73 }
74 run_test 2 "|x| 10 open(O_CREAT)s"
75
76 test_3() {
77     verify=$ROOT/tmp/verify-$$
78     dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $DIR/$tfile &
79     ddpid=$!
80     sync &
81     fail ost1
82     wait $ddpid || return 1
83     cmp $verify $DIR/$tfile || return 2
84     rm -f $verify $DIR/$tfile
85 }
86 run_test 3 "Fail OST during write, with verification"
87
88 test_4() {
89     verify=$ROOT/tmp/verify-$$
90     dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $DIR/$tfile
91     # invalidate cache, so that we're reading over the wire
92     cancel_lru_locks osc
93     cmp $verify $DIR/$tfile &
94     cmppid=$!
95     fail ost1
96     wait $cmppid || return 1
97     rm -f $verify $DIR/$tfile
98 }
99 run_test 4 "Fail OST during read, with verification"
100
101 test_5() {
102     [ -z "`which iozone 2> /dev/null`" ] && skip "iozone missing" && return 0
103     FREE=`df -P $DIR | tail -n 1 | awk '{ print $4/2 }'`
104     GB=1048576  # 1048576KB == 1GB
105     if (( FREE > GB )); then
106         FREE=$GB
107     fi
108     IOZONE_OPTS="-i 0 -i 1 -i 2 -+d -r 4 -s $FREE"
109     iozone $IOZONE_OPTS -f $DIR/$tfile &
110     PID=$!
111     
112     sleep 8
113     fail ost1
114     wait $PID
115     RC=$?
116     log "iozone rc=$RC"
117     rm -f $DIR/$tfile
118     [ $RC -ne 0 ] && return $RC || true
119 }
120 run_test 5 "Fail OST during iozone"
121
122 kbytesfree() {
123    calc_osc_kbytes kbytesfree
124 }
125
126 test_6() {
127     remote_mds_nodsh && skip "remote MDS with nodsh" && return 0
128
129     f=$DIR/$tfile
130     rm -f $f
131     sync && sleep 2 && sync     # wait for delete thread
132     before=`kbytesfree`
133     dd if=/dev/urandom bs=4096 count=1280 of=$f || return 28
134     lfs getstripe $f
135     sync
136     sleep 2                                     # ensure we have a fresh statfs
137     sync
138 #define OBD_FAIL_MDS_REINT_NET_REP       0x119
139     do_facet mds "lctl set_param fail_loc=0x80000119"
140     after_dd=`kbytesfree`
141     log "before: $before after_dd: $after_dd"
142     (( $before > $after_dd )) || return 1
143     rm -f $f
144     fail ost1
145     $CHECKSTAT -t file $f && return 2 || true
146     sync
147     # let the delete happen
148     sleep 5
149     after=`kbytesfree`
150     log "before: $before after: $after"
151     (( $before <= $after + 40 )) || return 3    # take OST logs into account
152 }
153 run_test 6 "Fail OST before obd_destroy"
154
155 test_7() {
156     f=$DIR/$tfile
157     rm -f $f
158     sync && sleep 5 && sync     # wait for delete thread
159     before=`kbytesfree`
160     dd if=/dev/urandom bs=4096 count=1280 of=$f || return 4
161     sync
162     sleep 2                                     # ensure we have a fresh statfs
163     sync
164     after_dd=`kbytesfree`
165     log "before: $before after_dd: $after_dd"
166     (( $before > $after_dd )) || return 1
167     replay_barrier ost1
168     rm -f $f
169     fail ost1
170     $CHECKSTAT -t file $f && return 2 || true
171     sync
172     # let the delete happen
173     sleep 5
174     after=`kbytesfree`
175     log "before: $before after: $after"
176     (( $before <= $after + 40 )) || return 3    # take OST logs into account
177 }
178 run_test 7 "Fail OST before obd_destroy"
179
180 equals_msg `basename $0`: test complete, cleaning up
181 check_and_cleanup_lustre
182 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG || true