Whamcloud - gitweb
i=eeb:
[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 [ "$CONFIGS" ] || CONFIGS="local"  #"local lov"
10 [ "$MAX_THREADS" ] || MAX_THREADS=20
11 RAMKB=`awk '/MemTotal:/ { print $2 }' /proc/meminfo`
12 if [ -z "$THREADS" ]; then
13         THREADS=$((RAMKB / 16384))
14         [ $THREADS -gt $MAX_THREADS ] && THREADS=$MAX_THREADS
15 fi
16 [ "$SIZE" ] || SIZE=$((RAMKB * 2))
17 [ "$RSIZE" ] || RSIZE=512
18 [ "$UID" ] || UID=1000
19 [ "$MOUNT" ] || MOUNT=/mnt/lustre
20 [ "$MOUNT2" ] || MOUNT2=${MOUNT}2
21 [ "$TMP" ] || TMP=/tmp
22 [ "$COUNT" ] || COUNT=1000
23 [ "$DEBUG_LVL" ] || DEBUG_LVL=0
24 [ "$DEBUG_OFF" ] || DEBUG_OFF="eval sysctl -w lnet.debug=\"$DEBUG_LVL\""
25 [ "$DEBUG_ON" ] || DEBUG_ON="eval sysctl -w lnet.debug=0x33f0484"
26
27
28 LIBLUSTRE=${LIBLUSTRE:-../liblustre}
29 LIBLUSTRETESTS=${LIBLUSTRETESTS:-$LIBLUSTRE/tests}
30
31 STARTTIME=`date +%s`
32 RANTEST=""
33
34 LUSTRE=${LUSTRE:-`dirname $0`/..}
35 . $LUSTRE/tests/test-framework.sh
36 init_test_env $@
37
38 SETUP=${SETUP:-setupall}
39 FORMAT=${FORMAT:-formatall}
40 CLEANUP=${CLEANUP:-stopall}
41
42 setup_if_needed() {
43     mount | grep $MOUNT && return
44     $FORMAT && $SETUP
45 }
46
47 title() {
48     echo "-----============= acceptance-small: "$*" ============-----"
49     RANTEST=${RANTEST}$*", "
50 }
51
52 for NAME in $CONFIGS; do
53         export NAME MOUNT START CLEAN
54         . $LUSTRE/tests/cfg/$NAME.sh
55         
56         assert_env mds_HOST MDS_MKFS_OPTS MDSDEV
57         assert_env ost_HOST OST_MKFS_OPTS OSTCOUNT
58         assert_env FSNAME MOUNT MOUNT2
59
60         setup_if_needed
61
62         if [ "$RUNTESTS" != "no" ]; then
63                 title runtests
64                 sh runtests
65                 $CLEANUP
66                 $SETUP
67         fi
68
69         if [ "$SANITY" != "no" ]; then
70                 title sanity
71                 SANITYLOG=/tmp/sanity.log sh sanity.sh
72                 $CLEANUP
73                 $SETUP
74         fi
75
76         which dbench > /dev/null 2>&1 || DBENCH=no
77         if [ "$DBENCH" != "no" ]; then
78                 title dbench
79                 SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
80                 DB_THREADS=$((SPACE / 50000))
81                 [ $THREADS -lt $DB_THREADS ] && DB_THREADS=$THREADS
82
83                 $DEBUG_OFF
84                 sh rundbench 1
85                 $DEBUG_ON
86                 $CLEANUP
87                 $SETUP
88                 if [ $DB_THREADS -gt 1 ]; then
89                         $DEBUG_OFF
90                         sh rundbench $DB_THREADS
91                         $DEBUG_ON
92                         $CLEANUP
93                         $SETUP
94                 fi
95                 rm -f /mnt/lustre/`hostname`/client.txt
96         fi
97
98         chown $UID $MOUNT && chmod 700 $MOUNT
99         which bonnie++ > /dev/null 2>&1 || BONNIE=no
100         if [ "$BONNIE" != "no" ]; then
101                 title bonnie
102                 SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
103                 [ $SPACE -lt $SIZE ] && SIZE=$((SPACE * 3 / 4))
104                 $DEBUG_OFF
105                 bonnie++ -f -r 0 -s $((SIZE / 1024)) -n 10 -u $UID -d $MOUNT
106                 $DEBUG_ON
107                 $CLEANUP
108                 $SETUP
109         fi
110
111         export O_DIRECT
112         which iozone > /dev/null 2>&1 || IOZONE=no
113         if [ "$IOZONE" != "no" ]; then
114                 title iozone
115                 SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
116                 [ $SPACE -lt $SIZE ] && SIZE=$((SPACE * 3 / 4))
117                 IOZONE_OPTS="-i 0 -i 1 -i 2 -e -+d -r $RSIZE -s $SIZE"
118                 IOZFILE="-f $MOUNT/iozone"
119                 $DEBUG_OFF
120                 iozone $IOZONE_OPTS $IOZFILE
121                 $DEBUG_ON
122                 $CLEANUP
123                 $SETUP
124
125                 # check if O_DIRECT support is implemented in kernel
126                 if [ -z "$O_DIRECT" ]; then
127                         touch $MOUNT/f.iozone
128                         if ! ./directio write $MOUNT/f.iozone 0 1; then
129                                 O_DIRECT=no
130                         fi
131                         rm -f $MOUNT/f.iozone
132                 fi
133                 if [ "$O_DIRECT" != "no" -a "$IOZONE_DIR" != "no" ]; then
134                         $DEBUG_OFF
135                         iozone -I $IOZONE_OPTS $IOZFILE.odir
136                         $DEBUG_ON
137                         $CLEANUP
138                         $SETUP
139                 fi
140
141                 SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
142                 IOZ_THREADS=$((SPACE / SIZE * 2 / 3 ))
143                 [ $THREADS -lt $IOZ_THREADS ] && IOZ_THREADS=$THREADS
144                 IOZVER=`iozone -v | awk '/Revision:/ {print $3}' | tr -d .`
145                 if [ "$IOZ_THREADS" -gt 1 -a "$IOZVER" -ge 3145 ]; then
146                         $DEBUG_OFF
147                         THREAD=1
148                         IOZFILE="-F "
149                         while [ $THREAD -le $IOZ_THREADS ]; do
150                                 IOZFILE="$IOZFILE $MOUNT/iozone.$THREAD"
151                                 THREAD=$((THREAD + 1))
152                         done
153                         iozone $IOZONE_OPTS -t $IOZ_THREADS $IOZFILE
154                         $DEBUG_ON
155                         $CLEANUP
156                         $SETUP
157                 elif [ $IOZVER -lt 3145 ]; then
158                         VER=`iozone -v | awk '/Revision:/ { print $3 }'`
159                         echo "iozone $VER too old for multi-thread test"
160                 fi
161         fi
162
163         if [ "$FSX" != "no" ]; then
164                 title fsx
165                 SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
166                 [ $SPACE -lt $SIZE ] && SIZE=$((SPACE * 3 / 4))
167                 $DEBUG_OFF
168                 ./fsx -c 50 -p 1000 -P $TMP -l $SIZE \
169                         -N $(($COUNT * 100)) $MOUNT/fsxfile
170                 $DEBUG_ON
171                 $CLEANUP
172                 $SETUP
173         fi      
174
175         if [ "$SANITYN" != "no" ]; then
176                 title sanityN
177                 $DEBUG_OFF
178
179                 mkdir -p $MOUNT2
180                 mount_client $MOUNT2
181                 #echo "can't mount2 for '$NAME', skipping sanityN.sh"
182                 SANITYLOG=$TMP/sanity.log START=: CLEAN=: sh sanityN.sh
183                 umount $MOUNT2
184
185                 $DEBUG_ON
186                 $CLEANUP
187                 $SETUP
188         fi
189
190         if [ "$LFSCK" != "no" -a -x /usr/sbin/lfsck ]; then
191                 title lfsck
192                 E2VER=`e2fsck -V 2>&1 | head -n 1 | cut -d' ' -f 2`
193                 if grep -q obdfilter /proc/fs/lustre/devices; then
194                         if [ `echo $E2VER | cut -d. -f2` -ge 39 ] && \
195                            [ "`echo $E2VER | grep cfs`" ]; then
196                                 sh lfscktest.sh
197                         else
198                                 e2fsck -V
199                                 echo "e2fsck does not support lfsck, skipping"
200                         fi
201                 else
202                         echo "remote OST, skipping test"
203                 fi
204         fi
205
206         if [ "$LIBLUSTRE" != "no" ]; then
207                 title liblustre
208                 assert_env MGSNID MOUNT2
209                 $CLEANUP
210                 unload_modules
211                 # Liblustre needs accept=all, noacl
212                 LNETOPTS="accept=all" MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl" $SETUP
213                 export LIBLUSTRE_MOUNT_POINT=$MOUNT2
214                 export LIBLUSTRE_MOUNT_TARGET=$MGSNID:/$FSNAME
215                 export LIBLUSTRE_TIMEOUT=`cat /proc/sys/lustre/timeout`
216                 #export LIBLUSTRE_DEBUG_MASK=`cat /proc/sys/lnet/debug`
217                 if [ -x $LIBLUSTRETESTS/sanity ]; then
218                         mkdir -p $MOUNT2
219                         $LIBLUSTRETESTS/sanity --target=$LIBLUSTRE_MOUNT_TARGET
220                 fi
221                 $CLEANUP
222                 #$SETUP
223         fi
224
225         $CLEANUP
226 done
227
228 if [ "$REPLAY_SINGLE" != "no" ]; then
229         title replay-single
230         sh replay-single.sh
231 fi
232
233 if [ "$CONF_SANITY" != "no" ]; then
234         title conf-sanity
235         sh conf-sanity.sh
236 fi
237
238 if [ "$RECOVERY_SMALL" != "no" ]; then
239         title recovery-small
240         sh recovery-small.sh
241 fi
242
243 if [ "$REPLAY_OST_SINGLE" != "no" ]; then
244         title replay-ost-single
245         sh replay-ost-single.sh
246 fi
247
248 if [ "$REPLAY_DUAL" != "no" ]; then
249         title replay-dual
250         sh replay-dual.sh
251 fi
252
253 if [ "$INSANITY" != "no" ]; then
254         title insanity
255         sh insanity.sh -r
256 fi
257
258 if [ "$SANITY_QUOTA" != "no" ]; then
259         title sanity-quota
260         sh sanity-quota.sh
261 fi
262
263
264 RC=$?
265 title FINISHED
266 echo "Finished at `date` in $((`date +%s` - $STARTTIME))s"
267 echo "Tests ran: $RANTEST"
268
269 echo "$0: completed with rc $RC" && exit $RC