2014-10-21 12:59:07 +02:00
|
|
|
require 'spec_helper_acceptance'
|
|
|
|
|
|
|
|
# These tests ensure that postgres can change itself to an alternative pgdata
|
|
|
|
# location properly.
|
2014-10-31 23:27:34 +01:00
|
|
|
|
|
|
|
# Allow postgresql to use /tmp/* as a datadir
|
|
|
|
if fact('osfamily') == 'RedHat'
|
|
|
|
shell("setenforce 0")
|
|
|
|
end
|
|
|
|
|
2014-10-21 12:59:07 +02:00
|
|
|
describe 'postgres::server', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
|
|
|
|
it 'on an alternative pgdata location' do
|
|
|
|
pp = <<-EOS
|
2014-10-31 23:27:34 +01:00
|
|
|
#file { '/var/lib/pgsql': ensure => directory, } ->
|
|
|
|
# needs_initdb will be true by default for all OS's except Debian
|
|
|
|
# in order to change the datadir we need to tell it explicitly to call initdb
|
|
|
|
class { 'postgresql::server': datadir => '/tmp/data', needs_initdb => true }
|
2014-10-21 12:59:07 +02:00
|
|
|
EOS
|
|
|
|
|
|
|
|
apply_manifest(pp, :catch_failures => true)
|
|
|
|
apply_manifest(pp, :catch_changes => true)
|
|
|
|
end
|
2014-10-31 23:27:34 +01:00
|
|
|
|
|
|
|
describe file('/tmp/data') do
|
|
|
|
it { should be_directory }
|
2014-10-21 12:59:07 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'can connect with psql' do
|
|
|
|
psql('--command="\l" postgres', 'postgres') do |r|
|
|
|
|
expect(r.stdout).to match(/List of databases/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|