Skip to content

Commit

Permalink
Add spec test to ensure correct behavior across PE versions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
npwalker committed Jan 14, 2019
1 parent 441ae77 commit 2cd4b5d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 9 deletions.
14 changes: 5 additions & 9 deletions manifests/maintenance/pg_repack.pp
Expand Up @@ -21,34 +21,31 @@
$reports_tables = '-t reports"'
$logging = "> ${logging_directory}/output.log 2>&1"

cron { 'pg_repack facts tables' :
Cron {
ensure => $ensure_cron,
user => 'root',
require => File[$logging_directory],
}

cron { 'pg_repack facts tables' :
weekday => [2,6],
hour => 4,
minute => 30,
command => "${repack} ${facts_tables} ${logging}",
require => File[$logging_directory],
}

cron { 'pg_repack catalogs tables' :
ensure => $ensure_cron,
user => 'root',
weekday => [0,4],
hour => 4,
minute => 30,
command => "${repack} ${catalogs_tables} ${logging}",
require => File[$logging_directory],
}

cron { 'pg_repack other tables' :
ensure => $ensure_cron,
user => 'root',
monthday => 20,
hour => 5,
minute => 30,
command => "${repack} ${other_tables} ${logging}",
require => File[$logging_directory],
}

cron { 'pg_repack reports tables' :
Expand All @@ -58,6 +55,5 @@
hour => 5,
minute => 30,
command => "${repack} ${reports_tables} ${logging}",
require => File[$logging_directory],
}
}
45 changes: 45 additions & 0 deletions spec/classes/maintenance_spec.rb
@@ -0,0 +1,45 @@
require 'spec_helper'

describe 'pe_databases::maintenance' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:pre_condition) { "class { 'pe_databases': }" }
let(:facts) { os_facts }

it { is_expected.to compile }

context 'on PE 2019.0.0' do
before(:each) do
facts['pe_server_version'] = '2019.0.0'
end

it { is_expected.to contain_class('pe_databases::maintenance::vacuum_full') }
it { is_expected.not_to contain_class('pe_databases::maintenance::pg_repack') }
end
context 'on PE 2018.1.4' do
before(:each) do
facts['pe_server_version'] = '2018.1.4'
end

it { is_expected.to contain_class('pe_databases::maintenance::vacuum_full') }
it { is_expected.not_to contain_class('pe_databases::maintenance::pg_repack') }
end
context 'on PE 2018.1.8' do
before(:each) do
facts['pe_server_version'] = '2018.1.9'
end

it { is_expected.to contain_class('pe_databases::maintenance::vacuum_full').with('disable_maintenance' => true) }
it { is_expected.to contain_class('pe_databases::maintenance::pg_repack') }
end
context 'on PE 2019.0.3' do
before(:each) do
facts['pe_server_version'] = '2019.0.3'
end

it { is_expected.to contain_class('pe_databases::maintenance::vacuum_full').with('disable_maintenance' => true) }
it { is_expected.to contain_class('pe_databases::maintenance::pg_repack') }
end
end
end
end

0 comments on commit 2cd4b5d

Please sign in to comment.