5 context 'on unsupported distributions' do
6 let(:facts) {{ :osfamily => 'Unsupported' }}
9 expect { catalogue }.to raise_error(Puppet::Error, /not supported on an Unsupported/)
13 context 'on Debian' do
14 let(:facts) {{ :osfamily => 'Debian', :lsbdistid => 'Debian', :lsbdistcodename => 'squeeze' }}
15 it 'includes rabbitmq::repo::apt' do
16 should contain_class('rabbitmq::repo::apt')
19 describe 'apt::source default values' do
20 it 'should add a repo with defaults values' do
21 should contain_apt__source('rabbitmq').with( {
23 :location => 'http://www.rabbitmq.com/debian/',
24 :release => 'testing',
31 context 'on Debian' do
32 let(:params) {{ :manage_repos => false }}
33 let(:facts) {{ :osfamily => 'Debian', :lsbdistid => 'Debian', :lsbdistcodename => 'squeeze' }}
34 it 'does ensure rabbitmq apt::source is absent when manage_repos is false' do
35 should_not contain_apt__source('rabbitmq')
39 context 'on Debian' do
40 let(:params) {{ :manage_repos => true }}
41 let(:facts) {{ :osfamily => 'Debian', :lsbdistid => 'Debian', :lsbdistcodename => 'squeeze' }}
43 it 'includes rabbitmq::repo::apt' do
44 should contain_class('rabbitmq::repo::apt')
47 describe 'apt::source default values' do
48 it 'should add a repo with defaults values' do
49 should contain_apt__source('rabbitmq').with( {
51 :location => 'http://www.rabbitmq.com/debian/',
52 :release => 'testing',
59 context 'on Debian' do
60 let(:params) {{ :repos_ensure => false }}
61 let(:facts) {{ :osfamily => 'Debian', :lsbdistid => 'Debian', :lsbdistcodename => 'squeeze' }}
62 it 'does ensure rabbitmq apt::source is absent when repos_ensure is false' do
63 should contain_apt__source('rabbitmq').with(
69 context 'on Debian' do
70 let(:params) {{ :repos_ensure => true }}
71 let(:facts) {{ :osfamily => 'Debian', :lsbdistid => 'Debian', :lsbdistcodename => 'squeeze' }}
73 it 'includes rabbitmq::repo::apt' do
74 should contain_class('rabbitmq::repo::apt')
77 describe 'apt::source default values' do
78 it 'should add a repo with defaults values' do
79 should contain_apt__source('rabbitmq').with( {
81 :location => 'http://www.rabbitmq.com/debian/',
82 :release => 'testing',
89 context 'on Debian' do
90 let(:params) {{ :manage_repos => true, :repos_ensure => false }}
91 let(:facts) {{ :osfamily => 'Debian', :lsbdistid => 'Debian', :lsbdistcodename => 'squeeze' }}
93 it 'includes rabbitmq::repo::apt' do
94 should contain_class('rabbitmq::repo::apt')
97 describe 'apt::source default values' do
98 it 'should add a repo with defaults values' do
99 should contain_apt__source('rabbitmq').with( {
106 context 'on Debian' do
107 let(:params) {{ :manage_repos => true, :repos_ensure => true }}
108 let(:facts) {{ :osfamily => 'Debian', :lsbdistid => 'Debian', :lsbdistcodename => 'squeeze' }}
110 it 'includes rabbitmq::repo::apt' do
111 should contain_class('rabbitmq::repo::apt')
114 describe 'apt::source default values' do
115 it 'should add a repo with defaults values' do
116 should contain_apt__source('rabbitmq').with( {
117 :ensure => 'present',
118 :location => 'http://www.rabbitmq.com/debian/',
119 :release => 'testing',
126 context 'on Debian' do
127 let(:params) {{ :manage_repos => false, :repos_ensure => true }}
128 let(:facts) {{ :osfamily => 'Debian', :lsbdistid => 'Debian', :lsbdistcodename => 'squeeze' }}
129 it 'does ensure rabbitmq apt::source is absent when manage_repos is false and repos_ensure is true' do
130 should_not contain_apt__source('rabbitmq')
134 context 'on Debian' do
135 let(:facts) {{ :osfamily => 'Debian', :lsbdistid => 'Debian', :lsbdistcodename => 'squeeze' }}
136 context 'with manage_repos => false and repos_ensure => false' do
137 let(:params) {{ :manage_repos => false, :repos_ensure => false }}
138 it 'does ensure rabbitmq apt::source is absent when manage_repos is false and repos_ensure is false' do
139 should_not contain_apt__source('rabbitmq')
143 context 'with file_limit => unlimited' do
144 let(:params) {{ :file_limit => 'unlimited' }}
145 it { should contain_file('/etc/default/rabbitmq-server').with_content(/ulimit -n unlimited/) }
148 context 'with file_limit => infinity' do
149 let(:params) {{ :file_limit => 'infinity' }}
150 it { should contain_file('/etc/default/rabbitmq-server').with_content(/ulimit -n infinity/) }
153 context 'with file_limit => -1' do
154 let(:params) {{ :file_limit => -1 }}
155 it { should contain_file('/etc/default/rabbitmq-server').with_content(/ulimit -n -1/) }
158 context 'with file_limit => \'1234\'' do
159 let(:params) {{ :file_limit => '1234' }}
160 it { should contain_file('/etc/default/rabbitmq-server').with_content(/ulimit -n 1234/) }
163 context 'with file_limit => foo' do
164 let(:params) {{ :file_limit => 'foo' }}
165 it 'does not compile' do
166 expect { catalogue }.to raise_error(Puppet::Error, /\$file_limit must be an integer, 'unlimited', or 'infinity'/)
171 context 'on Redhat' do
172 let(:facts) {{ :osfamily => 'RedHat' }}
173 it 'includes rabbitmq::repo::rhel' do
174 should contain_class('rabbitmq::repo::rhel')
175 should contain_exec('rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc')
179 context 'on Redhat' do
180 let(:params) {{ :repos_ensure => false }}
181 let(:facts) {{ :osfamily => 'RedHat' }}
182 it 'does not import repo public key when repos_ensure is false' do
183 should contain_class('rabbitmq::repo::rhel')
184 should_not contain_exec('rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc')
188 context 'on Redhat' do
189 let(:params) {{ :repos_ensure => true }}
190 let(:facts) {{ :osfamily => 'RedHat' }}
191 it 'does import repo public key when repos_ensure is true' do
192 should contain_class('rabbitmq::repo::rhel')
193 should contain_exec('rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc')
197 context 'on Redhat' do
198 let(:params) {{ :manage_repos => false }}
199 let(:facts) {{ :osfamily => 'RedHat' }}
200 it 'does not import repo public key when manage_repos is false' do
201 should_not contain_class('rabbitmq::repo::rhel')
202 should_not contain_exec('rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc')
206 context 'on Redhat' do
207 let(:params) {{ :manage_repos => true }}
208 let(:facts) {{ :osfamily => 'RedHat' }}
209 it 'does import repo public key when manage_repos is true' do
210 should contain_class('rabbitmq::repo::rhel')
211 should contain_exec('rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc')
215 context 'on Redhat' do
216 let(:params) {{ :manage_repos => false, :repos_ensure => true }}
217 let(:facts) {{ :osfamily => 'RedHat' }}
218 it 'does not import repo public key when manage_repos is false and repos_ensure is true' do
219 should_not contain_class('rabbitmq::repo::rhel')
220 should_not contain_exec('rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc')
224 context 'on Redhat' do
225 let(:params) {{ :manage_repos => true, :repos_ensure => true }}
226 let(:facts) {{ :osfamily => 'RedHat' }}
227 it 'does import repo public key when manage_repos is true and repos_ensure is true' do
228 should contain_class('rabbitmq::repo::rhel')
229 should contain_exec('rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc')
233 context 'on Redhat' do
234 let(:params) {{ :manage_repos => false, :repos_ensure => false }}
235 let(:facts) {{ :osfamily => 'RedHat' }}
236 it 'does not import repo public key when manage_repos is false and repos_ensure is false' do
237 should_not contain_class('rabbitmq::repo::rhel')
238 should_not contain_exec('rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc')
242 context 'on Redhat' do
243 let(:params) {{ :manage_repos => true, :repos_ensure => false }}
244 let(:facts) {{ :osfamily => 'RedHat' }}
245 it 'does not import repo public key when manage_repos is true and repos_ensure is false' do
246 should contain_class('rabbitmq::repo::rhel')
247 should_not contain_exec('rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc')
251 context 'on RedHat 7.0 or more' do
252 let(:facts) {{ :osfamily => 'RedHat', :operatingsystemmajrelease => '7' }}
254 it { should contain_file('/etc/systemd/system/rabbitmq-server.service.d').with(
255 'ensure' => 'directory',
259 'selinux_ignore_defaults' => true
262 it { should contain_exec('rabbitmq-systemd-reload').with(
263 'command' => '/usr/bin/systemctl daemon-reload',
264 'notify' => 'Class[Rabbitmq::Service]',
265 'refreshonly' => true
267 context 'with file_limit => unlimited' do
268 let(:params) {{ :file_limit => 'unlimited' }}
269 it { should contain_file('/etc/systemd/system/rabbitmq-server.service.d/limits.conf').with(
273 'notify' => 'Exec[rabbitmq-systemd-reload]',
274 'content' => '[Service]
275 LimitNOFILE=unlimited
280 context 'with file_limit => infinity' do
281 let(:params) {{ :file_limit => 'infinity' }}
282 it { should contain_file('/etc/systemd/system/rabbitmq-server.service.d/limits.conf').with(
286 'notify' => 'Exec[rabbitmq-systemd-reload]',
287 'content' => '[Service]
293 context 'with file_limit => -1' do
294 let(:params) {{ :file_limit => -1 }}
295 it { should contain_file('/etc/systemd/system/rabbitmq-server.service.d/limits.conf').with(
299 'notify' => 'Exec[rabbitmq-systemd-reload]',
300 'content' => '[Service]
306 context 'with file_limit => \'1234\'' do
307 let(:params) {{ :file_limit => '1234' }}
308 it { should contain_file('/etc/systemd/system/rabbitmq-server.service.d/limits.conf').with(
312 'notify' => 'Exec[rabbitmq-systemd-reload]',
313 'content' => '[Service]
319 context 'with file_limit => foo' do
320 let(:params) {{ :file_limit => 'foo' }}
321 it 'does not compile' do
322 expect { catalogue }.to raise_error(Puppet::Error, /\$file_limit must be an integer, 'unlimited', or 'infinity'/)
327 context 'on RedHat before 7.0' do
328 let(:facts) {{ :osfamily => 'RedHat', :operatingsystemmajrelease => '6' }}
330 context 'with file_limit => unlimited' do
331 let(:params) {{ :file_limit => 'unlimited' }}
332 it { should contain_file('/etc/security/limits.d/rabbitmq-server.conf').with(
336 'notify' => 'Class[Rabbitmq::Service]',
337 'content' => 'rabbitmq soft nofile unlimited
338 rabbitmq hard nofile unlimited
343 context 'with file_limit => infinity' do
344 let(:params) {{ :file_limit => 'infinity' }}
345 it { should contain_file('/etc/security/limits.d/rabbitmq-server.conf').with(
349 'notify' => 'Class[Rabbitmq::Service]',
350 'content' => 'rabbitmq soft nofile infinity
351 rabbitmq hard nofile infinity
356 context 'with file_limit => -1' do
357 let(:params) {{ :file_limit => -1 }}
358 it { should contain_file('/etc/security/limits.d/rabbitmq-server.conf').with(
362 'notify' => 'Class[Rabbitmq::Service]',
363 'content' => 'rabbitmq soft nofile -1
364 rabbitmq hard nofile -1
369 context 'with file_limit => \'1234\'' do
370 let(:params) {{ :file_limit => '1234' }}
371 it { should contain_file('/etc/security/limits.d/rabbitmq-server.conf').with(
375 'notify' => 'Class[Rabbitmq::Service]',
376 'content' => 'rabbitmq soft nofile 1234
377 rabbitmq hard nofile 1234
382 context 'with file_limit => foo' do
383 let(:params) {{ :file_limit => 'foo' }}
384 it 'does not compile' do
385 expect { catalogue }.to raise_error(Puppet::Error, /\$file_limit must be an integer, 'unlimited', or 'infinity'/)
390 ['Debian', 'RedHat', 'SUSE', 'Archlinux'].each do |distro|
391 context "on #{distro}" do
394 :lsbdistcodename => 'squeeze',
395 :lsbdistid => 'Debian'
398 it { should contain_class('rabbitmq::install') }
399 it { should contain_class('rabbitmq::config') }
400 it { should contain_class('rabbitmq::service') }
402 context 'with admin_enable set to true' do
403 let(:params) {{ :admin_enable => true }}
404 context 'with service_manage set to true' do
405 it 'we enable the admin interface by default' do
406 should contain_class('rabbitmq::install::rabbitmqadmin')
407 should contain_rabbitmq_plugin('rabbitmq_management').with(
408 'require' => 'Class[Rabbitmq::Install]',
409 'notify' => 'Class[Rabbitmq::Service]'
411 should contain_staging__file('rabbitmqadmin').with_source("http://guest:guest@localhost:15672/cli/rabbitmqadmin")
414 context 'with service_manage set to true and default user/pass specified' do
415 let(:params) {{ :admin_enable => true, :default_user => 'foobar', :default_pass => 'hunter2' }}
416 it 'we use the correct URL to rabbitmqadmin' do
417 should contain_staging__file('rabbitmqadmin').with_source("http://foobar:hunter2@localhost:15672/cli/rabbitmqadmin")
420 context 'with service_manage set to true and management port specified' do
421 # note that the 2.x management port is 55672 not 15672
422 let(:params) {{ :admin_enable => true, :management_port => '55672' }}
423 it 'we use the correct URL to rabbitmqadmin' do
424 should contain_staging__file('rabbitmqadmin').with_source("http://guest:guest@localhost:55672/cli/rabbitmqadmin")
427 context 'with service_manage set to false' do
428 let(:params) {{ :admin_enable => true, :service_manage => false }}
429 it 'should do nothing' do
430 should_not contain_class('rabbitmq::install::rabbitmqadmin')
431 should_not contain_rabbitmq_plugin('rabbitmq_management')
436 describe 'manages configuration directory correctly' do
437 it { should contain_file('/etc/rabbitmq').with(
438 'ensure' => 'directory'
442 describe 'manages configuration file correctly' do
443 it { should contain_file('rabbitmq.config') }
446 context 'configures config_cluster' do
447 let(:facts) {{ :osfamily => distro, :lsbdistid => 'Debian' }}
449 :config_cluster => true,
450 :cluster_nodes => ['hare-1', 'hare-2'],
451 :cluster_node_type => 'ram',
452 :wipe_db_on_cookie_change => false
455 describe 'with defaults' do
457 expect { catalogue }.to raise_error(Puppet::Error, /You must set the \$erlang_cookie value/)
461 describe 'with erlang_cookie set' do
463 :config_cluster => true,
464 :cluster_nodes => ['hare-1', 'hare-2'],
465 :cluster_node_type => 'ram',
466 :erlang_cookie => 'TESTCOOKIE',
467 :wipe_db_on_cookie_change => true
469 it 'contains the rabbitmq_erlang_cookie' do
470 should contain_rabbitmq_erlang_cookie('/var/lib/rabbitmq/.erlang.cookie')
474 describe 'and sets appropriate configuration' do
476 :config_cluster => true,
477 :cluster_nodes => ['hare-1', 'hare-2'],
478 :cluster_node_type => 'ram',
479 :erlang_cookie => 'ORIGINAL',
480 :wipe_db_on_cookie_change => true
482 it 'for cluster_nodes' do
483 should contain_file('rabbitmq.config').with({
484 'content' => /cluster_nodes.*\['rabbit@hare-1', 'rabbit@hare-2'\], ram/,
491 describe 'rabbitmq-env configuration' do
492 let(:params) {{ :environment_variables => {
493 'NODE_IP_ADDRESS' => '1.1.1.1',
494 'NODE_PORT' => '5656',
495 'NODENAME' => 'HOSTNAME',
496 'SERVICENAME' => 'RabbitMQ',
497 'CONSOLE_LOG' => 'RabbitMQ.debug',
498 'CTL_ERL_ARGS' => 'verbose',
499 'SERVER_ERL_ARGS' => 'v',
500 'SERVER_START_ARGS' => 'debug'
502 it 'should set environment variables' do
503 should contain_file('rabbitmq-env.config') \
504 .with_content(/NODE_IP_ADDRESS=1.1.1.1/) \
505 .with_content(/NODE_PORT=5656/) \
506 .with_content(/NODENAME=HOSTNAME/) \
507 .with_content(/SERVICENAME=RabbitMQ/) \
508 .with_content(/CONSOLE_LOG=RabbitMQ.debug/) \
509 .with_content(/CTL_ERL_ARGS=verbose/) \
510 .with_content(/SERVER_ERL_ARGS=v/) \
511 .with_content(/SERVER_START_ARGS=debug/)
515 context 'delete_guest_user' do
516 describe 'should do nothing by default' do
517 it { should_not contain_rabbitmq_user('guest') }
520 describe 'delete user when delete_guest_user set' do
521 let(:params) {{ :delete_guest_user => true }}
522 it 'removes the user' do
523 should contain_rabbitmq_user('guest').with(
524 'ensure' => 'absent',
525 'provider' => 'rabbitmqctl'
531 context 'configuration setting' do
532 describe 'node_ip_address when set' do
533 let(:params) {{ :node_ip_address => '172.0.0.1' }}
534 it 'should set NODE_IP_ADDRESS to specified value' do
535 should contain_file('rabbitmq-env.config').
536 with_content(%r{NODE_IP_ADDRESS=172\.0\.0\.1})
540 describe 'stomp by default' do
541 it 'should not specify stomp parameters in rabbitmq.config' do
542 should contain_file('rabbitmq.config').without({
543 'content' => /stomp/,})
546 describe 'stomp when set' do
547 let(:params) {{ :config_stomp => true, :stomp_port => 5679 }}
548 it 'should specify stomp port in rabbitmq.config' do
549 should contain_file('rabbitmq.config').with({
550 'content' => /rabbitmq_stomp.*tcp_listeners, \[5679\]/m,
554 describe 'stomp when set ssl port w/o ssl enabled' do
555 let(:params) {{ :config_stomp => true, :stomp_port => 5679, :ssl => false, :ssl_stomp_port => 5680 }}
556 it 'should not configure ssl_listeners in rabbitmq.config' do
557 should contain_file('rabbitmq.config').without({
558 'content' => /rabbitmq_stomp.*ssl_listeners, \[5680\]/m,
562 describe 'stomp when set with ssl' do
563 let(:params) {{ :config_stomp => true, :stomp_port => 5679, :ssl => true, :ssl_stomp_port => 5680 }}
564 it 'should specify stomp port and ssl stomp port in rabbitmq.config' do
565 should contain_file('rabbitmq.config').with({
566 'content' => /rabbitmq_stomp.*tcp_listeners, \[5679\].*ssl_listeners, \[5680\]/m,
572 describe 'configuring ldap authentication' do
574 { :config_stomp => true,
576 :ldap_server => 'ldap.example.com',
577 :ldap_user_dn_pattern => 'ou=users,dc=example,dc=com',
578 :ldap_other_bind => 'as_user',
579 :ldap_use_ssl => false,
582 :ldap_config_variables => { 'foo' => 'bar' }
586 it { should contain_rabbitmq_plugin('rabbitmq_auth_backend_ldap') }
588 it 'should contain ldap parameters' do
589 verify_contents(catalogue, 'rabbitmq.config',
590 ['[', ' {rabbit, [', ' {auth_backends, [rabbit_auth_backend_internal, rabbit_auth_backend_ldap]},', ' ]}',
591 ' {rabbitmq_auth_backend_ldap, [', ' {other_bind, as_user},',
592 ' {servers, ["ldap.example.com"]},',
593 ' {user_dn_pattern, "ou=users,dc=example,dc=com"},', ' {use_ssl, false},',
594 ' {port, 389},', ' {foo, bar},', ' {log, true}'])
598 describe 'configuring ldap authentication' do
600 { :config_stomp => false,
602 :ldap_server => 'ldap.example.com',
603 :ldap_user_dn_pattern => 'ou=users,dc=example,dc=com',
604 :ldap_other_bind => 'as_user',
605 :ldap_use_ssl => false,
608 :ldap_config_variables => { 'foo' => 'bar' }
612 it { should contain_rabbitmq_plugin('rabbitmq_auth_backend_ldap') }
614 it 'should contain ldap parameters' do
615 verify_contents(catalogue, 'rabbitmq.config',
616 ['[', ' {rabbit, [', ' {auth_backends, [rabbit_auth_backend_internal, rabbit_auth_backend_ldap]},', ' ]}',
617 ' {rabbitmq_auth_backend_ldap, [', ' {other_bind, as_user},',
618 ' {servers, ["ldap.example.com"]},',
619 ' {user_dn_pattern, "ou=users,dc=example,dc=com"},', ' {use_ssl, false},',
620 ' {port, 389},', ' {foo, bar},', ' {log, true}'])
624 describe 'default_user and default_pass set' do
625 let(:params) {{ :default_user => 'foo', :default_pass => 'bar' }}
626 it 'should set default_user and default_pass to specified values' do
627 should contain_file('rabbitmq.config').with({
628 'content' => /default_user, <<"foo">>.*default_pass, <<"bar">>/m,
633 describe 'interfaces option with no ssl' do
635 { :interface => '0.0.0.0',
638 it 'should set ssl options to specified values' do
639 should contain_file('rabbitmq.config').with_content(%r{tcp_listeners, \[\{"0.0.0.0", 5672\}\]})
643 describe 'ssl options' do
647 :ssl_cacert => '/path/to/cacert',
648 :ssl_cert => '/path/to/cert',
649 :ssl_key => '/path/to/key'
652 it 'should set ssl options to specified values' do
653 should contain_file('rabbitmq.config').with_content(
654 %r{ssl_listeners, \[3141\]}
656 should contain_file('rabbitmq.config').with_content(
659 should contain_file('rabbitmq.config').with_content(
660 %r{cacertfile,"/path/to/cacert"}
662 should contain_file('rabbitmq.config').with_content(
663 %r{certfile,"/path/to/cert"}
665 should contain_file('rabbitmq.config').with_content(
666 %r{keyfile,"/path/to/key"}
672 describe 'ssl options with ssl_interfaces' do
676 :ssl_interface => '0.0.0.0',
677 :ssl_cacert => '/path/to/cacert',
678 :ssl_cert => '/path/to/cert',
679 :ssl_key => '/path/to/key'
682 it 'should set ssl options to specified values' do
683 should contain_file('rabbitmq.config').with_content(%r{ssl_listeners, \[\{"0.0.0.0", 3141\}\]})
684 should contain_file('rabbitmq.config').with_content(%r{cacertfile,"/path/to/cacert"})
685 should contain_file('rabbitmq.config').with_content(%r{certfile,"/path/to/cert"})
686 should contain_file('rabbitmq.config').with_content(%r{keyfile,"/path/to/key})
692 describe 'ssl options with ssl_only' do
697 :ssl_cacert => '/path/to/cacert',
698 :ssl_cert => '/path/to/cert',
699 :ssl_key => '/path/to/key'
702 it 'should set ssl options to specified values' do
703 should contain_file('rabbitmq.config').with_content(%r{tcp_listeners, \[\]})
704 should contain_file('rabbitmq.config').with_content(%r{ssl_listeners, \[3141\]})
705 should contain_file('rabbitmq.config').with_content(%r{ssl_options, \[})
706 should contain_file('rabbitmq.config').with_content(%r{cacertfile,"/path/to/cacert"})
707 should contain_file('rabbitmq.config').with_content(%r{certfile,"/path/to/cert"})
708 should contain_file('rabbitmq.config').with_content(%r{keyfile,"/path/to/key})
712 describe 'ssl options with ssl_only and ssl_interfaces' do
717 :ssl_interface => '0.0.0.0',
718 :ssl_cacert => '/path/to/cacert',
719 :ssl_cert => '/path/to/cert',
720 :ssl_key => '/path/to/key'
723 it 'should set ssl options to specified values' do
724 should contain_file('rabbitmq.config').with_content(%r{tcp_listeners, \[\]})
725 should contain_file('rabbitmq.config').with_content(%r{ssl_listeners, \[\{"0.0.0.0", 3141\}\]})
726 should contain_file('rabbitmq.config').with_content(%r{cacertfile,"/path/to/cacert"})
727 should contain_file('rabbitmq.config').with_content(%r{certfile,"/path/to/cert"})
728 should contain_file('rabbitmq.config').with_content(%r{keyfile,"/path/to/key})
732 describe 'ssl options with specific ssl versions' do
736 :ssl_cacert => '/path/to/cacert',
737 :ssl_cert => '/path/to/cert',
738 :ssl_key => '/path/to/key',
739 :ssl_versions => ['tlsv1.2', 'tlsv1.1']
742 it 'should set ssl options to specified values' do
743 should contain_file('rabbitmq.config').with_content(%r{ssl_listeners, \[3141\]})
744 should contain_file('rabbitmq.config').with_content(%r{ssl_options, \[})
745 should contain_file('rabbitmq.config').with_content(%r{cacertfile,"/path/to/cacert"})
746 should contain_file('rabbitmq.config').with_content(%r{certfile,"/path/to/cert"})
747 should contain_file('rabbitmq.config').with_content(%r{keyfile,"/path/to/key})
748 should contain_file('rabbitmq.config').with_content(%r{ssl, \[\{versions, \['tlsv1.1', 'tlsv1.2'\]\}\]})
749 should contain_file('rabbitmq.config').with_content(%r{versions, \['tlsv1.1', 'tlsv1.2'\]})
753 describe 'ssl options with invalid ssl_versions type' do
757 :ssl_cacert => '/path/to/cacert',
758 :ssl_cert => '/path/to/cert',
759 :ssl_key => '/path/to/key',
760 :ssl_versions => 'tlsv1.2, tlsv1.1'
764 expect { catalogue }.to raise_error(Puppet::Error, /is not an Array/)
768 describe 'ssl options with ssl_versions and not ssl' do
772 :ssl_cacert => '/path/to/cacert',
773 :ssl_cert => '/path/to/cert',
774 :ssl_key => '/path/to/key',
775 :ssl_versions => ['tlsv1.2', 'tlsv1.1']
779 expect { catalogue }.to raise_error(Puppet::Error, /\$ssl_versions requires that \$ssl => true/)
783 describe 'ssl options with ssl ciphers' do
787 :ssl_cacert => '/path/to/cacert',
788 :ssl_cert => '/path/to/cert',
789 :ssl_key => '/path/to/key',
790 :ssl_ciphers => ['ecdhe_rsa,aes_256_cbc,sha', 'dhe_rsa,aes_256_cbc,sha']
793 it 'should set ssl ciphers to specified values' do
794 should contain_file('rabbitmq.config').with_content(%r{ciphers,\[[[:space:]]+{dhe_rsa,aes_256_cbc,sha},[[:space:]]+{ecdhe_rsa,aes_256_cbc,sha}[[:space:]]+\]})
798 describe 'ssl admin options with specific ssl versions' do
801 :ssl_management_port => 5926,
802 :ssl_cacert => '/path/to/cacert',
803 :ssl_cert => '/path/to/cert',
804 :ssl_key => '/path/to/key',
805 :ssl_versions => ['tlsv1.2', 'tlsv1.1'],
806 :admin_enable => true
809 it 'should set admin ssl opts to specified values' do
810 should contain_file('rabbitmq.config').with_content(%r{rabbitmq_management, \[})
811 should contain_file('rabbitmq.config').with_content(%r{listener, \[})
812 should contain_file('rabbitmq.config').with_content(%r{port, 5926\}})
813 should contain_file('rabbitmq.config').with_content(%r{ssl, true\}})
814 should contain_file('rabbitmq.config').with_content(%r{ssl_opts, \[\{cacertfile, "/path/to/cacert"\},})
815 should contain_file('rabbitmq.config').with_content(%r{certfile, "/path/to/cert"\},})
816 should contain_file('rabbitmq.config').with_content(%r{keyfile, "/path/to/key"\}})
817 should contain_file('rabbitmq.config').with_content(%r{,\{versions, \['tlsv1.1', 'tlsv1.2'\]\}[\r\n ]*\]\}})
821 describe 'ssl admin options' do
824 :ssl_management_port => 3141,
825 :ssl_cacert => '/path/to/cacert',
826 :ssl_cert => '/path/to/cert',
827 :ssl_key => '/path/to/key',
828 :admin_enable => true
831 it 'should set rabbitmq_management ssl options to specified values' do
832 should contain_file('rabbitmq.config').with_content(%r{rabbitmq_management, \[})
833 should contain_file('rabbitmq.config').with_content(%r{listener, \[})
834 should contain_file('rabbitmq.config').with_content(%r{port, 3141\}})
835 should contain_file('rabbitmq.config').with_content(%r{ssl, true\}})
836 should contain_file('rabbitmq.config').with_content(%r{ssl_opts, \[\{cacertfile, "/path/to/cacert"\},})
837 should contain_file('rabbitmq.config').with_content(%r{certfile, "/path/to/cert"\},})
838 should contain_file('rabbitmq.config').with_content(%r{keyfile, "/path/to/key"\}[\r\n ]*\]\}})
842 describe 'admin without ssl' do
845 :management_port => 3141,
846 :admin_enable => true
849 it 'should set rabbitmq_management options to specified values' do
850 should contain_file('rabbitmq.config').with_content(%r{rabbitmq_management, \[})
851 should contain_file('rabbitmq.config').with_content(%r{listener, \[})
852 should contain_file('rabbitmq.config').with_content(%r{port, 3141\}})
856 describe 'ssl admin options' do
859 :ssl_management_port => 3141,
860 :ssl_cacert => '/path/to/cacert',
861 :ssl_cert => '/path/to/cert',
862 :ssl_key => '/path/to/key',
863 :admin_enable => true
866 it 'should set rabbitmq_management ssl options to specified values' do
867 should contain_file('rabbitmq.config').with_content(%r{rabbitmq_management, \[})
868 should contain_file('rabbitmq.config').with_content(%r{listener, \[})
869 should contain_file('rabbitmq.config').with_content(%r{port, 3141\},})
870 should contain_file('rabbitmq.config').with_content(%r{ssl, true\},})
871 should contain_file('rabbitmq.config').with_content(%r{ssl_opts, \[\{cacertfile, "/path/to/cacert"\},})
872 should contain_file('rabbitmq.config').with_content(%r{certfile, "/path/to/cert"\},})
873 should contain_file('rabbitmq.config').with_content(%r{keyfile, "/path/to/key"\}[\r\n ]*\]\}})
877 describe 'admin without ssl' do
880 :management_port => 3141,
881 :admin_enable => true
884 it 'should set rabbitmq_management options to specified values' do
885 should contain_file('rabbitmq.config') \
886 .with_content(/\{rabbitmq_management, \[/) \
887 .with_content(/\{listener, \[/) \
888 .with_content(/\{port, 3141\}/)
892 describe 'config_variables options' do
893 let(:params) {{ :config_variables => {
894 'hipe_compile' => true,
895 'vm_memory_high_watermark' => 0.4,
896 'frame_max' => 131072,
897 'collect_statistics' => "none",
898 'auth_mechanisms' => "['PLAIN', 'AMQPLAIN']",
900 it 'should set environment variables' do
901 should contain_file('rabbitmq.config') \
902 .with_content(/\{hipe_compile, true\}/) \
903 .with_content(/\{vm_memory_high_watermark, 0.4\}/) \
904 .with_content(/\{frame_max, 131072\}/) \
905 .with_content(/\{collect_statistics, none\}/) \
906 .with_content(/\{auth_mechanisms, \['PLAIN', 'AMQPLAIN'\]\}/)
910 describe 'config_kernel_variables options' do
911 let(:params) {{ :config_kernel_variables => {
912 'inet_dist_listen_min' => 9100,
913 'inet_dist_listen_max' => 9105,
915 it 'should set config variables' do
916 should contain_file('rabbitmq.config') \
917 .with_content(/\{inet_dist_listen_min, 9100\}/) \
918 .with_content(/\{inet_dist_listen_max, 9105\}/)
922 describe 'tcp_keepalive enabled' do
923 let(:params) {{ :tcp_keepalive => true }}
924 it 'should set tcp_listen_options keepalive true' do
925 should contain_file('rabbitmq.config') \
926 .with_content(/\{tcp_listen_options, \[\{keepalive, true\}\]\},/)
930 describe 'tcp_keepalive disabled (default)' do
931 it 'should not set tcp_listen_options' do
932 should contain_file('rabbitmq.config') \
933 .without_content(/\{tcp_listen_options, \[\{keepalive, true\}\]\},/)
937 describe 'non-bool tcp_keepalive parameter' do
939 { :tcp_keepalive => 'string' }
942 it 'should raise an error' do
944 should contain_file('rabbitmq.config')
945 }.to raise_error(Puppet::Error, /is not a boolean/)
949 context 'delete_guest_user' do
950 describe 'should do nothing by default' do
951 it { should_not contain_rabbitmq_user('guest') }
954 describe 'delete user when delete_guest_user set' do
955 let(:params) {{ :delete_guest_user => true }}
956 it 'removes the user' do
957 should contain_rabbitmq_user('guest').with(
958 'ensure' => 'absent',
959 'provider' => 'rabbitmqctl'
968 describe 'service with default params' do
969 it { should contain_service('rabbitmq-server').with(
970 'ensure' => 'running',
972 'hasstatus' => 'true',
973 'hasrestart' => 'true'
977 describe 'service with ensure stopped' do
979 { :service_ensure => 'stopped' }
982 it { should contain_service('rabbitmq-server').with(
983 'ensure' => 'stopped',
988 describe 'service with ensure neither running neither stopped' do
990 { :service_ensure => 'foo' }
993 it 'should raise an error' do
995 should contain_service('rabbitmq-server').with(
996 'ensure' => 'stopped' )
997 }.to raise_error(Puppet::Error, /validate_re\(\): "foo" does not match "\^\(running\|stopped\)\$"/)
1001 describe 'service with service_manage equal to false' do
1003 { :service_manage => false }
1006 it { should_not contain_service('rabbitmq-server') }
1013 ## rabbitmq::install
1015 context "on RHEL" do
1016 let(:facts) {{ :osfamily => 'RedHat' }}
1017 let(:params) {{ :package_source => 'http://www.rabbitmq.com/releases/rabbitmq-server/v3.2.3/rabbitmq-server-3.2.3-1.noarch.rpm' }}
1018 it 'installs the rabbitmq package' do
1019 should contain_package('rabbitmq-server').with(
1020 'ensure' => 'installed',
1021 'name' => 'rabbitmq-server',
1022 'provider' => 'rpm',
1023 'source' => 'http://www.rabbitmq.com/releases/rabbitmq-server/v3.2.3/rabbitmq-server-3.2.3-1.noarch.rpm'
1028 context "on Debian" do
1029 let(:facts) {{ :osfamily => 'Debian', :lsbdistid => 'Debian', :lsbdistcodename => 'precise' }}
1030 it 'installs the rabbitmq package' do
1031 should contain_package('rabbitmq-server').with(
1032 'ensure' => 'installed',
1033 'name' => 'rabbitmq-server',
1039 context "on Archlinux" do
1040 let(:facts) {{ :osfamily => 'Archlinux' }}
1041 it 'installs the rabbitmq package' do
1042 should contain_package('rabbitmq-server').with(
1043 'ensure' => 'installed',
1044 'name' => 'rabbitmq')
1048 describe 'repo management on Debian' do
1049 let(:facts) {{ :osfamily => 'Debian', :lsbdistid => 'Debian' }}
1051 context 'with no pin' do
1052 let(:params) {{ :package_apt_pin => '' }}
1053 describe 'it sets up an apt::source' do
1055 it { should contain_apt__source('rabbitmq').with(
1056 'location' => 'http://www.rabbitmq.com/debian/',
1057 'release' => 'testing',
1059 'include_src' => false,
1060 'key' => 'F78372A06FF50C80464FC1B4F7B8CEA6056E8E56'
1065 context 'with pin' do
1066 let(:params) {{ :package_apt_pin => '700' }}
1067 describe 'it sets up an apt::source and pin' do
1069 it { should contain_apt__source('rabbitmq').with(
1070 'location' => 'http://www.rabbitmq.com/debian/',
1071 'release' => 'testing',
1073 'include_src' => false,
1074 'key' => 'F78372A06FF50C80464FC1B4F7B8CEA6056E8E56'
1077 it { should contain_apt__pin('rabbitmq').with(
1078 'packages' => 'rabbitmq-server',
1086 ['RedHat', 'SuSE'].each do |distro|
1087 describe "repo management on #{distro}" do
1088 describe 'imports the key' do
1089 let(:facts) {{ :osfamily => distro }}
1090 let(:params) {{ :package_gpg_key => 'http://www.rabbitmq.com/rabbitmq-signing-key-public.asc' }}
1092 it { should contain_exec("rpm --import #{params[:package_gpg_key]}").with(
1093 'path' => ['/bin','/usr/bin','/sbin','/usr/sbin']