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