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