The purpose of this test suite was originally to test the Sensu packages (.rpm, .deb, etc) but it is also fairly useful for testing Sensu provisioning systems such as sensu-chef.
Since the tests are run across 12 different platforms (as of April 2012) it's also quite helpful at flushing out platform issues that may come up when using Sensu on different OS's that may not be immediately obvious, e.g: Erlang SSL issues on Ubuntu <= 11.04.
The test suite relies heavily on Vagrant. The boxes used for testing are generally default/vanilla boxes built from Veewee templates. The boxes are all available at: http://vagrant.sensuapp.org
- A physical box with a lot of mem. 16GB works, 8GB might.
- Oracle VirtualBox
- Vagrant (only tested with Vagrant 1.x)
- rake (should work on 0.8.7+ and 0.9.x)
- bundler
- GNU parallel(1)
Bundler will install everything else that's needed. The rake bundler_install
task will install bundler and run bundle --install
.
Librarian-chef is used to pull down cookbooks. This should be done automatically
by the higher level rake tasks, but it can be run directly with rake chef_prep
too.
If you run the full test suite (rake vagrant
or para-vagrant.sh
) all
12 of the test VM's will be booted and each VM will use ~ 700MB RAM.
The testing process is 2 steps:
- install a full sensu-stack using Chef and the
sensu-chef
cookbooks. - run the rspec tests in
spec/spec_*
There are multiple ways to use the test suite.
Note that there is no default rake task. The Rakefile contains a mix of tasks, some which are only meant to be run outside of a VM, and some tasks that should only be run inside a VM.
$ rake vagrant
Which does the following:
- run
rake bundler_install
to install bundler and gems needed by Gemfile. - run
rake chef_prep
to download cookbooks inchef/
using librarian. - run
./para-vagrant.sh
to kick off vagrant provisioning.
The para-vagrant.sh
script first boots all the VM's sequentially to avoid
any VirtualBox kernel panics.
After the VM's are booted up, the vagrant provision
(test) process will
be executed in parallel on the VM's to speed up testing.
The provisioning concurrency can be controlled by setting $MAX_PROCS
at
the top of the para-vagrant.sh
script.
Detailed Logs of each provision process will be generated in the logs/
directory.
To run Chef + Rspec on just one platform, use one of these methods:
vagrant up <BOX_NAME>
- will boot the box and run the provision tasks.vagrant up --no-provision <BOX_NAME>
- Boot box but don't run provision.vagrant provision <BOX_NAME>
- Run provision tasks on already booted box. Good for re-running a failed test.- The tests can also be run directly inside a VM with
rake spec
.
-
Sometimes Vagrant will hang after running the provision process. I've seen this most often on the centos_5 boxes. It looks related to a possible Net::SSH bug: hashicorp/vagrant#603
-
It's not uncommon to see VirtualBox kernel panic on Mac OSX: hashicorp/vagrant#797
See TODO.md
Author:: Joe Miller (<joeym@joeym.net>)
Copyright:: Copyright (c) 2012 Joe Miller
License:: Apache License, Version 2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.