3 describe 'postgresql::server', :type => :class do
13 :osfamily => 'Debian',
14 :operatingsystem => 'Debian',
15 :lsbdistid => 'Debian',
16 :lsbdistcodename => 'jessie',
17 :operatingsystemrelease => '8.0',
18 :concat_basedir => tmpfilename('server'),
21 :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
25 describe 'with no parameters' do
26 it { is_expected.to contain_class("postgresql::params") }
27 it { is_expected.to contain_class("postgresql::server") }
28 it { is_expected.to contain_exec('postgresql_reload').with({
29 'command' => 'service postgresql reload',
32 it 'should validate connection' do
33 is_expected.to contain_postgresql_conn_validator('validate_service_is_running')
37 describe 'service_ensure => running' do
40 :service_ensure => 'running',
41 :postgres_password => 'new-p@s$word-to-set'
44 it { is_expected.to contain_class("postgresql::params") }
45 it { is_expected.to contain_class("postgresql::server") }
46 it { is_expected.to contain_class("postgresql::server::passwd") }
47 it 'should validate connection' do
48 is_expected.to contain_postgresql_conn_validator('validate_service_is_running')
50 it 'should set postgres password' do
51 is_expected.to contain_exec('set_postgres_postgrespw').with({
52 'command' => '/usr/bin/psql -c "ALTER ROLE \"postgres\" PASSWORD ${NEWPASSWD_ESCAPED}"',
55 "PGPASSWORD=new-p@s$word-to-set",
57 "NEWPASSWD_ESCAPED=$$new-p@s$word-to-set$$"
59 'unless' => "/usr/bin/psql -h localhost -p 5432 -c 'select 1' > /dev/null",
64 describe 'service_ensure => stopped' do
65 let(:params) {{ :service_ensure => 'stopped' }}
66 it { is_expected.to contain_class("postgresql::params") }
67 it { is_expected.to contain_class("postgresql::server") }
68 it 'shouldnt validate connection' do
69 is_expected.not_to contain_postgresql_conn_validator('validate_service_is_running')
73 describe 'service_restart_on_change => false' do
74 let(:params) {{ :service_restart_on_change => false }}
75 it { is_expected.to contain_class("postgresql::params") }
76 it { is_expected.to contain_class("postgresql::server") }
77 it { is_expected.to_not contain_Postgresql_conf('data_directory').that_notifies('Class[postgresql::server::service]')
79 it 'should validate connection' do
80 is_expected.to contain_postgresql_conn_validator('validate_service_is_running')
84 describe 'service_restart_on_change => true' do
85 let(:params) {{ :service_restart_on_change => true }}
86 it { is_expected.to contain_class("postgresql::params") }
87 it { is_expected.to contain_class("postgresql::server") }
88 it { is_expected.to contain_Postgresql_conf('data_directory').that_notifies('Class[postgresql::server::service]')
90 it 'should validate connection' do
91 is_expected.to contain_postgresql_conn_validator('validate_service_is_running')
95 describe 'service_reload => /bin/true' do
96 let(:params) {{ :service_reload => '/bin/true' }}
97 it { is_expected.to contain_class("postgresql::params") }
98 it { is_expected.to contain_class("postgresql::server") }
99 it { is_expected.to contain_exec('postgresql_reload').with({
100 'command' => '/bin/true',
103 it 'should validate connection' do
104 is_expected.to contain_postgresql_conn_validator('validate_service_is_running')
108 describe 'service_manage => true' do
109 let(:params) {{ :service_manage => true }}
110 it { is_expected.to contain_service('postgresqld') }
113 describe 'service_manage => false' do
114 let(:params) {{ :service_manage => false }}
115 it { is_expected.not_to contain_service('postgresqld') }
116 it 'shouldnt validate connection' do
117 is_expected.not_to contain_postgresql_conn_validator('validate_service_is_running')
121 describe 'package_ensure => absent' do
124 :package_ensure => 'absent',
128 it 'should remove the package' do
129 is_expected.to contain_package('postgresql-server').with({
134 it 'should still enable the service' do
135 is_expected.to contain_service('postgresqld').with({
136 :ensure => 'running',
141 describe 'needs_initdb => true' do
144 :needs_initdb => true,
148 it 'should contain proper initdb exec' do
149 is_expected.to contain_exec('postgresql_initdb')
153 describe 'postgresql_version' do
154 let(:pre_condition) do
156 class { 'postgresql::globals':
157 manage_package_repo => true,
159 before => Class['postgresql::server'],
163 it 'contains the correct package version' do
164 is_expected.to contain_class('postgresql::repo').with_version('99.5')