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