X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=vbuild-nightly.sh;h=14720d667e45ba019c73bbcc43462b4244380333;hb=5227765b6399259b227b5da70234445f0ab42931;hp=0775a2f84cc98025e35b330547a4b6350639f856;hpb=acb9be1f98fed99f927d5c3063628166d6068972;p=build.git diff --git a/vbuild-nightly.sh b/vbuild-nightly.sh index 0775a2f8..14720d66 100755 --- a/vbuild-nightly.sh +++ b/vbuild-nightly.sh @@ -11,15 +11,15 @@ DEFAULT_PERSONALITY=linux32 DEFAULT_BASE="@DATE@--@PLDISTRO@-@FCDISTRO@-@PERSONALITY@" DEFAULT_SVNPATH="http://svn.planet-lab.org/svn/build/trunk" DEFAULT_TESTSVNPATH="http://svn.planet-lab.org/svn/tests/trunk/system/" -DEFAULT_IFNAME=lo +DEFAULT_TESTCONFIG="default" +DEFAULT_IFNAME=eth0 # web publishing results DEFAULT_WEBPATH="/build/@PLDISTRO@/" # for the test part TESTBUILDURL="http://build.one-lab.org/" -TESTBOX=onelab-test.inria.fr -TESTBOXSSH=root@onelab-test.inria.fr +TESTBOXSSH=root@testbox.one-lab.org #################### # assuming vserver runs in UTC DATE=$(date +'%Y.%m.%d') @@ -98,9 +98,9 @@ function failure() { mkdir -p ${WEBPATH} cp $LOG ${WEBLOG} summary $LOG >> ${WEBLOG} - (echo -n "============================== $COMMAND: failure at " ; date ; tail -c 20k $WEBLOG) > ${WEBLOG}.ko + (echo -n "============================== $COMMAND: failure at " ; date ; tail -c 30k $WEBLOG) > ${WEBLOG}.ko if [ -n "$MAILTO" ] ; then - tail -c 20k ${WEBLOG} | mail -s "Failures for build ${BASE}" $MAILTO + tail -c 30k ${WEBLOG} | mail -s "Failures for build ${BASE}" $MAILTO fi exit 1 } @@ -111,41 +111,18 @@ function success () { mkdir -p ${WEBPATH} cp $LOG ${WEBLOG} summary $LOG >> ${WEBLOG} - touch ${WEBLOG}.ok + if [ -n "$DO_TEST" ] ; then + echo "Successfully built and tested - see testlogs for details" > ${WEBLOG}.pass + rm -f ${WEBLOG}.ok + else + echo "Successfully built"> ${WEBLOG}.ok + fi if [ -n "$MAILTO" ] ; then (echo "$PLDISTRO ($BASE) build for $FCDISTRO completed on $(date)" ) | mail -s "Successful build for ${BASE}" $MAILTO fi exit 0 } -# parses ifconfig's output to find out ip address and mask -# will then be passed to vserver as e.g. --interface 138.96.250.126/255.255.0.0 -# default is to use lo, that's enough for local mirrors -# use -i eth0 in case your fedora mirror is on a separate box on the network -function vserverIfconfig () { - ifname=$1; shift - local result="" - line=$(ifconfig $ifname 2> /dev/null | grep 'inet addr') - if [ -n "$line" ] ; then - set $line - for word in "$@" ; do - addr=$(echo $word | sed -e s,[aA][dD][dD][rR]:,,) - mask=$(echo $word | sed -e s,[mM][aA][sS][kK]:,,) - if [ "$word" != "$addr" ] ; then - result="${addr}" - elif [ "$word" != "$mask" ] ; then - result="${result}/${mask}" - fi - done - fi - if [ -z "$result" ] ; then - echo "vserverIfconfig failed to locate $ifname" - exit 1 - else - echo $result - fi -} - # run in the vserver - do not manage success/failure, will be done from the root ctx function build () { set -x @@ -188,25 +165,46 @@ function runtest () { echo -n "============================== Starting $COMMAND:runtest on $(date)" - ### the URL to the myplc package - rpm=$( (cd /vservers/$BASE/build/RPMS/i386 ; ls myplc-[0-9]*.rpm) ) - if [ ${#rpm[@]} != 1 ] ; then - echo "$COMMAND: Cannot locate rpm for testing" + ### the URL to the RPMS/ location + url="" + for a in i386 x86_64; do + archdir=/vservers/$BASE/build/RPMS/$a + if [ -d $archdir ] ; then + url=$(echo $archdir | sed -e "s,/vservers/$BASE/build,${TESTBUILDURL}${PLDISTRO}/${BASE},") + break + fi + done + + if [ -z "$url" ] ; then + echo "$COMMAND: Cannot locate arch URL for testing" failure exit 1 fi - url=${TESTBUILDURL}${PLDISTRO}/${BASE}/RPMS/i386/${rpm} - # compute test directory name on test box - testdir=test-${BASE} + # test directory name on test box + testdir=${BASE} # clean it ssh ${TESTBOXSSH} rm -rf ${testdir} # check it out ssh ${TESTBOXSSH} svn co ${TESTSVNPATH} ${testdir} # invoke test on testbox - pass url and build url - so the tests can use vtest-init-vserver.sh - ssh 2>&1 ${TESTBOXSSH} python -u ${testdir}/runtest --build ${SVNPATH} --url ${url} --all - - if [ "$?" != 0 ] ; then + configs="" + for config in ${TESTCONFIG} ; do + configs="$configs --config $config" + done + + # need to proceed despite of set -e + success=true + ssh 2>&1 ${TESTBOXSSH} ${testdir}/runtest --build ${SVNPATH} --url ${url} $configs --all || success= + + # gather logs in the vserver + mkdir -p /vservers/$BASE/build/testlogs + ssh 2>&1 ${TESTBOXSSH} tar -C ${testdir}/logs -cf - . | tar -C /vservers/$BASE/build/testlogs -xf - || true + # push them to the build web + rsync --archive --delete /vservers/$BASE/build/testlogs/ $WEBPATH/$BASE/testlogs/ + chmod -R a+r $WEBPATH/$BASE/testlogs/ + + if [ -z "$success" ] ; then failure fi @@ -239,7 +237,6 @@ function usage () { echo "Usage: $COMMAND [option] make-targets" echo "This is $REVISION" echo "Supported options" - echo " -n dry-run : -n passed to make - vserver gets created though - no mail sent" echo " -f fcdistro - defaults to $DEFAULT_FCDISTRO" echo " -d pldistro - defaults to $DEFAULT_PLDISTRO" echo " -p personality - defaults to $DEFAULT_PERSONALITY" @@ -248,16 +245,18 @@ function usage () { echo " -t pldistrotags - defaults to \${PLDISTRO}-tags.mk" echo " -r tagsrelease - a release number that refers to PLDISTROTAGS - defaults to HEAD" echo " -s svnpath - where to fetch the build module" - echo " -o : overwrite - re-run in base directory, do not create vserver" - echo " -m mailto" - echo " -a makevar=value - space in values are not supported" + echo " -x testsvnpath - defaults to $DEFAULT_TESTSVNPATH" + echo " -c testconfig - defaults to $DEFAULT_TESTCONFIG" echo " -w webpath - defaults to $DEFAULT_WEBPATH" - echo " -i ifname - defaults to $DEFAULT_IFNAME - set to e.g. eth0 for non-local mirrors" + echo " -m mailto - no default" + echo " -O : overwrite - re-run in base directory, do not re-create vserver" echo " -B : run build only" echo " -T : run test only" - echo " -x testsvnpath - defaults to $DEFAULT_TESTSVNPATH" + echo " -n dry-run : -n passed to make - vserver gets created though - no mail sent" echo " -v : be verbose" echo " -7 : uses weekday-@FCDISTRO@ as base" + echo " -a makevar=value - space in values are not supported" + echo " -i ifname - defaults to $DEFAULT_IFNAME - used to determine local IP" exit 1 } @@ -265,18 +264,13 @@ function main () { set -e - # preserve arguments for passing them again later - declare -a argv - for arg in "$@"; do argv=(${argv[@]} "$arg") ; done - # parse arguments MAKEVARS=() DRY_RUN= DO_BUILD=true DO_TEST=true - while getopts "nf:d:b:p:t:r:s:om:a:w:i:BTvh7" opt ; do + while getopts "f:d:p:b:t:r:s:x:c:w:m:OBTnv7a:i:" opt ; do case $opt in - n) DRY_RUN="-n" ;; f) FCDISTRO=$OPTARG ;; d) PLDISTRO=$OPTARG ;; p) PERSONALITY=$OPTARG ;; @@ -284,21 +278,27 @@ function main () { t) PLDISTROTAGS=$OPTARG ;; r) TAGSRELEASE=$OPTARG ;; s) SVNPATH=$OPTARG ;; - o) OVERWRITEMODE=true ;; - m) MAILTO=$OPTARG ;; - a) MAKEVARS=(${MAKEVARS[@]} "$OPTARG") ;; + x) TESTSVNPATH=$OPTARG ;; + c) TESTCONFIG="$TESTCONFIG $OPTARG" ;; w) WEBPATH=$OPTARG ;; - i) IFNAME=$OPTARG ;; + m) MAILTO=$OPTARG ;; + O) OVERWRITEMODE=true ;; B) DO_TEST= ;; T) DO_BUILD= ; OVERWRITEMODE=true ;; - x) TESTSVNPATH=$OPTARG ;; + n) DRY_RUN="-n" ;; v) set -x ;; 7) BASE="$(date +%a|tr A-Z a-z)-@FCDISTRO@" ;; + a) MAKEVARS=(${MAKEVARS[@]} "$OPTARG") ;; + i) IFNAME=$OPTARG ;; h|*) usage ;; esac done - shift $(($OPTIND - 1)) + # preserve options for passing them again later, together with expanded base + declare -a options + toshift=$(($OPTIND - 1)) + arg=1; while [ $arg -le $toshift ] ; do options=(${options[@]} "$1") ; shift; arg=$(($arg+1)) ; done + MAKETARGETS="$@" # set defaults @@ -311,6 +311,7 @@ function main () { [ -z "$IFNAME" ] && IFNAME="$DEFAULT_IFNAME" [ -z "$SVNPATH" ] && SVNPATH="$DEFAULT_SVNPATH" [ -z "$TESTSVNPATH" ] && TESTSVNPATH="$DEFAULT_TESTSVNPATH" + [ -z "$TESTCONFIG" ] && TESTCONFIG="$DEFAULT_TESTCONFIG" [ -n "$DRY_RUN" ] && MAILTO="" @@ -345,6 +346,8 @@ function main () { set -x echo "XXXXXXXXXX $COMMAND: using existing vserver $BASE" $(date) show_env + # start in case e.g. we just rebooted + vserver ${BASE} start || : # update build vserver ${BASE} exec svn update /build else @@ -374,8 +377,7 @@ function main () { svn export $SVNPATH $tmpdir # Create vserver cd $tmpdir - localip=$(vserverIfconfig $IFNAME) - ./vbuild-init-vserver.sh -f ${FCDISTRO} -d ${PLDISTRO} -p ${PERSONALITY} ${BASE} -- --interface $localip + ./vbuild-init-vserver.sh -f ${FCDISTRO} -d ${PLDISTRO} -p ${PERSONALITY} -i ${IFNAME} ${BASE} # cleanup cd - rm -rf $tmpdir @@ -402,13 +404,15 @@ function main () { # invoke this command in the vserver for building (-T) vserver ${BASE} exec chmod +x /build/$COMMAND - vserver ${BASE} exec /build/$COMMAND "${argv[@]}" -b "${BASE}" + vserver ${BASE} exec /build/$COMMAND "${options[@]}" -b "${BASE}" $MAKETARGETS fi # publish to the web so runtest can find them rm -rf $WEBPATH/$BASE ; mkdir -p $WEBPATH/$BASE/{RPMS,SRPMS} rsync --archive --delete --verbose /vservers/$BASE/build/RPMS/ $WEBPATH/$BASE/RPMS/ rsync --archive --delete --verbose /vservers/$BASE/build/SRPMS/ $WEBPATH/$BASE/SRPMS/ + # publish myplc-release + rsync --verbose /vservers/$BASE/build/myplc-release $WEBPATH/$BASE if [ -n "$DO_TEST" ] ; then runtest