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