-
Notifications
You must be signed in to change notification settings - Fork 36
Testing with Vagrant
You will have three aims; get the required gems into a development environment of yours (where you are developing your application), get the virtual machine into a state where it will accept the puppet module and let you test it and creating the configuration that you need for your application.
The first aim, to get the gems, is accomplshed by running bundle
in your folder. I will assume that you are using RVM, because that's the way to roll nowadays. By running bundle
you are telling bundler that you want to download the required gems as specified in Gemfile
. Furthermore, the Gemfile
has two comments on top: #ruby=1.8.7
and ruby-gemset=puppet-riak
- you can and should make similar comments in your own.
Now, run once, gem regenerate_binstubs
; it will run for your current gemset and make it possible to run things like rake vagrant:up
rather than bundle exec rake vagrant:up
. I.e. it sets the correct binstubs on your gems' executables for your current gemset, and makes sure that all bin invocations are consistent with your Gemfile
.
The reason that you run rake vagrant:up
comes from inspecting that task:
require 'puppetlabs_spec_helper/rake_tasks'
desc 'Bring the VM up'
task :up => [:spec_prep] do
system 'vagrant up'
end
The helper from PuppetLabs gives the task spec_prep
:
task :spec_prep do
fixtures("repositories").each do |repo, target|
File::exists?(target) || system("git clone #{repo} #{target}")
end
FileUtils::mkdir_p("spec/fixtures/modules")
fixtures("symlinks").each do |source, target|
File::exists?(target) || FileUtils::ln_s(source, target)
end
FileUtils::mkdir_p("spec/fixtures/manifests")
FileUtils::touch("spec/fixtures/manifests/site.pp")
end
This copies all of the module's dependencies into the fixtures
folder, so that you can run the tests with them.
Now, everything is set up for you to hack on the project. You can run rake specs
, for example, and all specs will be run. At the time of writing, there's a bug in hiera that keeps some specs from passing, and another in rspec-puppet that makes all specs fail! :) Awesome, but I'll see if I can help or get helped to fix that.
When you have modified something and want to test it, you run rake vagrant:provision
(assuming you've run :up
once). You can modify the verbosity of puppet through the Vagrantfile
.
git clone https://github.com/haf/puppet-riak.git
cd puppet-riak
- Install RVM and bundler.
curl -L https://get.rvm.io | bash -s stable --ruby --gems=bundler,rubygems-bundler
-
rvm requirements
: follow these instructions. I'm using RMI 1.9.3. bundle install
gem regenerate_binstubs
rake vagrant:up
- HACK!
rake vagrant:provision