80c85e8f2b
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 <ken@bob.sh>
54 lines
1.3 KiB
Ruby
54 lines
1.3 KiB
Ruby
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
|