Whamcloud - gitweb
b=14330
[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 PATH=`dirname $0`/../utils:$PATH
8
9 [ -z "$CONFIG" -a "$NAME" ] && CONFIGS=$NAME
10 [ "$CONFIGS" ] || CONFIGS="local"  #"local lov"
11 [ "$MAX_THREADS" ] || MAX_THREADS=20
12 RAMKB=`awk '/MemTotal:/ { print $2 }' /proc/meminfo`
13 if [ -z "$THREADS" ]; then
14         THREADS=$((RAMKB / 16384))
15         [ $THREADS -gt $MAX_THREADS ] && THREADS=$MAX_THREADS
16 fi
17 [ "$SIZE" ] || SIZE=$((RAMKB * 2))
18 [ "$RSIZE" ] || RSIZE=512
19 [ "$UID" ] || UID=1000
20 [ "$MOUNT" ] || MOUNT=/mnt/lustre
21 [ "$MOUNT2" ] || MOUNT2=${MOUNT}2
22 [ "$TMP" ] || TMP=/tmp
23 [ "$COUNT" ] || COUNT=1000
24 [ "$DEBUG_LVL" ] || DEBUG_LVL=0
25 [ "$DEBUG_OFF" ] || DEBUG_OFF="eval sysctl -w lnet.debug=\"$DEBUG_LVL\""
26 [ "$DEBUG_ON" ] || DEBUG_ON="eval sysctl -w lnet.debug=0x33f0484"
27
28 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"
29
30 if [ "$SLOW" = "no" ]; then
31 #          5 min  
32     export IOZONE="no"
33 fi
34
35 if [ "$ACC_SM_ONLY" ]; then
36     for O in $TESTSUITE_LIST; do
37         export ${O}="no"
38     done
39     for O in $ACC_SM_ONLY; do
40         O=`echo $O | tr "[:lower:]" "[:upper:]"`
41         export ${O}="yes"
42     done
43 fi
44 LFSCK="no" # bug 13698
45
46 LIBLUSTRETESTS=${LIBLUSTRETESTS:-../liblustre/tests}
47
48 STARTTIME=`date +%s`
49 RANTEST=""
50
51 LUSTRE=${LUSTRE:-`dirname $0`/..}
52 . $LUSTRE/tests/test-framework.sh
53 init_test_env $@
54
55 if $GSS; then
56     # liblustre doesn't support GSS
57     export LIBLUSTRE=no
58 fi
59
60 SETUP=${SETUP:-setupall}
61 FORMAT=${FORMAT:-formatall}
62 CLEANUP=${CLEANUP:-stopall}
63
64 setup_if_needed() {
65     mount | grep $MOUNT && return
66     $FORMAT && $SETUP
67 }
68
69 title() {
70     log "-----============= acceptance-small: "$*" ============----- `date`"
71     RANTEST=${RANTEST}$*", "
72 }
73
74 for NAME in $CONFIGS; do
75         export NAME MOUNT START CLEAN
76         . $LUSTRE/tests/cfg/$NAME.sh
77         
78         assert_env mds_HOST MDS_MKFS_OPTS MDSDEV
79         assert_env ost_HOST OST_MKFS_OPTS OSTCOUNT
80         assert_env FSNAME MOUNT MOUNT2
81
82         setup_if_needed
83
84         if [ "$RUNTESTS" != "no" ]; then
85                 title runtests
86                 bash runtests
87                 $CLEANUP
88                 $SETUP
89                 RUNTESTS="done"
90         fi
91
92         if [ "$SANITY" != "no" ]; then
93                 title sanity
94                 MOUNT2="" bash sanity.sh
95                 $CLEANUP
96                 $SETUP
97                 SANITY="done"
98         fi
99
100         which dbench > /dev/null 2>&1 || DBENCH=no
101         if [ "$DBENCH" != "no" ]; then
102                 title dbench
103                 DBENCHDIR=$MOUNT/$HOSTNAME
104                 mkdir -p $DBENCHDIR
105                 SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
106                 DB_THREADS=$((SPACE / 50000))
107                 [ $THREADS -lt $DB_THREADS ] && DB_THREADS=$THREADS
108
109                 $DEBUG_OFF
110                 myUID=$RUNAS_ID
111                 myRUNAS=$RUNAS
112                 FAIL_ON_ERROR=false check_runas_id $myUID $myRUNAS || { myRUNAS="" && myUID=$UID; }
113                 chown $myUID:$myUID $DBENCHDIR
114                 duration=""
115                 [ "$SLOW" = "no" ] && duration=" -t 120"
116                 if [ "$SLOW" != "no" -o $DB_THREADS -eq 1 ]; then
117                         DIR=$DBENCHDIR $myRUNAS bash rundbench 1 $duration
118                         $DEBUG_ON
119                         $CLEANUP
120                         $SETUP
121                 fi
122                 if [ $DB_THREADS -gt 1 ]; then
123                         $DEBUG_OFF
124                         DIR=$DBENCHDIR $myRUNAS bash rundbench $DB_THREADS $duration
125                         $DEBUG_ON
126                         $CLEANUP
127                         $SETUP
128                 fi
129                 rm -rf $DBENCHDIR
130                 DBENCH="done"
131         fi
132
133         which bonnie++ > /dev/null 2>&1 || BONNIE=no
134         if [ "$BONNIE" != "no" ]; then
135                 title bonnie
136                 BONDIR=$MOUNT/d0.bonnie
137                 mkdir -p $BONDIR
138                 $LFS setstripe -c -1 $BONDIR
139                 sync
140                 MIN=`cat /proc/fs/lustre/osc/*/kbytesavail | sort -n | head -n1`
141                 SPACE=$(( OSTCOUNT * MIN ))
142                 [ $SPACE -lt $SIZE ] && SIZE=$((SPACE * 3 / 4))
143                 log "min OST has ${MIN}kB available, using ${SIZE}kB file size"
144                 $DEBUG_OFF
145                 myUID=$RUNAS_ID
146                 myRUNAS=$RUNAS
147                 FAIL_ON_ERROR=false check_runas_id $myUID $myRUNAS || { myRUNAS="" && myUID=$UID; }
148                 chown $myUID:$myUID $BONDIR             
149                 $myRUNAS bonnie++ -f -r 0 -s$((SIZE / 1024)) -n 10 -u$myUID:$myUID -d$BONDIR
150                 $DEBUG_ON
151                 $CLEANUP
152                 $SETUP
153                 BONNIE="done"
154         fi
155
156         export O_DIRECT
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 $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         if [ "$LFSCK" != "no" -a -x /usr/sbin/lfsck ]; then
252                 title lfsck
253                 E2VER=`e2fsck -V 2>&1 | head -n 1 | cut -d' ' -f 2`
254                 if grep -q obdfilter /proc/fs/lustre/devices; then
255                         if [ `echo $E2VER | cut -d. -f2` -ge 39 ] && \
256                            [ "`echo $E2VER | grep cfs`" ]; then
257                                 bash lfscktest.sh
258                         else
259                                 e2fsck -V
260                                 echo "e2fsck does not support lfsck, skipping"
261                         fi
262                 else
263                         echo "remote OST, skipping test"
264                 fi
265                 LFSCK="done"
266         fi
267
268         if [ "$LIBLUSTRE" != "no" ]; then
269                 title liblustre
270                 assert_env MGSNID MOUNT2
271                 $CLEANUP
272                 unload_modules
273                 # Liblustre needs accept=all, noacl
274                 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
275                 [ -f /etc/modprobe.d/Lustre ] && MODPROBECONF=/etc/modprobe.d/Lustre
276
277                 LNETOPTS="$(awk '/^options lnet/ { print $0}' $MODPROBECONF | \
278                         sed 's/^options lnet //g') accept=all" \
279                         MDS_MOUNT_OPTS=$(echo $MDS_MOUNT_OPTS | sed 's/^[ \t]*//;s/[ \t]*$//') \
280                         MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl" \
281                         MDS_MOUNT_OPTS=${MDS_MOUNT_OPTS/#,/-o } \
282                         $SETUP
283                 export LIBLUSTRE_MOUNT_POINT=$MOUNT2
284                 export LIBLUSTRE_MOUNT_TARGET=$MGSNID:/$FSNAME
285                 export LIBLUSTRE_TIMEOUT=`cat /proc/sys/lustre/timeout`
286                 #export LIBLUSTRE_DEBUG_MASK=`cat /proc/sys/lnet/debug`
287                 if [ -x $LIBLUSTRETESTS/sanity ]; then
288                         mkdir -p $MOUNT2
289                         echo $LIBLUSTRETESTS/sanity --target=$LIBLUSTRE_MOUNT_TARGET
290                         $LIBLUSTRETESTS/sanity --target=$LIBLUSTRE_MOUNT_TARGET
291                 fi
292                 $CLEANUP
293                 #$SETUP
294                 LIBLUSTRE="done"
295         fi
296
297         $CLEANUP
298 done
299
300 if [ "$REPLAY_SINGLE" != "no" ]; then
301         title replay-single
302         bash replay-single.sh
303         REPLAY_SINGLE="done"
304 fi
305
306 if [ "$CONF_SANITY" != "no" ]; then
307         title conf-sanity
308         bash conf-sanity.sh
309         CONF_SANITY="done"
310 fi
311
312 if [ "$RECOVERY_SMALL" != "no" ]; then
313         title recovery-small
314         bash recovery-small.sh
315         RECOVERY_SMALL="done"
316 fi
317
318 if [ "$REPLAY_OST_SINGLE" != "no" ]; then
319         title replay-ost-single
320         bash replay-ost-single.sh
321         REPLAY_OST_SINGLE="done"
322 fi
323
324 if [ "$REPLAY_DUAL" != "no" ]; then
325         title replay-dual
326         bash replay-dual.sh
327         REPLAY_DUAL="done"
328 fi
329
330 if [ "$INSANITY" != "no" ]; then
331         title insanity
332         bash insanity.sh -r
333         INSANITY="done"
334 fi
335
336 if [ "$SANITY_QUOTA" != "no" ]; then
337         title sanity-quota
338         bash sanity-quota.sh
339         SANITY_QUOTA="done"
340 fi
341
342 if [ "$SANITY_SEC" != "no" ]; then
343         title sanity-sec
344         bash sanity-sec.sh
345 fi
346
347 RC=$?
348 title FINISHED
349 echo "Finished at `date` in $((`date +%s` - $STARTTIME))s"
350 echo "Tests ran: $RANTEST"
351 print_summary
352 echo "$0: completed with rc $RC" && exit $RC