Skip to content

Commit 22a7307

Browse files
authored
Merge pull request #95 from m0dular/SUP-2557-backup-class
(SUP-2557) Ensure backup class is not included by default
2 parents 62c1e51 + c0959d9 commit 22a7307

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

manifests/init.pp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@
4343
include pe_databases::postgresql_settings::table_settings
4444
}
4545
}
46-
if defined('$manage_database_backups') {
46+
# Because this parameter is a value of undef with a data type of Undef,
47+
# We can the NotUndef type to determine if the value has been set
48+
if $manage_database_backups =~ NotUndef {
4749
class { 'pe_databases::backup':
4850
disable_maintenance => ! $manage_database_backups,
4951
}

spec/acceptance/backup_spec.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,4 @@ class { 'pe_databases':
1111
# Run it twice and test for idempotency
1212
idempotent_apply(pp)
1313
end
14-
it 'checks if backup cron jobs are up' do
15-
run_shell('crontab -l -u pe-postgres') do |r|
16-
expect(r.stdout).to match(%r{pe-activity, pe-classifier, pe-inventory, pe-orchestrator, pe-postgres, pe-rbac})
17-
expect(r.stdout).to match(%r{pe-puppetdb})
18-
end
19-
end
2014
end

spec/classes/backup_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
require 'spec_helper'
2+
3+
describe 'pe_databases::backup' do
4+
context 'when backing up tables' do
5+
let(:pre_condition) { 'include pe_databases' }
6+
7+
it {
8+
# I have no idea how this works, but these are the resources we should end up with
9+
is_expected.to contain_cron('puppet_enterprise_database_backup_[pe-activity, pe-classifier, pe-inventory, pe-orchestrator, pe-postgres, pe-rbac]')
10+
is_expected.to contain_cron('puppet_enterprise_database_backup_[pe-puppetdb]')
11+
}
12+
end
13+
end

spec/classes/init_spec.rb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
require 'spec_helper'
22

33
describe 'pe_databases' do
4-
let(:params) do
5-
{
6-
manage_database_backups: false,
7-
manage_postgresql_settings: false,
8-
manage_table_settings: false,
9-
}
10-
end
11-
124
on_supported_os.each do |os, os_facts|
135
context "on #{os}" do
146
let(:facts) { os_facts }
@@ -32,4 +24,14 @@
3224

3325
it { is_expected.to contain_notify('pe_databases_systemd_warn') }
3426
end
27+
28+
context 'backups are not included by default' do
29+
it { is_expected.not_to contain_class('pe_databases::backup') }
30+
end
31+
32+
context 'backups are included if configured' do
33+
let(:params) { { manage_database_backups: true } }
34+
35+
it { is_expected.to contain_class('pe_databases::backup') }
36+
end
3537
end

0 commit comments

Comments
 (0)