Whamcloud - gitweb
b=11564
[fs/lustre-release.git] / lustre / tests / runfailure-mds
1 #!/bin/sh
2
3 SRCDIR="`dirname $0`"
4 . $SRCDIR/common.sh
5
6 . $SRCDIR/llmount.sh
7
8 MNT="setup_mount"
9
10 test_fail() {
11         echo $1 > /proc/sys/lustre/fail_loc
12         shift
13         echo "Running '$*'"
14         $* 
15
16         echo "Cleaning up and restarting MDS"
17         umount /mnt/lustre || fail "unable to unmount"
18         $OBDCTL <<- EOF
19         name2dev MDSDEV
20         cleanup
21         detach
22         quit
23         EOF
24
25         echo 0 > /proc/sys/lustre/fail_loc
26
27         $OBDCTL <<- EOF
28         newdev
29         attach mds MDSDEV
30         setup ${MDS} ${MDSFS}
31         quit
32         EOF
33         $MNT
34 }
35
36 #set -vx
37
38 touch /mnt/lustre/foo
39 chmod a+x /mnt/lustre/foo
40 sync
41
42 # OBD_FAIL_MDS_REINT_SETATTR_WRITE - MDS will discard data from setattr
43 test_fail 0x10a chmod 000 /mnt/lustre/foo
44 ls -l /mnt/lustre/foo
45 [ ! -x /mnt/lustre/foo ] && fail "/mnt/lustre/foo is not executable!"
46
47 # OBD_FAIL_MDS_REINT_CREATE_WRITE - MDS will not create the file
48 test_fail 0x10c touch /mnt/lustre/bar
49 ls /mnt/lustre/bar
50 [ $? -eq 0 ] && fail "/mnt/lustre/bar was created!"
51
52 # OBD_FAIL_MDS_REINT_UNLINK_WRITE - MDS will discard data from unlink
53 test_fail 0x10e rm /mnt/lustre/foo
54 ls /mnt/lustre/foo
55 [ $? -eq 1 ] && fail "/mnt/lustre/foo has been removed!"
56
57 # OBD_FAIL_MDS_REINT_RENAME_WRITE - MDS will discard data from rename
58 test_fail 0x112 mv /mnt/lustre/foo /mnt/lustre/bar
59 ls /mnt/lustre/foo /mnt/lustre/bar
60 [ ! -f /mnt/lustre/foo -o -f /mnt/lustre/bar ] && \
61         fail "/mnt/lustre/foo has been renamed to bar!"
62
63 echo "Done."