|
6 | 6 | require 'spec_helper'
|
7 | 7 |
|
8 | 8 | describe 'rabbitmq' do
|
9 |
| - on_supported_os.each do |os, facts| |
| 9 | + on_supported_os.each do |os, os_facts| |
10 | 10 | context "on #{os}" do
|
11 | 11 | let :facts do
|
12 |
| - facts |
| 12 | + os_facts |
13 | 13 | end
|
14 | 14 |
|
15 |
| - name = case facts[:osfamily] |
| 15 | + name = case os_facts[:osfamily] |
16 | 16 | when 'Archlinux', 'OpenBSD', 'FreeBSD'
|
17 | 17 | 'rabbitmq'
|
18 | 18 | else
|
19 | 19 | 'rabbitmq-server'
|
20 | 20 | end
|
21 | 21 |
|
| 22 | + rabbitmq_home = case os_facts[:osfamily] |
| 23 | + when 'FreeBSD' |
| 24 | + '/var/db/rabbitmq' |
| 25 | + else |
| 26 | + '/var/lib/rabbitmq' |
| 27 | + end |
| 28 | + |
22 | 29 | it { is_expected.to compile.with_all_deps }
|
23 | 30 | it { is_expected.to contain_class('rabbitmq::install') }
|
24 | 31 | it { is_expected.to contain_class('rabbitmq::config').that_notifies('Class[rabbitmq::service]') }
|
25 | 32 | it { is_expected.to contain_class('rabbitmq::service') }
|
26 | 33 |
|
27 | 34 | it { is_expected.to contain_package(name).with_ensure('installed').with_name(name) }
|
28 | 35 |
|
29 |
| - it { is_expected.to contain_package('rabbitmq-server-plugins') } if facts[:os]['family'] == 'Suse' |
| 36 | + it { is_expected.to contain_package('rabbitmq-server-plugins') } if os_facts[:os]['family'] == 'Suse' |
30 | 37 |
|
31 | 38 | context 'with default params' do
|
32 | 39 | it { is_expected.not_to contain_class('rabbitmq::repo::apt') }
|
|
44 | 51 | context 'with repos_ensure => true' do
|
45 | 52 | let(:params) { { repos_ensure: true } }
|
46 | 53 |
|
47 |
| - if facts[:os]['family'] == 'Debian' |
| 54 | + if os_facts[:os]['family'] == 'Debian' |
48 | 55 | it 'includes rabbitmq::repo::apt' do
|
49 | 56 | is_expected.to contain_class('rabbitmq::repo::apt').
|
50 | 57 | with_key_source('https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey').
|
|
54 | 61 | it 'adds a repo with default values' do
|
55 | 62 | is_expected.to contain_apt__source('rabbitmq').
|
56 | 63 | with_ensure('present').
|
57 |
| - with_location("https://packagecloud.io/rabbitmq/rabbitmq-server/#{facts[:os]['name'].downcase}"). |
| 64 | + with_location("https://packagecloud.io/rabbitmq/rabbitmq-server/#{os_facts[:os]['name'].downcase}"). |
58 | 65 | with_release(nil).
|
59 | 66 | with_repos('main')
|
60 | 67 | end
|
|
63 | 70 | it { is_expected.not_to contain_apt__souce('rabbitmq') }
|
64 | 71 | end
|
65 | 72 |
|
66 |
| - if facts[:os]['family'] == 'RedHat' |
| 73 | + if os_facts[:os]['family'] == 'RedHat' |
67 | 74 | it { is_expected.to contain_class('rabbitmq::repo::rhel') }
|
68 | 75 |
|
69 | 76 | it 'the repo should be present, and contain the expected values' do
|
|
78 | 85 | end
|
79 | 86 | end
|
80 | 87 |
|
81 |
| - context 'with no pin', if: facts[:os]['family'] == 'Debian' do |
| 88 | + context 'with no pin', if: os_facts[:os]['family'] == 'Debian' do |
82 | 89 | let(:params) { { repos_ensure: true, package_apt_pin: '' } }
|
83 | 90 |
|
84 | 91 | describe 'it sets up an apt::source' do
|
85 | 92 | it {
|
86 | 93 | is_expected.to contain_apt__source('rabbitmq').with(
|
87 |
| - 'location' => "https://packagecloud.io/rabbitmq/rabbitmq-server/#{facts[:os]['name'].downcase}", |
| 94 | + 'location' => "https://packagecloud.io/rabbitmq/rabbitmq-server/#{os_facts[:os]['name'].downcase}", |
88 | 95 | 'repos' => 'main',
|
89 | 96 | 'key' => '{"id"=>"8C695B0219AFDEB04A058ED8F4E789204D206F89", "source"=>"https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey", "content"=>nil}'
|
90 | 97 | )
|
91 | 98 | }
|
92 | 99 | end
|
93 | 100 | end
|
94 | 101 |
|
95 |
| - context 'with pin', if: facts[:os]['family'] == 'Debian' do |
| 102 | + context 'with pin', if: os_facts[:os]['family'] == 'Debian' do |
96 | 103 | let(:params) { { repos_ensure: true, package_apt_pin: '700' } }
|
97 | 104 |
|
98 | 105 | describe 'it sets up an apt::source and pin' do
|
99 | 106 | it {
|
100 | 107 | is_expected.to contain_apt__source('rabbitmq').with(
|
101 |
| - 'location' => "https://packagecloud.io/rabbitmq/rabbitmq-server/#{facts[:os]['name'].downcase}", |
| 108 | + 'location' => "https://packagecloud.io/rabbitmq/rabbitmq-server/#{os_facts[:os]['name'].downcase}", |
102 | 109 | 'repos' => 'main',
|
103 | 110 | 'key' => '{"id"=>"8C695B0219AFDEB04A058ED8F4E789204D206F89", "source"=>"https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey", "content"=>nil}'
|
104 | 111 | )
|
|
118 | 125 | context "with file_limit => '#{value}'" do
|
119 | 126 | let(:params) { { file_limit: value } }
|
120 | 127 |
|
121 |
| - if facts[:os]['family'] == 'RedHat' |
| 128 | + if os_facts[:os]['family'] == 'RedHat' |
122 | 129 | it do
|
123 | 130 | is_expected.to contain_file('/etc/security/limits.d/rabbitmq-server.conf').
|
124 | 131 | with_owner('0').
|
|
131 | 138 | it { is_expected.not_to contain_file('/etc/security/limits.d/rabbitmq-server.conf') }
|
132 | 139 | end
|
133 | 140 |
|
134 |
| - if facts[:os]['family'] == 'Debian' |
| 141 | + if os_facts[:os]['family'] == 'Debian' |
135 | 142 | it { is_expected.to contain_file('/etc/default/rabbitmq-server').with_content(%r{ulimit -n #{value}}) }
|
136 | 143 | else
|
137 | 144 | it { is_expected.not_to contain_file('/etc/default/rabbitmq-server') }
|
138 | 145 | end
|
139 | 146 |
|
140 |
| - if facts[:systemd] |
141 |
| - selinux_ignore_defaults = facts[:os]['family'] == 'RedHat' |
| 147 | + if os_facts[:systemd] |
| 148 | + selinux_ignore_defaults = os_facts[:os]['family'] == 'RedHat' |
142 | 149 |
|
143 | 150 | it do
|
144 | 151 | is_expected.to contain_systemd__service_limits("#{name}.service").
|
|
166 | 173 | context "with oom_score_adj => '#{value}'" do
|
167 | 174 | let(:params) { { oom_score_adj: value } }
|
168 | 175 |
|
169 |
| - if facts[:os]['family'] == 'Debian' |
| 176 | + if os_facts[:os]['family'] == 'Debian' |
170 | 177 | it { is_expected.to contain_file('/etc/default/rabbitmq-server').with_content(%r{^echo #{value} > /proc/\$\$/oom_score_adj$}) }
|
171 | 178 | else
|
172 | 179 | it { is_expected.not_to contain_file('/etc/default/rabbitmq-server') }
|
173 | 180 | end
|
174 | 181 |
|
175 |
| - if facts[:systemd] |
| 182 | + if os_facts[:systemd] |
176 | 183 | it do
|
177 | 184 | is_expected.to contain_systemd__service_limits("#{name}.service").
|
178 | 185 | with_limits('OOMScoreAdjust' => value).
|
|
194 | 201 | end
|
195 | 202 | end
|
196 | 203 |
|
197 |
| - context 'on systems with systemd', if: facts[:systemd] do |
| 204 | + context 'on systems with systemd', if: os_facts[:systemd] do |
198 | 205 | it do
|
199 | 206 | is_expected.to contain_systemd__service_limits("#{name}.service").
|
200 | 207 | with_restart_service(false)
|
201 | 208 | end
|
202 | 209 | end
|
203 | 210 |
|
204 |
| - context 'on systems without systemd', unless: facts[:systemd] do |
| 211 | + context 'on systems without systemd', unless: os_facts[:systemd] do |
205 | 212 | it { is_expected.not_to contain_systemd__service_limits("#{name}.service") }
|
206 | 213 | end
|
207 | 214 |
|
|
227 | 234 | is_expected.to contain_archive('rabbitmqadmin').with_source('http://1.1.1.1:15672/cli/rabbitmqadmin')
|
228 | 235 | end
|
229 | 236 |
|
230 |
| - it { is_expected.to contain_package('python') } if %w[RedHat Debian SUSE Archlinux].include?(facts[:os]['family']) |
231 |
| - it { is_expected.to contain_package('python2') } if %w[FreeBSD OpenBSD].include?(facts[:os]['family']) |
| 237 | + it { is_expected.to contain_package('python') } if %w[RedHat Debian SUSE Archlinux].include?(os_facts[:os]['family']) |
| 238 | + it { is_expected.to contain_package('python38') } if %w[FreeBSD].include?(os_facts[:os]['family']) |
232 | 239 | end
|
233 | 240 |
|
234 | 241 | context 'with manage_python false' do
|
|
241 | 248 | end
|
242 | 249 | end
|
243 | 250 |
|
244 |
| - context 'with $management_ip_address undef and service_manage set to true', unless: facts[:osfamily] == 'Archlinux' do |
| 251 | + context 'with $management_ip_address undef and service_manage set to true', unless: os_facts[:osfamily] == 'Archlinux' do |
245 | 252 | let(:params) { { admin_enable: true, management_ip_address: :undef } }
|
246 | 253 |
|
247 | 254 | it 'we enable the admin interface by default' do
|
|
253 | 260 | end
|
254 | 261 | end
|
255 | 262 |
|
256 |
| - context 'with service_manage set to true, node_ip_address = undef, and default user/pass specified', unless: facts[:osfamily] == 'Archlinux' do |
| 263 | + context 'with service_manage set to true, node_ip_address = undef, and default user/pass specified', unless: os_facts[:osfamily] == 'Archlinux' do |
257 | 264 | let(:params) { { admin_enable: true, default_user: 'foobar', default_pass: 'hunter2', node_ip_address: :undef } }
|
258 | 265 |
|
259 | 266 | it 'we use the correct URL to rabbitmqadmin' do
|
|
265 | 272 | end
|
266 | 273 | end
|
267 | 274 |
|
268 |
| - context 'with service_manage set to true and default user/pass specified', unless: facts[:osfamily] == 'Archlinux' do |
| 275 | + context 'with service_manage set to true and default user/pass specified', unless: os_facts[:osfamily] == 'Archlinux' do |
269 | 276 | let(:params) { { admin_enable: true, default_user: 'foobar', default_pass: 'hunter2', management_ip_address: '1.1.1.1' } }
|
270 | 277 |
|
271 | 278 | it 'we use the correct URL to rabbitmqadmin' do
|
|
277 | 284 | end
|
278 | 285 | end
|
279 | 286 |
|
280 |
| - context 'with service_manage set to true and archive_options set', unless: facts[:osfamily] == 'Archlinux' do |
| 287 | + context 'with service_manage set to true and archive_options set', unless: os_facts[:osfamily] == 'Archlinux' do |
281 | 288 | let(:params) do
|
282 | 289 | {
|
283 | 290 | admin_enable: true,
|
|
294 | 301 | end
|
295 | 302 | end
|
296 | 303 |
|
297 |
| - context 'with service_manage set to true and management port specified', unless: facts[:osfamily] == 'Archlinux' do |
| 304 | + context 'with service_manage set to true and management port specified', unless: os_facts[:osfamily] == 'Archlinux' do |
298 | 305 | # NOTE: that the 2.x management port is 55672 not 15672
|
299 | 306 | let(:params) { { admin_enable: true, management_port: 55_672, management_ip_address: '1.1.1.1' } }
|
300 | 307 |
|
|
307 | 314 | end
|
308 | 315 | end
|
309 | 316 |
|
310 |
| - context 'with ipv6, service_manage set to true and management port specified', unless: facts[:osfamily] == 'Archlinux' do |
| 317 | + context 'with ipv6, service_manage set to true and management port specified', unless: os_facts[:osfamily] == 'Archlinux' do |
311 | 318 | # NOTE: that the 2.x management port is 55672 not 15672
|
312 | 319 | let(:params) { { admin_enable: true, management_port: 55_672, management_ip_address: '::1' } }
|
313 | 320 |
|
|
404 | 411 | end
|
405 | 412 |
|
406 | 413 | it 'contains the rabbitmq_erlang_cookie' do
|
407 |
| - is_expected.to contain_rabbitmq_erlang_cookie('/var/lib/rabbitmq/.erlang.cookie') |
| 414 | + is_expected.to contain_rabbitmq_erlang_cookie("#{rabbitmq_home}/.erlang.cookie") |
408 | 415 | end
|
409 | 416 | end
|
410 | 417 |
|
|
417 | 424 | end
|
418 | 425 |
|
419 | 426 | it 'contains the rabbitmq_erlang_cookie' do
|
420 |
| - is_expected.to contain_rabbitmq_erlang_cookie('/var/lib/rabbitmq/.erlang.cookie') |
| 427 | + is_expected.to contain_rabbitmq_erlang_cookie("#{rabbitmq_home}/.erlang.cookie") |
421 | 428 | end
|
422 | 429 | end
|
423 | 430 |
|
|
428 | 435 | }
|
429 | 436 | end
|
430 | 437 |
|
431 |
| - it 'contains the rabbitmq_erlang_cookie' do |
432 |
| - is_expected.not_to contain_rabbitmq_erlang_cookie('/var/lib/rabbitmq/.erlang.cookie') |
| 438 | + it 'does not contains the rabbitmq_erlang_cookie' do |
| 439 | + is_expected.not_to contain_rabbitmq_erlang_cookie("#{rabbitmq_home}/.erlang.cookie") |
433 | 440 | end
|
434 | 441 | end
|
435 | 442 |
|
|
453 | 460 | describe 'rabbitmq-env configuration' do
|
454 | 461 | context 'with default params' do
|
455 | 462 | it 'sets environment variables' do
|
456 |
| - is_expected.to contain_file('rabbitmq-env.config'). \ |
457 |
| - with_content(%r{ERL_INETRC=/etc/rabbitmq/inetrc}) |
| 463 | + if %w[FreeBSD OpenBSD].include?(os_facts[:os]['family']) |
| 464 | + is_expected.to contain_file('rabbitmq-env.config'). \ |
| 465 | + with_content(%r{ERL_INETRC=/usr/local/etc/rabbitmq/inetrc}) |
| 466 | + else |
| 467 | + is_expected.to contain_file('rabbitmq-env.config'). \ |
| 468 | + with_content(%r{ERL_INETRC=/etc/rabbitmq/inetrc}) |
| 469 | + end |
458 | 470 | end
|
459 | 471 | end
|
460 | 472 |
|
|
1764 | 1776 | }
|
1765 | 1777 | end
|
1766 | 1778 |
|
1767 |
| - context 'on systems with systemd', if: facts[:systemd] do |
| 1779 | + context 'on systems with systemd', if: os_facts[:systemd] do |
1768 | 1780 | it do
|
1769 | 1781 | is_expected.to contain_service('rabbitmq-server').
|
1770 | 1782 | that_requires('Class[systemd::systemctl::daemon_reload]')
|
|
0 commit comments