-
Notifications
You must be signed in to change notification settings - Fork 29
/
qpid_spec.rb
304 lines (263 loc) · 9.94 KB
/
qpid_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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
require 'spec_helper'
describe 'qpid' do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) { facts }
let(:params) { {} }
context 'without parameters' do
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_class('qpid::install') }
it 'should install message store by default' do
is_expected.to contain_package('qpid-cpp-server-linearstore')
.that_comes_before(['Service[qpidd]'])
end
it { is_expected.to contain_class('qpid::config') }
it 'should create configuration file' do
verify_exact_contents(catalogue, '/etc/qpid/qpidd.conf', [
'data-dir=/var/lib/qpidd',
'log-enable=error+',
'log-to-syslog=yes',
'auth=no'
])
end
it { is_expected.to contain_class('qpid::service') }
it 'should configure systemd' do
is_expected.to contain_systemd__service_limits('qpidd.service')
.with_ensure('absent')
.that_notifies('Service[qpidd]')
is_expected.to contain_systemd__dropin_file('wait-for-port.conf')
.with_ensure('absent')
.that_notifies('Service[qpidd]')
end
end
context 'with ensure absent' do
let(:params) do
super().merge(
ensure: 'absent',
auth: true,
ssl: true,
ssl_port: 5671,
ssl_cert_db: "/etc/pki/katello/nssdb",
ssl_cert_password_file: "/etc/pki/katello/nssdb/nss_db_password-file",
ssl_cert_name: "broker",
ssl_require_client_auth: true
)
end
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_class('qpid::install') }
it { is_expected.to contain_package('qpid-cpp-server').with_ensure('purged') }
it { is_expected.to contain_package('qpid-cpp-client').with_ensure('purged') }
it { is_expected.to contain_package('qpid-cpp-server-linearstore').with_ensure('purged') }
it { is_expected.not_to contain_package('cyrus-sasl-plain') }
it { is_expected.to contain_package('qpid-tools').with_ensure('purged') }
it { is_expected.to contain_class('qpid::config') }
it { is_expected.to contain_group('qpidd').with_ensure('absent') }
it { is_expected.to contain_user('qpidd').with_ensure('absent') }
it { is_expected.to contain_file('/etc/qpid/qpidd.conf').with_ensure('absent') }
it { is_expected.to contain_file('/etc/qpid/qpid.acl').with_ensure('absent') }
it { is_expected.to contain_file('/var/lib/qpidd').with_ensure('absent') }
it { is_expected.to contain_class('qpid::service') }
it { is_expected.to contain_systemd__dropin_file('wait-for-port.conf').with_ensure('absent') }
it { is_expected.to contain_systemd__service_limits('qpidd.service').with_ensure('absent') }
it { is_expected.not_to contain_package('iproute') }
it 'should disable qpidd' do
is_expected.to contain_service('qpidd')
.with_ensure('false')
.with_enable('false')
end
end
context 'with services stopped' do
let(:params) { super().merge(service_ensure: false) }
it { is_expected.to compile.with_all_deps }
it 'should disable qpidd' do
is_expected.to contain_service('qpidd')
.with_ensure('false')
.with_enable('false')
end
end
context 'with service limits' do
let(:params) { super().merge(open_file_limit: 100) }
it { is_expected.to compile.with_all_deps }
it 'should configure systemd' do
is_expected.to contain_systemd__service_limits('qpidd.service')
.with_ensure('present')
.with_limits('LimitNOFILE' => 100)
.that_notifies('Service[qpidd]')
end
end
context 'message store disabled' do
let(:params) { super().merge(server_store: false) }
it { is_expected.to compile.with_all_deps }
it { is_expected.not_to contain_package('qpid-cpp-server-linearstore') }
end
context 'with interface' do
let(:params) { super().merge(interface: 'lo') }
it 'should create configuration file' do
verify_exact_contents(catalogue, '/etc/qpid/qpidd.conf', [
'data-dir=/var/lib/qpidd',
'log-enable=error+',
'log-to-syslog=yes',
'auth=no',
'interface=lo'
])
end
end
context 'with ACL file' do
let :params do
super().merge(
acl_file: "/etc/qpid/qpid.acl",
acl_content: "allow all all"
)
end
it 'should create configuration file' do
verify_exact_contents(catalogue, '/etc/qpid/qpidd.conf', [
'acl-file=/etc/qpid/qpid.acl',
'data-dir=/var/lib/qpidd',
'log-enable=error+',
'log-to-syslog=yes',
'auth=no',
])
end
it 'should create ACL file' do
verify_exact_contents(catalogue, '/etc/qpid/qpid.acl', [
'allow all all',
])
end
end
context 'with ssl options' do
let :params do
super().merge(
ssl: true,
ssl_port: 5671,
ssl_cert_db: "/etc/pki/katello/nssdb",
ssl_cert_password_file: "/etc/pki/katello/nssdb/nss_db_password-file",
ssl_cert_name: "broker",
ssl_require_client_auth: true
)
end
it 'should create configuration file' do
verify_exact_contents(catalogue, '/etc/qpid/qpidd.conf', [
'data-dir=/var/lib/qpidd',
'log-enable=error+',
'log-to-syslog=yes',
'auth=no',
'require-encryption=yes',
'ssl-require-client-authentication=yes',
'ssl-port=5671',
'ssl-cert-db=/etc/pki/katello/nssdb',
'ssl-cert-password-file=/etc/pki/katello/nssdb/nss_db_password-file',
'ssl-cert-name=broker'
])
end
it 'should configure systemd to wait for the ssl port to be open' do
is_expected.to contain_systemd__dropin_file('wait-for-port.conf')
.with_ensure('present')
.that_notifies('Service[qpidd]')
.that_requires('Package[iproute]')
is_expected.to contain_package('iproute')
.with_ensure('installed')
verify_exact_contents(catalogue, '/etc/systemd/system/qpidd.service.d/wait-for-port.conf', [
"[Service]",
"ExecStartPost=/bin/bash -c 'while ! ss --no-header --tcp --listening --numeric sport = :5671 | grep -q \"^LISTEN.*:5671\"; do sleep 1; done'"
])
end
end
context 'with session-max-unacked' do
let(:params) { super().merge(session_unacked: 10) }
it 'should create configuration file' do
verify_exact_contents(catalogue, '/etc/qpid/qpidd.conf', [
'data-dir=/var/lib/qpidd',
'log-enable=error+',
'log-to-syslog=yes',
'auth=no',
'session-max-unacked=10'
])
end
end
context 'with mgmt-pub-interval' do
let(:params) { super().merge(mgmt_pub_interval: 4) }
it 'should create configuration file' do
verify_exact_contents(catalogue, '/etc/qpid/qpidd.conf', [
'data-dir=/var/lib/qpidd',
'log-enable=error+',
'log-to-syslog=yes',
'auth=no',
'mgmt-pub-interval=4'
])
end
end
context 'with wcache_page_size' do
let(:params) { super().merge(wcache_page_size: 4) }
it 'should create configuration file' do
verify_exact_contents(catalogue, '/etc/qpid/qpidd.conf', [
'data-dir=/var/lib/qpidd',
'log-enable=error+',
'log-to-syslog=yes',
'auth=no',
'wcache-page-size=4'
])
end
end
context 'with default_queue_limit' do
let(:params) { super().merge(default_queue_limit: 10000) }
it 'should create configuration file' do
verify_exact_contents(catalogue, '/etc/qpid/qpidd.conf', [
'data-dir=/var/lib/qpidd',
'log-enable=error+',
'log-to-syslog=yes',
'auth=no',
'default-queue-limit=10000'
])
end
end
context 'with custom_settings' do
let :pre_condition do
<<-PUPPET
class {'qpid':
custom_settings => {
efp-file-size => 512,
log-to-file => '/tmp/qpidd.log',
},
}
PUPPET
end
it 'should create configuration file' do
verify_exact_contents(catalogue, '/etc/qpid/qpidd.conf', [
'data-dir=/var/lib/qpidd',
'log-enable=error+',
'log-to-syslog=yes',
'auth=no',
'efp-file-size=512',
'log-to-file=/tmp/qpidd.log',
])
end
end
context 'with max-connections' do
let(:params) { super().merge(max_connections: 2000) }
it 'should create configuration file' do
verify_exact_contents(catalogue, '/etc/qpid/qpidd.conf', [
'data-dir=/var/lib/qpidd',
'log-enable=error+',
'log-to-syslog=yes',
'auth=no',
'max-connections=2000'
])
end
end
context 'with auth' do
let(:params) { super().merge(auth: true) }
it 'should create configuration file' do
verify_exact_contents(catalogue, '/etc/qpid/qpidd.conf', [
'data-dir=/var/lib/qpidd',
'log-enable=error+',
'log-to-syslog=yes',
'auth=yes',
])
end
it 'should install cyrus-sasl-plain' do
is_expected.to contain_package('cyrus-sasl-plain')
end
end
end
end
end