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