Laptop is tested by using it to provision a fresh VM. The process is lengthy but scripted, and relies on Vagrant, ruby, and rspec.
Currently, only the linux script is tested.
- VirtualBox
- Vagrant - version >= 1.5.0
- aws-cli - optional, for publishers only.
- A modern ruby that allows you to install gems.
aws-cli
is only necessary if you're one of the maintainers and want to
publish new "Laptop'ed" boxes.
- From the repository root:
bundle
bundle exec rake
For each file found at ./spec/vagrantfiles/Vagrantfile.*
:
- No specs are run if a rendered box already exists
- Vagrant creates and starts a VM as described by the Vagrantfile
- The appropriate Laptop script is run inside the VM
- Some assertions are made against the VMs state
- If all specs pass, then a vagrant box is rendered to the filesystem, ready to be published to s3
If you want to re-run specs (and therefore re-render new vagrant boxes with
laptop freshly applied to them), rm *.box
in the repository root and Laptop
will be re-run against all Vagrantfiles.
The "render box when specs are successful" workflow allows you to focus on failing distros and re-run only those specs that've failed.
The following are the assertions:
- The VM was brought up successfully
- The Laptop script(s) ran successfully
- The VM reports the correct
$SHELL
- The VM reports the correct ruby
- A rails app can be created successfully
- A scaffolded model can be created within that rails app
- A default sqlite development and test database can be created and migrations can be run
silver_searcher
(akaag
) is installed and available on$PATH
.
Vagrant VMs are destroyed before specs are run for a specific Vagrantfile, so
the last VM will be available until you re-run or explicitly vagrant destroy
.
Adding additional linux distros to test via this framework should be easy:
simply add a new Vagrantfile in the ./spec/vagrantfiles/
directory which uses
a base box with the desired distribution.
OSX will need to be handled specially:
- The VMware provider will have to be used
- Building an OSX base box may or may not be easy
- The resulting test can only be run on an OSX host
First, you'll need to install and configure aws-cli. When you're ready to publish a new set of boxes:
- Run the specs as described above, which will render passing boxes to the filesystem.
- run
./bin/publish_laptopped_boxes.sh
to publish changed boxes to s3.
You do not need to re-create or update the box config in vagrantcloud for an updated box, as long as the URL stays the same.
This will copy the new box to a temporary name, remove the original and move the temp into place to minimize downtime.
It only publishes boxes that have a different file size locally than what's on S3. Unfortunately, S3 does not return an md5sum for large files in a way that'd be easy to compare to a local copy without downloading the entire file. So - theoretically - if a new Laptop'ed box had the same size as the immediately previous one, it would not get published to S3. This seems fairly unlikely, given that we're dealing with an entire operating system.
- Remove the vagrantfile under
spec/vagrantfiles
- Remove the files published to s3
- Remove the box config in vagrantcloud
- Update README.md
You might want to repackage base boxes on occasion to make running the automated suite faster. There will be fewer updates to apply, and sometimes vendor-supplied updates do not apply cleanly in a non-interactive shell.
./bin/repackage_base_boxes.sh
This will iterate over spec/vagrantfiles/Vagrantfile.*
, spin up a VM, drop
you into an interactive shell and then give you the option to repackage
afterwards. It will skip any boxes that already exist in the project root,
similar to behavior of the rspec suite.
After repackaging, use ./bin/publish_laptopped_boxes.sh
to publish to aws.
- Download a 64 bit minimal server ISO
- Set up a new virtualbox machine
- Name it logically:
ubuntu-14-04-server
or similar - 512 meg of RAM
- 2 CPUs
- 8 gig dynamically allocated disk, choosing the default VDI storage
- Name it logically:
- Install. During installation:
- Create a
vagrant
user with the password "vagrant" - Don't encrypt your home drive
- Choose the minimal packages necessary to get a working SSH server
- Create a
- Reboot. And then follow the general base box instructions, specifically:
- Log in as the
vagrant
user,sudo -i
and then set root's password to 'vagrant' - Modify
/etc/sudoers
to allow vagrant password-lesssudo
for all commands - Install the vagrant insecure SSH keypair into the
vagrant
account - Set up guest additions according to the virtualbox provider docs. See this bug in 4.3.10.
- Update and clean up:
aptitude update && aptitude dist-upgrade -y && aptitude clean
- Log in as the
- Package the new minimal base box.
vagrant package --base ubuntu-14-04-server --output ubuntu-14-04-server.box
- Test the new base box.
- Add the box to your local vagrant:
vagrant box add ubuntu-14-04-server.box --name ubuntu-14-04-server
- Create a minimal
Vagrantfile
that uses your new box by name vagrant up
- Connect to your box via
vagrant ssh
- Make sure you can see shared files under the
/vagrant
directory. - If it works, clean up after yourself:
vagrant destroy
vagrant box remove ubuntu-14-04-server
- Remove the release ISO if you're sure everything works.
- Add the box to your local vagrant:
- Upload the new base box to s3. Assuming you have aws-cli installed:
aws s3 cp ubuntu-14-04-server.box s3://laptop-boxes/ --acl public-read
- Add a new box config to vagrantcloud, named and described logically.
- Create a version (0.1.0) and a provider with the s3 URL you created above.
- Release the config. It's OK if the box hasn't been uploaded to s3 yet, vagrantcloud issues a 302 when a box is requested.
- Create a Vagrantfile under
spec/vagrantfiles
that uses the vagrantcloud remote name. - Run the rspecs and see if the laptop tests succeed.
- If tests completed successfully, you'll have a
*-with-laptop.box
file. Publish it via./bin/publish_laptopped_boxes.sh
if you are a laptop maintainer. - Create another vagrantcloud box config, this time linking to the
-with-laptop.box
image you uploaded to s3.
The test script may fail when changing the vagrant user's shell to zsh
. If
this happens, you need to configure PAM to allow a user to change their shell
without a password. Open '/etc/pam.d/chsh' and change the line:
auth sufficient pam_rootok.so
to
auth sufficient pam_permit.so
which will allow the vagrant user to change their shell without a password. You'll need to repackage and re-upload the base box with this change.