Skip to content

Commit ee97431

Browse files
author
Helen
authored
Merge pull request puppetlabs#1062 from david22swan/FM-7789
(FM-7789) - Clean up of PostgreSQL Test's
2 parents 5ce085f + 37898c0 commit ee97431

26 files changed

+210
-457
lines changed

.sync.yml

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
---
2+
.gitlab-ci.yml:
3+
unmanaged: true
4+
25
.travis.yml:
36
docker_sets:
47
- set: docker/centos-7
@@ -9,6 +12,9 @@
912
branches:
1013
- release
1114

15+
appveyor.yml:
16+
delete: true
17+
1218
Gemfile:
1319
required:
1420
':system_tests':
@@ -29,8 +35,6 @@ Gemfile:
2935
Rakefile:
3036
changelog_user: puppetlabs
3137

32-
appveyor.yml:
33-
delete: true
34-
35-
.gitlab-ci.yml:
36-
unmanaged: true
38+
spec/spec_helper.rb:
39+
mock_with: ':rspec'
40+
coverage_report: true

lib/puppet/provider/postgresql_psql/ruby.rb

+7-18
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,12 @@ def get_environment # rubocop:disable Style/AccessorMethodName : Refactor does n
5555

5656
def run_command(command, user, group, environment)
5757
command = command.join ' '
58-
if Puppet::PUPPETVERSION.to_f < 3.0
59-
require 'puppet/util/execution'
60-
Puppet::Util::Execution.withenv environment do
61-
Puppet::Util::SUIDManager.run_and_capture(command, user, group)
62-
end
63-
elsif Puppet::PUPPETVERSION.to_f < 3.4
64-
Puppet::Util.withenv environment do
65-
Puppet::Util::SUIDManager.run_and_capture(command, user, group)
66-
end
67-
else
68-
output = Puppet::Util::Execution.execute(command, uid: user,
69-
gid: group,
70-
failonfail: false,
71-
combine: true,
72-
override_locale: true,
73-
custom_environment: environment)
74-
[output, $CHILD_STATUS.dup]
75-
end
58+
output = Puppet::Util::Execution.execute(command, uid: user,
59+
gid: group,
60+
failonfail: false,
61+
combine: true,
62+
override_locale: true,
63+
custom_environment: environment)
64+
[output, $CHILD_STATUS.dup]
7665
end
7766
end

lib/puppet/provider/postgresql_replication_slot/ruby.rb

+7-11
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,12 @@ def self.run_sql_command(sql)
4444
end
4545

4646
def self.run_command(command, user, group)
47-
if Puppet::PUPPETVERSION.to_f < 3.4
48-
Puppet::Util::SUIDManager.run_and_capture(command, user, group)
49-
else
50-
output = Puppet::Util::Execution.execute(command, uid: user,
51-
gid: group,
52-
failonfail: false,
53-
combine: true,
54-
override_locale: true,
55-
custom_environment: {})
56-
[output, $CHILD_STATUS.dup]
57-
end
47+
output = Puppet::Util::Execution.execute(command, uid: user,
48+
gid: group,
49+
failonfail: false,
50+
combine: true,
51+
override_locale: true,
52+
custom_environment: {})
53+
[output, $CHILD_STATUS.dup]
5854
end
5955
end

metadata.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,5 @@
8484
],
8585
"pdk-version": "1.9.0",
8686
"template-url": "https://github.com/puppetlabs/pdk-templates/",
87-
"template-ref": "1.9.0-0-g7281db5"
88-
}
87+
"template-ref": "heads/master-0-g615413e"
88+
}

spec/acceptance/00-utf8_encoding_spec.rb

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
require 'spec_helper_acceptance' # rubocop:disable Style/FileName
22

3-
# These tests are designed to ensure that the module, when ran with defaults,
4-
# sets up everything correctly and allows us to connect to Postgres.
5-
describe 'postgresql::server', unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
3+
describe 'postgresql::server', unless: UNSUPPORTED_PLATFORMS.include?(os[:family]) do
64
pp = <<-MANIFEST
75
class { 'postgresql::globals':
86
encoding => 'UTF8',
@@ -11,8 +9,7 @@ class { 'postgresql::globals':
119
class { 'postgresql::server': }
1210
MANIFEST
1311
it 'with defaults' do
14-
apply_manifest(pp, catch_failures: true)
15-
apply_manifest(pp, catch_changes: true)
12+
idempotent_apply(default, pp)
1613
end
1714

1815
describe port(5432) do

spec/acceptance/alternative_port_spec.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22

33
# These tests ensure that postgres can change itself to an alternative port
44
# properly.
5-
describe 'postgresql::server', unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
5+
describe 'postgresql::server', unless: UNSUPPORTED_PLATFORMS.include?(os[:family]) do
66
it 'on an alternative port' do
77
pp = <<-MANIFEST
88
class { 'postgresql::server': port => '55433' }
99
MANIFEST
1010

11-
apply_manifest(pp, catch_failures: true)
12-
apply_manifest(pp, catch_changes: true)
11+
idempotent_apply(default, pp)
1312
end
1413

1514
describe port(55433) do # rubocop:disable Style/NumericLiterals

spec/acceptance/db_spec.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'spec_helper_acceptance'
22

3-
describe 'postgresql::server::db', unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
3+
describe 'postgresql::server::db', unless: UNSUPPORTED_PLATFORMS.include?(os[:family]) do
44
# rubocop:disable Metrics/LineLength
55
it 'creates a database' do
66
begin
@@ -20,8 +20,7 @@ class { 'postgresql::server':
2020
}
2121
MANIFEST
2222

23-
apply_manifest(pp, catch_failures: true)
24-
apply_manifest(pp, catch_changes: true)
23+
idempotent_apply(default, pp)
2524

2625
# Verify that the postgres password works
2726
shell("echo 'localhost:*:*:postgres:\'space password\'' > /root/.pgpass")

spec/acceptance/default_parameters_spec.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22

33
# These tests are designed to ensure that the module, when ran with defaults,
44
# sets up everything correctly and allows us to connect to Postgres.
5-
describe 'postgresql::server', unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
5+
describe 'postgresql::server', unless: UNSUPPORTED_PLATFORMS.include?(os[:family]) do
66
it 'with defaults' do
77
pp = <<-MANIFEST
88
class { 'postgresql::server': }
99
MANIFEST
1010

11-
apply_manifest(pp, catch_failures: true)
12-
apply_manifest(pp, catch_changes: true)
11+
idempotent_apply(default, pp)
1312
end
1413

1514
describe port(5432) do

spec/acceptance/overridden_settings_spec.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# These tests are designed to ensure that the module, when ran overrides,
44
# sets up everything correctly and allows us to connect to Postgres.
5-
describe 'postgresql::server', unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
5+
describe 'postgresql::server', unless: UNSUPPORTED_PLATFORMS.include?(os[:family]) do
66
pp = <<-MANIFEST
77
class { 'postgresql::server':
88
roles => {
@@ -31,8 +31,7 @@ class { 'postgresql::server':
3131
MANIFEST
3232

3333
it 'with additional hiera entries' do
34-
apply_manifest(pp, catch_failures: true)
35-
apply_manifest(pp, catch_changes: true)
34+
idempotent_apply(default, pp)
3635
end
3736

3837
describe port(5432) do

spec/acceptance/postgresql_conn_validator_spec.rb

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'spec_helper_acceptance'
22

3-
describe 'postgresql_conn_validator', unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
3+
describe 'postgresql_conn_validator', unless: UNSUPPORTED_PLATFORMS.include?(os[:family]) do
44
let(:install_pp) do
55
<<-MANIFEST
66
class { 'postgresql::server':
@@ -34,8 +34,7 @@ class { 'postgresql::server':
3434
}
3535
MANIFEST
3636

37-
apply_manifest(pp, catch_failures: true)
38-
apply_manifest(pp, catch_changes: true)
37+
idempotent_apply(default, pp)
3938
end
4039

4140
it 'works with connect settings hash' do
@@ -53,8 +52,7 @@ class { 'postgresql::server':
5352
}
5453
MANIFEST
5554

56-
apply_manifest(pp, catch_failures: true)
57-
apply_manifest(pp, catch_changes: true)
55+
idempotent_apply(default, pp)
5856
end
5957

6058
it 'fails gracefully' do

spec/acceptance/postgresql_psql_spec.rb

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'spec_helper_acceptance'
22

3-
describe 'postgresql_psql', unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
3+
describe 'postgresql_psql', unless: UNSUPPORTED_PLATFORMS.include?(os[:family]) do
44
pp_one = <<-MANIFEST
55
class { 'postgresql::server': } ->
66
postgresql_psql { 'foobar':
@@ -38,8 +38,7 @@ class { 'postgresql::server': } ->
3838
}
3939
MANIFEST
4040
it 'does not run SQL when the unless query returns rows' do
41-
apply_manifest(pp_three, catch_failures: true)
42-
apply_manifest(pp_three, catch_changes: true)
41+
idempotent_apply(default, pp_three)
4342
end
4443

4544
pp_four = <<-MANIFEST
@@ -69,8 +68,7 @@ class { 'postgresql::server': } ->
6968
}
7069
MANIFEST
7170
it 'does not run SQL when the unless query returns no rows' do
72-
apply_manifest(pp_five, catch_failures: true)
73-
apply_manifest(pp_five, catch_changes: true)
71+
idempotent_apply(default, pp_five)
7472
end
7573

7674
pp_six = <<-MANIFEST.unindent
@@ -166,8 +164,7 @@ class { 'postgresql::server': } ->
166164
}
167165
MANIFEST
168166

169-
apply_manifest(pp, catch_failures: true)
170-
apply_manifest(pp, expect_changes: false)
167+
idempotent_apply(default, pp)
171168
end
172169
end
173170
end

spec/acceptance/remote_access_spec.rb

-71
This file was deleted.

spec/acceptance/server/config_entry_spec.rb

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
require 'spec_helper_acceptance'
22

33
describe 'postgresql::server::config_entry' do
4-
let(:pp_setup) do
5-
<<-MANIFEST
6-
class { 'postgresql::server':
7-
postgresql_conf_path => '/tmp/postgresql.conf',
8-
}
9-
MANIFEST
10-
end
11-
124
context 'unix_socket_directories' do
135
let(:pp_test) do
14-
pp_setup + <<-MANIFEST
6+
<<-MANIFEST
7+
class { 'postgresql::server':
8+
postgresql_conf_path => '/tmp/postgresql.conf',
9+
}
10+
1511
postgresql::server::config_entry { 'unix_socket_directories':
1612
value => '/var/socket/, /root/'
1713
}
@@ -25,8 +21,7 @@ class { 'postgresql::server':
2521

2622
if version >= '9.3'
2723
it 'is expected to run idempotently' do
28-
apply_manifest(pp_test, catch_failures: true)
29-
apply_manifest(pp_test, catch_changes: true)
24+
idempotent_apply(default, pp_test)
3025
end
3126

3227
it 'is expected to contain directories' do

0 commit comments

Comments
 (0)