Whamcloud - gitweb
b=15660
[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 [ "$ACC_SM_ONLY" ]; then
31     for O in $TESTSUITE_LIST; do
32         export ${O}="no"
33     done
34     for O in $ACC_SM_ONLY; do
35         O=`echo $O | tr "[:lower:]" "[:upper:]"`
36         export ${O}="yes"
37     done
38 fi
39 LFSCK="no" # bug 13698
40
41 LIBLUSTRETESTS=${LIBLUSTRETESTS:-../liblustre/tests}
42
43 STARTTIME=`date +%s`
44 RANTEST=""
45
46 LUSTRE=${LUSTRE:-`dirname $0`/..}
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     log "-----============= acceptance-small: "$*" ============----- `date`"
66     RANTEST=${RANTEST}$*", "
67 }
68
69 for NAME in $CONFIGS; do
70         export NAME MOUNT START CLEAN
71         . $LUSTRE/tests/cfg/$NAME.sh
72
73         if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mds.ko -a \
74             ! -f `dirname $0`/../mds/mds.ko ]; then
75             export CLIENTMODSONLY=true
76         fi
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_ret $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_ret $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         [ "$SLOW" = "no" ] && export IOZONE=no # 5 minutes
158
159         which iozone > /dev/null 2>&1 || IOZONE=no
160         if [ "$IOZONE" != "no" ]; then
161                 title iozone
162                 IOZDIR=$MOUNT/d0.iozone
163                 mkdir -p $IOZDIR
164                 $LFS setstripe -c -1 $IOZDIR
165                 sync
166                 MIN=`cat /proc/fs/lustre/osc/*/kbytesavail | sort -n | head -n1`
167                 SPACE=$(( OSTCOUNT * MIN ))
168                 [ $SPACE -lt $SIZE ] && SIZE=$((SPACE * 3 / 4))
169                 log "min OST has ${MIN}kB available, using ${SIZE}kB file size"
170                 IOZONE_OPTS="-i 0 -i 1 -i 2 -e -+d -r $RSIZE -s $SIZE"
171                 IOZFILE="$IOZDIR/iozone"
172                 # $SPACE was calculated with all OSTs
173                 $DEBUG_OFF
174                 myUID=$RUNAS_ID
175                 myRUNAS=$RUNAS
176                 FAIL_ON_ERROR=false check_runas_id_ret $myUID $myRUNAS || { myRUNAS="" && myUID=$UID; }
177                 chown $myUID:$myUID $IOZDIR
178                 $myRUNAS iozone $IOZONE_OPTS -f $IOZFILE
179                 $DEBUG_ON
180                 $CLEANUP
181                 $SETUP
182
183                 # check if O_DIRECT support is implemented in kernel
184                 if [ -z "$O_DIRECT" ]; then
185                         touch $MOUNT/f.iozone
186                         if ! ./directio write $MOUNT/f.iozone 0 1; then
187                                 O_DIRECT=no
188                         fi
189                         rm -f $MOUNT/f.iozone
190                 fi
191                 if [ "$O_DIRECT" != "no" -a "$IOZONE_DIR" != "no" ]; then
192                         $DEBUG_OFF
193                         # cd TMP to have write permission for tmp file iozone writes
194                         ( cd $TMP && $myRUNAS iozone -I $IOZONE_OPTS $IOZFILE.odir )
195                         $DEBUG_ON
196                         $CLEANUP
197                         $SETUP
198                 fi
199
200                 SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
201                 IOZ_THREADS=$((SPACE / SIZE * 2 / 3 ))
202                 [ $THREADS -lt $IOZ_THREADS ] && IOZ_THREADS=$THREADS
203                 IOZVER=`iozone -v | awk '/Revision:/ {print $3}' | tr -d .`
204                 if [ "$IOZ_THREADS" -gt 1 -a "$IOZVER" -ge 3145 ]; then
205                         $LFS setstripe -c 1 $IOZDIR
206                         $DEBUG_OFF
207                         THREAD=1
208                         IOZFILE="-F "
209                         while [ $THREAD -le $IOZ_THREADS ]; do
210                                 IOZFILE="$IOZFILE $IOZDIR/iozone.$THREAD"
211                                 THREAD=$((THREAD + 1))
212                         done
213                         $myRUNAS iozone $IOZONE_OPTS -t $IOZ_THREADS $IOZFILE
214                         $DEBUG_ON
215                         $CLEANUP
216                         $SETUP
217                 elif [ $IOZVER -lt 3145 ]; then
218                         VER=`iozone -v | awk '/Revision:/ { print $3 }'`
219                         echo "iozone $VER too old for multi-thread test"
220                 fi
221                 IOZONE="done"
222         fi
223
224         if [ "$FSX" != "no" ]; then
225                 title fsx
226                 SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
227                 [ $SPACE -lt $SIZE ] && SIZE=$((SPACE * 3 / 4))
228                 $DEBUG_OFF
229                 ./fsx -c 50 -p 1000 -P $TMP -l $SIZE \
230                         -N $(($COUNT * 100)) $MOUNT/fsxfile
231                 $DEBUG_ON
232                 $CLEANUP
233                 $SETUP
234                 FSX="done"
235         fi      
236
237         if [ "$SANITYN" != "no" ]; then
238                 title sanityN
239                 $DEBUG_OFF
240
241                 mkdir -p $MOUNT2
242                 mount_client $MOUNT2
243                 #echo "can't mount2 for '$NAME', skipping sanityN.sh"
244                 START=: CLEAN=: bash sanityN.sh
245                 umount $MOUNT2
246
247                 $DEBUG_ON
248                 $CLEANUP
249                 $SETUP
250                 SANITYN="done"
251         fi
252
253         if [ "$LFSCK" != "no" -a -x /usr/sbin/lfsck ]; then
254                 title lfsck
255                 E2VER=`e2fsck -V 2>&1 | head -n 1 | cut -d' ' -f 2`
256                 if grep -q obdfilter /proc/fs/lustre/devices; then
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                 else
266                         echo "remote OST, skipping test"
267                 fi
268                 LFSCK="done"
269         fi
270
271         [ "$NETTYPE" = "tcp" ] || LIBLUSTRE=no # bug 15660
272         if [ "$LIBLUSTRE" != "no" ]; then
273                 title liblustre
274                 assert_env MGSNID MOUNT2
275                 $CLEANUP
276                 unload_modules
277                 # Liblustre needs accept=all, noacl
278                 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
279                 [ -f /etc/modprobe.d/Lustre ] && MODPROBECONF=/etc/modprobe.d/Lustre
280
281                 LNETOPTS="$(awk '/^options lnet/ { print $0}' $MODPROBECONF | \
282                         sed 's/^options lnet //g') accept=all" \
283                         MDS_MOUNT_OPTS=$(echo $MDS_MOUNT_OPTS | sed 's/^[ \t]*//;s/[ \t]*$//') \
284                         MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl" \
285                         MDS_MOUNT_OPTS=${MDS_MOUNT_OPTS/#,/-o } \
286                         $SETUP
287                 export LIBLUSTRE_MOUNT_POINT=$MOUNT2
288                 export LIBLUSTRE_MOUNT_TARGET=$MGSNID:/$FSNAME
289                 export LIBLUSTRE_TIMEOUT=`cat /proc/sys/lustre/timeout`
290                 #export LIBLUSTRE_DEBUG_MASK=`cat /proc/sys/lnet/debug`
291                 if [ -x $LIBLUSTRETESTS/sanity ]; then
292                         mkdir -p $MOUNT2
293                         echo $LIBLUSTRETESTS/sanity --target=$LIBLUSTRE_MOUNT_TARGET
294                         $LIBLUSTRETESTS/sanity --target=$LIBLUSTRE_MOUNT_TARGET
295                 fi
296                 $CLEANUP
297                 #$SETUP
298                 LIBLUSTRE="done"
299         fi
300
301         $CLEANUP
302 done
303
304 if [ "$REPLAY_SINGLE" != "no" ]; then
305         title replay-single
306         bash replay-single.sh
307         REPLAY_SINGLE="done"
308 fi
309
310 if [ "$CONF_SANITY" != "no" ]; then
311         title conf-sanity
312         bash conf-sanity.sh
313         CONF_SANITY="done"
314 fi
315
316 if [ "$RECOVERY_SMALL" != "no" ]; then
317         title recovery-small
318         bash recovery-small.sh
319         RECOVERY_SMALL="done"
320 fi
321
322 if [ "$REPLAY_OST_SINGLE" != "no" ]; then
323         title replay-ost-single
324         bash replay-ost-single.sh
325         REPLAY_OST_SINGLE="done"
326 fi
327
328 if [ "$REPLAY_DUAL" != "no" ]; then
329         title replay-dual
330         bash replay-dual.sh
331         REPLAY_DUAL="done"
332 fi
333
334 if [ "$INSANITY" != "no" ]; then
335         title insanity
336         bash insanity.sh -r
337         INSANITY="done"
338 fi
339
340 if [ "$SANITY_QUOTA" != "no" ]; then
341         title sanity-quota
342         bash sanity-quota.sh
343         SANITY_QUOTA="done"
344 fi
345
346 if [ "$SANITY_SEC" != "no" ]; then
347         title sanity-sec
348         bash sanity-sec.sh
349 fi
350
351 RC=$?
352 title FINISHED
353 echo "Finished at `date` in $((`date +%s` - $STARTTIME))s"
354 echo "Tests ran: $RANTEST"
355 print_summary
356 echo "$0: completed with rc $RC" && exit $RC