Whamcloud - gitweb
land b_eq on HEAD
[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 rm -f ostactive
51
52 gen_config
53
54 start ost --reformat $OSTLCONFARGS
55
56 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
57 start mds --reformat $MDSLCONFARGS
58 zconf_mount `hostname` $MOUNT
59
60 mkdir -p $DIR
61
62 test_0() {
63     fail ost
64     cp /etc/profile  $DIR/$tfile
65     sync
66     diff /etc/profile $DIR/$tfile
67 }
68 run_test 0 "empty replay"
69
70 test_1() {
71     date > $DIR/$tfile
72     fail ost
73     $CHECKSTAT -t file $DIR/$tfile || return 1
74 }
75 run_test 1 "touch"
76
77 test_2() {
78     for i in `seq 10`; do
79         echo "tag-$i" > $DIR/$tfile-$i
80     done 
81     fail ost
82     for i in `seq 10`; do
83       grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
84     done 
85 }
86 run_test 2 "|x| 10 open(O_CREAT)s"
87
88 test_3() {
89     verify=$ROOT/tmp/verify-$$
90     dd if=/dev/urandom bs=1024 count=5120 | tee $verify > $DIR/$tfile &
91     ddpid=$!
92     sync &
93     fail ost
94     wait $ddpid || return 1
95     cmp $verify $DIR/$tfile || return 2
96     rm -f $verify $DIR/$tfile
97 }
98 run_test 3 "Fail OST during write, with verification"
99
100 test_4() {
101     verify=$ROOT/tmp/verify-$$
102     dd if=/dev/urandom bs=1024 count=5120 | tee $verify > $DIR/$tfile
103     # invalidate cache, so that we're reading over the wire
104     for i in /proc/fs/lustre/ldlm/namespaces/OSC_*MNT*; do
105         echo -n clear > $i/lru_size
106     done
107     cmp $verify $DIR/$tfile &
108     cmppid=$!
109     fail ost
110     wait $cmppid || return 1
111     rm -f $verify $DIR/$tfile
112 }
113 run_test 4 "Fail OST during read, with verification"
114
115 test_5() {
116     IOZONE_OPTS="-i 0 -i 1 -i 2 -+d -r 64 -s 1g"
117     iozone $IOZONE_OPTS -f $DIR/$tfile &
118     PID=$!
119     
120     sleep 10
121     fail ost
122     wait $PID || return 1
123 }
124 run_test 5 "Fail OST during iozone"
125
126 equals_msg test complete, cleaning up
127 cleanup