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