Whamcloud - gitweb
Land b_smallfix onto HEAD (20040428_2142)
[fs/lustre-release.git] / lustre / tests / replay-ost-single.sh
1 #!/bin/sh
2
3 set -e
4
5 LUSTRE=${LUSTRE:-`dirname $0`/..}
6 . $LUSTRE/tests/test-framework.sh
7
8 init_test_env $@
9
10 . ${CONFIG:=$LUSTRE/tests/cfg/local.sh}
11
12 ostfailover_HOST=${ostfailover_HOST:-$ost_HOST}
13
14 # Skip these tests
15 ALWAYS_EXCEPT="5"
16 # test 5 needs a larger fs than what local normally has
17
18 gen_config() {
19     rm -f $XMLCONFIG
20     add_mds mds --dev $MDSDEV --size $MDSSIZE
21     add_lov lov1 mds --stripe_sz $STRIPE_BYTES\
22         --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
23     add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE --failover
24     if [ ! -z "$ostfailover_HOST" ]; then
25          add_ostfailover ost --dev $OSTDEV --size $OSTSIZE
26     fi
27     add_client client mds --lov lov1 --path $MOUNT
28 }
29
30 cleanup() {
31     # make sure we are using the primary MDS, so the config log will
32     # be able to clean up properly.
33     activeost=`facet_active ost`
34     if [ $activeost != "ost" ]; then
35         fail ost
36     fi
37     zconf_umount `hostname` $MOUNT
38     stop mds ${FORCE} $MDSLCONFARGS
39     stop ost ${FORCE} --dump cleanup.log
40 }
41
42 if [ "$ONLY" == "cleanup" ]; then
43     sysctl -w portals.debug=0
44     cleanup
45     exit
46 fi
47
48 build_test_filter
49
50 SETUP=${SETUP:-"setup"}
51 CLEANUP=${CLEANUP:-"cleanup"}
52
53 setup() {
54     gen_config
55
56     start ost --reformat $OSTLCONFARGS
57     [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
58     start mds --reformat $MDSLCONFARGS
59     grep " $MOUNT " /proc/mounts || zconf_mount `hostname` $MOUNT
60 }
61
62 mkdir -p $DIR
63
64 $SETUP
65
66 test_0() {
67     fail ost
68     cp /etc/profile  $DIR/$tfile
69     sync
70     diff /etc/profile $DIR/$tfile
71     rm -f $DIR/$tfile
72 }
73 run_test 0 "empty replay"
74
75 test_1() {
76     date > $DIR/$tfile
77     fail ost
78     $CHECKSTAT -t file $DIR/$tfile || return 1
79     rm -f $DIR/$tfile
80 }
81 run_test 1 "touch"
82
83 test_2() {
84     for i in `seq 10`; do
85         echo "tag-$i" > $DIR/$tfile-$i
86     done 
87     fail ost
88     for i in `seq 10`; do
89       grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
90     done 
91     rm -f $DIR/$tfile-*
92 }
93 run_test 2 "|x| 10 open(O_CREAT)s"
94
95 test_3() {
96     verify=$ROOT/tmp/verify-$$
97     dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $DIR/$tfile &
98     ddpid=$!
99     sync &
100     fail ost
101     wait $ddpid || return 1
102     cmp $verify $DIR/$tfile || return 2
103     rm -f $verify $DIR/$tfile
104 }
105 run_test 3 "Fail OST during write, with verification"
106
107 test_4() {
108     verify=$ROOT/tmp/verify-$$
109     dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $DIR/$tfile
110     # invalidate cache, so that we're reading over the wire
111     for i in /proc/fs/lustre/ldlm/namespaces/OSC_*MNT*; do
112         echo -n clear > $i/lru_size
113     done
114     cmp $verify $DIR/$tfile &
115     cmppid=$!
116     fail ost
117     wait $cmppid || return 1
118     rm -f $verify $DIR/$tfile
119 }
120 run_test 4 "Fail OST during read, with verification"
121
122 test_5() {
123     IOZONE_OPTS="-i 0 -i 1 -i 2 -+d -r 64 -s 1g"
124     iozone $IOZONE_OPTS -f $DIR/$tfile &
125     PID=$!
126     
127     sleep 10
128     fail ost
129     wait $PID || return 1
130     rm -f $DIR/$tfile
131 }
132 run_test 5 "Fail OST during iozone"
133
134 kbytesfree() {
135    awk '{total+=$1} END {print total}' /proc/fs/lustre/osc/OSC_*MNT*/kbytesfree
136 }
137
138 test_6() {
139     f=$DIR/$tfile
140     rm -f $f
141     sync && sleep 2 && sync     # wait for delete thread
142     before=`kbytesfree`
143     dd if=/dev/urandom bs=4096 count=1280 of=$f
144 #define OBD_FAIL_MDS_REINT_NET_REP       0x119
145     do_facet mds "sysctl -w lustre.fail_loc=0x80000119"
146     sync
147     sleep 1                                     # ensure we have a fresh statfs
148     after_dd=`kbytesfree`
149     log "before: $before after_dd: $after_dd"
150     (( $before > $after_dd )) || return 1
151     rm -f $f
152     fail ost
153     $CHECKSTAT -t file $f && return 2 || true
154     sync
155     # let the delete happen
156     sleep 2
157     after=`kbytesfree`
158     log "before: $before after: $after"
159     (( $before <= $after + 40 )) || return 3    # take OST logs into account
160 }
161 run_test 6 "Fail OST before obd_destroy"
162
163 test_7() {
164     f=$DIR/$tfile
165     rm -f $f
166     sync && sleep 2 && sync     # wait for delete thread
167     before=`kbytesfree`
168     dd if=/dev/urandom bs=4096 count=1280 of=$f
169     sync
170     after_dd=`kbytesfree`
171     log "before: $before after_dd: $after_dd"
172     (( $before > $after_dd )) || return 1
173     replay_barrier ost
174     rm -f $f
175     fail ost
176     $CHECKSTAT -t file $f && return 2 || true
177     sync
178     # let the delete happen
179     sleep 2
180     after=`kbytesfree`
181     log "before: $before after: $after"
182     (( $before <= $after + 40 )) || return 3    # take OST logs into account
183 }
184 run_test 7 "Fail OST before obd_destroy"
185
186 equals_msg test complete, cleaning up
187 $CLEANUP