| 1 | #!/bin/sh |
|---|
| 2 | |
|---|
| 3 | # i'm not married to bash. just wanted to get things prototyped |
|---|
| 4 | |
|---|
| 5 | # prereqs: |
|---|
| 6 | # - $user needs to be in the sudoers file |
|---|
| 7 | # - $user needs to be able to sudo w/o prompting |
|---|
| 8 | # - please don't cheat and run this as root: will not catch permissions bugs |
|---|
| 9 | |
|---|
| 10 | # you can override these settings in nightly-tests.cfg |
|---|
| 11 | export PVFS2_DEST=/tmp/pvfs2-nightly |
|---|
| 12 | export PVFS2_MOUNTPOINT=/pvfs2-nightly |
|---|
| 13 | export EXTRA_TESTS=${HOME}/src/benchmarks |
|---|
| 14 | |
|---|
| 15 | # look for a 'nightly-test.cfg' in the same directory as this script |
|---|
| 16 | if [ -f $(cd `dirname $0`; pwd)/nightly-tests.cfg ] ; then |
|---|
| 17 | . $(cd `dirname $0`; pwd)/nightly-tests.cfg |
|---|
| 18 | fi |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | # need to make this a command line arugment: |
|---|
| 22 | export CVS_TAG="${CVS_TAG:-HEAD}" |
|---|
| 23 | |
|---|
| 24 | # no need to modify these. they make their own gravy |
|---|
| 25 | STARTTIME=`date +%s` |
|---|
| 26 | TINDERSCRIPT=$(cd `dirname $0`; pwd)/tinder-pvfs2-status |
|---|
| 27 | SYSINT_SCRIPTS=${PVFS2_DEST}/pvfs2-${CVS_TAG}/test/automated/sysint-tests.d |
|---|
| 28 | VFS_SCRIPTS=${PVFS2_DEST}/pvfs2-${CVS_TAG}/test/automated/vfs-tests.d |
|---|
| 29 | MPIIO_DRIVER=${PVFS2_DEST}/pvfs2-${CVS_TAG}/test/automated/testscrpt-mpi.sh |
|---|
| 30 | REPORT_LOG=${PVFS2_DEST}/alltests-${CVS_TAG}.log |
|---|
| 31 | |
|---|
| 32 | # for debugging and testing, you might need to set the above to your working |
|---|
| 33 | # direcory.. .unless you like checking in broken scripts |
|---|
| 34 | #SYSINT_SCRIPTS=$(cd `dirname $0`; pwd)/sysint-tests.d |
|---|
| 35 | #VFS_SCRIPTS=$(cd `dirname $0`; pwd)/vfs-tests.d |
|---|
| 36 | MPIIO_DRIVER=$(cd `dirname $0`; pwd)/testscrpt-mpi.sh |
|---|
| 37 | |
|---|
| 38 | TESTNAME="`hostname -s`-nightly" |
|---|
| 39 | |
|---|
| 40 | # before starting any client apps, we need to deal with the possiblity that we |
|---|
| 41 | # might have built with shared libraries |
|---|
| 42 | export LD_LIBRARY_PATH=${PVFS2_DEST}/INSTALL-pvfs2-${CVS_TAG}/lib:${LD_LIBRARY_PATH} |
|---|
| 43 | |
|---|
| 44 | # we only have a few hosts that meet all the earlier stated prereqs |
|---|
| 45 | VFS_HOSTS="gil lain stan" |
|---|
| 46 | |
|---|
| 47 | # |
|---|
| 48 | # Detect basic heap corruption |
|---|
| 49 | # |
|---|
| 50 | export MALLOC_CHECK_=2 |
|---|
| 51 | |
|---|
| 52 | # takes one argument: a tag or branch in CVS |
|---|
| 53 | pull_and_build_pvfs2 () { |
|---|
| 54 | # debugging aide... when we run this script repeatedly, we don't |
|---|
| 55 | # really need to build everything again |
|---|
| 56 | [ -n "$SKIP_BUILDING_PVFS2" ] && return 0 |
|---|
| 57 | |
|---|
| 58 | mkdir -p $PVFS2_DEST |
|---|
| 59 | with_kernel="" |
|---|
| 60 | if [ $do_vfs -eq 1 ] ; then |
|---|
| 61 | with_kernel="-k /lib/modules/`uname -r`/build" |
|---|
| 62 | fi |
|---|
| 63 | # a bit of gross shell hackery, but cuts down on the number of |
|---|
| 64 | # variables we have to set. Assumes we ran this script out of a |
|---|
| 65 | # checked out pvfs2 tree |
|---|
| 66 | $(cd `dirname $0`;pwd)/../../maint/build/pvfs2-build.sh -t -v $1 \ |
|---|
| 67 | $with_kernel -r $PVFS2_DEST |
|---|
| 68 | |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | pull_and_build_mpich2 () { |
|---|
| 72 | # just to make debugging less painful |
|---|
| 73 | [ -n "${SKIP_BUILDING_MPICH2}" ] && return 0 |
|---|
| 74 | [ -d ${PVFS2_DEST} ] || mkdir ${PVFS2_DEST} |
|---|
| 75 | cd ${PVFS2_DEST} |
|---|
| 76 | rm -rf mpich2-latest.tar.gz |
|---|
| 77 | wget --passive-ftp --quiet 'ftp://ftp.mcs.anl.gov/pub/mpi/misc/mpich2snap/mpich2-snap-*' -O mpich2-latest.tar.gz |
|---|
| 78 | rm -rf mpich2-snap-* |
|---|
| 79 | tar xzf mpich2-latest.tar.gz |
|---|
| 80 | cd mpich2-snap-* |
|---|
| 81 | mkdir build |
|---|
| 82 | cd build |
|---|
| 83 | ../configure -q --prefix=${PVFS2_DEST}/soft/mpich2 \ |
|---|
| 84 | --enable-romio --with-file-system=ufs+nfs+testfs+pvfs2 \ |
|---|
| 85 | --with-pvfs2=${PVFS2_DEST}/INSTALL-pvfs2-${CVS_TAG} \ |
|---|
| 86 | --enable-g=dbg --without-mpe \ |
|---|
| 87 | --disable-f77 >mpich2config-${CVS_TAG}.log &&\ |
|---|
| 88 | make >/dev/null && make install >/dev/null |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | |
|---|
| 92 | teardown_vfs() { |
|---|
| 93 | sudo umount $PVFS2_MOUNTPOINT |
|---|
| 94 | sudo killall pvfs2-client |
|---|
| 95 | sleep 1 |
|---|
| 96 | sudo /sbin/rmmod pvfs2 |
|---|
| 97 | # let teardown alway ssucceed. pvfs2-client might already be killed |
|---|
| 98 | # and pvfs2 kernel module might not be loaded yet |
|---|
| 99 | return 0 |
|---|
| 100 | } |
|---|
| 101 | |
|---|
| 102 | setup_vfs() { |
|---|
| 103 | sudo dmesg -c >/dev/null |
|---|
| 104 | sudo /sbin/insmod ${PVFS2_DEST}/INSTALL-pvfs2-${CVS_TAG}/lib/modules/`uname -r`/kernel/fs/pvfs2/pvfs2.ko |
|---|
| 105 | sudo LD_LIBRARY_PATH=${LD_LIBRARY_PATH} ${PVFS2_DEST}/INSTALL-pvfs2-${CVS_TAG}/sbin/pvfs2-client \ |
|---|
| 106 | -p ${PVFS2_DEST}/INSTALL-pvfs2-${CVS_TAG}/sbin/pvfs2-client-core \ |
|---|
| 107 | -L ${PVFS2_DEST}/pvfs2-client-${CVS_TAG}.log |
|---|
| 108 | # sudo screen -d -m cgdb -x ${PVFS2_DEST}/.gdbinit --args ${PVFS2_DEST}/INSTALL-pvfs2-${CVS_TAG}/sbin/pvfs2-client-core -L ${PVFS2_DEST}/pvfs2-client-${CVS_TAG}.log |
|---|
| 109 | #sudo valgrind --log-file=${PVFS2_DEST}/pvfs2-client.vg ${PVFS2_DEST}/INSTALL-pvfs2-${CVS_TAG}/sbin/pvfs2-client-core -L ${PVFS2_DEST}/pvfs2-client-${CVS_TAG}.log & |
|---|
| 110 | sudo chmod 644 ${PVFS2_DEST}/pvfs2-client-${CVS_TAG}.log |
|---|
| 111 | sudo mount -t pvfs2 tcp://`hostname -s`:3399/pvfs2-fs ${PVFS2_MOUNTPOINT} |
|---|
| 112 | } |
|---|
| 113 | |
|---|
| 114 | setup_pvfs2() { |
|---|
| 115 | cd $PVFS2_DEST |
|---|
| 116 | rm -f fs.conf |
|---|
| 117 | INSTALL-pvfs2-${CVS_TAG}/bin/pvfs2-genconfig fs.conf \ |
|---|
| 118 | --protocol tcp \ |
|---|
| 119 | --iospec="`hostname -s`:{3396-3399}" \ |
|---|
| 120 | --metaspec="`hostname -s`:{3396-3399}" \ |
|---|
| 121 | --storage ${PVFS2_DEST}/STORAGE-pvfs2-${CVS_TAG} \ |
|---|
| 122 | --logfile=${PVFS2_DEST}/pvfs2-server-${CVS_TAG}.log --quiet |
|---|
| 123 | # clean up any artifacts from earlier runs |
|---|
| 124 | rm -rf ${PVFS2_DEST}/STORAGE-pvfs2-${CVS_TAG}* |
|---|
| 125 | rm -f ${PVFS2_DEST}/pvfs2-server-${CVS_TAG}.log* |
|---|
| 126 | failure_logs="${PVFS2_DEST}/pvfs2-server-${CVS_TAG}.log* $failure_logs" |
|---|
| 127 | for alias in `grep 'Alias ' fs.conf | cut -d ' ' -f 2`; do |
|---|
| 128 | INSTALL-pvfs2-${CVS_TAG}/sbin/pvfs2-server \ |
|---|
| 129 | -p `pwd`/pvfs2-server-${alias}.pid \ |
|---|
| 130 | -f fs.conf -a $alias |
|---|
| 131 | INSTALL-pvfs2-${CVS_TAG}/sbin/pvfs2-server \ |
|---|
| 132 | -p `pwd`/pvfs2-server-${alias}.pid \ |
|---|
| 133 | fs.conf $server_conf -a $alias |
|---|
| 134 | done |
|---|
| 135 | |
|---|
| 136 | echo "tcp://`hostname -s`:3399/pvfs2-fs ${PVFS2_MOUNTPOINT} pvfs2 defaults 0 0" > ${PVFS2_DEST}/pvfs2tab |
|---|
| 137 | # do we need to use our own pvfs2tab file? If we will mount pvfs2, we |
|---|
| 138 | # can fall back to /etc/fstab |
|---|
| 139 | grep -q 'pvfs2-nightly' /etc/fstab |
|---|
| 140 | if [ $? -ne 0 -a $do_vfs -eq 0 ] ; then |
|---|
| 141 | export PVFS2TAB_FILE=${PVFS2_DEST}/pvfs2tab |
|---|
| 142 | fi |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | teardown_pvfs2() { |
|---|
| 146 | for pidfile in ${PVFS2_DEST}/pvfs2-server*.pid ; do |
|---|
| 147 | [ ! -f $pidfile ] && continue |
|---|
| 148 | |
|---|
| 149 | kill `cat $pidfile` |
|---|
| 150 | # occasionally the server ends up in a hard-to-kill state. |
|---|
| 151 | # server has atexit(3) remove .pid file |
|---|
| 152 | sleep 3 |
|---|
| 153 | if [ -f $pidfile ] ; then |
|---|
| 154 | kill -9 `cat $pidfile` |
|---|
| 155 | fi |
|---|
| 156 | done |
|---|
| 157 | |
|---|
| 158 | # let teardown always succeed. pvfs2-server.pid could be stale |
|---|
| 159 | return 0 |
|---|
| 160 | } |
|---|
| 161 | |
|---|
| 162 | buildfail() { |
|---|
| 163 | echo "Failure in build process" |
|---|
| 164 | cat ${PVFS2_DEST}/configure-${CVS_TAG}.log \ |
|---|
| 165 | ${PVFS2_DEST}/make-extracted-${CVS_TAG}.log \ |
|---|
| 166 | ${PVFS2_DEST}/make-install-${CVS_TAG}.log \ |
|---|
| 167 | ${PVFS2_DEST}/make-${CVS_TAG}.log \ |
|---|
| 168 | ${PVFS2_DEST}/make-test-${CVS_TAG}.log | \ |
|---|
| 169 | ${TINDERSCRIPT} ${TESTNAME}-${CVS_TAG} build_failed $STARTTIME |
|---|
| 170 | exit 1 |
|---|
| 171 | } |
|---|
| 172 | |
|---|
| 173 | setupfail() { |
|---|
| 174 | echo "Failure in setup" |
|---|
| 175 | dmesg > ${PVFS2_DEST}/dmesg |
|---|
| 176 | cat ${PVFS2_DEST}/dmesg ${PVFS2_DEST}/pvfs2-client-${CVS_TAG}.log \ |
|---|
| 177 | ${PVFS2_DEST}/pvfs2-server-${CVS_TAG}.log* | \ |
|---|
| 178 | ${TINDERSCRIPT} ${TESTNAME}-${CVS_TAG} test_failed $STARTTIME |
|---|
| 179 | exit 1 |
|---|
| 180 | } |
|---|
| 181 | |
|---|
| 182 | tinder_report() { |
|---|
| 183 | eval cat $REPORT_LOG $failure_logs |\ |
|---|
| 184 | ${TINDERSCRIPT} ${TESTNAME}-${CVS_TAG} $1 $STARTTIME \ |
|---|
| 185 | "$nr_failed of $(( $nr_failed + $nr_passed)) failed" |
|---|
| 186 | } |
|---|
| 187 | |
|---|
| 188 | testfail() { |
|---|
| 189 | echo "Failure in testing" |
|---|
| 190 | tinder_report test_failed |
|---|
| 191 | exit 1 |
|---|
| 192 | } |
|---|
| 193 | |
|---|
| 194 | # idea stolen from debian: for a given directory, run every executable file |
|---|
| 195 | run_parts() { |
|---|
| 196 | cd $1 |
|---|
| 197 | for f in *; do |
|---|
| 198 | # skip CVS |
|---|
| 199 | [ -d $f ] && continue |
|---|
| 200 | if [ -x $f ] ; then |
|---|
| 201 | echo -n "====== running $f ..." |
|---|
| 202 | ./$f > ${PVFS2_DEST}/${f}-${CVS_TAG}.log |
|---|
| 203 | if [ $? -eq 0 ] ; then |
|---|
| 204 | nr_passed=$((nr_passed + 1)) |
|---|
| 205 | echo "OK" |
|---|
| 206 | else |
|---|
| 207 | nr_failed=$((nr_failed + 1)) |
|---|
| 208 | failure_logs="$failure_logs ${PVFS2_DEST}/${f}-${CVS_TAG}.log" |
|---|
| 209 | echo "FAILED" |
|---|
| 210 | fi |
|---|
| 211 | fi |
|---|
| 212 | done |
|---|
| 213 | } |
|---|
| 214 | |
|---|
| 215 | ### |
|---|
| 216 | ### entry point for script |
|---|
| 217 | ### |
|---|
| 218 | |
|---|
| 219 | # show that we're doing something |
|---|
| 220 | ${TINDERSCRIPT} ${TESTNAME}-${CVS_TAG} building $STARTTIME </dev/null |
|---|
| 221 | |
|---|
| 222 | # will we be able to do VFS-related tests? |
|---|
| 223 | do_vfs=0 |
|---|
| 224 | for s in $(echo $VFS_HOSTS); do |
|---|
| 225 | if [ `hostname -s` = $s ] ; then |
|---|
| 226 | do_vfs=1 |
|---|
| 227 | break |
|---|
| 228 | fi |
|---|
| 229 | done |
|---|
| 230 | |
|---|
| 231 | failure_logs="" # a space-delimited list of logs that failed |
|---|
| 232 | # compile and install |
|---|
| 233 | pull_and_build_pvfs2 $CVS_TAG || buildfail |
|---|
| 234 | |
|---|
| 235 | teardown_pvfs2 && setup_pvfs2 |
|---|
| 236 | |
|---|
| 237 | if [ $? != 0 ] ; then |
|---|
| 238 | echo "setup failed" |
|---|
| 239 | setupfail |
|---|
| 240 | fi |
|---|
| 241 | |
|---|
| 242 | if [ $do_vfs -eq 1 ] ; then |
|---|
| 243 | teardown_vfs && setup_vfs |
|---|
| 244 | |
|---|
| 245 | if [ $? != 0 ] ; then |
|---|
| 246 | echo "setup failed" |
|---|
| 247 | setupfail |
|---|
| 248 | fi |
|---|
| 249 | fi |
|---|
| 250 | |
|---|
| 251 | # at this point we've got |
|---|
| 252 | # - pvfs2 servers running |
|---|
| 253 | # on hosts in our whitelist |
|---|
| 254 | # - an entry in /etc/fstab (that was a prerequisite for this script after all) |
|---|
| 255 | # - the VFS mounted at $PVFS2_MOUNTPOINT |
|---|
| 256 | |
|---|
| 257 | nr_passed=0 |
|---|
| 258 | nr_failed=0 |
|---|
| 259 | |
|---|
| 260 | # save file descriptors for later |
|---|
| 261 | exec 6<&1 |
|---|
| 262 | exec 7<&2 |
|---|
| 263 | |
|---|
| 264 | exec 1> ${REPORT_LOG} |
|---|
| 265 | exec 2>&1 |
|---|
| 266 | run_parts ${SYSINT_SCRIPTS} |
|---|
| 267 | |
|---|
| 268 | if [ $do_vfs -eq 1 ] ; then |
|---|
| 269 | export VFS_SCRIPTS |
|---|
| 270 | run_parts ${VFS_SCRIPTS} |
|---|
| 271 | fi |
|---|
| 272 | |
|---|
| 273 | # down the road (as we get our hands on more clusters) we'll need a more |
|---|
| 274 | # generic way of submitting jobs. for now assume all the world has pbs |
|---|
| 275 | which qsub >/dev/null 2>&1 |
|---|
| 276 | if [ $? -eq 0 ] ; then |
|---|
| 277 | # go through the hassle of downloading/building mpich2 only if we are |
|---|
| 278 | # actually going to use it |
|---|
| 279 | pull_and_build_mpich2 || buildfail |
|---|
| 280 | . $MPIIO_DRIVER |
|---|
| 281 | fi |
|---|
| 282 | |
|---|
| 283 | # restore file descriptors and close temporary fds |
|---|
| 284 | exec 1<&6 6<&- |
|---|
| 285 | exec 2<&7 7<&- |
|---|
| 286 | |
|---|
| 287 | if [ -f $PVFS2_DEST/pvfs2-built-with-warnings -o \ |
|---|
| 288 | -f ${PVFS2_DEST}/pvfs2-test-built-with-warnings ] ; then |
|---|
| 289 | tinder_report successwarn |
|---|
| 290 | rm -f $PVFS2_DEST/pvfs2-built-with-warnings |
|---|
| 291 | rm -f ${PVFS2_DEST}/pvfs2-test-built-with-warnings |
|---|
| 292 | |
|---|
| 293 | elif [ $nr_failed -gt 0 ]; then |
|---|
| 294 | tinder_report test_failed |
|---|
| 295 | else |
|---|
| 296 | tinder_report success |
|---|
| 297 | fi |
|---|
| 298 | |
|---|
| 299 | [ $do_vfs -eq 1 ] && teardown_vfs |
|---|
| 300 | teardown_pvfs2 |
|---|