Documentation/RunningOnHudson

Not logged in - Log In / Register

Hudson is a continuous integration server written in Java and used for many projects. Although its main use is to create builds and running unit tests it can also work to run Mago tests unattended.

We will be running Mago tests in a Xvfb session.

Prerequisites

You will need to have the following packages installed:

Installing Hudson

The first thing you will need to do is install Hudson. Hudson provide packages for Debian that work well in Ubuntu. To install Hudson just follow the instructions:

http://hudson-ci.org/debian/ and Hudson on Ubuntu

Creating an a11y environment

Hudson runs on a command line environment, but, because we need accessibility to be enabled (which is not accessible in a command line environment), we need to provide a workaround to it. (Thanks to Nagappan Alagappan who wrote these scripts)

Copy a11yservice.py and a11yclient.py into /usr/bin, with executable permissions.

Copy hudson-a11y-service.desktop into /etc/xdg/autostart

hudson-a11y-service.desktop

This file will make a11yservice run automatically when the X session starts.

a11yservice.py

This file will be run automatically when the X session starts and will be listening in a UNIX socket for petitions.

a11yclient.py

It will provide the communication between the X server and Hudson. It will pass a command to a11yservice that will return the status back.

Stopping the Hudson service

  1. if you just want to temporarily stop the service: sudo service hudson stop. To restart it, run sudo service hudson start.

  2. to permanently disable automatic startup on reboot: sudo update-rc.d hudson disable. You will still be able to start the service anytime by using 'sudo service hudson start'.

Creating the job in Hudson

For this example we are going to create a job that runs Mago gedit tests. This is a complete example. To run any other tests, just change the mago bits of the job.

  1. On Hudson main page, click on New Job and create a "Free-style software project".

hudson1.png

  1. Under Build select Add Build Step -> Execute Shell

hudson2.png

  1. In the text space write the following shell code:

# Let us assume only *ONE* test will be run at a time in this X session at any point
# So, only one gnome session for hudson user
if [ ! -f "hudson.xinitrc" ]; then
    # Control will enter here if hudson.xinitrc doesn't exist
    # Will dump to current workspace
    echo "export OOO_FORCE_DESKTOP=gnome" > hudson.xinitrc
    echo "export LANG=\"en_US.UTF-8\"" >> hudson.xinitrc
    echo "export LC_ALL=\"en_US.UTF-8\"" >> hudson.xinitrc
    echo "export LANGUAGE=\"en_US.UTF-8\"" >> hudson.xinitrc
    echo "export LC_CTYPE=\"en_US.UTF-8\"" >> hudson.xinitrc
    echo "gnome-settings-daemon &" >> hudson.xinitrc
    echo "dbus-launch" >> hudson.xinitrc
    echo "exec gnome-session" >> hudson.xinitrc
fi

# Enable accessibility on the "hudson" user
gconftool-2 --set --type bool /desktop/gnome/interface/accessibility true
# Accessibility test will hang, if screensaver starts
gconftool-2 --type bool --set /apps/gnome-screensaver/idle_activation_enabled false

# Start the X session (it will run under Xvfb and it will start a11yservice.py)
xinit "`pwd`"/hudson.xinitrc -- /usr/bin/Xvfb :2 -screen 0 1024x768x24 -fbdir /tmp :2 &

# Wait until the X session starts
sleep 10

if [ ! -d "mago" ]; then
    # Control will enter here if mago doesn't exist
    bzr branch lp:mago
fi
# Current folder is workspace folder
cd mago
# Check for latest files in mago
bzr pull lp:mago

# Quit gnome-screensaver
/usr/bin/a11yclient.py 'xterm -e "gnome-screensaver-command --exit"'

# Following sleep just for testing
/usr/bin/a11yclient.py 'gnome-terminal --disable-factory -e "sleep 5"'

# Hudson services started from workspace folder, let us navigate to mago folder
## The following line is the one you need to change, depending on what tests you want to run
/usr/bin/a11yclient.py 'xterm -e "cd mago;PYTHONPATH=. ./bin/mago --noa11y -a gedit -t ../../../../userContent/mago"'

# Above one doesn't work with gnome-terminal and so using xterm
# Following sleep just for testing
/usr/bin/a11yclient.py 'gnome-terminal --disable-factory -e "sleep 5"'

# Logout from current X session
/usr/bin/a11yclient.py 'gnome-terminal --disable-factory -e "gnome-session-save --force-logout"'

Improving the reports

As you know, Mago generates HTML reports. These reports can be easily integrated in Hudson to keep the history.

  1. First, we need to install the HTML Reports plugin. Under Manage Hudson click on Manage Plugins

hudson3.png

  1. We are going to configure our Hudson job to include the HTML reports. Right at the bottom of the job configuration select "Publish HTML reports" and add the following information:

hudson4.png

Of course, the location and name of reports will change depending on the tests run.

Running the tests

Once set up, you will be able to run the tests by clicking on "Build Now". The build information will contain a link to the Mago reports.

Documentation/RunningOnHudson (last edited 2011-01-05 17:23:30 by hggdh2)