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