Whamcloud - gitweb
cff40b18619098f8ff26119e90bf048bc61a8044
[fs/lustre-release.git] / lustre / tests / runfailure-mds
1 #!/bin/sh
2
3 SRCDIR="`dirname $0`"
4 . $SRCDIR/common.sh
5
6 NETWORK=tcp
7 LOCALHOST=localhost
8 SERVER=localhost
9 PORT=1234
10
11 setup_portals
12 setup_lustre
13
14 new_fs ext2 /tmp/ost 10000
15 OST=$LOOPDEV
16 MDSFS=ext3
17 new_fs ${MDSFS} /tmp/mds 10000
18 MDS=$LOOPDEV
19
20 echo 0xffffffff > /proc/sys/portals/debug
21
22 $OBDCTL <<EOF
23 device 0
24 attach mds MDSDEV
25 setup ${MDS} ${MDSFS}
26 device 1
27 attach obdfilter OBDDEV
28 setup ${OST}
29 device 2
30 attach ost OSTDEV
31 setup 1
32 device 3
33 attach ptlrpc RPCDEV
34 setup
35 device 4
36 attach ldlm LDLMDEV
37 setup
38 device 5
39 attach osc OSCDEV
40 setup -1
41 quit
42 EOF
43
44 MNT='mount -t lustre_lite -o device=`$OBDCTL name2dev OSCDEV` none /mnt/lustre'
45 $MNT
46
47 test_fail() {
48         echo $1 > /proc/sys/lustre/fail_loc
49         shift
50         echo "Running '$*'"
51         $* 
52
53         echo "Cleaning up and restarting MDS"
54         umount /mnt/lustre || fail "unable to unmount"
55         $OBDCTL <<- EOF
56         device 0
57         cleanup
58         detach
59         quit
60         EOF
61
62         echo 0 > /proc/sys/lustre/fail_loc
63
64         $OBDCTL <<- EOF
65         device 0
66         attach mds
67         setup ${MDS} ${MDSFS}
68         quit
69         EOF
70         $MNT
71 }
72
73 #set -vx
74
75 touch /mnt/lustre/foo
76 chmod a+x /mnt/lustre/foo
77 sync
78
79 # OBD_FAIL_MDS_REINT_SETATTR_WRITE - MDS will discard data from setattr
80 test_fail 0x10a chmod 000 /mnt/lustre/foo
81 ls -l /mnt/lustre/foo
82 [ ! -x /mnt/lustre/foo ] && fail "/mnt/lustre/foo is not executable!"
83
84 # OBD_FAIL_MDS_REINT_CREATE_WRITE - MDS will not create the file
85 test_fail 0x10c touch /mnt/lustre/bar
86 ls /mnt/lustre/bar
87 [ $? -eq 0 ] && fail "/mnt/lustre/bar was created!"
88
89 # OBD_FAIL_MDS_REINT_UNLINK_WRITE - MDS will discard data from unlink
90 test_fail 0x10e rm /mnt/lustre/foo
91 ls /mnt/lustre/foo
92 [ $? -eq 1 ] && fail "/mnt/lustre/foo has been removed!"
93
94 # OBD_FAIL_MDS_REINT_RENAME_WRITE - MDS will discard data from rename
95 test_fail 0x112 mv /mnt/lustre/foo /mnt/lustre/bar
96 ls /mnt/lustre/foo /mnt/lustre/bar
97 [ ! -f /mnt/lustre/foo -o -f /mnt/lustre/bar ] && \
98         fail "/mnt/lustre/foo has been renamed to bar!"
99
100 echo "Done."