ReferencePlatforms/RefPlatformTeam

From MozillaWiki
Jump to: navigation, search

VMware team

This document describes how to create a VMware team consisting of a Linux buildslave, Win32 buildslave, and Linux CVS server/buildmaster.

Prerequisites

Before completing anything below you should have the following 3 VMs:

Create the Team

  1. File->New->Team
  2. Next
  3. Pick a name and location, click Next
  4. Select "Yes", click Next
  5. Use "Add->Existing Virtual Machine" to add all 3 of the above VMs
  6. The buildserver should be first in the list and have a delay of "30s"
  7. The other VMs should have a delay of 10s
  8. Click Next
  9. Select "Yes", click Next
  10. Add one LAN Segement, click Next
  11. Add an Ethernet Adapter to each VM, set all of them to "LAN 1", click Next
  12. Click Finish

Set-up the IP addresses of the VMs

Linux ref image

Create the file /etc/sysconfig/network-scripts/ifcfg-eth1 with the following contents:

DEVICE=eth1
ONBOOT=yes
BOOTPROTO=static
BROADCAST=10.0.0.255
IPADDR=10.0.0.2
NETMASK=255.255.255.0
NETWORK=10.0.0.0/24

Buildserver ref image

Create the file /etc/sysconfig/network-scripts/ifcfg-eth1 with the following contents:

DEVICE=eth1
ONBOOT=yes
BOOTPROTO=static
BROADCAST=10.0.0.255
IPADDR=10.0.0.1
NETMASK=255.255.255.0
NETWORK=10.0.0.0/24

Win32 ref image

  1. Start->Settings->Control Panel->Network Connections
  2. Right click "Local Area Connection 2" (maybe 3) -> Properties
  3. Double click "Internet Protocol (TCP/IP)"
  4. Select "Use the following IP address"
  5. IP Address: 10.0.0.3
  6. Subnet mask: 255.255.255.0
  7. Click "OK"

Create Buildslaves

Linux ref image

Login as root and do the following:

mkdir /buildbot
chown buildbot buildbot/

Then login as buildbot and do:

cd /buildbot
mkdir default
cd default
buildbot create-slave --umask=002 . 10.0.0.1:9990 linux l1nuxbu1ld3r

As root again, create the file /etc/defaults/buildbot with the contents:

# buildbots to manage
# add a new set of variables for each buildbot to start

# BB_NUMBER    -> index for the buildbot
# BB_NAME      -> short name that is printed when starting/stopping
# BB_USER      -> user to run the buildbot as
# BB_BASEDIR   -> the absolute path to the buildbot master or slave
# BB_OPTIONS   -> extra options to pass to buildbot
# BB_PREFIXCMD -> prefix command, ie. nice, linux32, etc.
#
# Each of the preceeding are arrays. Each Buildbot you wish to run should
# increase the index of each. For example, the first Buildbot should use
# [0] on each array. The next one uses [1], etc.

BB_NUMBER[0]=0
BB_NAME[0]="Default Buildbot"
BB_USER[0]="buildbot"
BB_BASEDIR[0]="/buildbot/default/"
BB_OPTIONS[0]=""
BB_PREFIXCMD[0]=""

And create the file /etc/init.d/buildbot with the contents:

#! /bin/bash
# initscript for buildbot

### BEGIN INIT INFO
# Provides:          cvsd
# Required-Start:    $local_fs $network
# Required-Stop:     $local_fs
# Should-Start:      $remote_fs 
# Should-Stop:       $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      S 0 1 6
# Short-Description: Buildbot
# Description:       Buildbot
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DESC="BuildBot"

USER=buildbot

DAEMON=/tools/buildbot/bin/buildbot
DNAME=buildbot
PROCNAME=$NAME

[ -r /etc/default/buildbot ] && . /etc/default/buildbot

test -x ${DAEMON} || exit 0

. /lib/lsb/init-functions

check_config()
{
    errors=0
    for i in ${BB_NUMBER[@]}; do
	[ $i -ge 0 ] || continue
	if [ -z "${BB_NAME[$i]}" ]; then
	    echo >&2 "buildbot $i: no name"
	    errors=$(($errors+1))
	fi
	if [ -z "${BB_USER[$i]}" ]; then
	    echo >&2 "buildbot $i: no user"
	    errors=$(($errors+1))
	elif ! getent passwd ${BB_USER[$i]} >/dev/null; then
	    echo >&2 "buildbot $i: unknown user ${BB_USER[$i]}"
	    errors=$(($errors+1))
	fi
	if [ ! -d "${BB_BASEDIR[$i]}" ]; then
	    echo >&2 "buildbot $i: no base directory ${BB_BASEDIR[$i]}"
	    errors=$(($errors+1))
	fi
    done
    [ $errors -eq 0 ] || exit 1
}

check_config

start_buildbot() {
    NAME="$1"
    USER="$2"
    BASEDIR="$3"
    PREFIXCMD="$4"
    OPTIONS="$5"

    #START="--start --quiet --exec ${DAEMON} --name ${NAME} --pidfile ${BASEDIR}/twistd.pid"
    #[ -n "${USER}" ] && START="${START} --chuid ${USER}"
    #START="${START} -- start ${BASEDIR} ${OPTIONS}"
    #${PREFIXCMD} start-stop-daemon ${START} >/dev/null 2>&1
    ${PREFIXCMD} su -s /bin/bash -c "${DAEMON} start ${BASEDIR} ${OPTIONS}" - ${USER}
    return $?
}

stop_buildbot() {
    NAME="$1"
    USER="$2"
    BASEDIR="$3"
    PREFIXCMD="$4"

    ${PREFIXCMD} su -s /bin/bash -c "${DAEMON} stop ${BASEDIR}" - ${USER}
    return $?
}

reload_buildbot() {
    NAME="$1"
    USER="$2"
    BASEDIR="$3"
    PREFIXCMD="$4"

    ${PREFIXCMD} su -s /bin/bash -c "${DAEMON} sighup ${BASEDIR}" - ${USER}
    return $?
}

do_start () {
    errors=0
    for i in ${BB_NUMBER[@]}; do
	[ $i -ge 0 ] || continue
	echo "Starting buildbot ${BB_NAME[$i]}"
	if start_buildbot "${BB_NAME[$i]}" "${BB_USER[$i]}" "${BB_BASEDIR[$i]}" \
	    "${BB_PREFIXCMD[$i]}" "${BB_OPTIONS[$i]}"
	then
	    echo "started"
	else
	    echo "not started"
	    errors=$(($errors+1))
	fi
    done
    return $errors
}

do_stop () {
    errors=0
    for i in ${BB_NUMBER[@]}; do
	[ $i -ge 0 ] || continue
	echo "Stopping buildbot ${BB_NAME[$i]}"
	if stop_buildbot "${BB_NAME[$i]}" "${BB_USER[$i]}" "${BB_BASEDIR[$i]}" \
	    "${BB_PREFIXCMD[$i]}"
	then
	    echo "stopped"
	else
	    echo "not stopped"
	    errors=$(($errors+1))
	fi
    done
    return $errors
}

do_reload () {
    errors=0
    for i in ${BB_NUMBER[@]}; do
	[ $i -ge 0 ] || continue
	echo "Reload buildbot ${BB_NAME[$i]}"
	if reload_buildbot "${BB_NAME[$i]}" "${BB_USER[$i]}" "${BB_BASEDIR[$i]}" \
	    "${BB_PREFIXCMD[$i]}"
	then
	    echo "reloaded"
	else
	    echo "not reloaded"
	    errors=$(($errors+1))
	fi
    done
    return $errors
}

do_restart () {
    errors=0
    for i in ${BB_NUMBER[@]}; do
	[ $i -ge 0 ] || continue
	echo "Restarting buildbot ${BB_NAME[$i]}"
	stop_buildbot "${BB_NAME[$i]}" "${BB_USER[$i]}" "${BB_BASEDIR[$i]}" \
	    "${BB_PREFIXCMD[$i]}" || true
	if start_buildbot "${BB_NAME[$i]}" "${BB_USER[$i]}" "${BB_BASEDIR[$i]}" \
	    "${BB_PREFIXCMD[$i]}" "${BB_OPTIONS[$i]}"
	then
	    echo "restarted"
	else
	    echo "not restarted"
	    errors=$(($errors+1))
	fi
    done
    return $errors
}

case "$1" in
  start)
  	do_start
  	exit $?
	;;
  stop)
  	do_stop
  	exit $?
	;;
  reload)
  	do_reload
  	exit $?
	;;
  restart|force-reload)
  	do_restart
  	exit $?
	;;
  *)
	log_warning_msg "Usage: $0 {start|stop|restart|reload|force-reload}"
	exit 1
	;;
esac

exit 0

To have Buildbot start with the system run the following command:

chkconfig --add buildbot

Win32 ref image

Adapted from http://buildbot.net/trac/wiki/RunningBuildbotOnWindows Open up a command line (as an Administrator) and do the following:

buildbot create-slave --umask=002 d:\buildbot\default 10.0.0.1:9990 win32 w1nbu1ld3r

Add permission to allow the builder user to "Log on as a service":

  1. Start->Settings->Control Panel->Administrative Tools->Local Security Policy
  2. Local Policies->User Rights Assignment
  3. Add 'cltbld' to the "Log on as a service" policy.

Back in the console enter:

buildbot_service.py --user WIN2K3-REF-IMG\cltbld --password [cltbld password] --startup auto install

Give the cltbld user full permissions to some registry keys:

  1. Start->Run->'regedit'
  2. HKLM\System\CurrentControlSet\Services
  3. Right click on Buildbot->Permissions
  4. Give 'cltbld' Full Control.

Back in the console do:

buildbot_service.py start "D:\buildbot\default"

The service will remember this directory for future starts and stops.