VagrantSpec is a Vagrant plugin that makes integration testing for deployments to clustered systems a breeze. It also separates the build and deployment steps to clearly separate pipeline tasks.

For a complete tutorial, reference Welcome to VagrantSpec

Installation

vagrant plugin install vagrant_spec

Why not use TestKitchen or vagrant-serverspec?

Sample Vagrantfile

Vagrant.configure(2) do |config|
  config.vm.box = 'ubuntu/trusty64'

  config.vm.define 'test_ansible' do |b|
    b.vm.hostname = 'ansible'
  end

  config.vm.define 'test_pansible' do |b|
    b.vm.hostname = 'pansible'
  end

  # key: Ansible Group Name
  # value: Regexp matching your node names or an array of nodes
  config.spec.ansible_inventory = { 'ansi' => /_ansi/, 'pansi' => /_pansi/ }

  # nodes: Regexp matching the desired nodes or array of nodes
  # flags: Command line flags you would pass to rspec
  config.spec.test_plan = [
    {
      'nodes' => /test_ansi/,
      'flags' => '--format documentation --color --pattern serverspec/ansi*'
    },
    {
      'nodes' => /test_pansi/,
      'flags' => '--format documentation --color --pattern serverspec/pansi*'
    }
  ]
end

Configuration

Sub Commands

Sample Test Files

serverspec/ansible_spec.rb

describe 'Test Hostname' do
  it 'hostname is ansible' do
    expect(command('printf "$(hostname)"').stdout).to eq('ansible')
  end
end

serverspec/pansible_spec.rb

describe 'Test Hostname' do
  it 'hostname is pansible' do
    expect(command('printf "$(hostname)"').stdout).to eq('pansible')
  end
end

Sample Output

> vagrant up

...

> vagrant spec init

> vagrant spec test

*******************************************************
***************** ServerSpec Test Run *****************
*******************************************************

[test_ansible]

Test Hostname
  hostname is ansible

Finished in 0.43356 seconds (files took 1.61 seconds to load)
1 example, 0 failures

[test_pansible]

Test Hostname
  hostname is pansible

Finished in 0.22762 seconds (files took 0.59837 seconds to load)
1 example, 0 failures

> echo $?
0

Testing Resources

Development