Skip to content

Commit 45c7fa4

Browse files
committed
Add spec test to ensure correct behavior across PE versions
This spec test makes sure that the pg_repack class is included on versions of PE that support it and is not included on versions that do not support it.
1 parent 29dcf4a commit 45c7fa4

File tree

2 files changed

+50
-11
lines changed

2 files changed

+50
-11
lines changed

manifests/maintenance/pg_repack.pp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,43 +21,37 @@
2121
$reports_tables = '-t reports"'
2222
$logging = "> ${logging_directory}/output.log 2>&1"
2323

24-
cron { 'pg_repack facts tables' :
24+
Cron {
2525
ensure => $ensure_cron,
2626
user => 'root',
27+
require => File[$logging_directory],
28+
}
29+
30+
cron { 'pg_repack facts tables' :
2731
weekday => [2,6],
2832
hour => 4,
2933
minute => 30,
3034
command => "${repack} ${facts_tables} ${logging}",
31-
require => File[$logging_directory],
3235
}
3336

3437
cron { 'pg_repack catalogs tables' :
35-
ensure => $ensure_cron,
36-
user => 'root',
3738
weekday => [0,4],
3839
hour => 4,
3940
minute => 30,
4041
command => "${repack} ${catalogs_tables} ${logging}",
41-
require => File[$logging_directory],
4242
}
4343

4444
cron { 'pg_repack other tables' :
45-
ensure => $ensure_cron,
46-
user => 'root',
4745
monthday => 20,
4846
hour => 5,
4947
minute => 30,
5048
command => "${repack} ${other_tables} ${logging}",
51-
require => File[$logging_directory],
5249
}
5350

5451
cron { 'pg_repack reports tables' :
55-
ensure => $ensure_cron,
56-
user => 'root',
5752
weekday => [3],
5853
hour => 4,
5954
minute => 30,
6055
command => "${repack} ${reports_tables} ${logging}",
61-
require => File[$logging_directory],
6256
}
6357
}

spec/classes/maintenance_spec.rb

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
require 'spec_helper'
2+
3+
describe 'pe_databases::maintenance' do
4+
on_supported_os.each do |os, os_facts|
5+
context "on #{os}" do
6+
let(:pre_condition) { "class { 'pe_databases': }" }
7+
let(:facts) { os_facts }
8+
9+
it { is_expected.to compile }
10+
11+
context 'on PE 2019.0.0' do
12+
before(:each) do
13+
facts['pe_server_version'] = '2019.0.0'
14+
end
15+
16+
it { is_expected.to contain_class('pe_databases::maintenance::vacuum_full') }
17+
it { is_expected.not_to contain_class('pe_databases::maintenance::pg_repack') }
18+
end
19+
context 'on PE 2018.1.4' do
20+
before(:each) do
21+
facts['pe_server_version'] = '2018.1.4'
22+
end
23+
24+
it { is_expected.to contain_class('pe_databases::maintenance::vacuum_full') }
25+
it { is_expected.not_to contain_class('pe_databases::maintenance::pg_repack') }
26+
end
27+
context 'on PE 2018.1.8' do
28+
before(:each) do
29+
facts['pe_server_version'] = '2018.1.9'
30+
end
31+
32+
it { is_expected.to contain_class('pe_databases::maintenance::vacuum_full').with('disable_maintenance' => true) }
33+
it { is_expected.to contain_class('pe_databases::maintenance::pg_repack') }
34+
end
35+
context 'on PE 2019.0.3' do
36+
before(:each) do
37+
facts['pe_server_version'] = '2019.0.3'
38+
end
39+
40+
it { is_expected.to contain_class('pe_databases::maintenance::vacuum_full').with('disable_maintenance' => true) }
41+
it { is_expected.to contain_class('pe_databases::maintenance::pg_repack') }
42+
end
43+
end
44+
end
45+
end

0 commit comments

Comments
 (0)