diff --git a/Gemfile b/Gemfile index e3b7b18115..4609bd9b9a 100644 --- a/Gemfile +++ b/Gemfile @@ -1,8 +1,30 @@ source 'https://rubygems.org' -puppetversion = ENV['PUPPET_VERSION'] -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 \ No newline at end of file diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb new file mode 100644 index 0000000000..0842e31253 --- /dev/null +++ b/spec/acceptance/class_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper_acceptance' + +describe 'sensu class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + + context 'sensu' 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', + } + EOS + + # Run it twice and test for idempotency + expect(apply_manifest(pp).exit_code).to_not eq(1) + expect(apply_manifest(pp).exit_code).to eq(0) + end + it 'should start the API' do + shell('curl localhost:4567/info') do |curl| + expect(curl.stdout).to include 'sensu', 'version' + end + end + end + end +end \ No newline at end of file diff --git a/spec/acceptance/nodesets/centos-64-x64.yml b/spec/acceptance/nodesets/centos-64-x64.yml new file mode 100644 index 0000000000..fb933cdbee --- /dev/null +++ b/spec/acceptance/nodesets/centos-64-x64.yml @@ -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 diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml new file mode 100644 index 0000000000..901bb92fcc --- /dev/null +++ b/spec/acceptance/nodesets/default.yml @@ -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 diff --git a/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml b/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml new file mode 100644 index 0000000000..901bb92fcc --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml @@ -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 diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb new file mode 100644 index 0000000000..8a7444a350 --- /dev/null +++ b/spec/spec_helper_acceptance.rb @@ -0,0 +1,45 @@ +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 => 'sensu') + 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,1] }) + shell('puppet module install maestrodev/wget --version 1.4.5', { :acceptable_exit_codes => [0,1] }) + shell('puppet module install puppetlabs-rabbitmq --version 4.1.0', { :acceptable_exit_codes => [0,1] }) + shell('puppet module install fsalum-redis --version 1.0.0', { :acceptable_exit_codes => [0,1] }) + shell('puppet module install puppetlabs/apt --version 1.6.0', { :acceptable_exit_codes => [0,1] }) + end + end +end