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