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