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