Skip to content

Commit ab9bc91

Browse files
service and conn_validator need unique titles for instances
1 parent e7cba51 commit ab9bc91

File tree

9 files changed

+23
-23
lines changed

9 files changed

+23
-23
lines changed

manifests/server/instance/service.pp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
anchor { "postgresql::server::service::begin::${name}": }
2929

3030
if $service_manage {
31-
service { 'postgresqld':
31+
service { "postgresqld_instance_${name}":
3232
ensure => $service_ensure,
3333
enable => $service_enable,
3434
name => $service_name,
@@ -43,18 +43,18 @@
4343
#
4444
# Without it, we may continue doing more work before the database is
4545
# prepared leading to a nasty race condition.
46-
postgresql_conn_validator { 'validate_service_is_running':
46+
postgresql_conn_validator { "validate_service_is_running_instance_${name}":
4747
run_as => $user,
4848
db_name => $default_database,
4949
port => $port,
5050
connect_settings => $connect_settings,
5151
sleep => 1,
5252
tries => 60,
5353
psql_path => $psql_path,
54-
require => Service['postgresqld'],
54+
require => Service["postgresqld_instance_${name}"],
5555
before => Anchor["postgresql::server::service::end::${name}"],
5656
}
57-
Postgresql::Server::Database <| title == $default_database |> -> Postgresql_conn_validator['validate_service_is_running']
57+
Postgresql::Server::Database <| title == $default_database |> -> Postgresql_conn_validator["validate_service_is_running_instance_${name}"]
5858
}
5959
}
6060

spec/classes/server/service_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
end
1111

1212
it { is_expected.to contain_class('postgresql::server::service') }
13-
it { is_expected.to contain_service('postgresqld').with_name('postgresql').with_status('systemctl status postgresql') }
13+
it { is_expected.to contain_service('postgresqld').with_name('postgresqld_instance_main').with_status('systemctl status postgresql') }
1414
end

spec/classes/server_spec.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
}
1616

1717
it 'validates connection' do
18-
expect(subject).to contain_postgresql_conn_validator('validate_service_is_running')
18+
expect(subject).to contain_postgresql_conn_validator('validate_service_is_running_instance_main')
1919
end
2020
end
2121

@@ -61,7 +61,7 @@ class { 'postgresql::globals':
6161
it { is_expected.to contain_class('postgresql::server::passwd') }
6262

6363
it 'validates connection' do
64-
expect(subject).to contain_postgresql_conn_validator('validate_service_is_running')
64+
expect(subject).to contain_postgresql_conn_validator('validate_service_is_running_instance_main')
6565
end
6666

6767
it 'sets postgres password' do
@@ -85,7 +85,7 @@ class { 'postgresql::globals':
8585
it { is_expected.to contain_class('postgresql::server::passwd') }
8686

8787
it 'validates connection' do
88-
expect(subject).to contain_postgresql_conn_validator('validate_service_is_running')
88+
expect(subject).to contain_postgresql_conn_validator('validate_service_is_running_instance_main')
8989
end
9090

9191
it 'sets postgres password' do
@@ -103,7 +103,7 @@ class { 'postgresql::globals':
103103
it { is_expected.to contain_class('postgresql::server') }
104104

105105
it 'shouldnt validate connection' do
106-
expect(subject).not_to contain_postgresql_conn_validator('validate_service_is_running')
106+
expect(subject).not_to contain_postgresql_conn_validator('validate_service_is_running_instance_main')
107107
end
108108
end
109109

@@ -118,7 +118,7 @@ class { 'postgresql::globals':
118118
}
119119

120120
it 'validates connection' do
121-
expect(subject).to contain_postgresql_conn_validator('validate_service_is_running')
121+
expect(subject).to contain_postgresql_conn_validator('validate_service_is_running_instance_main')
122122
end
123123
end
124124

@@ -135,7 +135,7 @@ class { 'postgresql::globals':
135135
it { is_expected.to contain_postgresql__server__config_entry('data_directory_for_instance_main') }
136136

137137
it 'validates connection' do
138-
expect(subject).to contain_postgresql_conn_validator('validate_service_is_running')
138+
expect(subject).to contain_postgresql_conn_validator('validate_service_is_running_instance_main')
139139
end
140140
end
141141

@@ -150,23 +150,23 @@ class { 'postgresql::globals':
150150
}
151151

152152
it 'validates connection' do
153-
expect(subject).to contain_postgresql_conn_validator('validate_service_is_running')
153+
expect(subject).to contain_postgresql_conn_validator('validate_service_is_running_instance_main')
154154
end
155155
end
156156

157157
describe 'service_manage => true' do
158158
let(:params) { { service_manage: true } }
159159

160-
it { is_expected.to contain_service('postgresqld') }
160+
it { is_expected.to contain_service('postgresqld_instance_main') }
161161
end
162162

163163
describe 'service_manage => false' do
164164
let(:params) { { service_manage: false } }
165165

166-
it { is_expected.not_to contain_service('postgresqld') }
166+
it { is_expected.not_to contain_service('postgresqld_instance_main') }
167167

168168
it 'shouldnt validate connection' do
169-
expect(subject).not_to contain_postgresql_conn_validator('validate_service_is_running')
169+
expect(subject).not_to contain_postgresql_conn_validator('validate_service_is_running_instance_main')
170170
end
171171
end
172172

@@ -182,7 +182,7 @@ class { 'postgresql::globals':
182182
end
183183

184184
it 'stills enable the service' do
185-
expect(subject).to contain_service('postgresqld').with(ensure: 'running')
185+
expect(subject).to contain_service('postgresqld_instance_main').with(ensure: 'running')
186186
end
187187
end
188188

spec/defines/server/database_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
end
1414

1515
it { is_expected.to contain_postgresql__server__database('test') }
16-
it { is_expected.to contain_postgresql_psql('CREATE DATABASE "test"').that_requires('Service[postgresqld]') }
16+
it { is_expected.to contain_postgresql_psql('CREATE DATABASE "test"').that_requires('Service[postgresqld_instance_main]') }
1717

1818
context "with comment set to 'test comment'" do
1919
let(:params) { { comment: 'test comment' } }

spec/defines/server/default_privileges_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ class {'postgresql::server':}
337337

338338
it do
339339
expect(subject).to contain_postgresql_psql('default_privileges:test') \
340-
.that_requires(['Service[postgresqld]', 'Postgresql::Server::Role[test]'])
340+
.that_requires(['Service[postgresqld_instance_main]', 'Postgresql::Server::Role[test]'])
341341
end
342342
end
343343

spec/defines/server/grant_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class {'postgresql::server':}
207207

208208
it do
209209
expect(subject).to contain_postgresql_psql('grant:test') \
210-
.that_requires(['Service[postgresqld]', 'Postgresql::Server::Role[test]'])
210+
.that_requires(['Service[postgresqld_instance_main]', 'Postgresql::Server::Role[test]'])
211211
end
212212
end
213213

spec/defines/server/reassign_owned_by_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ class {'postgresql::server':}
3131
expect(subject).to contain_postgresql_psql('reassign_owned_by:test:REASSIGN OWNED BY "test_old_role" TO "test_new_role"')
3232
.with_command('REASSIGN OWNED BY "test_old_role" TO "test_new_role"')
3333
.with_onlyif(%r{SELECT tablename FROM pg_catalog.pg_tables WHERE\s*schemaname NOT IN \('pg_catalog', 'information_schema'\) AND\s*tableowner = 'test_old_role'.*}m)
34-
.that_requires('Service[postgresqld]')
34+
.that_requires('Service[postgresqld_instance_main]')
3535
}
3636
end

spec/defines/server/role_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
.with_unless("SELECT 1 FROM pg_roles WHERE rolname = 'test'")
9090
.with_port(5432)
9191
.with_connect_settings('PGHOST' => 'postgres-db-server', 'DBVERSION' => '9.1', 'PGUSER' => 'login-user', 'PGPASSWORD' => 'login-pass')
92-
.that_requires('Service[postgresqld]')
92+
.that_requires('Service[postgresqld_instance_main]')
9393
end
9494

9595
it 'has alter role for "test" user with password as ****' do
@@ -165,7 +165,7 @@
165165
end
166166

167167
it 'has drop role for "test" user if ensure absent' do
168-
expect(subject).to contain_postgresql_psql('DROP ROLE "test"').that_requires('Service[postgresqld]')
168+
expect(subject).to contain_postgresql_psql('DROP ROLE "test"').that_requires('Service[postgresqld_instance_main]')
169169
end
170170
end
171171

spec/defines/server/tablespace_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
it { is_expected.to contain_file('/srv/data/foo').with_ensure('directory') }
2323
it { is_expected.to contain_postgresql__server__tablespace('test') }
24-
it { is_expected.to contain_postgresql_psql('CREATE TABLESPACE "test"').that_requires('Service[postgresqld]') }
24+
it { is_expected.to contain_postgresql_psql('CREATE TABLESPACE "test"').that_requires('Service[postgresqld_instance_main]') }
2525

2626
context 'with different owner' do
2727
let :params do

0 commit comments

Comments
 (0)