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