Whamcloud - gitweb
Made changes so that tinderbox runtest doesnt fail
[fs/lustre-release.git] / lustre / tests / runtests
1 #!/bin/sh
2 #
3 # Script which does some basic tests to ensure we haven't regressed.
4 # Probably a good idea to run this before doing any checkins.
5 # In the future this can become more fancy, but it's OK for now.
6
7 SRCDIR="`dirname $0`"
8 fail() { 
9         echo "ERROR: $1" 1>&2
10         [ $2 ] && RC=$2 || RC=1
11         exit $RC
12 }
13
14 export PATH=/sbin:/usr/sbin:$SRCDIR:$PATH
15
16 ERROR=
17 SRC=/etc
18 [ "$COUNT" ] || COUNT=1000
19
20 [ "$LCONF" ] || LCONF=$SRCDIR/../utils/lconf
21
22 [ "$MCREATE" ] || MCREATE=$SRCDIR/../tests/mcreate
23 [ "$MKDIRMANY" ] || MKDIRMANY=$SRCDIR/../tests/mkdirmany
24
25 while [ "$1" ]; do
26         case $1 in
27         *.xml) export NAME=`echo $1 | sed "s/.xml//"` ;;
28         esac
29         shift
30 done
31
32 OSCMT="`mount | awk '/ lustre_lite / { print $3 }' | tail -1`"
33 if [ -z "$OSCMT" ]; then
34         sh llmount.sh
35         OSCMT="`mount | awk '/ lustre_lite / { print $3 }' | tail -1`"
36         [ -z "$OSCMT" ] && fail "no lustre filesystem mounted" 1
37         I_MOUNTED="yes"
38 fi
39
40 OSCTMP=`echo $OSCMT | tr "/" "."`
41 USED=`df | awk "/$OSCTMP/ { print \\$3 }" | tail -1`
42 USED=`expr $USED + 16`  # Some space for the status file
43
44 # let's start slowly here...
45 echo "touching $OSCMT"
46 touch $OSCMT || fail "can't touch $OSCMT" 2
47 HOSTS=$OSCMT/hosts.$$
48
49 # this will cause the following cp to trigger bug #620096
50 echo "create an empty file $HOSTS"
51 $MCREATE $HOSTS
52
53 echo "copying /etc/hosts to $HOSTS"
54 cp /etc/hosts $HOSTS || fail "can't cp /etc/hosts to $HOSTS" 3
55 echo "comparing /etc/hosts and $HOSTS"
56 diff -u /etc/hosts $HOSTS || fail "$HOSTS different" 4
57 echo "renaming $HOSTS to $HOSTS.ren"
58 mv $HOSTS $HOSTS.ren || fail "can't rename $HOSTS to $HOSTS.ren" 5
59 echo "copying /etc/hosts to $HOSTS again"
60 cp /etc/hosts $HOSTS || fail "can't cp /etc/hosts to $HOSTS again" 6
61 echo "truncating $HOSTS"
62 > $HOSTS || fail "can't truncate $HOSTS" 8
63 echo "removing $HOSTS"
64 rm $HOSTS || fail "can't remove $HOSTS" 9
65
66 DST=$OSCMT/runtest.$$
67 # let's start slowly here...
68 echo "creating $DST"
69 mkdir $DST || fail "can't mkdir $DST" 10
70
71 # ok, that hopefully worked, so let's do a little more, with files that
72 # haven't changed in the last day (hopefully they don't change during test)
73 FILES=`find $SRC -type f -mtime +1 -ctime +1 | head -$COUNT`
74 echo "copying files from $SRC to $DST$SRC"
75 tar cf - $FILES | tar xvf - -C $DST || fail "copying $SRC" 11
76
77 echo "comparing newly copied files"
78 for f in $FILES; do
79         [ $V ] && echo "verifying $DST/$f"
80         diff -q $f $DST/$f || ERROR=11
81 done
82
83 [ "$ERROR" ] && fail "old and new files are different" $ERROR
84
85 sh llmountcleanup.sh || exit 19
86 sh llrmount.sh || exit 20
87
88 echo "comparing previously copied files"
89 for f in $FILES; do
90         [ $V ] && echo "verifying $DST/$f"
91         diff -q $f $DST/$f || ERROR=22
92 done
93
94 [ "$ERROR" ] && fail "old and new files are different on second diff" $ERROR
95
96 sh llmountcleanup.sh || exit 19
97 sh llrmount.sh || exit 20
98
99 echo "renaming $HOSTS.ren to $HOSTS"
100 mv $HOSTS.ren $HOSTS || fail "can't rename $HOSTS.ren to $HOSTS" 32
101 echo "truncating $HOSTS"
102 > $HOSTS || fail "can't truncate $HOSTS" 34
103 echo "removing $HOSTS"
104 rm $HOSTS || fail "can't remove $HOSTS again" 36
105 echo "removing $DST"
106 rm -r $V $DST || fail "can't remove $DST" 37
107
108 # mkdirmany test (bug 589)
109 echo "running mkdirmany $OSCMT/base$$ 100"
110 $MKDIRMANY $OSCMT/base$$ 100 || fail "mkdirmany failed"
111 echo "removing mkdirmany directories"
112 rmdir $OSCMT/base$$* || fail "mkdirmany cleanup failed"
113
114 NOWUSED=`df | awk "/$OSCTMP/ { print \\$3 }" | tail -1`
115 if [ $NOWUSED -gt $USED ]; then
116         echo "Space not all freed: now ${NOWUSED}kB, was ${USED}kB." 1>&2
117         echo "This is normal on BA OSTs, because of subdirectories." 1>&2
118 fi
119
120 if [ "$I_MOUNTED" = "yes" ]; then
121         sh llmountcleanup.sh || exit 29
122 fi