Skip to content

Commit 314cddb

Browse files
committed
test(inspec): add tests for multiple ports and postgres versions
* Fix `opensuse-leap-15` (enable `suse` and workaround `service` bug) * Use port `5433` for `debian` and `opensuse-leap-15` * Use upstream repo version `10` for `debian`
1 parent 7b7ebc7 commit 314cddb

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

Diff for: test/integration/default/controls/command_spec.rb

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
# Overide by OS
2+
pg_port = '5432'
3+
if os[:family] == 'debian' or os[:name] == 'suse'
4+
pg_port = '5433'
5+
end
6+
17
control 'Postgres command' do
28
title 'should match desired lines'
39

4-
describe command(%q{su - postgres -c 'psql -qtc "\l+ db2"'}) do
10+
# Can't use `%Q` here due to the `\`
11+
describe command(%q{su - postgres -c 'psql -p} + pg_port + %q{ -qtc "\l+ db2"'}) do
512
its(:stdout) { should match(/.*db2.*my_space/) }
613
# its(:stdout) { should match(/db2.*remoteUser.*UTF8.*en_US\.UTF-8.*en_US\.UTF-8.*my_space/) }
714
end

Diff for: test/integration/default/controls/services_spec.rb

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
# Overide by OS
22
service_name = 'postgresql'
3+
pg_port = 5432
34
if os[:name] == 'centos' and os[:release].start_with?('6')
45
service_name = 'postgresql-9.6'
6+
elsif os[:family] == 'debian' or os[:name] == 'suse'
7+
pg_port = 5433
58
end
69

10+
# Temporary `if` due to `opensuse-leap-15` bug re: `service`
11+
if os[:name] == 'suse'
12+
puts "[Skip `service`-based tests due to `opensuse-leap-15` bug]"
13+
else
714
control 'Postgres service' do
815
impact 0.5
916
title 'should be running and enabled'
@@ -13,7 +20,8 @@
1320
it { should be_running }
1421
end
1522

16-
describe port(5432) do
23+
describe port(pg_port) do
1724
it { should be_listening }
1825
end
1926
end
27+
end

Diff for: test/integration/default/inspec.yml

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ supports:
99
- os-name: centos
1010
- os-name: fedora
1111
- os-name: opensuse
12+
- os-name: suse

Diff for: test/salt/pillar/postgres.sls

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Port to use for the cluster -- can be used to provide a non-standard port
22
# NOTE: If already set in the minion config, that value takes priority
3+
4+
{%- if not (grains.os_family == 'Debian' or grains.osfinger == 'Leap-15') %}
35
postgres.port: '5432'
6+
{%- else %}
7+
postgres.port: '5433'
8+
{%- endif %}
49

510
postgres:
611
# UPSTREAM REPO
@@ -10,7 +15,11 @@ postgres:
1015
{%- else %}
1116
use_upstream_repo: True
1217
# Version to install from upstream repository (if upstream_repo: True)
18+
{%- if not (grains.os_family == 'Debian') %}
1319
version: '9.6'
20+
{%- else %}
21+
version: '10'
22+
{%- endif %}
1423
# # Set True to add a file in /etc/profile.d adding the bin dir in $PATH
1524
# # as packages from upstream put them somewhere like /usr/pgsql-10/bin
1625
# add_profile: False

0 commit comments

Comments
 (0)