switch to beaker-rspec from rspec-system-puppet
This commit is contained in:
parent
c54359f5fe
commit
e5085f39e6
13 changed files with 86 additions and 159 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,9 +1,10 @@
|
||||||
files/server_test.crt
|
files/server_test.crt
|
||||||
files/server_test.pem
|
files/server_test.pem
|
||||||
pkg/
|
pkg/
|
||||||
pkg/
|
log/
|
||||||
Gemfile.lock
|
Gemfile.lock
|
||||||
spec/fixtures/modules
|
spec/fixtures/modules
|
||||||
spec/fixtures/manifests
|
spec/fixtures/manifests
|
||||||
vendor
|
vendor
|
||||||
.ruby-version
|
.ruby-version
|
||||||
|
.vagrant/
|
||||||
|
|
31
.nodeset.yml
31
.nodeset.yml
|
@ -1,31 +0,0 @@
|
||||||
---
|
|
||||||
default_set: 'centos-64-x64'
|
|
||||||
sets:
|
|
||||||
'centos-59-x64':
|
|
||||||
nodes:
|
|
||||||
"main.foo.vm":
|
|
||||||
prefab: 'centos-59-x64'
|
|
||||||
'centos-64-x64':
|
|
||||||
nodes:
|
|
||||||
"main.foo.vm":
|
|
||||||
prefab: 'centos-64-x64'
|
|
||||||
'fedora-18-x64':
|
|
||||||
nodes:
|
|
||||||
"main.foo.vm":
|
|
||||||
prefab: 'fedora-18-x64'
|
|
||||||
'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'
|
|
4
Gemfile
4
Gemfile
|
@ -7,14 +7,14 @@ end
|
||||||
group :rake, :test do
|
group :rake, :test do
|
||||||
gem 'puppetlabs_spec_helper', '>=0.8.2', :require => false
|
gem 'puppetlabs_spec_helper', '>=0.8.2', :require => false
|
||||||
gem 'puppet-blacksmith', :require => false
|
gem 'puppet-blacksmith', :require => false
|
||||||
gem 'rspec-system-puppet', :require => false
|
gem 'beaker', :require => false
|
||||||
|
gem 'beaker-rspec', :require => false
|
||||||
end
|
end
|
||||||
|
|
||||||
group :rake do
|
group :rake do
|
||||||
gem 'rspec-puppet', '>=2', :require => false
|
gem 'rspec-puppet', '>=2', :require => false
|
||||||
gem 'rake', '>=0.9.2.2'
|
gem 'rake', '>=0.9.2.2'
|
||||||
gem 'puppet-lint', '>=1.0.1'
|
gem 'puppet-lint', '>=1.0.1'
|
||||||
gem 'rspec-system-serverspec', :require => false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if puppetversion = ENV['PUPPET_GEM_VERSION']
|
if puppetversion = ENV['PUPPET_GEM_VERSION']
|
||||||
|
|
1
Rakefile
1
Rakefile
|
@ -7,7 +7,6 @@ CLOBBER.include('.tmp', '.librarian')
|
||||||
|
|
||||||
require 'puppetlabs_spec_helper/rake_tasks'
|
require 'puppetlabs_spec_helper/rake_tasks'
|
||||||
require 'puppet_blacksmith/rake_tasks'
|
require 'puppet_blacksmith/rake_tasks'
|
||||||
require 'rspec-system/rake_task'
|
|
||||||
|
|
||||||
task :default => [:clean, :spec]
|
task :default => [:clean, :spec]
|
||||||
|
|
||||||
|
|
31
spec/acceptance/class_spec.rb
Normal file
31
spec/acceptance/class_spec.rb
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
require 'spec_helper_acceptance'
|
||||||
|
|
||||||
|
describe "nginx class:" do
|
||||||
|
case fact('osfamily')
|
||||||
|
when 'RedHat'
|
||||||
|
package_name = 'nginx'
|
||||||
|
when 'Debian'
|
||||||
|
package_name = 'nginx'
|
||||||
|
when 'Suse'
|
||||||
|
package_name = 'nginx-0.8'
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'default parameters' do
|
||||||
|
it 'should run successfully' do
|
||||||
|
pp = "class { 'nginx': }"
|
||||||
|
|
||||||
|
# Run it twice and test for idempotency
|
||||||
|
apply_manifest(pp, :catch_failures => true)
|
||||||
|
expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe package(package_name) do
|
||||||
|
it { is_expected.to be_installed }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe service('nginx') do
|
||||||
|
it { is_expected.to be_running }
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -1,4 +1,4 @@
|
||||||
require 'spec_helper_system'
|
require 'spec_helper_acceptance'
|
||||||
|
|
||||||
describe "nginx::resource::mailhost define:" do
|
describe "nginx::resource::mailhost define:" do
|
||||||
it 'should run successfully' do
|
it 'should run successfully' do
|
||||||
|
@ -7,10 +7,6 @@ describe "nginx::resource::mailhost define:" do
|
||||||
class { 'nginx':
|
class { 'nginx':
|
||||||
mail => true,
|
mail => true,
|
||||||
}
|
}
|
||||||
nginx::resource::vhost { 'www.puppetlabs.com':
|
|
||||||
ensure => present,
|
|
||||||
www_root => '/var/www/www.puppetlabs.com',
|
|
||||||
}
|
|
||||||
nginx::resource::mailhost { 'domain1.example':
|
nginx::resource::mailhost { 'domain1.example':
|
||||||
ensure => present,
|
ensure => present,
|
||||||
auth_http => 'localhost/cgi-bin/auth',
|
auth_http => 'localhost/cgi-bin/auth',
|
||||||
|
@ -21,13 +17,7 @@ describe "nginx::resource::mailhost define:" do
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
|
||||||
puppet_apply(pp) do |r|
|
apply_manifest(pp, :catch_failures => true)
|
||||||
[0,2].should include r.exit_code
|
|
||||||
r.refresh
|
|
||||||
# Not until deprecated variables fixed.
|
|
||||||
#r.stderr.should be_empty
|
|
||||||
r.exit_code.should be_zero
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe file('/etc/nginx/conf.mail.d/domain1.example.conf') do
|
describe file('/etc/nginx/conf.mail.d/domain1.example.conf') do
|
||||||
|
@ -35,8 +25,4 @@ describe "nginx::resource::mailhost define:" do
|
||||||
it { should contain "auth_http localhost/cgi-bin/auth;" }
|
it { should contain "auth_http localhost/cgi-bin/auth;" }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe file('/etc/nginx/sites-available/www.puppetlabs.com.conf') do
|
|
||||||
it { should be_file }
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
|
@ -1,4 +1,4 @@
|
||||||
require 'spec_helper_system'
|
require 'spec_helper_acceptance'
|
||||||
|
|
||||||
describe "nginx::resource::upstream define:" do
|
describe "nginx::resource::upstream define:" do
|
||||||
it 'should run successfully' do
|
it 'should run successfully' do
|
||||||
|
@ -19,12 +19,7 @@ describe "nginx::resource::upstream define:" do
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
|
||||||
puppet_apply(pp) do |r|
|
apply_manifest(pp, :catch_failures => true)
|
||||||
[0,2].should include r.exit_code
|
|
||||||
r.refresh
|
|
||||||
r.stderr.should be_empty
|
|
||||||
r.exit_code.should be_zero
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe file('/etc/nginx/conf.d/puppet_rack_app-upstream.conf') do
|
describe file('/etc/nginx/conf.d/puppet_rack_app-upstream.conf') do
|
||||||
|
@ -37,7 +32,7 @@ describe "nginx::resource::upstream define:" do
|
||||||
|
|
||||||
describe file('/etc/nginx/sites-available/rack.puppetlabs.com.conf') do
|
describe file('/etc/nginx/sites-available/rack.puppetlabs.com.conf') do
|
||||||
it { should be_file }
|
it { should be_file }
|
||||||
it { should contain "proxy_pass http://puppet_rack_app;" }
|
it { should contain "proxy_pass http://puppet_rack_app;" }
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -1,4 +1,4 @@
|
||||||
require 'spec_helper_system'
|
require 'spec_helper_acceptance'
|
||||||
|
|
||||||
describe "nginx::resource::vhost define:" do
|
describe "nginx::resource::vhost define:" do
|
||||||
context 'new vhost on port 80' do
|
context 'new vhost on port 80' do
|
||||||
|
@ -15,12 +15,7 @@ describe "nginx::resource::vhost define:" do
|
||||||
file { '/var/www/www.puppetlabs.com/index.html': ensure => file, content => 'Hello from www\n', }
|
file { '/var/www/www.puppetlabs.com/index.html': ensure => file, content => 'Hello from www\n', }
|
||||||
"
|
"
|
||||||
|
|
||||||
puppet_apply(pp) do |r|
|
apply_manifest(pp, :catch_failures => true)
|
||||||
[0,2].should include r.exit_code
|
|
||||||
r.refresh
|
|
||||||
r.stderr.should be_empty
|
|
||||||
r.exit_code.should be_zero
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe file('/etc/nginx/sites-available/www.puppetlabs.com.conf') do
|
describe file('/etc/nginx/sites-available/www.puppetlabs.com.conf') do
|
||||||
|
@ -61,12 +56,7 @@ describe "nginx::resource::vhost define:" do
|
||||||
file { '/var/www/www.puppetlabs.com/index.html': ensure => file, content => 'Hello from www\n', }
|
file { '/var/www/www.puppetlabs.com/index.html': ensure => file, content => 'Hello from www\n', }
|
||||||
"
|
"
|
||||||
|
|
||||||
puppet_apply(pp) do |r|
|
apply_manifest(pp, :catch_failures => true)
|
||||||
[0,2].should include r.exit_code
|
|
||||||
r.refresh
|
|
||||||
r.stderr.should be_empty
|
|
||||||
r.exit_code.should be_zero
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe file('/etc/nginx/sites-available/www.puppetlabs.com.conf') do
|
describe file('/etc/nginx/sites-available/www.puppetlabs.com.conf') do
|
11
spec/acceptance/nodesets/default.yml
Normal file
11
spec/acceptance/nodesets/default.yml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
HOSTS:
|
||||||
|
ubuntu-server-1404-x64:
|
||||||
|
roles:
|
||||||
|
- master
|
||||||
|
platform: ubuntu-14.04-amd64
|
||||||
|
box: puppetlabs/ubuntu-14.04-64-nocm
|
||||||
|
box_url: https://vagrantcloud.com/puppetlabs/ubuntu-14.04-64-nocm
|
||||||
|
hypervisor: vagrant
|
||||||
|
CONFIG:
|
||||||
|
log_level: debug
|
||||||
|
type: git
|
11
spec/acceptance/nodesets/ubuntu-server-1404-x64.yml
Normal file
11
spec/acceptance/nodesets/ubuntu-server-1404-x64.yml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
HOSTS:
|
||||||
|
ubuntu-server-1404-x64:
|
||||||
|
roles:
|
||||||
|
- master
|
||||||
|
platform: ubuntu-14.04-amd64
|
||||||
|
box: puppetlabs/ubuntu-14.04-64-nocm
|
||||||
|
box_url: https://vagrantcloud.com/puppetlabs/ubuntu-14.04-64-nocm
|
||||||
|
hypervisor: vagrant
|
||||||
|
CONFIG:
|
||||||
|
log_level: debug
|
||||||
|
type: git
|
|
@ -1,30 +1,31 @@
|
||||||
require 'rspec-system/spec_helper'
|
require 'beaker-rspec'
|
||||||
require 'rspec-system-puppet/helpers'
|
|
||||||
require 'rspec-system-serverspec/helpers'
|
hosts.each do |host|
|
||||||
include RSpecSystemPuppet::Helpers
|
# Install Puppet
|
||||||
|
on host, install_puppet
|
||||||
|
end
|
||||||
|
|
||||||
RSpec.configure do |c|
|
RSpec.configure do |c|
|
||||||
# Project root
|
# Project root
|
||||||
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
||||||
|
|
||||||
# Enable colour
|
c.formatter = :documentation
|
||||||
c.tty = true
|
|
||||||
|
|
||||||
# This is where we 'setup' the nodes before running our tests
|
# This is where we 'setup' the nodes before running our tests
|
||||||
c.before :suite do
|
c.before :suite do
|
||||||
# Install puppet
|
hosts.each do |host|
|
||||||
puppet_install
|
# Install module
|
||||||
|
copy_module_to(host, :source => proj_root, :module_name => 'nginx')
|
||||||
|
if fact('osfamily') == 'Debian'
|
||||||
|
on host, puppet('module','install','puppetlabs-apt'), { :acceptable_exit_codes => [0,1] }
|
||||||
|
end
|
||||||
|
on host, puppet('module','install','puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] }
|
||||||
|
on host, puppet('module','install','puppetlabs-concat'), { :acceptable_exit_codes => [0,1] }
|
||||||
|
|
||||||
# Install modules and dependencies
|
# Fake keys.
|
||||||
puppet_module_install(:source => proj_root, :module_name => 'nginx')
|
# Valid self-signed SSL key with 10 year expiry.
|
||||||
shell('puppet module install puppetlabs-apt')
|
# Required for nginx to start when SSL enabled
|
||||||
shell('puppet module install puppetlabs-stdlib')
|
on host, shell('echo "-----BEGIN PRIVATE KEY-----
|
||||||
shell('puppet module install puppetlabs-concat')
|
|
||||||
|
|
||||||
# Fake keys.
|
|
||||||
# Valid self-signed SSL key with 10 year expiry.
|
|
||||||
# Required for nginx to start when SSL enabled
|
|
||||||
shell('echo "-----BEGIN PRIVATE KEY-----
|
|
||||||
MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAOPchwRZRF4KmU6E
|
MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAOPchwRZRF4KmU6E
|
||||||
g7C6Pq9zhdLiQt9owdcLZNiZS+UVRQjeDHSy3titzh5YwSoQonlnSqd0g/PJ6kNA
|
g7C6Pq9zhdLiQt9owdcLZNiZS+UVRQjeDHSy3titzh5YwSoQonlnSqd0g/PJ6kNA
|
||||||
O3CNOMVuzAddnAaHzW1J4Rt6sZwOuidtJC4t/hFCgz5NqOMgYOOfratQx00A7ZXK
|
O3CNOMVuzAddnAaHzW1J4Rt6sZwOuidtJC4t/hFCgz5NqOMgYOOfratQx00A7ZXK
|
||||||
|
@ -40,7 +41,7 @@ J9lmX7GV9nUCM7lKVD2ckFOQNlMwCURs8ukJh7H/MfQ8Dt5xoQAMjQJBAOWpK6k6
|
||||||
b0fTREZFZRGZBJcSu959YyMzhpSFA+lXkLNTWX8j1/D88H731oMSImoQNWcYx2dH
|
b0fTREZFZRGZBJcSu959YyMzhpSFA+lXkLNTWX8j1/D88H731oMSImoQNWcYx2dH
|
||||||
sCwOCDqu1nZ2LJ8=
|
sCwOCDqu1nZ2LJ8=
|
||||||
-----END PRIVATE KEY-----" > /tmp/blah.key')
|
-----END PRIVATE KEY-----" > /tmp/blah.key')
|
||||||
shell('echo "-----BEGIN CERTIFICATE-----
|
on host, shell('echo "-----BEGIN CERTIFICATE-----
|
||||||
MIIDRjCCAq+gAwIBAgIJAL9m0V4sHW2tMA0GCSqGSIb3DQEBBQUAMIG7MQswCQYD
|
MIIDRjCCAq+gAwIBAgIJAL9m0V4sHW2tMA0GCSqGSIb3DQEBBQUAMIG7MQswCQYD
|
||||||
VQQGEwItLTESMBAGA1UECAwJU29tZVN0YXRlMREwDwYDVQQHDAhTb21lQ2l0eTEZ
|
VQQGEwItLTESMBAGA1UECAwJU29tZVN0YXRlMREwDwYDVQQHDAhTb21lQ2l0eTEZ
|
||||||
MBcGA1UECgwQU29tZU9yZ2FuaXphdGlvbjEfMB0GA1UECwwWU29tZU9yZ2FuaXph
|
MBcGA1UECgwQU29tZU9yZ2FuaXphdGlvbjEfMB0GA1UECwwWU29tZU9yZ2FuaXph
|
||||||
|
@ -60,5 +61,6 @@ HaHIWGMBuXApE7t4PNdYWZ5Y56tI+HT59yVoDjc1YSnuzkKlWUPibVYoLpX/ROKr
|
||||||
aIZ8kxsBjLvpi9KQTHi7Wl6Sw3ecoYdKy+2P8S5xOIpWjs8XVmOWf7Tq1+9KPv3z
|
aIZ8kxsBjLvpi9KQTHi7Wl6Sw3ecoYdKy+2P8S5xOIpWjs8XVmOWf7Tq1+9KPv3z
|
||||||
HLw/FDCzntkdq3G4em15CdFlO9BTY4HXiHU=
|
HLw/FDCzntkdq3G4em15CdFlO9BTY4HXiHU=
|
||||||
-----END CERTIFICATE-----" > /tmp/blah.cert')
|
-----END CERTIFICATE-----" > /tmp/blah.cert')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,33 +0,0 @@
|
||||||
require 'spec_helper_system'
|
|
||||||
|
|
||||||
# Here we put the more basic fundamental tests, ultra obvious stuff.
|
|
||||||
describe "basic tests:" do
|
|
||||||
context 'make sure we have copied the module across' do
|
|
||||||
# No point diagnosing any more if the module wasn't copied properly
|
|
||||||
context shell 'ls /etc/puppet/modules/nginx' do
|
|
||||||
its(:stdout) { should =~ /Modulefile/ }
|
|
||||||
its(:stderr) { should be_empty }
|
|
||||||
its(:exit_code) { should be_zero }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
#puppet smoke test
|
|
||||||
context puppet_apply 'notice("foo")' do
|
|
||||||
its(:stdout) { should =~ /foo/ }
|
|
||||||
its(:stderr) { should be_empty }
|
|
||||||
its(:exit_code) { should be_zero }
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'nginx class should work with no errors' do
|
|
||||||
pp = <<-EOS
|
|
||||||
class { 'nginx': }
|
|
||||||
EOS
|
|
||||||
|
|
||||||
# Run it twice and test for idempotency
|
|
||||||
puppet_apply(pp) do |r|
|
|
||||||
[0,2].should include(r.exit_code)
|
|
||||||
r.refresh
|
|
||||||
r.exit_code.should be_zero
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,35 +0,0 @@
|
||||||
require 'spec_helper_system'
|
|
||||||
|
|
||||||
describe "nginx class:" do
|
|
||||||
case node.facts['osfamily']
|
|
||||||
when 'RedHat'
|
|
||||||
package_name = 'nginx'
|
|
||||||
when 'Debian'
|
|
||||||
package_name = 'nginx'
|
|
||||||
when 'Suse'
|
|
||||||
package_name = 'nginx-0.8'
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'should run successfully' do
|
|
||||||
it 'should run successfully' do
|
|
||||||
pp = "class { 'nginx': }"
|
|
||||||
|
|
||||||
puppet_apply(pp) do |r|
|
|
||||||
#r.stderr.should be_empty
|
|
||||||
[0,2].should include r.exit_code
|
|
||||||
r.refresh
|
|
||||||
#r.stderr.should be_empty
|
|
||||||
r.exit_code.should be_zero
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe package(package_name) do
|
|
||||||
it { should be_installed }
|
|
||||||
end
|
|
||||||
|
|
||||||
describe service('nginx') do
|
|
||||||
it { should be_running }
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
Loading…
Reference in a new issue