forked from puppetlabs/puppetlabs-postgresql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert system tests to use rspec-system
This patch ports all of the existing system tests to use rspec-system instead. To assist with this conversion some patches were made to fix OS compatibility where necessary. We also added an ensure parameter to the postgresql::server class to assist with removing PostgreSQL configuration to aid with testing cleanups. The documentation has been updated to indicate test usage with rspec-system, we've also renamed the 'tests' directory to 'examples'. Signed-off-by: Ken Barber <[email protected]>
- Loading branch information
Showing
47 changed files
with
784 additions
and
904 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
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,14 +1,12 @@ | ||
require 'puppetlabs_spec_helper/rake_tasks' | ||
require 'puppet-lint/tasks/puppet-lint' | ||
|
||
PuppetLint.configuration.send("disable_80chars") | ||
require 'rubygems' | ||
require 'bundler/setup' | ||
|
||
RSpec::Core::RakeTask.new(:system_test) do |c| | ||
c.pattern = "spec/system/**/*_spec.rb" | ||
end | ||
Bundler.require :default | ||
|
||
require 'puppetlabs_spec_helper/rake_tasks' | ||
require 'rspec-system/rake_task' | ||
require 'puppet-lint/tasks/puppet-lint' | ||
|
||
namespace :spec do | ||
desc 'Run system tests' | ||
task :system => :system_test | ||
task :default do | ||
sh %{rake -T} | ||
end |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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,54 @@ | ||
require 'rspec-system/spec_helper' | ||
require 'rspec-system-puppet/helpers' | ||
require 'tempfile' | ||
|
||
module LocalHelpers | ||
include RSpecSystem::Util | ||
|
||
def psql(psql_cmd, user = 'postgres', &block) | ||
psql = "psql #{psql_cmd}" | ||
shell("su #{shellescape(user)} -c #{shellescape(psql)}", &block) | ||
end | ||
end | ||
|
||
include RSpecSystemPuppet::Helpers | ||
|
||
RSpec.configure do |c| | ||
# Project root for the firewall code | ||
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) | ||
|
||
# Enable colour in Jenkins | ||
c.tty = true | ||
|
||
# Include in our local helpers | ||
c.include ::LocalHelpers | ||
|
||
# Puppet helpers | ||
c.include RSpecSystemPuppet::Helpers | ||
c.extend RSpecSystemPuppet::Helpers | ||
|
||
# This is where we 'setup' the nodes before running our tests | ||
c.before :suite do | ||
# Install puppet | ||
puppet_install | ||
|
||
# Copy this module into the module path of the test node | ||
puppet_module_install(:source => proj_root, :module_name => 'postgresql') | ||
shell('puppet module install puppetlabs/stdlib') | ||
shell('puppet module install puppetlabs/firewall') | ||
shell('puppet module install puppetlabs/apt') | ||
shell('puppet module install ripienaar/concat') | ||
|
||
file = Tempfile.new('foo') | ||
begin | ||
file.write(<<-EOS) | ||
--- | ||
:logger: noop | ||
EOS | ||
file.close | ||
rcp(:sp => file.path, :dp => '/etc/puppet/hiera.yaml') | ||
ensure | ||
file.unlink | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.