Skip to content
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

extend validation of backup_options #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
5 changes: 3 additions & 2 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
# rsync command. If set to postgres barman will use the
# pg_basebackup command to execute the backup.
# [*backup_options*] - Behavior for backup operations: possible values are
# exclusive_backup (default) and concurrent_backup.
# exclusive_backup (default) and concurrent_backup with optional
# external_configuration.
# [*recovery_options*] - The restore command to write in the recovery.conf.
# Possible values are 'get-wal' and undef. Default: undef.
# [*bandwidth_limit*] - This option allows you to specify a maximum transfer rate
Expand Down Expand Up @@ -249,7 +250,7 @@
validate_re($ensure, '^(present|absent)$', "${ensure} is not a valid value (ensure = present|absent).")

# check if backup_options has correct values
validate_re($backup_options, [ '^exclusive_backup$', '^concurrent_backup$', 'Invalid backup option please use exclusive_backup or concurrent_backup' ])
validate_re($backup_options, [ '^(exclusive_backup|concurrent_backup)(,external_configuration)?$', 'Invalid backup option please use exclusive_backup or concurrent_backup with optional external_configuration' ])

if($recovery_options) {
# Check if recovery has correct values, if specified
Expand Down
25 changes: 25 additions & 0 deletions spec/defines/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,29 @@
}
end

context "with valid backup_options => exclusive_backup" do
let(:params) { @defaults.merge({ :backup_options => 'exclusive_backup' }) }
it { is_expected.to compile }
end

context "with valid backup_options => concurrent_backup" do
let(:params) { @defaults.merge({ :backup_options => 'concurrent_backup' }) }
it { is_expected.to compile }
end

context "with valid backup_options => exclusive_backup,external_configuration" do
let(:params) { @defaults.merge({ :backup_options => 'exclusive_backup,external_configuration' }) }
it { is_expected.to compile }
end

context "with valid backup_options => concurrent_backup,external_configuration" do
let(:params) { @defaults.merge({ :backup_options => 'concurrent_backup,external_configuration' }) }
it { is_expected.to compile }
end

context "with invalid backup_options => external_configuration" do
let(:params) { @defaults.merge({ :backup_options => 'external_configuration' }) }
it { is_expected.to compile.and_raise_error(/Invalid backup option please use exclusive_backup or concurrent_backup with optional external_configuration/) }
end

end