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