Skip to content

(SUP-2557) Ensure backup class is not included by default #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
include pe_databases::postgresql_settings::table_settings
}
}
if defined('$manage_database_backups') {
# Because this parameter is a value of undef with a data type of Undef,
# We can the NotUndef type to determine if the value has been set
if $manage_database_backups =~ NotUndef {
class { 'pe_databases::backup':
disable_maintenance => ! $manage_database_backups,
}
Expand Down
6 changes: 0 additions & 6 deletions spec/acceptance/backup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,4 @@ class { 'pe_databases':
# Run it twice and test for idempotency
idempotent_apply(pp)
end
it 'checks if backup cron jobs are up' do
run_shell('crontab -l -u pe-postgres') do |r|
expect(r.stdout).to match(%r{pe-activity, pe-classifier, pe-inventory, pe-orchestrator, pe-postgres, pe-rbac})
expect(r.stdout).to match(%r{pe-puppetdb})
end
end
end
13 changes: 13 additions & 0 deletions spec/classes/backup_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'spec_helper'

describe 'pe_databases::backup' do
context 'when backing up tables' do
let(:pre_condition) { 'include pe_databases' }

it {
# I have no idea how this works, but these are the resources we should end up with
is_expected.to contain_cron('puppet_enterprise_database_backup_[pe-activity, pe-classifier, pe-inventory, pe-orchestrator, pe-postgres, pe-rbac]')
is_expected.to contain_cron('puppet_enterprise_database_backup_[pe-puppetdb]')
}
end
end
18 changes: 10 additions & 8 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
require 'spec_helper'

describe 'pe_databases' do
let(:params) do
{
manage_database_backups: false,
manage_postgresql_settings: false,
manage_table_settings: false,
}
end

on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }
Expand All @@ -32,4 +24,14 @@

it { is_expected.to contain_notify('pe_databases_systemd_warn') }
end

context 'backups are not included by default' do
it { is_expected.not_to contain_class('pe_databases::backup') }
end

context 'backups are included if configured' do
let(:params) { { manage_database_backups: true } }

it { is_expected.to contain_class('pe_databases::backup') }
end
end