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