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