Whamcloud - gitweb
Add checks into MDS failure test to verify operations failed.
[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
12 setup_portals
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
25 setup ${MDS} ${MDSFS}
26 device 1
27 attach obdext2
28 setup ${OST}
29 device 2
30 attach ost
31 setup 1
32 device 3
33 attach osc
34 setup -1
35 quit
36 EOF
37
38 mount -t lustre_light -o device=3 none /mnt/obd
39
40 test_fail() {
41         echo $1 > /proc/sys/lustre/fail_loc
42         shift
43         echo "Running '$*'"
44         $* 
45
46         echo "Cleaning up and restarting MDS"
47         umount /mnt/obd
48         $OBDCTL <<- EOF
49         device 0
50         cleanup
51         detach
52         EOF
53
54         echo 0 > /proc/sys/lustre/fail_loc
55
56         $OBDCTL <<- EOF
57         device 0
58         attach mds
59         setup ${MDS} ${MDSFS}
60         EOF
61         mount -t lustre_light -o device=3 none /mnt/obd
62 }
63
64 set -vx
65
66 touch /mnt/obd/foo
67 chmod a+x /mnt/obd/foo
68 sync
69
70 # OBD_FAIL_MDS_REINT_SETATTR_WRITE - MDS will discard data from setattr
71 test_fail 0x10a chmod 000 /mnt/obd/foo
72 ls -l /mnt/obd/foo
73 [ ! -x /mnt/obd/foo ] && echo "/mnt/obd/foo is executable!" 1>&2 && exit -1
74
75 # OBD_FAIL_MDS_REINT_CREATE_WRITE - MDS will not create the file
76 test_fail 0x10c touch /mnt/obd/bar
77 ls /mnt/obd/bar
78 [ $? -eq 0 ] && echo "/mnt/obd/bar was created!" 1>&2 && exit -1
79
80 # OBD_FAIL_MDS_REINT_UNLINK_WRITE - MDS will discard data from unlink
81 test_fail 0x10e rm /mnt/obd/foo
82 ls /mnt/obd/foo
83 [ $? -eq 1 ] && echo "/mnt/obd/foo has been removed!" 1>&2 && exit -1
84
85 # OBD_FAIL_MDS_REINT_RENAME_WRITE - MDS will discard data from rename
86 test_fail 0x112 mv /mnt/obd/foo /mnt/obd/bar
87 ls /mnt/obd/bar
88 [ $? -eq 0 ] && echo "/mnt/obd/foo has been renamed to bar!" 1>&2 && exit -1
89
90 echo "Done."