Whamcloud - gitweb
b=11564
[fs/lustre-release.git] / lustre / tests / acceptance-small.sh
1 #!/bin/bash
2 # script which _must_ complete successfully (at minimum) before checkins to
3 # the CVS HEAD are allowed.
4 #set -vx
5 set -e
6
7 PATH=`dirname $0`/../utils:$PATH
8
9 [ "$CONFIGS" ] || CONFIGS="local"  #"local lov"
10 [ "$MAX_THREADS" ] || MAX_THREADS=20
11 RAMKB=`awk '/MemTotal:/ { print $2 }' /proc/meminfo`
12 if [ -z "$THREADS" ]; then
13         THREADS=$((RAMKB / 16384))
14         [ $THREADS -gt $MAX_THREADS ] && THREADS=$MAX_THREADS
15 fi
16 [ "$SIZE" ] || SIZE=$((RAMKB * 2))
17 [ "$RSIZE" ] || RSIZE=512
18 [ "$UID" ] || UID=1000
19 [ "$MOUNT" ] || MOUNT=/mnt/lustre
20 [ "$MOUNT2" ] || MOUNT2=${MOUNT}2
21 [ "$TMP" ] || TMP=/tmp
22 [ "$COUNT" ] || COUNT=1000
23 [ "$DEBUG_LVL" ] || DEBUG_LVL=0
24 [ "$DEBUG_OFF" ] || DEBUG_OFF="sysctl -w lnet.debug=$DEBUG_LVL"
25 [ "$DEBUG_ON" ] || DEBUG_ON="sysctl -w lnet.debug=0x33f0484"
26
27
28 LIBLUSTRE=${LIBLUSTRE:-../liblustre}
29 LIBLUSTRETESTS=${LIBLUSTRETESTS:-$LIBLUSTRE/tests}
30
31 LUSTRE=${LUSTRE:-`dirname $0`/..}
32 . $LUSTRE/tests/test-framework.sh
33 init_test_env $@
34
35 SETUP=${SETUP:-setupall}
36 FORMAT=${FORMAT:-formatall}
37 CLEANUP=${CLEANUP:-stopall}
38
39 setup_if_needed() {
40     mount | grep $MOUNT && return
41     $FORMAT && $SETUP
42 }
43
44 title() {
45     echo "-----============= acceptance-small: "$*" ============-----"
46 }
47
48 for NAME in $CONFIGS; do
49         export NAME MOUNT START CLEAN
50         . $LUSTRE/tests/cfg/$NAME.sh
51         
52         assert_env mds_HOST MDS_MKFS_OPTS MDSDEV
53         assert_env ost_HOST OST_MKFS_OPTS OSTCOUNT
54         assert_env FSNAME MOUNT MOUNT2
55
56         setup_if_needed
57
58         if [ "$RUNTESTS" != "no" ]; then
59                 title runtests
60                 sh runtests
61                 $CLEANUP
62                 $SETUP
63         fi
64
65         if [ "$SANITY" != "no" ]; then
66                 title sanity
67                 SANITYLOG=/tmp/sanity.log sh sanity.sh
68                 $CLEANUP
69                 $SETUP
70         fi
71
72         which dbench > /dev/null 2>&1 || DBENCH=no
73         if [ "$DBENCH" != "no" ]; then
74                 title dbench
75                 SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
76                 DB_THREADS=$((SPACE / 50000))
77                 [ $THREADS -lt $DB_THREADS ] && DB_THREADS=$THREADS
78
79                 $DEBUG_OFF
80                 sh rundbench 1
81                 $DEBUG_ON
82                 $CLEANUP
83                 $SETUP
84                 if [ $DB_THREADS -gt 1 ]; then
85                         $DEBUG_OFF
86                         sh rundbench $DB_THREADS
87                         $DEBUG_ON
88                         $CLEANUP
89                         $SETUP
90                 fi
91                 rm -f /mnt/lustre/`hostname`/client.txt
92         fi
93
94         chown $UID $MOUNT && chmod 700 $MOUNT
95         which bonnie++ > /dev/null 2>&1 || BONNIE=no
96         if [ "$BONNIE" != "no" ]; then
97                 title bonnie
98                 SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
99                 [ $SPACE -lt $SIZE ] && SIZE=$((SPACE * 3 / 4))
100                 $DEBUG_OFF
101                 bonnie++ -f -r 0 -s $((SIZE / 1024)) -n 10 -u $UID -d $MOUNT
102                 $DEBUG_ON
103                 $CLEANUP
104                 $SETUP
105         fi
106
107         export O_DIRECT
108         which iozone > /dev/null 2>&1 || IOZONE=no
109         if [ "$IOZONE" != "no" ]; then
110                 title iozone
111                 SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
112                 [ $SPACE -lt $SIZE ] && SIZE=$((SPACE * 3 / 4))
113                 IOZONE_OPTS="-i 0 -i 1 -i 2 -e -+d -r $RSIZE -s $SIZE"
114                 IOZFILE="-f $MOUNT/iozone"
115                 $DEBUG_OFF
116                 iozone $IOZONE_OPTS $IOZFILE
117                 $DEBUG_ON
118                 $CLEANUP
119                 $SETUP
120
121                 # check if O_DIRECT support is implemented in kernel
122                 if [ -z "$O_DIRECT" ]; then
123                         touch $MOUNT/f.iozone
124                         if ! ./directio write $MOUNT/f.iozone 0 1; then
125                                 O_DIRECT=no
126                         fi
127                         rm -f $MOUNT/f.iozone
128                 fi
129                 if [ "$O_DIRECT" != "no" -a "$IOZONE_DIR" != "no" ]; then
130                         $DEBUG_OFF
131                         iozone -I $IOZONE_OPTS $IOZFILE.odir
132                         $DEBUG_ON
133                         $CLEANUP
134                         $SETUP
135                 fi
136
137                 SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
138                 IOZ_THREADS=$((SPACE / SIZE * 2 / 3 ))
139                 [ $THREADS -lt $IOZ_THREADS ] && IOZ_THREADS=$THREADS
140                 IOZVER=`iozone -v | awk '/Revision:/ {print $3}' | tr -d .`
141                 if [ "$IOZ_THREADS" -gt 1 -a "$IOZVER" -ge 3145 ]; then
142                         $DEBUG_OFF
143                         THREAD=1
144                         IOZFILE="-F "
145                         while [ $THREAD -le $IOZ_THREADS ]; do
146                                 IOZFILE="$IOZFILE $MOUNT/iozone.$THREAD"
147                                 THREAD=$((THREAD + 1))
148                         done
149                         iozone $IOZONE_OPTS -t $IOZ_THREADS $IOZFILE
150                         $DEBUG_ON
151                         $CLEANUP
152                         $SETUP
153                 elif [ $IOZVER -lt 3145 ]; then
154                         VER=`iozone -v | awk '/Revision:/ { print $3 }'`
155                         echo "iozone $VER too old for multi-thread test"
156                 fi
157         fi
158
159         if [ "$FSX" != "no" ]; then
160                 title fsx
161                 SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
162                 [ $SPACE -lt $SIZE ] && SIZE=$((SPACE * 3 / 4))
163                 $DEBUG_OFF
164                 ./fsx -c 50 -p 1000 -P $TMP -l $SIZE \
165                         -N $(($COUNT * 100)) $MOUNT/fsxfile
166                 $DEBUG_ON
167                 $CLEANUP
168                 $SETUP
169         fi      
170
171         if [ "$SANITYN" != "no" ]; then
172                 title sanityN
173                 $DEBUG_OFF
174
175                 mkdir -p $MOUNT2
176                 mount_client $MOUNT2
177                 #echo "can't mount2 for '$NAME', skipping sanityN.sh"
178                 SANITYLOG=$TMP/sanity.log START=: CLEAN=: sh sanityN.sh
179                 umount $MOUNT2
180
181                 $DEBUG_ON
182                 $CLEANUP
183                 $SETUP
184         fi
185
186         if [ "$LFSCK" != "no" -a -x /usr/sbin/lfsck ]; then
187                 title lfsck
188                 E2VER=`e2fsck -V 2>&1 | head -n 1 | cut -d' ' -f 2`
189                 [ `echo $E2VER | cut -d. -f2` -ge 39 ] && \
190                         [ "`echo $E2VER | grep cfs`" ] && sh lfscktest.sh
191         fi
192
193         if [ "$LIBLUSTRE" != "no" ]; then
194                 title liblustre
195                 assert_env MGSNID
196                 export LIBLUSTRE_MOUNT_POINT=$MOUNT2
197                 export LIBLUSTRE_MOUNT_TARGET=$MGSNID:/$FSNAME
198                 export LIBLUSTRE_TIMEOUT=`cat /proc/sys/lustre/timeout`
199                 #export LIBLUSTRE_DEBUG_MASK=`cat /proc/sys/lnet/debug`
200                 if [ -x $LIBLUSTRETESTS/sanity ]; then
201                         mkdir -p $MOUNT2
202                         $LIBLUSTRETESTS/sanity --target=$LIBLUSTRE_MOUNT_TARGET
203                 fi
204                 $CLEANUP
205                 #$SETUP
206         fi
207
208         $CLEANUP
209 done
210
211 if [ "$SANITY_QUOTA" != "no" ]; then
212         title sanity-quota
213         sh sanity-quota.sh
214 fi
215
216 if [ "$REPLAY_SINGLE" != "no" ]; then
217         title replay-single
218         sh replay-single.sh
219 fi
220
221 if [ "$CONF_SANITY" != "no" ]; then
222         title conf-sanity
223         sh conf-sanity.sh
224 fi
225
226 if [ "$RECOVERY_SMALL" != "no" ]; then
227         title recovery-small
228         sh recovery-small.sh
229 fi
230
231 if [ "$REPLAY_OST_SINGLE" != "no" ]; then
232         title replay-ost-single
233         sh replay-ost-single.sh
234 fi
235
236 if [ "$REPLAY_DUAL" != "no" ]; then
237         title replay-dual
238         sh replay-dual.sh
239 fi
240
241 if [ "$INSANITY" != "no" ]; then
242         title insanity
243         sh insanity.sh -r
244 fi
245
246 title FINISHED
247
248 RC=$?
249 echo "$0: completed with rc $RC" && exit $RC