-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add rspec-system-puppet infrastructure + basic system tests
- Loading branch information
Joshua Hoblitt
committed
Sep 30, 2013
1 parent
1f34762
commit 6029324
Showing
6 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ Gemfile.lock | |
*.orig | ||
*.rej | ||
*.patch | ||
.rspec_system/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
default_set: 'centos-64-x64' | ||
sets: | ||
'centos-64-x64': | ||
nodes: | ||
'main.vm': | ||
prefab: 'centos-64-x64' | ||
'debian-607-x64': | ||
nodes: | ||
'main.vm': | ||
prefab: 'debian-607-x64' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 => 'smartd') | ||
shell('puppet module install puppetlabs-stdlib') | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
require 'spec_helper_system' | ||
|
||
describe 'smartd class' do | ||
case node.facts['osfamily'] | ||
when 'RedHat', 'Debian' | ||
package_name = 'smartmontools' | ||
service_name = 'smartd' | ||
end | ||
|
||
describe 'running puppet code' do | ||
# Using puppet_apply as a helper | ||
it 'should work with no errors' do | ||
pp = <<-EOS | ||
class { 'smartd': } | ||
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(package_name) do | ||
it { should be_installed } | ||
end | ||
|
||
describe service(service_name) do | ||
it { should be_running } | ||
it { should be_enabled } | ||
end | ||
|
||
describe file('/etc/smartd.conf') do | ||
it { should be_file } | ||
it { should contain([ | ||
'DEFAULT -m root -M daily', | ||
'DEVICESCAN', | ||
]) } | ||
end | ||
end |