Add rspec-system / serverspec tests
This commit is contained in:
parent
ec7e40e18d
commit
c34bcc0f73
6 changed files with 98 additions and 4 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1,5 @@
|
|||
*.swp
|
||||
pkg/
|
||||
Gemfile.lock
|
||||
.rspec_system
|
||||
spec/fixtures
|
||||
|
|
31
.nodeset.yml
Normal file
31
.nodeset.yml
Normal file
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
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'
|
12
Gemfile
12
Gemfile
|
@ -1,10 +1,14 @@
|
|||
source 'https://rubygems.org'
|
||||
|
||||
group :development, :test do
|
||||
gem 'rake', :require => false
|
||||
gem 'rspec-puppet', :require => false
|
||||
gem 'puppetlabs_spec_helper', :require => false
|
||||
gem 'puppet-lint', :require => false
|
||||
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 'puppet-lint', :require => false
|
||||
end
|
||||
|
||||
if puppetversion = ENV['PUPPET_GEM_VERSION']
|
||||
|
|
1
Rakefile
1
Rakefile
|
@ -1 +1,2 @@
|
|||
require 'puppetlabs_spec_helper/rake_tasks'
|
||||
require 'rspec-system/rake_task'
|
||||
|
|
28
spec/spec_helper_system.rb
Normal file
28
spec/spec_helper_system.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
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
|
||||
# Install puppet
|
||||
puppet_install
|
||||
|
||||
# Install modules and dependencies
|
||||
puppet_module_install(:source => proj_root, :module_name => 'mysql')
|
||||
shell('puppet module install puppetlabs-stdlib')
|
||||
end
|
||||
end
|
28
spec/system/mysql_spec.rb
Normal file
28
spec/system/mysql_spec.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
require 'spec_helper_system'
|
||||
|
||||
describe 'mysql class' do
|
||||
describe 'running puppet code' do
|
||||
# Using puppet_apply as a helper
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
class { 'mysql': }
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
describe package('mysql') do
|
||||
it { should be_installed }
|
||||
end
|
||||
|
||||
describe service('mysqld') do
|
||||
it { should_not be_running }
|
||||
it { should_not be_enabled }
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue