Whamcloud - gitweb
merge b_devel into HEAD. Includes:
[fs/lustre-release.git] / lustre / tests / sanityN.sh
1 #!/bin/bash
2
3 set -e
4
5 PATH=$PATH:.
6
7 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
8 MOUNT1=${MOUNT1:-/mnt/lustre1}
9 MOUNT2=${MOUNT2:-/mnt/lustre2}
10 export NAME=${NAME:-mount2}
11
12 clean() {
13         echo -n "cln.."
14         sh llmountcleanup.sh > /dev/null
15 }
16
17 CLEAN=${CLEAN:-clean}
18 start() {
19         echo -n "mnt.."
20         sh llrmount.sh > /dev/null
21         echo -n "done"
22 }
23 START=${START:-start}
24
25 error () { 
26     echo FAIL
27     exit 1
28 }
29
30 pass() { 
31     echo PASS
32 }
33
34 mkdir -p $MOUNT2
35 mount | grep $MOUNT1 || sh llmount.sh
36
37 echo -n "test 1: check create on 2 mtpt's..."
38 touch $MOUNT1/f1
39 [ -f $MOUNT2/f1 ] || error
40 pass
41
42 echo "test 2: check attribute updates on 2 mtpt's..."
43 chmod 777 $MOUNT2/f1
44 $CHECKSTAT -t file -p 0777 $MOUNT1/f1 || error
45 pass
46
47 echo "test 2b: check cached attribute updates on 2 mtpt's..."
48 touch $MOUNT1/f2b
49 ls -l $MOUNT2/f2b
50 chmod 777 $MOUNT2/f2b
51 $CHECKSTAT -t file -p 0777 $MOUNT1/f2b || error
52 pass
53
54 echo "test 2c: check cached attribute updates on 2 mtpt's..."
55 touch $MOUNT1/f2c
56 ls -l $MOUNT2/f2c
57 chmod 777 $MOUNT1/f2c
58 $CHECKSTAT -t file -p 0777 $MOUNT2/f2c || error
59 pass
60
61 echo "test 3: check after remount attribute updates on 2 mtpt's..."
62 chmod a-x $MOUNT2/f1
63 $CLEAN
64 $START
65 $CHECKSTAT -t file -p 0666 $MOUNT1/f1 || error
66 pass
67
68 echo "test 4: unlink on one mountpoint removes file on other..."
69 rm $MOUNT2/f1
70 $CHECKSTAT -a $MOUNT1/f1 || error
71 pass
72
73 echo -n "test 5: symlink on one mtpt, readlink on another..."
74 ( cd $MOUNT1 ; ln -s this/is/good lnk )
75
76 [ "this/is/good" = "`perl -e 'print readlink("/mnt/lustre2/lnk");'`" ] || error
77 pass
78
79 echo -n "test 6: fstat validation on multiple mount points..."
80 ./multifstat $MOUNT1/f6 $MOUNT2/f6
81 pass
82
83 echo "test 9: remove of open file on other node..."
84 ./openunlink $MOUNT1/f9 $MOUNT2/f9 || error
85 pass
86
87 echo -n "test 10: append of file with sub-page size on multiple mounts..."
88 MTPT=1
89 > $MOUNT2/f10
90 for C in a b c d e f g h i j k l; do
91         MOUNT=`eval echo \\$MOUNT$MTPT`
92         echo -n $C >> $MOUNT/f10
93         [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
94 done
95 [ "`cat $MOUNT1/f10`" = "abcdefghijkl" ] && pass || error
96         
97 echo -n "test 11: write of file with sub-page size on multiple mounts..."
98 MTPT=1
99 OFFSET=0
100 > $MOUNT2/f11
101 for C in a b c d e f g h i j k l; do
102         MOUNT=`eval echo \\$MOUNT$MTPT`
103         echo -n $C | dd of=$MOUNT/f11 bs=1 seek=$OFFSET count=1
104         [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
105         OFFSET=`expr $OFFSET + 1`
106 done
107 [ "`cat $MOUNT1/f11`" = "abcdefghijkl" ] && pass || error
108         
109 echo "test 12: file length and contents across mounts"
110 dd if=$SHELL of=$MOUNT1/f12 bs=4096 count=1
111 $CHECKSTAT -s 4096 $MOUNT1/f12 $MOUNT2/f12 || error
112 dd if=$SHELL bs=4096 count=1 |                                  \
113         md5sum - $MOUNT1/f12 $MOUNT2/f12 | (                    \
114                 read GOODSUM DASH;                              \
115                 while read SUM FILE ; do                        \
116                         [ $SUM == $GOODSUM ] || exit 2;         \
117                 done; ) || error
118
119 echo "test 13: open(,O_TRUNC,), close() across mounts"
120 dd if=$SHELL of=$MOUNT1/f13 bs=4096 count=1
121 > $MOUNT1/f13
122 $CHECKSTAT -s 0 $MOUNT1/f13 $MOUNT2/f13 || error
123
124 echo "test 14: file extension while holding the fd open"
125 > $MOUNT1/f14
126 # ugh.
127 touch $MOUNT1/f14-start
128 sh -c "
129   echo -n a;
130   mv $MOUNT1/f14-start $MOUNT1/f14-going;
131   while [ -f $MOUNT1/f14-going ] ; do sleep 1; done;
132     "  >> $MOUNT1/f14 &
133 while [ -f $MOUNT1/f14-start ] ; do sleep 1; done;
134 $CHECKSTAT -s 1 $MOUNT1/f14 $MOUNT2/f14 || error
135 rm $MOUNT1/f14-going
136
137 rm -f $MOUNT1/f[0-9]* $MOUNT1/lnk
138 $CLEAN
139
140 exit