Running your watir-webdriver tests in the cloud, for free!

  • What if you could run unlimited Watir WebDriver tests in the cloud? Check.
  • What if the Watir WebDriver tests would run automatically as soon as you pushed a change to github? Check.
  • What if you would have a full visual history of results with embedded screenshots on failure? Check.
  • What if all of this was free?* Checkmate.

I’ve spent a bit of time over the last week working out how to do this. Here are the basics of what you need to do:

And here’s the detailed instructions.

Set up an Amazon EC2 micro instance running Ubuntu.

  1. First you need to sign up for an Amazon AWS account. This means you’re eligible for a free-tier micro instance for a year.
  2. Once you have an account set up, you need to launch a new instance. I found a free tier eligible Ubuntu image (11.04 Natty 64 bit desktop) and launched that.
  3. You will also want to create an elastic IP and associate it to your instance so that if you reboot your machine, you will have the same IP address. This is done through the AWS console under Elastic IPs.
  4. While you’re here, you’ll want to edit your machine’s security group and open up port 22 for SSH, and 80 for HTTP.
  5. This gives you secure shell (SSH) access to this machine using the provided key, and user ‘ubuntu’:
    ssh -i your-key-name.pem ubuntu@your-ip-address
  6. Everything you will do to configure this machine will be through this SSH session, so polish up your unix command line skills!

Set up Jenkins on your machine

There is a useful page for installing Jenkins on Ubuntu.

wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo aptitude update
sudo aptitude install jenkins

Make Jenkins available on port 80 so that you don’t need to specify port

Jenkins installs by default on port 80. Ubuntu won’t let applications run on port 80 unless they’re running as root, so it’s best to set up an Apache 2 proxy to port 80 to 8080.

sudo aptitude install apache2
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod vhost_alias
sudo a2dissite default

Then create a file called jenkins in /etc/apache2/sites-available


	ServerAdmin webmaster@localhost
	ServerName ci.company.com
	ServerAlias ci
	ProxyRequests Off
	
		Order deny,allow
		Allow from all
	
	ProxyPreserveHost on
	ProxyPass / http://localhost:8080/

Then run the following commands:

sudo a2ensite jenkins
sudo apache2ctl restart

Password Protect Jenkins

You should go to your Jenkins site (accessible directly at your instance’s IP address through a web browser), and create an account, and then configure the security of Jenkins.

Install Jenkins Plugins

You will need to install the following Jenkins plugins

  • Github: to integrate to Github SCM
  • Rake: to run ruby rake tasks that run Watir-WebDriver tests
  • Green balls: because blue balls are just plain wrong

Install RVM for the Jenkins user

First we’ll need to install git

sudo apt-get install git

Jenkins will need to be able to run ruby, so we’ll install RVM as the Jenkins user.

To run as the jenkins user, we’ll use the sudo command, with the -Hiu arguments to load the home directory and bash profile:

sudo -Hiu jenkins

Once we are user Jenkins, we’ll install RVM using Git.

bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

Now we need to work out what Ubuntu packages Ruby needs, which is easily done via RVM.

rvm notes

which gives me something like

For Ruby (MRI, Rubinius, & REE)  you should install the following OS dependencies:
/usr/bin/apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake

So, we can log-out as the Jenkins user (control-D) and install the following as ubuntu

sudo apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake

Once we’ve done this, we’ll want to run the following as the Jenkins user (
sudo -Hiu jenkins) to install Ruby 1.9.2.

rvm pkg install zlib
rvm install 1.9.2 --with-zlib-dir=$rvm_path/usr

Running headless Watir-WebDriver tests

I choose a desktop version of Ubuntu, so it’ll already have Firefox installed, but if you don’t, you can install it by:

sudo apt-get install firefox

To run our Watir WebDriver tests headlessly using the headless gem, we’ll need xvfb

sudo apt-get install xvfb

Configuring Jenkins to run tests via Rake

You add a new build in Jenkins where you can specify the github repository location.

As we’ve installed the rake plugin, we can configure a new Jenkins project to use an RVM ruby install (in my case ruby-1.9.2-p290@watirmelon-cucumber).

I simply set up a default task in rake, which runs all my cucumber tests. This generates a results.html file which is captured as an artifact, and also creates and captures junit xml results, which are used to show test summary information.I also capture any file created under the ‘screenshots’ directory.

Summary and Outcome

I have set up both my WatirMelonCucumber and EtsyWatirWebDriver projects on jenkins.watirmelon.com.

My Jenkins Dashboard looks something like this:

Please feel to leave a comment below and let me know what you think.

* Free for one year using an free tier EC2 micro instance

Everything is amazing and nobody is happy

I love this film clip of Loius C.K. talking about how complacent we’ve become with technology. As someone who works in technology everyday, I know it’s easy to become complacent and critical of what we’re doing, but occasionally we need to remind ourselves of how amazing things actually are. For example, tonight I was using Skype to video call my wife and son from my hotel room 1000km from our home. Every now and then it would become a little stuttered, and I’d get a little annoyed. But I need to remind myself: I am 1000km from home and I can talk to, and see, my wife and son fullscreen on my laptop, for free! How amazing is that.

On 37signals selling Sortfolio

I found this comment about 37signals selling off Sortfolio particularly pertinent, considering it’s against what those guys often preach.

I don’t remotely understand this. From the guys who say “build something that scratches your itch, charge for it, stay small, iterate, never sell” to say, “Oh, by the way, and we’re selling this thing.” I don’t get it.

Brady Wetherington on Sortfolio deserves a better home. Make us an offer.

Happy 5th Birthday to two great open source projects

November 2009 marks the fifth birthday of two great open source projects, both of which I couldn’t live without.

  1. Firefox was first released on November 9th, 2004. I remember first installing it in 2004, loving it and I still use it to this day. I’m actually using it right now to write this post.
  2. Watir made its first public appearance on November 15th, 2004, in a tutorial by Bret and Paul at StarWest 2004.

The two projects became connected in late 2006 when FireWatir was developed by Angrez Singh. Since then Watir has incorporated native Firefox support.

So here’s cheers to these two great open source projects! Hope there are many more great birthdays to come!

Five user JIRA and Confluence licenses for $5

If you know me you will know that I am a big fan of Atlassian, both the products and the company. I just saw Mike Cannon Brooks’s tweet about offering five user JIRA and Confluence licenses for $5 for the next five days, with all proceeds to Room To Read.

The world economy needs to get back on track and we want to help. Our products help teams communicate better, have more productive interactions and get stuff done. We want to help small entrepreneurial teams get the economy back into high gear.

This is awesome. If you work in a small team and have always wanted Confluence and JIRA but couldn’t convince management, now is the time. They can’t possibly say no!

Websites don’t need holidays

I am really dissapointed in the Australian Tax Office for taking down their entire web site for eleven days over Christmas/New Years 2008-2009. The website contains important reference information that should be accessible anytime. How can any organisation justify such a lengthy period of down time, especially for a web site with mostly static content for reference?

tax-office-it-shutdown

Twitter is over capacity

I like friendly error messages; I don’t think you can get much cuter than Twitter’s over capacity error message:

Twitter error message

Twitter error message

I just love how the whale is smiling. It makes it such a better error message. I don’t think many companies would be game to use a whale on their capacity error page (if they even had one) but in this case it just works.

Gmail Terminal & Prism: conspicuous at work

I really like the new Gmail themes now available: they make Yahoo Mail look so passé.

The terminal theme is particularly interesting, a product of a bet, it’s really well done, right down to the ASCII art for the Gmail logo.

Gmail with terminal theme under Prism on Ubuntu

Gmail with terminal theme under Prism on Ubuntu

This would be handy for us who still use green screens as you could run Gmail Terminal in Prism to keep your webmailing at work discrete. Not that I would condone such behaviour :P

Mac Bank’s monotonic website is a refreshing design change

As I’ve mentioned before, I surf the web a lot and I’ve got used to surfing a lot of different sites. Every now and then I come across a new web page that, design wise, completely blows my mind. Last night that web page was the homepage of Macquarie Private Wealth.

Macquarie Private Wealth home page

Macquarie Private Wealth home page

I think their monotonic design, with limited shades of purple, is superbly aesthetic. It strikes me as bold, confident and professional. It’s a brave move, most modern websites use a lot of colour, but they’ve resisted and in my opinion it’s worked.

Perpetual home page

Perpetual home page

Just compare it to Perpetual’s home page which also uses monotonic images, but with lots of colour elsewhere. I don’t find this page has any where near as much impact.