Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Sample Rails3 project with Vagrantfile + cookbooks

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 app rename app November 06, 2010
Octocat-spinner-32 config
Octocat-spinner-32 cookbooks
Octocat-spinner-32 db
Octocat-spinner-32 doc “Initial” November 05, 2010
Octocat-spinner-32 lib “Initial” November 05, 2010
Octocat-spinner-32 public
Octocat-spinner-32 script
Octocat-spinner-32 test
Octocat-spinner-32 vendor
Octocat-spinner-32 .gitignore Setup mysql root password to "" (which is default rails assumption) November 06, 2010
Octocat-spinner-32 .vagrant Setup mysql root password to "" (which is default rails assumption) November 06, 2010
Octocat-spinner-32 Gemfile lots of cookbook goodness November 06, 2010
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 README.md added another image November 08, 2010
Octocat-spinner-32 Rakefile
Octocat-spinner-32 Vagrantfile
Octocat-spinner-32 config.ru rename app November 06, 2010
README.md

Sample Rails3, Vagrantfile and testing within Hudson CI

This README describes how to start up a Hudson CI server, create a VM and add it to Hudson CI server as a slave, and create/build a job to run this project's tests.

This app has a Vagrantfile and Chef recipes to create a VirtualBox VM ready for integration testing.

It includes a Java JRE so that Hudson CI can use the VM as a slave node, SSH into it, inject its slave.jar and automated it.

Preparation

For the tutorial on running CI tests through Hudson CI with VM instances constructed by Vagrant, there are a couple preparation steps:

git clone git://github.com/drnic/railsapp-vagrant.git
cd railsapp-vagrant

Next, install VirtualBox.

Vagrant

Install Vagrant and download the Ubuntu Lucid 32bit VirtualBox image:

gem install vagrant -v 0.6.7 # if other version, the replace '0.6.7' in instructions below
vagrant box add base http://files.vagrantup.com/lucid32.box

Then to spin up a VM for this Rails app (takes 10 minutes, mostly due to installing Java JRE, I think):

vagrant init base
vagrant up

To access this project within the VM:

vagrant ssh
$ cd /vagrant/
$ rake test
/vagrant/db/schema.rb doesn't exist yet.

Quick fix of VM

When I do this the ~/.gem folder is owned by root and not the vagrant user. This isn't correct. Fix it within the VM:

$ sudo chown vagrant:vagrant ~/.gem
$ exit

Testing within Hudson CI

You can add this VM into Hudson CI as a slave, create a Hudson job for this project, and restrict it to running the tests only within this VM. This will ensure that you have all the system/utility/ruby requirements for your tests. Ideally, these will match your production deployment environment.

To experiment with Hudson CI:

gem install hudson
hudson server

This spins up Hudson CI at http://localhost:3010.

In another terminal, add the VM as a slave node:

$ hudson add_node localhost --name "VM" \
    --label railsapp-vagrant \
    --slave-port 2222 \
    --slave-user vagrant \
    --slave-fs /vagrant/tmp/hudson-slave \
    --master-key /Library/Ruby/Gems/1.8/gems/vagrant-0.6.7/keys/vagrant \
    --host localhost --port 3010

$ hudson nodes --host localhost --port 3001
master
VM

Visit your Hudson CI to see the Slave node registered as "VM" on the left hand side.

To add this Rails3 application as a CI job in Hudson:

hudson create . --template rails3 --assigned-node railsapp-vagrant

Note: the --host and --port flags are only required when you want the hudson CLI to change/set which Hudson CI master it is communicating with. Well, that's how the CLI works at the time of writing.

Visit your Hudson CI and see a new job in the list and it should start building automatically. Click through and find the Output Log to see the build in progress. It should end up with SUCCESS!

Something went wrong with that request. Please try again.