Whamcloud - gitweb
b=17397
[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 SANITY_SEC SANITY_GSS PERFORMANCE_SANITY"
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%.sh} | tr "-" "_"`
34         O=`echo $O | tr "[:lower:]" "[:upper:]"`
35         export ${O}="yes"
36     done
37 fi
38 LFSCK="no" # bug 13698
39 SANITY_QUOTA="no" # bug 13058
40
41 LIBLUSTRETESTS=${LIBLUSTRETESTS:-../liblustre/tests}
42
43 STARTTIME=`date +%s`
44 RANTEST=""
45
46 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
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 else
54     export SANITY_GSS="no"
55 fi
56
57 SETUP=${SETUP:-setupall}
58 FORMAT=${FORMAT:-formatall}
59 CLEANUP=${CLEANUP:-stopall}
60
61 setup_if_needed() {
62     mount | grep $MOUNT && return
63     $FORMAT && $SETUP
64 }
65
66 title() {
67     # update titlebar if stdin is attaached to an xterm
68     if ${UPDATE_TITLEBAR:-false}; then
69         if tty -s; then
70             case $TERM in 
71                 xterm*)
72                     echo -ne "\033]2; acceptance-small: $* \007" >&0
73                     ;;
74             esac
75         fi
76     fi 
77     log "-----============= acceptance-small: "$*" ============----- `date`"
78     RANTEST=${RANTEST}$*", "
79 }
80
81 skip_remost()
82 {
83         remote_ost_nodsh && log "SKIP: $1: remote OST with nodsh" && return 0
84         return 1
85 }
86
87 skip_remmds()
88 {
89         remote_mds_nodsh && log "SKIP: $1: remote MDS with nodsh" && return 0
90         return 1
91 }
92
93 for NAME in $CONFIGS; do
94         export NAME MOUNT START CLEAN
95         . $LUSTRE/tests/cfg/$NAME.sh
96
97         if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mds.ko -a \
98             ! -f `dirname $0`/../mds/mds.ko ]; then
99             export CLIENTMODSONLY=true
100         fi
101         
102         assert_env mds_HOST MDS_MKFS_OPTS 
103         assert_env ost_HOST OST_MKFS_OPTS OSTCOUNT
104         assert_env FSNAME MOUNT MOUNT2
105
106         setup_if_needed
107
108         MSKIPPED=0
109         OSKIPPED=0
110         if [ "$RUNTESTS" != "no" ]; then
111                 title runtests
112                 bash runtests
113                 $CLEANUP
114                 $SETUP
115                 RUNTESTS="done"
116         fi
117
118         if [ "$SANITY" != "no" ]; then
119                 title sanity
120                 MOUNT2="" bash sanity.sh
121                 $CLEANUP
122                 $SETUP
123                 SANITY="done"
124         fi
125
126         which dbench > /dev/null 2>&1 || DBENCH=no
127         if [ "$DBENCH" != "no" ]; then
128                 title dbench
129                 DBENCHDIR=$MOUNT/$HOSTNAME
130                 mkdir -p $DBENCHDIR
131                 SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
132                 DB_THREADS=$((SPACE / 50000))
133                 [ $THREADS -lt $DB_THREADS ] && DB_THREADS=$THREADS
134
135                 $DEBUG_OFF
136                 myUID=$RUNAS_ID
137                 myRUNAS=$RUNAS
138                 FAIL_ON_ERROR=false check_runas_id_ret $myUID $myRUNAS || { myRUNAS="" && myUID=$UID; }
139                 chown $myUID:$myUID $DBENCHDIR
140                 duration=""
141                 [ "$SLOW" = "no" ] && duration=" -t 120"
142                 if [ "$SLOW" != "no" -o $DB_THREADS -eq 1 ]; then
143                         $myRUNAS bash rundbench -D $DBENCHDIR 1 $duration || error "dbench failed!"
144                         $DEBUG_ON
145                         $CLEANUP
146                         $SETUP
147                 fi
148                 if [ $DB_THREADS -gt 1 ]; then
149                         $DEBUG_OFF
150                         $myRUNAS bash rundbench -D $DBENCHDIR $DB_THREADS $duration
151                         $DEBUG_ON
152                         $CLEANUP
153                         $SETUP
154                 fi
155                 rm -rf $DBENCHDIR
156                 DBENCH="done"
157         fi
158
159         which bonnie++ > /dev/null 2>&1 || BONNIE=no
160         if [ "$BONNIE" != "no" ]; then
161                 title bonnie
162                 BONDIR=$MOUNT/d0.bonnie
163                 mkdir -p $BONDIR
164                 $LFS setstripe -c -1 $BONDIR
165                 sync
166                 MIN=`lctl get_param -n 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                 $DEBUG_OFF
171                 myUID=$RUNAS_ID
172                 myRUNAS=$RUNAS
173                 FAIL_ON_ERROR=false check_runas_id_ret $myUID $myRUNAS || { myRUNAS="" && myUID=$UID; }
174                 chown $myUID:$myUID $BONDIR             
175                 $myRUNAS bonnie++ -f -r 0 -s$((SIZE / 1024)) -n 10 -u$myUID:$myUID -d$BONDIR
176                 $DEBUG_ON
177                 $CLEANUP
178                 $SETUP
179                 BONNIE="done"
180         fi
181
182         export O_DIRECT
183         [ "$SLOW" = "no" ] && export IOZONE=no # 5 minutes
184
185         which iozone > /dev/null 2>&1 || IOZONE=no
186         if [ "$IOZONE" != "no" ]; then
187                 title iozone
188                 IOZDIR=$MOUNT/d0.iozone
189                 mkdir -p $IOZDIR
190                 $LFS setstripe -c -1 $IOZDIR
191                 sync
192                 MIN=`lctl get_param -n osc.*.kbytesavail | sort -n | head -n1`
193                 SPACE=$(( OSTCOUNT * MIN ))
194                 [ $SPACE -lt $SIZE ] && SIZE=$((SPACE * 3 / 4))
195                 log "min OST has ${MIN}kB available, using ${SIZE}kB file size"
196                 IOZONE_OPTS="-i 0 -i 1 -i 2 -e -+d -r $RSIZE"
197                 IOZFILE="$IOZDIR/iozone"
198                 IOZLOG=$TMP/iozone.log
199                 # $SPACE was calculated with all OSTs
200                 $DEBUG_OFF
201                 myUID=$RUNAS_ID
202                 myRUNAS=$RUNAS
203                 FAIL_ON_ERROR=false check_runas_id_ret $myUID $myRUNAS || { myRUNAS="" && myUID=$UID; }
204                 chown $myUID:$myUID $IOZDIR
205                 $myRUNAS iozone $IOZONE_OPTS -s $SIZE -f $IOZFILE 2>&1 | tee $IOZLOG
206                 tail -1 $IOZLOG | grep -q complete || \
207                         { error "iozone (1) failed" && false; }
208                 rm -f $IOZLOG
209                 $DEBUG_ON
210                 $CLEANUP
211                 $SETUP
212
213                 # check if O_DIRECT support is implemented in kernel
214                 if [ -z "$O_DIRECT" ]; then
215                         touch $MOUNT/f.iozone
216                         if ! ./directio write $MOUNT/f.iozone 0 1; then
217                                 log "SKIP iozone DIRECT IO test"
218                                 O_DIRECT=no
219                         fi
220                         rm -f $MOUNT/f.iozone
221                 fi
222                 if [ "$O_DIRECT" != "no" -a "$IOZONE_DIR" != "no" ]; then
223                         $DEBUG_OFF
224                         $myRUNAS iozone -I $IOZONE_OPTS -s $SIZE -f $IOZFILE.odir 2>&1 | tee $IOZLOG
225                         tail -1 $IOZLOG | grep -q complete || \
226                                 { error "iozone (2) failed" && false; }
227                         rm -f $IOZLOG
228                         $DEBUG_ON
229                         $CLEANUP
230                         $SETUP
231                 fi
232
233                 SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
234                 IOZ_THREADS=$((SPACE / SIZE * 2 / 3 ))
235                 [ $THREADS -lt $IOZ_THREADS ] && IOZ_THREADS=$THREADS
236                 IOZVER=`iozone -v | awk '/Revision:/ {print $3}' | tr -d .`
237                 if [ "$IOZ_THREADS" -gt 1 -a "$IOZVER" -ge 3145 ]; then
238                         $LFS setstripe -c -1 $IOZDIR
239                         $DEBUG_OFF
240                         THREAD=1
241                         IOZFILE=" "
242                         while [ $THREAD -le $IOZ_THREADS ]; do
243                                 IOZFILE="$IOZFILE $IOZDIR/iozone.$THREAD"
244                                 THREAD=$((THREAD + 1))
245                         done
246                         $myRUNAS iozone $IOZONE_OPTS -s $((SIZE / IOZ_THREADS)) -t $IOZ_THREADS -F $IOZFILE 2>&1 | tee $IOZLOG
247                         tail -1 $IOZLOG | grep -q complete || \
248                                 { error "iozone (3) failed" && false; }
249                         rm -f $IOZLOG
250                         $DEBUG_ON
251                         $CLEANUP
252                         $SETUP
253                 elif [ $IOZVER -lt 3145 ]; then
254                         VER=`iozone -v | awk '/Revision:/ { print $3 }'`
255                         echo "iozone $VER too old for multi-thread test"
256                 fi
257                 IOZONE="done"
258         fi
259
260         if [ "$FSX" != "no" ]; then
261                 title fsx
262                 SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
263                 [ $SPACE -lt $SIZE ] && SIZE=$((SPACE * 3 / 4))
264                 $DEBUG_OFF
265                 FSX_SEED=${FSX_SEED:-$RANDOM}
266                 rm -f $MOUNT/fsxfile
267                 $LFS setstripe -c -1 $MOUNT/fsxfile
268                 ./fsx -c 50 -p 1000 -S $FSX_SEED -P $TMP -l $SIZE \
269                         -N $(($COUNT * 100)) $MOUNT/fsxfile
270                 $DEBUG_ON
271                 $CLEANUP
272                 $SETUP
273                 FSX="done"
274         fi      
275
276         if [ "$SANITYN" != "no" ]; then
277                 title sanityN
278                 $DEBUG_OFF
279
280                 mkdir -p $MOUNT2
281                 mount_client $MOUNT2
282                 #echo "can't mount2 for '$NAME', skipping sanityN.sh"
283                 START=: CLEAN=: bash sanityN.sh
284                 umount $MOUNT2
285
286                 $DEBUG_ON
287                 $CLEANUP
288                 $SETUP
289                 SANITYN="done"
290         fi
291
292         [ "$LFSCK" != "no" ] && remote_mds && log "Remote MDS, skipping LFSCK test" && LFSCK=no && MSKIPPED=1
293         [ "$LFSCK" != "no" ] && remote_ost && log "Remote OST, skipping LFSCK test" && LFSCK=no && OSKIPPED=1
294         if [ "$LFSCK" != "no" ]; then
295                 title lfsck
296                 if [ -x /usr/sbin/lfsck ]; then
297                         bash lfscktest.sh
298                 else
299                         log "$(e2fsck -V)"
300                         log "SKIP: e2fsck does not support lfsck"
301                 fi
302                 LFSCK="done"
303         fi
304
305         [ "$NETTYPE" = "tcp" -o "$NETTYPE" = "ptl" ] || LIBLUSTRE=no # bug 15660
306         if [ "$LIBLUSTRE" != "no" ]; then
307                 title liblustre
308                 assert_env MGSNID MOUNT2
309                 export LIBLUSTRE_MOUNT_POINT=$MOUNT2
310                 export LIBLUSTRE_MOUNT_RETRY=5
311                 export LIBLUSTRE_MOUNT_TARGET=$MGSNID:/$FSNAME
312                 export LIBLUSTRE_TIMEOUT=`lctl get_param -n timeout`
313                 #export LIBLUSTRE_DEBUG_MASK=`lctl get_param -n debug`
314                 if [ -x $LIBLUSTRETESTS/sanity ]; then
315                         mkdir -p $MOUNT2
316                         echo $LIBLUSTRETESTS/sanity --target=$LIBLUSTRE_MOUNT_TARGET
317                         $LIBLUSTRETESTS/sanity --target=$LIBLUSTRE_MOUNT_TARGET
318                 fi
319                 $CLEANUP
320                 #$SETUP
321                 LIBLUSTRE="done"
322         fi
323
324         $CLEANUP
325 done
326
327 [ "$REPLAY_SINGLE" != "no" ] && skip_remmds replay-single && REPLAY_SINGLE=no && MSKIPPED=1
328 if [ "$REPLAY_SINGLE" != "no" ]; then
329         title replay-single
330         bash replay-single.sh
331         REPLAY_SINGLE="done"
332 fi
333
334 [ "$CONF_SANITY" != "no" ] && skip_remmds conf-sanity && CONF_SANITY=no && MSKIPPED=1
335 [ "$CONF_SANITY" != "no" ] && skip_remost conf-sanity && CONF_SANITY=no && OSKIPPED=1
336 if [ "$CONF_SANITY" != "no" ]; then
337         title conf-sanity
338         bash conf-sanity.sh
339         CONF_SANITY="done"
340 fi
341
342 [ "$RECOVERY_SMALL" != "no" ] && skip_remmds recover-small && RECOVERY_SMALL=no && MSKIPPED=1
343 if [ "$RECOVERY_SMALL" != "no" ]; then
344         title recovery-small
345         bash recovery-small.sh
346         RECOVERY_SMALL="done"
347 fi
348
349 [ "$REPLAY_OST_SINGLE" != "no" ] && skip_remost replay-ost-single && REPLAY_OST_SINGLE=no && OSKIPPED=1
350 if [ "$REPLAY_OST_SINGLE" != "no" ]; then
351         title replay-ost-single
352         bash replay-ost-single.sh
353         REPLAY_OST_SINGLE="done"
354 fi
355
356 [ "$REPLAY_DUAL" != "no" ] && skip_remost replay-dual && REPLAY_DUAL=no && OSKIPPED=1
357 if [ "$REPLAY_DUAL" != "no" ]; then
358         title replay-dual
359         bash replay-dual.sh
360         REPLAY_DUAL="done"
361 fi
362
363 [ "$INSANITY" != "no" ] && skip_remmds insanity && INSANITY=no && MSKIPPED=1
364 [ "$INSANITY" != "no" ] && skip_remost insanity && INSANITY=no && OSKIPPED=1
365 if [ "$INSANITY" != "no" ]; then
366         title insanity
367         bash insanity.sh -r
368         INSANITY="done"
369 fi
370
371 [ "$SANITY_QUOTA" != "no" ] && skip_remmds sanity-quota && SANITY_QUOTA=no && MSKIPPED=1
372 [ "$SANITY_QUOTA" != "no" ] && skip_remost sanity-quota && SANITY_QUOTA=no && OSKIPPED=1
373 if [ "$SANITY_QUOTA" != "no" ]; then
374         title sanity-quota
375         bash sanity-quota.sh
376         SANITY_QUOTA="done"
377 fi
378
379 [ "$SANITY_SEC" != "no" ] && skip_remmds sanity-sec && SANITY_SEC=no && MSKIPPED=1
380 [ "$SANITY_SEC" != "no" ] && skip_remost sanity-sec && SANITY_SEC=no && OSKIPPED=1
381 if [ "$SANITY_SEC" != "no" ]; then
382         title sanity-sec
383         bash sanity-sec.sh
384         SANITY_SEC="done"
385 fi
386
387 [ "$SANITY_GSS" != "no" ] && skip_remmds sanity-gss && SANITY_GSS=no && MSKIPPED=1
388 if [ "$SANITY_GSS" != "no" ]; then
389         title sanity-gss
390         bash sanity-gss.sh
391         SANITY_GSS="done"
392 fi
393
394 [ "$SLOW" = no ] && PERFORMANCE_SANITY="no"
395 [ -x "$MDSRATE" ] || PERFORMANCE_SANITY="no"
396 which mpirun > /dev/null 2>&1 || PERFORMANCE_SANITY="no"
397 if [ "$PERFORMANCE_SANITY" != "no" ]; then
398         title performance-sanity
399         bash performance-sanity.sh
400         PERFORMANCE_SANITY="done"
401 fi
402
403 RC=$?
404 title FINISHED
405 echo "Finished at `date` in $((`date +%s` - $STARTTIME))s"
406 echo "Tests ran: $RANTEST"
407 print_summary
408 [ "$MSKIPPED" = 1 ] && log "FAIL: remote MDS tests skipped" && RC=1
409 [ "$OSKIPPED" = 1 ] && log "FAIL: remote OST tests skipped" && RC=1
410 echo "$0: completed with rc $RC" && exit $RC