Whamcloud - gitweb
branch: b_new_cmd
[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 -vxe
5
6 PATH=`dirname $0`/../utils:$PATH
7
8 [ "$CONFIGS" ] || CONFIGS="local"  #"local lov"
9 [ "$MAX_THREADS" ] || MAX_THREADS=20
10 RAMKB=`awk '/MemTotal:/ { print $2 }' /proc/meminfo`
11 if [ -z "$THREADS" ]; then
12         THREADS=$((RAMKB / 16384))
13         [ $THREADS -gt $MAX_THREADS ] && THREADS=$MAX_THREADS
14 fi
15 [ "$SIZE" ] || SIZE=$((RAMKB * 2))
16 [ "$RSIZE" ] || RSIZE=512
17 [ "$UID" ] || UID=1000
18 [ "$MOUNT" ] || MOUNT=/mnt/lustre
19 [ "$MOUNT2" ] || MOUNT2=${MOUNT}2
20 [ "$TMP" ] || TMP=/tmp
21 [ "$COUNT" ] || COUNT=1000
22 [ "$DEBUG_LVL" ] || DEBUG_LVL=0
23 [ "$DEBUG_OFF" ] || DEBUG_OFF="sysctl -w lnet.debug=$DEBUG_LVL"
24 [ "$DEBUG_ON" ] || DEBUG_ON="sysctl -w lnet.debug=0x33f0484"
25
26 LIBLUSTRE=${LIBLUSTRE:-../liblustre}
27 LIBLUSTRETESTS=${LIBLUSTRETESTS:-$LIBLUSTRE/tests}
28
29 LUSTRE=${LUSTRE:-`dirname $0`/..}
30 . $LUSTRE/tests/test-framework.sh
31 init_test_env $@
32
33 SETUP=${SETUP:-setupall}
34 FORMAT=${FORMAT:-formatall}
35 CLEANUP=${CLEANUP:-stopall}
36
37 setup_if_needed() {
38     mount | grep $MOUNT || $FORMAT && $SETUP
39 }
40
41 for NAME in $CONFIGS; do
42         export NAME MOUNT START CLEAN
43         . $LUSTRE/tests/cfg/$NAME.sh
44         
45         assert_env mds_HOST MDS_MKFS_OPTS MDSDEV
46         assert_env ost_HOST OST_MKFS_OPTS OSTCOUNT
47         assert_env FSNAME
48
49         if [ "$RUNTESTS" != "no" ]; then
50                 sh runtests
51         fi
52
53         if [ "$SANITY" != "no" ]; then
54                 SANITYLOG=/tmp/sanity.log sh sanity.sh
55         fi
56
57         if [ "$DBENCH" != "no" ]; then
58                 setup_if_needed
59                 SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
60                 DB_THREADS=$((SPACE / 50000))
61                 [ $THREADS -lt $DB_THREADS ] && DB_THREADS=$THREADS
62
63                 $DEBUG_OFF
64                 sh rundbench 1
65                 $DEBUG_ON
66                 $CLEANUP
67                 $SETUP
68                 if [ $DB_THREADS -gt 1 ]; then
69                         $DEBUG_OFF
70                         sh rundbench $DB_THREADS
71                         $DEBUG_ON
72                         $CLEANUP
73                         $SETUP
74                 fi
75                 rm -f /mnt/lustre/`hostname`/client.txt
76         fi
77
78         chown $UID $MOUNT && chmod 700 $MOUNT
79         if [ "$BONNIE" != "no" ]; then
80                 setup_if_needed
81                 SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
82                 [ $SPACE -lt $SIZE ] && SIZE=$((SPACE * 3 / 4))
83                 $DEBUG_OFF
84                 bonnie++ -f -r 0 -s $((SIZE / 1024)) -n 10 -u $UID -d $MOUNT
85                 $DEBUG_ON
86                 $CLEANUP
87                 $SETUP
88         fi
89
90         export O_DIRECT
91         if [ "$IOZONE" != "no" ]; then
92                 setup_if_needed
93                 SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
94                 [ $SPACE -lt $SIZE ] && SIZE=$((SPACE * 3 / 4))
95                 IOZONE_OPTS="-i 0 -i 1 -i 2 -e -+d -r $RSIZE -s $SIZE"
96                 IOZFILE="-f $MOUNT/iozone"
97                 $DEBUG_OFF
98                 iozone $IOZONE_OPTS $IOZFILE
99                 $DEBUG_ON
100                 $CLEANUP
101                 $SETUP
102
103                 # check if O_DIRECT support is implemented in kernel
104                 if [ -z "$O_DIRECT" ]; then
105                         touch $MOUNT/f.iozone
106                         if ! ./directio write $MOUNT/f.iozone 0 1; then
107                                 O_DIRECT=no
108                         fi
109                         rm -f $MOUNT/f.iozone
110                 fi
111                 if [ "$O_DIRECT" != "no" -a "$IOZONE_DIR" != "no" ]; then
112                         $DEBUG_OFF
113                         iozone -I $IOZONE_OPTS $IOZFILE.odir
114                         $DEBUG_ON
115                         $CLEANUP
116                         $SETUP
117                 fi
118
119                 SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
120                 IOZ_THREADS=$((SPACE / SIZE * 2 / 3 ))
121                 [ $THREADS -lt $IOZ_THREADS ] && IOZ_THREADS=$THREADS
122                 IOZVER=`iozone -v | awk '/Revision:/ {print $3}' | tr -d .`
123                 if [ "$IOZ_THREADS" -gt 1 -a "$IOZVER" -ge 3145 ]; then
124                         $DEBUG_OFF
125                         THREAD=1
126                         IOZFILE="-F "
127                         while [ $THREAD -le $IOZ_THREADS ]; do
128                                 IOZFILE="$IOZFILE $MOUNT/iozone.$THREAD"
129                                 THREAD=$((THREAD + 1))
130                         done
131                         iozone $IOZONE_OPTS -t $IOZ_THREADS $IOZFILE
132                         $DEBUG_ON
133                         $CLEANUP
134                         $SETUP
135                 elif [ $IOZVER -lt 3145 ]; then
136                         VER=`iozone -v | awk '/Revision:/ { print $3 }'`
137                         echo "iozone $VER too old for multi-thread test"
138                 fi
139         fi
140
141         if [ "$FSX" != "no" ]; then
142                 setup_if_needed
143                 SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
144                 [ $SPACE -lt $SIZE ] && SIZE=$((SPACE * 3 / 4))
145                 $DEBUG_OFF
146                 ./fsx -c 50 -p 1000 -P $TMP -l $SIZE \
147                         -N $(($COUNT * 100)) $MOUNT/fsxfile
148                 $DEBUG_ON
149                 $CLEANUP
150                 $SETUP
151         fi      
152
153         mkdir -p $MOUNT2
154         case $NAME in
155         local|lov)
156                 MDSNODE=`hostname`
157                 MDSNAME=mds1
158                 CLIENT=client
159                 ;;
160         *)      # we could extract this from $NAME.xml somehow
161                 ;;
162         esac
163
164         if [ "$SANITYN" != "no" ]; then
165                 setup_if_needed
166                 $DEBUG_OFF
167
168                 if [ "$MDSNODE" -a "$MDSNAME" -a "$CLIENT" ]; then
169                         mount_client $MOUNT2
170                         SANITYLOG=$TMP/sanity.log START=: CLEAN=: sh sanityN.sh
171                         umount $MOUNT2
172                 else
173                         echo "don't know \$MDSNODE, \$MDSNAME, \$CLIENT"
174                         echo "can't mount2 for '$NAME', skipping sanityN.sh"
175                 fi
176
177                 $DEBUG_ON
178                 $CLEANUP
179                 $SETUP
180         fi
181
182         if [ "$LIBLUSTRE" != "no" ]; then
183                 setup_if_needed
184                 export LIBLUSTRE_MOUNT_POINT=$MOUNT2
185                 export LIBLUSTRE_MOUNT_TARGET=$MDSNODE:/$MDSNAME/$CLIENT
186                 export LIBLUSTRE_TIMEOUT=`cat /proc/sys/lustre/timeout`
187                 #export LIBLUSTRE_DEBUG_MASK=`cat /proc/sys/lnet/debug`
188                 if [ -x $LIBLUSTRETESTS/sanity ]; then
189                         $LIBLUSTRETESTS/sanity --target=$LIBLUSTRE_MOUNT_TARGET
190                 fi
191                 $CLEANUP
192                 #$SETUP
193         fi
194
195         $CLEANUP
196 done
197
198 if [ "$REPLAY_SINGLE" != "no" ]; then
199         sh replay-single.sh
200 fi
201
202 if [ "$CONF_SANITY" != "no" ]; then
203         sh conf-sanity.sh
204 fi
205
206 if [ "$RECOVERY_SMALL" != "no" ]; then
207         sh recovery-small.sh
208 fi
209
210 if [ "$REPLAY_OST_SINGLE" != "no" ]; then
211         sh replay-ost-single.sh
212 fi
213
214 if [ "$REPLAY_DUAL" != "no" ]; then
215         sh replay-dual.sh
216 fi
217
218 if [ "$INSANITY" != "no" ]; then
219         sh insanity.sh -r
220 fi
221
222 RC=$?
223 echo "completed with rc $RC" && exit $RC