Whamcloud - gitweb
land v0.9.1 on HEAD, in preparation for a 1.0.x branch
[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=""
16
17 gen_config() {
18     rm -f $XMLCONFIG
19     add_mds mds --dev $MDSDEV --size $MDSSIZE
20     add_lov lov1 mds --stripe_sz $STRIPE_BYTES\
21         --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
22     add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE --failover
23     if [ ! -z "$ostfailover_HOST" ]; then
24          add_ostfailover ost --dev $OSTDEV --size $OSTSIZE
25     fi
26     add_client client mds --lov lov1 --path $MOUNT
27 }
28
29 cleanup() {
30     # make sure we are using the primary MDS, so the config log will
31     # be able to clean up properly.
32     activeost=`facet_active ost`
33     if [ $activeost != "ost" ]; then
34         fail ost
35     fi
36     zconf_umount $MOUNT
37     stop mds ${FORCE} $MDSLCONFARGS
38     stop ost ${FORCE} --dump cleanup.log
39 }
40
41 if [ "$ONLY" == "cleanup" ]; then
42     sysctl -w portals.debug=0
43     cleanup
44     exit
45 fi
46
47 build_test_filter
48
49 rm -f ostactive
50
51 gen_config
52
53 start ost --reformat $OSTLCONFARGS
54 PINGER=`cat /proc/fs/lustre/pinger`
55
56 if [ "$PINGER" != "on" ]; then
57     echo "ERROR: Lustre must be built with --enable-pinger for this test."
58     stop ost
59     exit 1
60 fi
61 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
62 start mds --reformat $MDSLCONFARGS
63 zconf_mount $MOUNT
64
65 mkdir -p $DIR
66
67 test_0() {
68     replay_barrier ost
69     fail ost
70     cp /etc/profile  $DIR/$tfile
71     sync
72     diff /etc/profile $DIR/$tfile
73 }
74 run_test 0 "empty replay"
75
76 test_1() {
77     replay_barrier ost
78     date > $DIR/$tfile
79     fail ost
80     $CHECKSTAT -t file $DIR/$tfile || return 1
81 }
82 run_test 1 "touch"
83
84 test_2() {
85     replay_barrier ost
86     for i in `seq 10`; do
87         echo "tag-$i" > $DIR/$tfile-$i
88     done 
89     fail ost
90     for i in `seq 10`; do
91       grep -q "tag-$i" $DIR/$tfile-$i || error "f1c-$i"
92     done 
93 }
94 run_test 2 "|x| 10 open(O_CREAT)s"
95
96 test_3() {
97     verify=$ROOT/tmp/verify-$$
98     dd if=/dev/urandom bs=1024 count=5120 | tee $verify > $DIR/$tfile &
99     ddpid=$!
100     sync &
101     fail ost
102     wait $ddpid || return 1
103     cmp $verify $DIR/$tfile || return 2
104     rm $verify
105 }
106 run_test 3 "Fail OST during write, with verification"
107
108 test_4() {
109     verify=$ROOT/tmp/verify-$$
110     dd if=/dev/urandom bs=1024 count=5120 | tee $verify > $DIR/$tfile
111     # invalidate cache, so that we're reading over the wire
112     for i in /proc/fs/lustre/ldlm/namespaces/OSC_*MNT*; do
113         echo -n clear > $i/lru_size
114     done
115     cmp $verify $DIR/$tfile &
116     cmppid=$!
117     fail ost
118     wait $cmppid || return 1
119     rm $verify
120 }
121 run_test 4 "Fail OST during read, with verification"
122
123 equals_msg test complete, cleaning up
124 cleanup