Convert existing tests over to beakr-rspec.
This commit is contained in:
parent
8530c66d77
commit
661c6731d7
13 changed files with 78 additions and 102 deletions
19
.nodeset.yml
19
.nodeset.yml
|
@ -1,19 +0,0 @@
|
||||||
---
|
|
||||||
default_set: 'ubuntu-server-12042-x64'
|
|
||||||
sets:
|
|
||||||
'debian-607-x64':
|
|
||||||
nodes:
|
|
||||||
"main.foo.vm":
|
|
||||||
prefab: 'debian-607-x64'
|
|
||||||
'debian-70rc1-x64':
|
|
||||||
nodes:
|
|
||||||
"main.foo.vm":
|
|
||||||
prefab: 'debian-70rc1-x64'
|
|
||||||
'ubuntu-server-10044-x64':
|
|
||||||
nodes:
|
|
||||||
"main.foo.vm":
|
|
||||||
prefab: 'ubuntu-server-10044-x64'
|
|
||||||
'ubuntu-server-12042-x64':
|
|
||||||
nodes:
|
|
||||||
"main.foo.vm":
|
|
||||||
prefab: 'ubuntu-server-12042-x64'
|
|
6
Gemfile
6
Gemfile
|
@ -4,9 +4,9 @@ group :development, :test do
|
||||||
gem 'rake', :require => false
|
gem 'rake', :require => false
|
||||||
gem 'rspec-puppet', :require => false
|
gem 'rspec-puppet', :require => false
|
||||||
gem 'puppetlabs_spec_helper', :require => false
|
gem 'puppetlabs_spec_helper', :require => false
|
||||||
gem 'rspec-system', :require => false
|
gem 'serverspec', :require => false
|
||||||
gem 'rspec-system-puppet', :require => false
|
gem 'beaker', :require => false
|
||||||
gem 'rspec-system-serverspec', :require => false
|
gem 'beaker-rspec', :require => false
|
||||||
end
|
end
|
||||||
|
|
||||||
if puppetversion = ENV['PUPPET_GEM_VERSION']
|
if puppetversion = ENV['PUPPET_GEM_VERSION']
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
require 'spec_helper_system'
|
require 'spec_helper_acceptance'
|
||||||
|
|
||||||
describe 'apt::builddep' do
|
describe 'apt::builddep' do
|
||||||
|
|
||||||
|
@ -16,9 +16,7 @@ describe 'apt::builddep' do
|
||||||
apt::builddep { 'glusterfs-server': }
|
apt::builddep { 'glusterfs-server': }
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
puppet_apply(pp) do |r|
|
apply_manifest(pp, :catch_failures => true)
|
||||||
r.exit_code.should_not == 1
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'should install g++ as a dependency' do
|
describe 'should install g++ as a dependency' do
|
|
@ -1,11 +1,11 @@
|
||||||
require 'spec_helper_system'
|
require 'spec_helper_acceptance'
|
||||||
|
|
||||||
describe 'apt::key' do
|
describe 'apt::key' do
|
||||||
|
|
||||||
context 'reset' do
|
context 'reset' do
|
||||||
it 'clean up keys' do
|
it 'clean up keys' do
|
||||||
shell('apt-key del 4BD6EC30')
|
shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
|
||||||
shell('apt-key del D50582E6')
|
shell('apt-key del D50582E6', :acceptable_exit_codes => [0,1,2])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -24,20 +24,18 @@ describe 'apt::key' do
|
||||||
}
|
}
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
puppet_apply(pp) do |r|
|
apply_manifest(pp, :catch_failures => true)
|
||||||
r.exit_code.should_not == 1
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'keys should exist' do
|
describe 'keys should exist' do
|
||||||
it 'finds puppetlabs key' do
|
it 'finds puppetlabs key' do
|
||||||
shell('apt-key list | grep 4BD6EC30') do |r|
|
shell('apt-key list | grep 4BD6EC30') do |r|
|
||||||
r.exit_code.should be_zero
|
expect(r.exit_code).to be_zero
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
it 'finds jenkins key' do
|
it 'finds jenkins key' do
|
||||||
shell('apt-key list | grep D50582E6') do |r|
|
shell('apt-key list | grep D50582E6') do |r|
|
||||||
r.exit_code.should be_zero
|
expect(r.exit_code).to be_zero
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,11 +1,11 @@
|
||||||
require 'spec_helper_system'
|
require 'spec_helper_acceptance'
|
||||||
|
|
||||||
describe 'apt::ppa' do
|
describe 'apt::ppa' do
|
||||||
|
|
||||||
context 'reset' do
|
context 'reset' do
|
||||||
it 'removes ppa' do
|
it 'removes ppa' do
|
||||||
shell('rm /etc/apt/sources.list.d/drizzle-developers-ppa*')
|
shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0,1,2])
|
||||||
shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*')
|
shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*', :acceptable_exit_codes => [0,1,2])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -13,19 +13,15 @@ describe 'apt::ppa' do
|
||||||
it 'should work with no errors' do
|
it 'should work with no errors' do
|
||||||
pp = <<-EOS
|
pp = <<-EOS
|
||||||
include '::apt'
|
include '::apt'
|
||||||
apt::ppa { 'ppa:drizzle-developers/ppa': }
|
apt::ppa { 'ppa:canonical-kernel-team/ppa': }
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
puppet_apply(pp) do |r|
|
apply_manifest(pp, :catch_failures => true)
|
||||||
r.exit_code.should_not == 1
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'contains the source file' do
|
describe 'contains the source file' do
|
||||||
it 'contains a drizzle ppa source' do
|
it 'contains a kernel ppa source' do
|
||||||
shell('ls /etc/apt/sources.list.d/drizzle-developers-ppa-*.list') do |r|
|
shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0])
|
||||||
r.exit_code.should be_zero
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -43,15 +39,13 @@ describe 'apt::ppa' do
|
||||||
apt::ppa { 'ppa:raravena80/collectd5': }
|
apt::ppa { 'ppa:raravena80/collectd5': }
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
puppet_apply(pp) do |r|
|
apply_manifest(pp, :catch_failures => true)
|
||||||
r.exit_code.should_not == 1
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'reset' do
|
context 'reset' do
|
||||||
it 'removes added ppas' do
|
it 'removes added ppas' do
|
||||||
shell('rm /etc/apt/sources.list.d/drizzle-developers-ppa*')
|
shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*')
|
||||||
shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*')
|
shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*')
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,11 +1,11 @@
|
||||||
require 'spec_helper_system'
|
require 'spec_helper_acceptance'
|
||||||
|
|
||||||
describe 'apt::source' do
|
describe 'apt::source' do
|
||||||
|
|
||||||
context 'reset' do
|
context 'reset' do
|
||||||
it 'clean up puppetlabs repo' do
|
it 'clean up puppetlabs repo' do
|
||||||
shell('apt-key del 4BD6EC30')
|
shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
|
||||||
shell('rm /etc/apt/sources.list.d/puppetlabs.list')
|
shell('rm /etc/apt/sources.list.d/puppetlabs.list', :acceptable_exit_codes => [0,1,2])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -21,15 +21,13 @@ describe 'apt::source' do
|
||||||
}
|
}
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
puppet_apply(pp) do |r|
|
apply_manifest(pp, :catch_failures => true)
|
||||||
r.exit_code.should_not == 1
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'key should exist' do
|
describe 'key should exist' do
|
||||||
it 'finds puppetlabs key' do
|
it 'finds puppetlabs key' do
|
||||||
shell('apt-key list | grep 4BD6EC30') do |r|
|
shell('apt-key list | grep 4BD6EC30') do |r|
|
||||||
r.exit_code.should be_zero
|
expect(r.exit_code).to be_zero
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,4 +1,4 @@
|
||||||
require 'spec_helper_system'
|
require 'spec_helper_acceptance'
|
||||||
|
|
||||||
describe 'apt class' do
|
describe 'apt class' do
|
||||||
|
|
||||||
|
@ -10,11 +10,8 @@ describe 'apt class' do
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
# Run it twice and test for idempotency
|
# Run it twice and test for idempotency
|
||||||
puppet_apply(pp) do |r|
|
apply_manifest(pp, :catch_failures => true)
|
||||||
r.exit_code.should_not == 1
|
apply_manifest(pp, :catch_failures => true)
|
||||||
r.refresh
|
|
||||||
r.exit_code.should be_zero
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
8
spec/acceptance/nodesets/debian-70rc1-x64.yml
Normal file
8
spec/acceptance/nodesets/debian-70rc1-x64.yml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
HOSTS:
|
||||||
|
debian-70rc1-x64:
|
||||||
|
roles:
|
||||||
|
- master
|
||||||
|
platform: debian-70rc1-x64
|
||||||
|
box : debian-70rc1-x64-vbox4210-nocm
|
||||||
|
box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-70rc1-x64-vbox4210-nocm.box
|
||||||
|
hypervisor : vagrant
|
8
spec/acceptance/nodesets/default.yml
Normal file
8
spec/acceptance/nodesets/default.yml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
HOSTS:
|
||||||
|
ubuntu-server-12042-x64:
|
||||||
|
roles:
|
||||||
|
- master
|
||||||
|
platform: ubuntu-server-12.04-amd64
|
||||||
|
box : ubuntu-server-12042-x64-vbox4210-nocm
|
||||||
|
box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box
|
||||||
|
hypervisor : vagrant
|
8
spec/acceptance/nodesets/ubuntu-server-12042-x64.yml
Normal file
8
spec/acceptance/nodesets/ubuntu-server-12042-x64.yml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
HOSTS:
|
||||||
|
ubuntu-server-12042-x64:
|
||||||
|
roles:
|
||||||
|
- master
|
||||||
|
platform: ubuntu-server-12.04-amd64
|
||||||
|
box : ubuntu-server-12042-x64-vbox4210-nocm
|
||||||
|
box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box
|
||||||
|
hypervisor : vagrant
|
26
spec/spec_helper_acceptance.rb
Normal file
26
spec/spec_helper_acceptance.rb
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
require 'beaker-rspec'
|
||||||
|
|
||||||
|
hosts.each do |host|
|
||||||
|
# Install Puppet
|
||||||
|
install_package host, 'rubygems'
|
||||||
|
on host, 'gem install puppet --no-ri --no-rdoc'
|
||||||
|
on host, "mkdir -p #{host['distmoduledir']}"
|
||||||
|
end
|
||||||
|
|
||||||
|
RSpec.configure do |c|
|
||||||
|
# Project root
|
||||||
|
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
||||||
|
|
||||||
|
# Readable test descriptions
|
||||||
|
c.formatter = :documentation
|
||||||
|
|
||||||
|
# Configure all nodes in nodeset
|
||||||
|
c.before :suite do
|
||||||
|
# Install module and dependencies
|
||||||
|
puppet_module_install(:source => proj_root, :module_name => 'apt')
|
||||||
|
hosts.each do |host|
|
||||||
|
shell('/bin/touch /etc/puppet/hiera.yaml')
|
||||||
|
shell('puppet module install puppetlabs-stdlib', { :acceptable_exit_codes => [0,1] })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,30 +0,0 @@
|
||||||
require 'rspec-system/spec_helper'
|
|
||||||
require 'rspec-system-puppet/helpers'
|
|
||||||
require 'rspec-system-serverspec/helpers'
|
|
||||||
|
|
||||||
include RSpecSystemPuppet::Helpers
|
|
||||||
|
|
||||||
include Serverspec::Helper::RSpecSystem
|
|
||||||
include Serverspec::Helper::DetectOS
|
|
||||||
|
|
||||||
RSpec.configure do |c|
|
|
||||||
# Project root
|
|
||||||
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
|
||||||
|
|
||||||
# Enable colour
|
|
||||||
c.tty = true
|
|
||||||
|
|
||||||
c.include RSpecSystemPuppet::Helpers
|
|
||||||
|
|
||||||
# This is where we 'setup' the nodes before running our tests
|
|
||||||
c.before :suite do
|
|
||||||
# May as well update here as this can only run on apt-get machines.
|
|
||||||
shell('apt-get update')
|
|
||||||
# Install puppet
|
|
||||||
puppet_install
|
|
||||||
|
|
||||||
# Install modules and dependencies
|
|
||||||
puppet_module_install(:source => proj_root, :module_name => 'apt')
|
|
||||||
shell('puppet module install puppetlabs-stdlib')
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,10 +0,0 @@
|
||||||
require 'spec_helper_system'
|
|
||||||
|
|
||||||
describe 'basic tests:' do
|
|
||||||
# Using puppet_apply as a subject
|
|
||||||
context puppet_apply 'notice("foo")' do
|
|
||||||
its(:stdout) { should =~ /foo/ }
|
|
||||||
its(:stderr) { should be_empty }
|
|
||||||
its(:exit_code) { should be_zero }
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in a new issue