Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

petdance (2468)

petdance
  andy@petdance.com
http://www.perlbuzz.com/
AOL IM: petdance (Add Buddy, Send Message)
Yahoo! ID: petdance (Add User, Send Message)
Jabber: petdance@gmail.com

I'm Andy Lester, and I like to test stuff. I also write for the Perl Journal, and do tech edits on books. Sometimes I write code, too.

Journal of petdance (2468)

Thursday February 17, 2005
10:00 PM

smokebot: Running your tests hourly

[ #23239 ]
I got an email from someone asking about automating hourly tests, what we call a "smokebot". Here's the code for it:

#!/bin/sh

# set -xv  # Watch it run

if [ $# -lt 2 ]
then
    echo Must pass at least a branch, and one email address,
    echo plus any parms to pass to smoke.
    exit 1
fi

BRANCH=$1
shift

MAIL=$1
shift

TMP=/tmp/smoke
STAMP=`date +%m%d-%H%M`
TWROOT=$TMP/tw-$STAMP
export TWROOT
# the -n switch to ln allow ln to force-replace (-f)
# a symlink to a directory.
ln -fsn $TWROOT ~/tw

# OLD: cvs -d/home/cvs -Q co -d $DIR -r $REV tw > /dev/null
svn export file:///home/svn/tw/$BRANCH $TWROOT > /dev/null

# devapache = personal Apache instance
DEVAPACHE=$TWROOT/Dev/devapache
SMOKEOUT=$TWROOT/smoke.out
SMOKEOUTF AIL=$TWROOT/smoke.out.fail

$DEVAPACHE stop  > /dev/null 2>&1
$DEVAPACHE start > $SMOKEOUT 2>&1

cd $TWROOT
smoke $@ >> $SMOKEOUT 2>&1
$DEVAPACHE stop >> $SMOKEOUT 2>&1

rm -f ~/tw
grep -i "^Failed" $SMOKEOUT > $SMOKEOUTFAIL
if [ -s $SMOKEOUTFAIL ]
then
    STATUS="FAILED"
    mail -s"Smoke $REV $@ $STATUS `date`" $MAIL < $SMOKEOUT
else
    STATUS="passed"
    rm -fr $TWROOT
fi

and here's the crontab for the smoke user on the dev box:

PATH=/bin:/usr/bin:/usr/local/bin
TMP=/home/smoke
USER=smoke

# Smoke the trunk at :00
0 * * * * smokebot trunk smokereports@mycompany.com

# Smoke the branch at :30
30 * * * * smokebot branch/proj-name smokereports@mycompany.com
# More branches possible, of course.

A couple of notes: "TW" is TITLEWAVE, our website, and everything lives in the user's ~/tw directory. The smoke program is a TW-specific predecessor of prove that comes with Test::Harness. The smokereports email address is an alias that explodes to the entire department. If the smoke fails, it leaves the temp directory for port-mortem.

At some point I'll have a genericized version of this in Test::Harness.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.