-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathadd_compiler_spec.rb
137 lines (113 loc) · 5.11 KB
/
add_compiler_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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
require 'spec_helper'
describe 'peadm::add_compiler' do
include BoltSpec::Plans
def allow_standard_non_returning_calls
allow_apply
allow_any_command
execute_no_plan
allow_out_message
end
describe 'basic functionality' do
let(:params) do
{
'primary_host' => 'primary',
'compiler_host' => 'compiler',
}
end
let(:params_with_avail_group_b) do
params.merge({ 'avail_group_letter' => 'B' })
end
let(:params_with_primary_postgresql_host) do
params.merge({ 'primary_postgresql_host' => 'custom_postgresql' })
end
let(:cfg) do
{
'params' => {
'primary_host' => 'primary',
'replica_host' => nil,
'primary_postgresql_host' => nil,
'replica_postgresql_host' => nil
},
'role-letter' => {
'server' => {
'A' => 'server_a',
'B' => nil
},
'postgresql': {
'A' => nil,
'B' => nil
}
}
}
end
it 'runs successfully when no alt-names are specified' do
allow_standard_non_returning_calls
expect_task('peadm::get_peadm_config').always_return(cfg)
expect_task('peadm::get_psql_version').with_targets(['server_a'])
expect_plan('peadm::subplans::component_install')
expect_plan('peadm::util::copy_file').be_called_times(1)
expect_task('peadm::puppet_runonce').with_targets(['compiler'])
expect_task('peadm::puppet_runonce').with_targets(['server_a'])
expect(run_plan('peadm::add_compiler', params)).to be_ok
end
it 'handles different avail_group_letter values' do
allow_standard_non_returning_calls
cfg['role-letter']['server']['B'] = 'server_b'
expect_task('peadm::get_peadm_config').always_return(cfg)
expect_task('peadm::get_psql_version').with_targets(['server_b'])
expect_plan('peadm::subplans::component_install')
expect_plan('peadm::util::copy_file').be_called_times(1)
expect_task('peadm::puppet_runonce').with_targets(['compiler'])
expect_task('peadm::puppet_runonce').with_targets(['server_a'])
expect_task('peadm::puppet_runonce').with_targets(['server_b'])
expect(run_plan('peadm::add_compiler', params_with_avail_group_b)).to be_ok
end
it 'handles specified primary_postgresql_host' do
allow_standard_non_returning_calls
expect_task('peadm::get_peadm_config').always_return(cfg)
expect_task('peadm::get_psql_version').with_targets(['custom_postgresql'])
expect_plan('peadm::subplans::component_install')
expect_plan('peadm::util::copy_file').be_called_times(1)
expect_task('peadm::puppet_runonce').with_targets(['compiler'])
expect_task('peadm::puppet_runonce').with_targets(['custom_postgresql'])
expect(run_plan('peadm::add_compiler', params_with_primary_postgresql_host)).to be_ok
end
it 'handles external postgresql host group A' do
allow_standard_non_returning_calls
cfg['params']['primary_postgresql_host'] = 'external_postgresql'
cfg['params']['replica_postgresql_host'] = 'external_postgresql'
expect_task('peadm::get_peadm_config').always_return(cfg)
expect_task('peadm::get_psql_version').with_targets(['external_postgresql'])
expect_plan('peadm::subplans::component_install')
expect_plan('peadm::util::copy_file').be_called_times(1)
expect_task('peadm::puppet_runonce').with_targets(['compiler'])
expect_task('peadm::puppet_runonce').with_targets(['external_postgresql'])
expect(run_plan('peadm::add_compiler', params)).to be_ok
end
it 'handles external postgresql host group A with replica' do
allow_standard_non_returning_calls
cfg['params']['primary_postgresql_host'] = 'external_postgresql'
cfg['role-letter']['server']['B'] = 'replica'
expect_task('peadm::get_peadm_config').always_return(cfg)
expect_task('peadm::get_psql_version').with_targets(['external_postgresql'])
expect_plan('peadm::subplans::component_install')
expect_plan('peadm::util::copy_file').be_called_times(1)
expect_task('peadm::puppet_runonce').with_targets(['compiler'])
expect_task('peadm::puppet_runonce').with_targets(['external_postgresql'])
expect_task('peadm::puppet_runonce').with_targets(['replica'])
expect(run_plan('peadm::add_compiler', params)).to be_ok
end
it 'handles external postgresql host group B' do
allow_standard_non_returning_calls
cfg['params']['replica_postgresql_host'] = 'replica_external_postgresql'
expect_task('peadm::get_peadm_config').always_return(cfg)
expect_task('peadm::get_psql_version').with_targets(['replica_external_postgresql'])
expect_plan('peadm::subplans::component_install')
expect_plan('peadm::util::copy_file').be_called_times(1)
expect_task('peadm::puppet_runonce').with_targets(['compiler'])
expect_task('peadm::puppet_runonce').with_targets(['replica_external_postgresql'])
expect_task('peadm::puppet_runonce').with_targets(['server_a'])
expect(run_plan('peadm::add_compiler', params_with_avail_group_b)).to be_ok
end
end
end