-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First draft at a skeleton framework for rspec-system-puppet tests.
- Loading branch information
Showing
6 changed files
with
105 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 |
---|---|---|
@@ -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' |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
require 'puppetlabs_spec_helper/rake_tasks' | ||
require 'rspec-system/rake_task' |
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,26 @@ | ||
require 'rspec-system/spec_helper' | ||
require 'rspec-system-puppet/helpers' | ||
|
||
RSpec.configure do |c| | ||
# Project root | ||
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) | ||
|
||
# Enable colour in Jenkins | ||
c.tty = true | ||
|
||
# This is where we 'setup' the nodes before running our tests | ||
c.system_setup_block = proc do | ||
# TODO: find a better way of importing this into this namespace | ||
include RSpecSystemPuppet::Helpers | ||
|
||
# Install puppet | ||
puppet_install | ||
puppet_master_install | ||
|
||
# Replace mymodule with your module name | ||
puppet_module_install(:source => proj_root, :module_name => 'apache') | ||
system_run('puppet module install puppetlabs-firewall') | ||
system_run('puppet module install ripienaar-concat') | ||
system_run('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,29 @@ | ||
require 'spec_helper_system' | ||
|
||
# Here we put the more basic fundamental tests, ultra obvious stuff. | ||
describe "basic tests:" do | ||
it 'make sure we have copied the module across' do | ||
# No point diagnosing any more if the module wasn't copied properly | ||
system_run("ls /etc/puppet/modules/apache") do |r| | ||
r[:exit_code].should == 0 | ||
r[:stdout].should =~ /Modulefile/ | ||
r[:stderr].should == '' | ||
end | ||
end | ||
|
||
it 'my class should work with no errors' do | ||
pp = <<-EOS | ||
class { 'apache': } | ||
EOS | ||
|
||
# Run it once and make sure it doesn't bail with errors | ||
puppet_apply(pp) do |r| | ||
r.exit_code.should_not eq(1) | ||
end | ||
|
||
# Run it again and make sure no changes occurred this time, proving idempotency | ||
puppet_apply(pp) do |r| | ||
r.exit_code.should == 0 | ||
end | ||
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,17 @@ | ||
require 'spec_helper_system' | ||
|
||
describe 'apache class' do | ||
it 'should install apache' do | ||
if system_node.facts['osfamily'] == 'Debian' | ||
system_run('dpkg --get-selections | grep apache2') do |r| | ||
r.stdout.should =~ /^apache2\s+install$/ | ||
r.exit_code.should == 0 | ||
end | ||
elsif system_node.facts['osfamily'] == 'RedHat' | ||
system_run('rpm -q httpd') do |r| | ||
r.stdout.should =~ /httpd/ | ||
r.exit_code.should == 0 | ||
end | ||
end | ||
end | ||
end |