-
Notifications
You must be signed in to change notification settings - Fork 611
/
Copy pathrecovery_spec.rb
109 lines (97 loc) · 3.59 KB
/
recovery_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# frozen_string_literal: true
require 'spec_helper'
describe 'postgresql::server::recovery' do
include_examples 'Debian 11'
let(:title) do
'test'
end
let :target do
tmpfilename('recovery')
end
context 'managing recovery' do
let(:pre_condition) do
<<-MANIFEST
class { 'postgresql::globals':
manage_recovery_conf => true,
}
class { 'postgresql::server': }
MANIFEST
end
let(:params) do
{
restore_command: 'restore_command',
recovery_target_timeline: 'recovery_target_timeline'
}
end
it do
expect(subject).to contain_concat__fragment('test-recovery.conf')
.with(content: %r{restore_command = 'restore_command'\n+recovery_target_timeline = 'recovery_target_timeline'})
end
end
context 'not managing recovery' do
let(:pre_condition) do
<<-MANIFEST
class { 'postgresql::globals':
manage_recovery_conf => false,
}
class { 'postgresql::server': }
MANIFEST
end
let(:params) do
{
restore_command: ''
}
end
it 'fails because $manage_recovery_conf is false' do
expect { catalogue }.to raise_error(Puppet::Error,
%r{postgresql::server::manage_recovery_conf has been disabled})
end
end
context 'not managing recovery, missing param' do
let(:pre_condition) do
<<-MANIFEST
class { 'postgresql::globals':
manage_recovery_conf => true,
}
class { 'postgresql::server': }
MANIFEST
end
it 'fails because no param set' do
expect { catalogue }.to raise_error(Puppet::Error,
%r{postgresql::server::recovery use this resource but do not pass a parameter will avoid creating the recovery.conf, because it makes no sense.})
end
end
context 'managing recovery with all params' do
let(:pre_condition) do
<<-MANIFEST
class { 'postgresql::globals':
manage_recovery_conf => true,
}
class { 'postgresql::server': }
MANIFEST
end
let(:params) do
{
restore_command: 'restore_command',
archive_cleanup_command: 'archive_cleanup_command',
recovery_end_command: 'recovery_end_command',
recovery_target_name: 'recovery_target_name',
recovery_target_time: 'recovery_target_time',
recovery_target_xid: 'recovery_target_xid',
recovery_target_inclusive: true,
recovery_target: 'recovery_target',
recovery_target_timeline: 'recovery_target_timeline',
pause_at_recovery_target: true,
standby_mode: 'on',
primary_conninfo: 'primary_conninfo',
primary_slot_name: 'primary_slot_name',
trigger_file: 'trigger_file',
recovery_min_apply_delay: 0
}
end
it do
expect(subject).to contain_concat__fragment('test-recovery.conf')
.with(content: %r{restore_command = 'restore_command'\n+archive_cleanup_command = 'archive_cleanup_command'\n+recovery_end_command = 'recovery_end_command'\n+recovery_target_name = 'recovery_target_name'\n+recovery_target_time = 'recovery_target_time'\n+recovery_target_xid = 'recovery_target_xid'\n+recovery_target_inclusive = true\n+recovery_target = 'recovery_target'\n+recovery_target_timeline = 'recovery_target_timeline'\n+pause_at_recovery_target = true\n+standby_mode = on\n+primary_conninfo = 'primary_conninfo'\n+primary_slot_name = 'primary_slot_name'\n+trigger_file = 'trigger_file'\n+recovery_min_apply_delay = 0\n+}) # rubocop:disable Layout/LineLength
end
end
end