Skip to content
This repository has been archived by the owner on Feb 4, 2020. It is now read-only.

Add beaker tests #17

Merged
merged 4 commits into from
Oct 2, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
source 'https://rubygems.org'

puppetversion = ENV['PUPPET_VERSION']
rspecversion = ENV.key?('RSPEC_VERSION') ? "= #{ENV['RSPEC_VERSION']}" : ['>= 2.9 ', '< 3.0.0']
gem 'puppet', puppetversion, :require => false
gem 'puppet-lint'
gem 'rspec-puppet'
gem 'puppetlabs_spec_helper', '>= 0.1.0'
gem 'puppet-syntax'
source ENV['GEM_SOURCE'] || "https://rubygems.org"

group :development, :test do
gem 'rake', :require => false
gem 'rspec-puppet', :require => false
gem 'puppetlabs_spec_helper', :require => false
gem 'serverspec', :require => false
gem 'puppet-lint', :require => false
gem 'beaker', :require => false
gem 'beaker-rspec', "~> 2.2.4",:require => false
gem 'pry', :require => false
gem 'simplecov', :require => false
gem 'vagrant-wrapper', :require => false
end

if facterversion = ENV['FACTER_GEM_VERSION']
gem 'facter', facterversion, :require => false
else
gem 'facter', :require => false
end

if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end

# vim:ft=ruby
148 changes: 146 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,16 +1,120 @@
GEM
remote: https://rubygems.org/
remote: https://rubygems.org/
specs:
CFPropertyList (2.2.8)
addressable (2.3.6)
archive-tar-minitar (0.5.2)
autoparse (0.3.3)
addressable (>= 2.3.1)
extlib (>= 0.9.15)
multi_json (>= 1.0.0)
aws-sdk (1.42.0)
json (~> 1.4)
nokogiri (>= 1.4.4)
beaker (1.17.6)
aws-sdk (= 1.42.0)
blimpy (~> 0.6)
docker-api
fission (~> 0.4)
google-api-client (~> 0.7.1)
hocon (~> 0.0.4)
inifile (~> 2.0)
json (~> 1.8)
mime-types (~> 1.25)
net-scp (~> 1.1)
net-ssh (~> 2.6)
nokogiri (~> 1.5.10)
rbvmomi (= 1.8.1)
unf (~> 0.1)
beaker-rspec (2.2.6)
beaker (~> 1.10)
rspec
serverspec (~> 1.0)
specinfra (~> 1.0)
blimpy (0.6.7)
fog
minitar
thor
builder (3.2.2)
coderay (1.1.0)
diff-lcs (1.2.5)
docile (1.1.5)
docker-api (1.13.2)
archive-tar-minitar
excon (>= 0.38.0)
json
excon (0.39.5)
extlib (0.9.16)
facter (2.1.0)
CFPropertyList (~> 2.2.6)
faraday (0.9.0)
multipart-post (>= 1.2, < 3)
fission (0.5.0)
CFPropertyList (~> 2.2)
fog (1.23.0)
fog-brightbox
fog-core (~> 1.23)
fog-json
fog-softlayer
ipaddress (~> 0.5)
nokogiri (~> 1.5, >= 1.5.11)
fog-brightbox (0.4.1)
fog-core (~> 1.22)
fog-json
inflecto
fog-core (1.24.0)
builder
excon (~> 0.38)
formatador (~> 0.2)
mime-types
net-scp (~> 1.1)
net-ssh (>= 2.1.3)
fog-json (1.0.0)
multi_json (~> 1.0)
fog-softlayer (0.3.15)
fog-core
fog-json
formatador (0.2.5)
google-api-client (0.7.1)
addressable (>= 2.3.2)
autoparse (>= 0.3.3)
extlib (>= 0.9.15)
faraday (>= 0.9.0)
jwt (>= 0.1.5)
launchy (>= 2.1.1)
multi_json (>= 1.0.0)
retriable (>= 1.4)
signet (>= 0.5.0)
uuidtools (>= 2.1.0)
hiera (1.3.4)
json_pure
highline (1.6.21)
hocon (0.0.4)
inflecto (0.0.2)
inifile (2.0.2)
ipaddress (0.8.0)
json (1.8.1)
json_pure (1.8.1)
jwt (1.0.0)
launchy (2.4.2)
addressable (~> 2.3)
metaclass (0.0.4)
method_source (0.8.2)
mime-types (1.25.1)
minitar (0.5.4)
mocha (1.1.0)
metaclass (~> 0.0.1)
multi_json (1.10.1)
multipart-post (2.0.0)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (2.9.1)
nokogiri (1.5.11)
pry (0.10.1)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
puppet (3.6.2)
facter (> 1.6, < 3)
hiera (~> 1.0)
Expand All @@ -27,6 +131,11 @@ GEM
rspec
rspec-puppet
rake (10.3.2)
rbvmomi (1.8.1)
builder
nokogiri (>= 1.4.1)
trollop
retriable (1.4.1)
rgen (0.6.6)
rspec (2.99.0)
rspec-core (~> 2.99.0)
Expand All @@ -35,16 +144,51 @@ GEM
rspec-core (2.99.1)
rspec-expectations (2.99.2)
diff-lcs (>= 1.1.3, < 2.0)
rspec-its (1.0.1)
rspec-core (>= 2.99.0.beta1)
rspec-expectations (>= 2.99.0.beta1)
rspec-mocks (2.99.2)
rspec-puppet (1.0.1)
rspec
serverspec (1.14.0)
highline
net-ssh
rspec (~> 2.99)
rspec-its
specinfra (~> 1.25)
signet (0.5.1)
addressable (>= 2.2.3)
faraday (>= 0.9.0.rc5)
jwt (>= 0.1.5)
multi_json (>= 1.0.0)
simplecov (0.9.0)
docile (~> 1.1.0)
multi_json
simplecov-html (~> 0.8.0)
simplecov-html (0.8.0)
slop (3.6.0)
specinfra (1.25.8)
thor (0.19.1)
trollop (2.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.6)
uuidtools (2.1.5)
vagrant-wrapper (1.2.1.1)

PLATFORMS
ruby

DEPENDENCIES
beaker
beaker-rspec (~> 2.2.4)
facter
pry
puppet
puppet-lint
puppet-syntax
puppetlabs_spec_helper (>= 0.1.0)
puppetlabs_spec_helper
rake
rspec-puppet
serverspec
simplecov
vagrant-wrapper
57 changes: 57 additions & 0 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
require 'spec_helper_acceptance'

describe 'sensu class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do

context 'uchiwa' do
context 'ensure => present' do
it 'should work with no errors' do
pp = <<-EOS
class { 'rabbitmq':
ssl => false,
delete_guest_user => true,
}
-> rabbitmq_vhost { 'sensu': }
-> rabbitmq_user { 'sensu': password => 'secret' }
-> rabbitmq_user_permissions { 'sensu@sensu':
configure_permission => '.*',
read_permission => '.*',
write_permission => '.*',
}
class { 'redis': }
class { 'sensu':
server => true,
api => true,
purge_config => true,
rabbitmq_password => 'secret',
rabbitmq_host => 'localhost',
}

class { 'uchiwa':
install_repo => false,
require => Class['sensu'],
}

uchiwa::api { 'Main Server':
host => '192.168.50.4',
ssl => false,
port => 4567,
user => 'sensu',
pass => 'secret',
path => '',
timeout => 5000
}

EOS

# Run it twice and test for idempotency
expect(apply_manifest(pp, :catch_failures => true).exit_code)
expect(apply_manifest(pp, :catch_failures => true).exit_code)
end
it 'should start uchiwa' do
shell('curl localhost:3000/') do |curl|
expect(curl.stdout).to include '<html lang="en" ng-app="uchiwa" ng-controller="init">'
end
end
end
end
end
11 changes: 11 additions & 0 deletions spec/acceptance/nodesets/centos-64-x64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
HOSTS:
centos-64-x64:
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:
log_level: verbose
type: foss
11 changes: 11 additions & 0 deletions spec/acceptance/nodesets/default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
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:
log_level: verbose
type: foss
11 changes: 11 additions & 0 deletions spec/acceptance/nodesets/ubuntu-server-12042-x64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
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:
log_level: verbose
type: foss
47 changes: 47 additions & 0 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
require 'beaker-rspec'

unless ENV['RS_PROVISION'] == 'no'
hosts.each do |host|
if host.is_pe?
install_pe
else
install_puppet
on host, "mkdir -p #{host['distmoduledir']}"
end
end
end

UNSUPPORTED_PLATFORMS = ['windows']

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 => 'uchiwa')
hosts.each do |host|
if fact('osfamily') == 'Debian'
# RubyGems missing on some Vagrant boxes
# Otherwise you'lll get a load of 'Provider gem is not functional on this host'
shell('apt-get install rubygems -y')
end
if fact('osfamily') == 'RedHat'
# RedHat needs EPEL for RabbitMQ and Redis
shell('wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm && sudo rpm -Uvh epel-release-6*.rpm')
end
shell('/bin/touch /etc/puppet/hiera.yaml')
shell('puppet module install puppetlabs-stdlib --version 3.2.0', { :acceptable_exit_codes => [0] })
shell('puppet module install maestrodev/wget --version 1.4.5', { :acceptable_exit_codes => [0] })
shell('puppet module install puppetlabs-rabbitmq --version 4.1.0', { :acceptable_exit_codes => [0] })
shell('puppet module install fsalum-redis --version 1.0.0', { :acceptable_exit_codes => [0] })
shell('puppet module install puppetlabs/apt --version 1.6.0', { :acceptable_exit_codes => [0] })
shell('puppet module install sensu-sensu', { :acceptable_exit_codes => [0] })
shell('puppet module install richardc/datacat', { :acceptable_exit_codes => [0] })
end
end
end