Whamcloud - gitweb
Branch HEAD
[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 [ -z "$CONFIG" -a "$NAME" ] && CONFIGS=$NAME
8 [ "$CONFIGS" ] || CONFIGS="local"  #"local lov"
9 [ "$MAX_THREADS" ] || MAX_THREADS=20
10 RAMKB=`awk '/MemTotal:/ { print $2 }' /proc/meminfo`
11 if [ -z "$THREADS" ]; then
12         THREADS=$((RAMKB / 16384))
13         [ $THREADS -gt $MAX_THREADS ] && THREADS=$MAX_THREADS
14 fi
15 [ "$SIZE" ] || SIZE=$((RAMKB * 2))
16 [ "$RSIZE" ] || RSIZE=512
17 [ "$UID" ] || UID=1000
18 [ "$MOUNT" ] || MOUNT=/mnt/lustre
19 [ "$MOUNT2" ] || MOUNT2=${MOUNT}2
20 [ "$TMP" ] || TMP=/tmp
21 [ "$COUNT" ] || COUNT=1000
22 [ "$DEBUG_LVL" ] || DEBUG_LVL=0
23 [ "$DEBUG_OFF" ] || DEBUG_OFF="eval lctl set_param debug=\"$DEBUG_LVL\""
24 [ "$DEBUG_ON" ] || DEBUG_ON="eval lctl set_param debug=0x33f0484"
25
26 export TESTSUITE_LIST="RUNTESTS SANITY DBENCH BONNIE IOZONE FSX SANITYN LFSCK LIBLUSTRE REPLAY_SINGLE CONF_SANITY RECOVERY_SMALL REPLAY_OST_SINGLE REPLAY_DUAL INSANITY SANITY_QUOTA SANITY_SEC SANITY_GSS"
27
28 if [ "$ACC_SM_ONLY" ]; then
29     for O in $TESTSUITE_LIST; do
30         export ${O}="no"
31     done
32     for O in $ACC_SM_ONLY; do
33         O=`echo ${O%.sh} | tr "-" "_"`
34         O=`echo $O | tr "[:lower:]" "[:upper:]"`
35         export ${O}="yes"
36     done
37 fi
38 LFSCK="no" # bug 13698
39 SANITY_QUOTA="no" # bug 13058
40
41 LIBLUSTRETESTS=${LIBLUSTRETESTS:-../liblustre/tests}
42
43 STARTTIME=`date +%s`
44 RANTEST=""
45
46 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
47 . $LUSTRE/tests/test-framework.sh
48 init_test_env $@
49
50 export SANITY_GSS="no"
51 if $GSS; then
52     export SANITY_GSS="yes"
53     # liblustre doesn't support GSS
54     export LIBLUSTRE=no
55 fi
56
57 SETUP=${SETUP:-setupall}
58 FORMAT=${FORMAT:-formatall}
59 CLEANUP=${CLEANUP:-stopall}
60
61 setup_if_needed() {
62     mount | grep $MOUNT && return
63     $FORMAT && $SETUP
64 }
65
66 title() {
67     # update titlebar if stdin is attaached to an xterm
68     if ${UPDATE_TITLEBAR:-false}; then
69         if tty -s; then
70             case $TERM in 
71                 xterm*)
72                     echo -ne "\033]2; acceptance-small: $* \007" >&0
73                     ;;
74             esac
75         fi
76     fi 
77     log "-----============= acceptance-small: "$*" ============----- `date`"
78     RANTEST=${RANTEST}$*", "
79 }
80
81 for NAME in $CONFIGS; do
82         export NAME MOUNT START CLEAN
83         . $LUSTRE/tests/cfg/$NAME.sh
84
85         if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mds.ko -a \
86             ! -f `dirname $0`/../mds/mds.ko ]; then
87             export CLIENTMODSONLY=true
88         fi
89         
90         assert_env mds_HOST MDS_MKFS_OPTS MDSDEV
91         assert_env ost_HOST OST_MKFS_OPTS OSTCOUNT
92         assert_env FSNAME MOUNT MOUNT2
93
94         setup_if_needed
95
96         if [ "$RUNTESTS" != "no" ]; then
97                 title runtests
98                 bash runtests
99                 $CLEANUP
100                 $SETUP
101                 RUNTESTS="done"
102         fi
103
104         if [ "$SANITY" != "no" ]; then
105                 title sanity
106                 MOUNT2="" bash sanity.sh
107                 $CLEANUP
108                 $SETUP
109                 SANITY="done"
110         fi
111
112         which dbench > /dev/null 2>&1 || DBENCH=no
113         if [ "$DBENCH" != "no" ]; then
114                 title dbench
115                 DBENCHDIR=$MOUNT/$HOSTNAME
116                 mkdir -p $DBENCHDIR
117                 SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
118                 DB_THREADS=$((SPACE / 50000))
119                 [ $THREADS -lt $DB_THREADS ] && DB_THREADS=$THREADS
120
121                 $DEBUG_OFF
122                 myUID=$RUNAS_ID
123                 myRUNAS=$RUNAS
124                 FAIL_ON_ERROR=false check_runas_id_ret $myUID $myRUNAS || { myRUNAS="" && myUID=$UID; }
125                 chown $myUID:$myUID $DBENCHDIR
126                 duration=""
127                 [ "$SLOW" = "no" ] && duration=" -t 120"
128                 if [ "$SLOW" != "no" -o $DB_THREADS -eq 1 ]; then
129                         $myRUNAS bash rundbench -D $DBENCHDIR 1 $duration || error "dbench failed!"
130                         $DEBUG_ON
131                         $CLEANUP
132                         $SETUP
133                 fi
134                 if [ $DB_THREADS -gt 1 ]; then
135                         $DEBUG_OFF
136                         $myRUNAS bash rundbench -D $DBENCHDIR $DB_THREADS $duration
137                         $DEBUG_ON
138                         $CLEANUP
139                         $SETUP
140                 fi
141                 rm -rf $DBENCHDIR
142                 DBENCH="done"
143         fi
144
145         which bonnie++ > /dev/null 2>&1 || BONNIE=no
146         if [ "$BONNIE" != "no" ]; then
147                 title bonnie
148                 BONDIR=$MOUNT/d0.bonnie
149                 mkdir -p $BONDIR
150                 $LFS setstripe -c -1 $BONDIR
151                 sync
152                 MIN=`cat /proc/fs/lustre/osc/*/kbytesavail | sort -n | head -n1`
153                 SPACE=$(( OSTCOUNT * MIN ))
154                 [ $SPACE -lt $SIZE ] && SIZE=$((SPACE * 3 / 4))
155                 log "min OST has ${MIN}kB available, using ${SIZE}kB file size"
156                 $DEBUG_OFF
157                 myUID=$RUNAS_ID
158                 myRUNAS=$RUNAS
159                 FAIL_ON_ERROR=false check_runas_id_ret $myUID $myRUNAS || { myRUNAS="" && myUID=$UID; }
160                 chown $myUID:$myUID $BONDIR             
161                 $myRUNAS bonnie++ -f -r 0 -s$((SIZE / 1024)) -n 10 -u$myUID:$myUID -d$BONDIR
162                 $DEBUG_ON
163                 $CLEANUP
164                 $SETUP
165                 BONNIE="done"
166         fi
167
168         export O_DIRECT
169         [ "$SLOW" = "no" ] && export IOZONE=no # 5 minutes
170
171         which iozone > /dev/null 2>&1 || IOZONE=no
172         if [ "$IOZONE" != "no" ]; then
173                 title iozone
174                 IOZDIR=$MOUNT/d0.iozone
175                 mkdir -p $IOZDIR
176                 $LFS setstripe -c -1 $IOZDIR
177                 sync
178                 MIN=`cat /proc/fs/lustre/osc/*/kbytesavail | sort -n | head -n1`
179                 SPACE=$(( OSTCOUNT * MIN ))
180                 [ $SPACE -lt $SIZE ] && SIZE=$((SPACE * 3 / 4))
181                 log "min OST has ${MIN}kB available, using ${SIZE}kB file size"
182                 IOZONE_OPTS="-i 0 -i 1 -i 2 -e -+d -r $RSIZE -s $SIZE"
183                 IOZFILE="$IOZDIR/iozone"
184                 IOZLOG=$TMP/iozone.log
185                 # $SPACE was calculated with all OSTs
186                 $DEBUG_OFF
187                 myUID=$RUNAS_ID
188                 myRUNAS=$RUNAS
189                 FAIL_ON_ERROR=false check_runas_id_ret $myUID $myRUNAS || { myRUNAS="" && myUID=$UID; }
190                 chown $myUID:$myUID $IOZDIR
191                 $myRUNAS iozone $IOZONE_OPTS -f $IOZFILE 2>&1 | tee $IOZLOG
192                 tail -1 $IOZLOG | grep -q complete || \
193                         { error "iozone (1) failed" && false; }
194                 rm -f $IOZLOG
195                 $DEBUG_ON
196                 $CLEANUP
197                 $SETUP
198
199                 # check if O_DIRECT support is implemented in kernel
200                 if [ -z "$O_DIRECT" ]; then
201                         touch $MOUNT/f.iozone
202                         if ! ./directio write $MOUNT/f.iozone 0 1; then
203                                 O_DIRECT=no
204                         fi
205                         rm -f $MOUNT/f.iozone
206                 fi
207                 if [ "$O_DIRECT" != "no" -a "$IOZONE_DIR" != "no" ]; then
208                         $DEBUG_OFF
209                         # cd TMP to have write permission for tmp file iozone writes
210                         ( cd $TMP && $myRUNAS iozone -I $IOZONE_OPTS $IOZFILE.odir 2>&1 | tee $IOZLOG)
211                         tail -1 $IOZLOG | grep -q complete || \
212                                 { error "iozone (2) failed" && false; }
213                         rm -f $IOZLOG
214                         $DEBUG_ON
215                         $CLEANUP
216                         $SETUP
217                 fi
218
219                 SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
220                 IOZ_THREADS=$((SPACE / SIZE * 2 / 3 ))
221                 [ $THREADS -lt $IOZ_THREADS ] && IOZ_THREADS=$THREADS
222                 IOZVER=`iozone -v | awk '/Revision:/ {print $3}' | tr -d .`
223                 if [ "$IOZ_THREADS" -gt 1 -a "$IOZVER" -ge 3145 ]; then
224                         $LFS setstripe -c -1 $IOZDIR
225                         $DEBUG_OFF
226                         THREAD=1
227                         IOZFILE="-F "
228                         while [ $THREAD -le $IOZ_THREADS ]; do
229                                 IOZFILE="$IOZFILE $IOZDIR/iozone.$THREAD"
230                                 THREAD=$((THREAD + 1))
231                         done
232                         $myRUNAS iozone $IOZONE_OPTS -t $IOZ_THREADS $IOZFILE 2>&1 | tee $IOZLOG
233                         tail -1 $IOZLOG | grep -q complete || \
234                                 { error "iozone (3) failed" && false; }
235                         rm -f $IOZLOG
236                         $DEBUG_ON
237                         $CLEANUP
238                         $SETUP
239                 elif [ $IOZVER -lt 3145 ]; then
240                         VER=`iozone -v | awk '/Revision:/ { print $3 }'`
241                         echo "iozone $VER too old for multi-thread test"
242                 fi
243                 IOZONE="done"
244         fi
245
246         if [ "$FSX" != "no" ]; then
247                 title fsx
248                 SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
249                 [ $SPACE -lt $SIZE ] && SIZE=$((SPACE * 3 / 4))
250                 $DEBUG_OFF
251                 ./fsx -c 50 -p 1000 -P $TMP -l $SIZE \
252                         -N $(($COUNT * 100)) $MOUNT/fsxfile
253                 $DEBUG_ON
254                 $CLEANUP
255                 $SETUP
256                 FSX="done"
257         fi      
258
259         if [ "$SANITYN" != "no" ]; then
260                 title sanityN
261                 $DEBUG_OFF
262
263                 mkdir -p $MOUNT2
264                 mount_client $MOUNT2
265                 #echo "can't mount2 for '$NAME', skipping sanityN.sh"
266                 START=: CLEAN=: bash sanityN.sh
267                 umount $MOUNT2
268
269                 $DEBUG_ON
270                 $CLEANUP
271                 $SETUP
272                 SANITYN="done"
273         fi
274
275         remote_mds && log "Remote MDS, skipping LFSCK test" && LFSCK=no
276         remote_ost && log "Remote OST, skipping LFSCK test" && LFSCK=no
277
278         if [ "$LFSCK" != "no" -a -x /usr/sbin/lfsck ]; then
279                 title lfsck
280                 E2VER=`e2fsck -V 2>&1 | head -n 1 | cut -d' ' -f 2`
281                 if [ `echo $E2VER | cut -d. -f2` -ge 39 ] && \
282                    [ "`echo $E2VER | grep cfs`" -o \
283                         "`echo $E2VER | grep sun`" ]; then
284                                 bash lfscktest.sh
285                 else
286                         e2fsck -V
287                         echo "e2fsck does not support lfsck, skipping"
288                 fi
289                 LFSCK="done"
290         fi
291
292         [ "$NETTYPE" = "tcp" -o "$NETTYPE" = "ptl" ] || LIBLUSTRE=no # bug 15660
293         if [ "$LIBLUSTRE" != "no" ]; then
294                 title liblustre
295                 assert_env MGSNID MOUNT2
296                 $CLEANUP
297                 unload_modules
298                 # Liblustre needs accept=all, noacl
299                 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
300                 [ -f /etc/modprobe.d/Lustre ] && MODPROBECONF=/etc/modprobe.d/Lustre
301
302                 LNETOPTS="$(awk '/^options lnet/ { print $0}' $MODPROBECONF | \
303                         sed 's/^options lnet //g; s/"//g') accept=all" \
304                         MDS_MOUNT_OPTS=$(echo $MDS_MOUNT_OPTS | sed 's/^[ \t]*//;s/[ \t]*$//') \
305                         MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl" \
306                         MDS_MOUNT_OPTS=${MDS_MOUNT_OPTS/#,/-o } \
307                         $SETUP
308                 export LIBLUSTRE_MOUNT_POINT=$MOUNT2
309                 export LIBLUSTRE_MOUNT_TARGET=$MGSNID:/$FSNAME
310                 export LIBLUSTRE_TIMEOUT=`cat /proc/sys/lustre/timeout`
311                 #export LIBLUSTRE_DEBUG_MASK=`cat /proc/sys/lnet/debug`
312                 if [ -x $LIBLUSTRETESTS/sanity ]; then
313                         mkdir -p $MOUNT2
314                         echo $LIBLUSTRETESTS/sanity --target=$LIBLUSTRE_MOUNT_TARGET
315                         $LIBLUSTRETESTS/sanity --target=$LIBLUSTRE_MOUNT_TARGET
316                 fi
317                 $CLEANUP
318                 #$SETUP
319                 LIBLUSTRE="done"
320         fi
321
322         $CLEANUP
323 done
324
325 if [ "$REPLAY_SINGLE" != "no" ]; then
326         title replay-single
327         bash replay-single.sh
328         REPLAY_SINGLE="done"
329 fi
330
331 if [ "$CONF_SANITY" != "no" ]; then
332         title conf-sanity
333         bash conf-sanity.sh
334         CONF_SANITY="done"
335 fi
336
337 if [ "$RECOVERY_SMALL" != "no" ]; then
338         title recovery-small
339         bash recovery-small.sh
340         RECOVERY_SMALL="done"
341 fi
342
343 if [ "$REPLAY_OST_SINGLE" != "no" ]; then
344         title replay-ost-single
345         bash replay-ost-single.sh
346         REPLAY_OST_SINGLE="done"
347 fi
348
349 if [ "$REPLAY_DUAL" != "no" ]; then
350         title replay-dual
351         bash replay-dual.sh
352         REPLAY_DUAL="done"
353 fi
354
355 if [ "$INSANITY" != "no" ]; then
356         title insanity
357         bash insanity.sh -r
358         INSANITY="done"
359 fi
360
361 if [ "$SANITY_QUOTA" != "no" ]; then
362         title sanity-quota
363         bash sanity-quota.sh
364         SANITY_QUOTA="done"
365 fi
366
367 if [ "$SANITY_SEC" != "no" ]; then
368         title sanity-sec
369         bash sanity-sec.sh
370         SANITY_SEC="done"
371 fi
372
373 if [ "$SANITY_GSS" != "no" ]; then
374         title sanity-gss
375         bash sanity-gss.sh
376         SANITY_GSS="done"
377 fi
378
379 RC=$?
380 title FINISHED
381 echo "Finished at `date` in $((`date +%s` - $STARTTIME))s"
382 echo "Tests ran: $RANTEST"
383 print_summary
384 echo "$0: completed with rc $RC" && exit $RC