Convert existing tests over to beakr-rspec.

This commit is contained in:
Ashley Penney 2014-01-06 17:39:48 -05:00
parent 8530c66d77
commit 661c6731d7
13 changed files with 78 additions and 102 deletions

View file

@ -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'

View file

@ -4,9 +4,9 @@ group :development, :test do
gem 'rake', :require => false
gem 'rspec-puppet', :require => false
gem 'puppetlabs_spec_helper', :require => false
gem 'rspec-system', :require => false
gem 'rspec-system-puppet', :require => false
gem 'rspec-system-serverspec', :require => false
gem 'serverspec', :require => false
gem 'beaker', :require => false
gem 'beaker-rspec', :require => false
end
if puppetversion = ENV['PUPPET_GEM_VERSION']

View file

@ -1,4 +1,4 @@
require 'spec_helper_system'
require 'spec_helper_acceptance'
describe 'apt::builddep' do
@ -16,9 +16,7 @@ describe 'apt::builddep' do
apt::builddep { 'glusterfs-server': }
EOS
puppet_apply(pp) do |r|
r.exit_code.should_not == 1
end
apply_manifest(pp, :catch_failures => true)
end
describe 'should install g++ as a dependency' do

View file

@ -1,11 +1,11 @@
require 'spec_helper_system'
require 'spec_helper_acceptance'
describe 'apt::key' do
context 'reset' do
it 'clean up keys' do
shell('apt-key del 4BD6EC30')
shell('apt-key del D50582E6')
shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
shell('apt-key del D50582E6', :acceptable_exit_codes => [0,1,2])
end
end
@ -24,20 +24,18 @@ describe 'apt::key' do
}
EOS
puppet_apply(pp) do |r|
r.exit_code.should_not == 1
end
apply_manifest(pp, :catch_failures => true)
end
describe 'keys should exist' do
it 'finds puppetlabs key' do
shell('apt-key list | grep 4BD6EC30') do |r|
r.exit_code.should be_zero
expect(r.exit_code).to be_zero
end
end
it 'finds jenkins key' do
shell('apt-key list | grep D50582E6') do |r|
r.exit_code.should be_zero
expect(r.exit_code).to be_zero
end
end
end

View file

@ -1,11 +1,11 @@
require 'spec_helper_system'
require 'spec_helper_acceptance'
describe 'apt::ppa' do
context 'reset' do
it 'removes ppa' do
shell('rm /etc/apt/sources.list.d/drizzle-developers-ppa*')
shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*')
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-*', :acceptable_exit_codes => [0,1,2])
end
end
@ -13,19 +13,15 @@ describe 'apt::ppa' do
it 'should work with no errors' do
pp = <<-EOS
include '::apt'
apt::ppa { 'ppa:drizzle-developers/ppa': }
apt::ppa { 'ppa:canonical-kernel-team/ppa': }
EOS
puppet_apply(pp) do |r|
r.exit_code.should_not == 1
end
apply_manifest(pp, :catch_failures => true)
end
describe 'contains the source file' do
it 'contains a drizzle ppa source' do
shell('ls /etc/apt/sources.list.d/drizzle-developers-ppa-*.list') do |r|
r.exit_code.should be_zero
end
it 'contains a kernel ppa source' do
shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0])
end
end
end
@ -43,15 +39,13 @@ describe 'apt::ppa' do
apt::ppa { 'ppa:raravena80/collectd5': }
EOS
puppet_apply(pp) do |r|
r.exit_code.should_not == 1
end
apply_manifest(pp, :catch_failures => true)
end
end
context 'reset' 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-*')
end
end

View file

@ -1,11 +1,11 @@
require 'spec_helper_system'
require 'spec_helper_acceptance'
describe 'apt::source' do
context 'reset' do
it 'clean up puppetlabs repo' do
shell('apt-key del 4BD6EC30')
shell('rm /etc/apt/sources.list.d/puppetlabs.list')
shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
shell('rm /etc/apt/sources.list.d/puppetlabs.list', :acceptable_exit_codes => [0,1,2])
end
end
@ -21,15 +21,13 @@ describe 'apt::source' do
}
EOS
puppet_apply(pp) do |r|
r.exit_code.should_not == 1
end
apply_manifest(pp, :catch_failures => true)
end
describe 'key should exist' do
it 'finds puppetlabs key' do
shell('apt-key list | grep 4BD6EC30') do |r|
r.exit_code.should be_zero
expect(r.exit_code).to be_zero
end
end
end

View file

@ -1,4 +1,4 @@
require 'spec_helper_system'
require 'spec_helper_acceptance'
describe 'apt class' do
@ -10,11 +10,8 @@ describe 'apt class' do
EOS
# Run it twice and test for idempotency
puppet_apply(pp) do |r|
r.exit_code.should_not == 1
r.refresh
r.exit_code.should be_zero
end
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_failures => true)
end
end
end

View 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

View 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

View 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

View 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

View file

@ -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

View file

@ -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