Merge pull request #114 from apenney/beaker

Convert tests to beaker.
This commit is contained in:
Ashley Penney 2014-02-03 08:43:36 -08:00
commit ba3eab6f95
15 changed files with 194 additions and 106 deletions

View file

@ -3,9 +3,11 @@ source 'https://rubygems.org'
group :development, :test do
gem 'rake'
gem 'puppetlabs_spec_helper', :require => false
gem 'rspec-system-puppet', '~>2.0'
gem 'rspec-puppet', '~>1.0'
gem 'puppet-lint', '~> 0.3.2'
gem 'beaker', :require => false
gem 'beaker-rspec', :require => false
gem 'serverspec', :require => false
end
if puppetversion = ENV['PUPPET_GEM_VERSION']

View file

@ -5,7 +5,6 @@ Bundler.require :default
require 'rspec/core/rake_task'
require 'puppetlabs_spec_helper/rake_tasks'
require 'rspec-system/rake_task'
task :default do
sh %{rake -T}

View file

@ -0,0 +1,48 @@
require 'spec_helper_acceptance'
describe 'basic tests:' do
it 'make sure we have copied the module across' do
# No point diagnosing any more if the module wasn't copied properly
shell("ls /etc/puppet/modules/puppetdb") do |r|
r.exit_code.should == 0
r.stdout.should =~ /Modulefile/
r.stderr.should == ''
end
end
describe 'single node setup' do
pp = <<-EOS
# Single node setup
class { 'ntp': panic => false } ->
class { 'puppetdb': disable_ssl => true, } ->
class { 'puppetdb::master::config': puppetdb_port => '8080', puppetdb_server => 'localhost' }
EOS
it 'make sure it runs without error' do
apply_manifest(pp, :catch_errors => true)
apply_manifest(pp, :catch_changes => true)
end
end
describe 'enabling report processor' do
pp = <<-EOS
class { 'ntp': panic => false } ->
class { 'puppetdb': disable_ssl => true, } ->
class { 'puppetdb::master::config':
puppetdb_port => '8080',
manage_report_processor => true,
enable_reports => true,
puppetdb_server => 'localhost'
}
EOS
it 'should add the puppetdb report processor to puppet.conf' do
apply_manifest(pp, :catch_errors => true)
apply_manifest(pp, :catch_changes => true)
shell('cat /etc/puppet/puppet.conf') do |r|
expect(r.stdout).to match(/^reports\s*=\s*([^,]+,)*puppetdb(,[^,]+)*$/)
end
end
end
end

View file

@ -0,0 +1,10 @@
HOSTS:
centos-510-x64:
roles:
- master
platform: el-5-x86_64
box : centos-510-x64-virtualbox-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-510-x64-virtualbox-nocm.box
hypervisor : vagrant
CONFIG:
type: foss

View file

@ -0,0 +1,10 @@
HOSTS:
centos-59-x64:
roles:
- master
platform: el-5-x86_64
box : centos-59-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-59-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: foss

View file

@ -0,0 +1,12 @@
HOSTS:
centos-64-x64:
roles:
- master
- database
- dashboard
platform: el-6-x86_64
box : centos-64-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: pe

View file

@ -0,0 +1,10 @@
HOSTS:
centos-64-x64.local:
roles:
- master
platform: el-6-x86_64
box : centos-64-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: foss

View file

@ -0,0 +1,10 @@
HOSTS:
debian-607-x64:
roles:
- master
platform: debian-6-amd64
box : debian-607-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-607-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: foss

View file

@ -0,0 +1,10 @@
HOSTS:
debian-73-x64:
roles:
- master
platform: debian-7-amd64
box : debian-73-x64-virtualbox-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-73-x64-virtualbox-nocm.box
hypervisor : vagrant
CONFIG:
type: foss

View file

@ -0,0 +1,10 @@
HOSTS:
centos-64-x64.local:
roles:
- master
platform: el-6-x86_64
box : centos-64-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: foss

View file

@ -0,0 +1,10 @@
HOSTS:
ubuntu-server-10044-x64:
roles:
- master
platform: ubuntu-10.04-amd64
box : ubuntu-server-10044-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: foss

View file

@ -0,0 +1,10 @@
HOSTS:
ubuntu-server-12042-x64:
roles:
- master
platform: ubuntu-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
CONFIG:
type: foss

View file

@ -0,0 +1,51 @@
require 'beaker-rspec/spec_helper'
require 'beaker-rspec/helpers/serverspec'
hosts.each do |host|
if host['platform'] =~ /debian/
on host, 'echo \'export PATH=/var/lib/gems/1.8/bin/:${PATH}\' >> ~/.bashrc'
end
if host.is_pe?
install_pe
else
#install_puppet
if host['platform'] =~ /el-(5|6)/
relver = $1
on host, "rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-el-#{relver}.noarch.rpm"
on host, 'yum install -y puppet puppet-server'
elsif host['platform'] =~ /fedora-(\d+)/
relver = $1
on host, "rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-fedora-#{relver}.noarch.rpm"
on host, 'yum install -y puppet-server'
elsif host['platform'] =~ /(ubuntu|debian)/
if ! host.check_for_package 'curl'
on host, 'apt-get install -y curl'
end
on host, 'curl -O http://apt.puppetlabs.com/puppetlabs-release-$(lsb_release -c -s).deb'
on host, 'dpkg -i puppetlabs-release-$(lsb_release -c -s).deb'
on host, 'apt-get -y -f -m update'
on host, 'apt-get install -y puppet puppetmaster'
else
raise "install_puppet() called for unsupported platform '#{host['platform']}' on '#{host.name}'"
end
end
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 => 'puppetdb')
hosts.each do |host|
on host, puppet('module', 'install', 'puppetlabs-ntp'), { :acceptable_exit_codes => [0,1] }
on host, puppet('module', 'install', 'puppetlabs-postgresql', '--version', '">= 3.1.0 <4.0.0"'), { :acceptable_exit_codes => [0,1] }
on host, puppet('module', 'install', 'puppetlabs-inifile', '--version', '1.x'), { :acceptable_exit_codes => [0,1] }
end
end
end

View file

@ -1,38 +0,0 @@
require 'rspec-system/spec_helper'
require 'rspec-system-puppet/helpers'
include RSpecSystemPuppet::Helpers
RSpec.configure do |c|
# Project root for the firewall code
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
# Enable colour in Jenkins
c.tty = true
# Import puppet helpers
c.include RSpecSystemPuppet::Helpers
c.extend RSpecSystemPuppet::Helpers
# This is where we 'setup' the nodes before running our tests
c.before :suite do
# Time sync
if node.facts['osfamily'] == 'Debian' then
shell('apt-get install -y ntpdate')
elsif node.facts['osfamily'] == 'RedHat' then
if node.facts['lsbmajdistrelease'] == '5' then
shell('yum install -y ntp')
else
shell('yum install -y ntpdate')
end
end
shell('ntpdate -u pool.ntp.org')
# Install puppet
puppet_install
puppet_master_install
# Copy this module into the module path of the test node
puppet_module_install(:source => proj_root, :module_name => 'puppetdb')
end
end

View file

@ -1,66 +0,0 @@
require 'spec_helper_system'
describe 'basic tests:' do
it 'make sure we have copied the module across' do
# No point diagnosing any more if the module wasn't copied properly
shell("ls /etc/puppet/modules/puppetdb") do |r|
r.exit_code.should == 0
r.stdout.should =~ /Modulefile/
r.stderr.should == ''
end
end
it 'make sure a puppet agent has ran' do
puppet_agent do |r|
r.stderr.should == ''
r.exit_code.should == 0
end
end
describe 'single node setup' do
let(:pp) do
pp = <<-EOS
# Single node setup
class { 'puppetdb': }
class { 'puppetdb::master::config': }
EOS
end
it 'make sure it runs without error' do
shell('puppet module install puppetlabs/stdlib --version ">= 2.2.0"')
shell('puppet module install puppetlabs/postgresql --version ">= 3.1.0 <4.0.0"')
shell('puppet module install puppetlabs/inifile --version "1.x"')
puppet_apply(pp) do |r|
r.exit_code.should_not eq(1)
r.refresh
r.exit_code.should == 0
end
end
end
describe 'enabling report processor' do
let(:pp) do
pp = <<-EOS
class { 'puppetdb::master::config':
manage_report_processor => true,
enable_reports => true
}
EOS
end
it 'should add the puppetdb report processor to puppet.conf' do
puppet_apply(pp) do |r|
r.exit_code.should_not eq(1)
r.refresh
r.exit_code.should == 0
end
shell("cat /etc/puppet/puppet.conf") do |r|
r[:stdout].should =~ /^reports\s*=\s*([^,]+,)*puppetdb(,[^,]+)*$/
end
end
end
end