1 require 'spec_helper_acceptance'
3 describe 'rabbitmq binding:' do
4 context 'create binding and queue resources when using default management port' do
5 it 'runs successfully' do
7 if $facts['os']['family'] == 'RedHat' {
8 class { 'erlang': epel_enable => true }
9 Class['erlang'] -> Class['rabbitmq']
12 service_manage => true,
14 delete_guest_user => true,
18 rabbitmq_user { 'dan':
21 tags => ['monitoring', 'tag1'],
24 rabbitmq_user_permissions { 'dan@host1':
25 configure_permission => '.*',
26 read_permission => '.*',
27 write_permission => '.*',
30 rabbitmq_vhost { 'host1':
34 rabbitmq_exchange { 'exchange1@host1':
41 rabbitmq_queue { 'queue1@host1':
49 rabbitmq_binding { 'exchange1@queue1@host1':
52 destination_type => 'queue',
59 apply_manifest(pp, catch_failures: true)
60 apply_manifest(pp, catch_changes: true)
63 # rubocop:disable RSpec/MultipleExpectations
64 it 'has the binding' do
65 shell('rabbitmqctl list_bindings -q -p host1') do |r|
66 expect(r.stdout).to match(%r{exchange1\sexchange\squeue1\squeue\s#})
67 expect(r.exit_code).to be_zero
72 shell('rabbitmqctl list_queues -q -p host1') do |r|
73 expect(r.stdout).to match(%r{queue1})
74 expect(r.exit_code).to be_zero
77 # rubocop:enable RSpec/MultipleExpectations
80 context 'create multiple bindings when same source / destination / vhost but different routing keys' do
81 it 'runs successfully' do
83 if $facts['os']['family'] == 'RedHat' {
84 class { 'erlang': epel_enable => true }
85 Class['erlang'] -> Class['rabbitmq']
88 service_manage => true,
90 delete_guest_user => true,
94 rabbitmq_user { 'dan':
97 tags => ['monitoring', 'tag1'],
100 rabbitmq_user_permissions { 'dan@host1':
101 configure_permission => '.*',
102 read_permission => '.*',
103 write_permission => '.*',
106 rabbitmq_vhost { 'host1':
110 rabbitmq_exchange { 'exchange1@host1':
117 rabbitmq_queue { 'queue1@host1':
121 auto_delete => false,
125 rabbitmq_binding { 'binding 1':
126 source => 'exchange1',
127 destination => 'queue1',
131 destination_type => 'queue',
132 routing_key => 'test1',
136 rabbitmq_binding { 'binding 2':
137 source => 'exchange1',
138 destination => 'queue1',
142 destination_type => 'queue',
143 routing_key => 'test2',
149 apply_manifest(pp, catch_failures: true)
150 apply_manifest(pp, catch_changes: true)
153 # rubocop:disable RSpec/MultipleExpectations
154 it 'has the bindings' do
155 shell('rabbitmqctl list_bindings -q -p host1') do |r|
156 expect(r.stdout).to match(%r{exchange1\sexchange\squeue1\squeue\stest1})
157 expect(r.stdout).to match(%r{exchange1\sexchange\squeue1\squeue\stest2})
158 expect(r.exit_code).to be_zero
161 # rubocop:enable RSpec/MultipleExpectations
163 it 'puppet resource shows a binding' do
164 shell('puppet resource rabbitmq_binding') do |r|
165 expect(r.stdout).to match(%r{source\s+=>\s+'exchange1',})
170 context 'create binding and queue resources when using a non-default management port' do
171 it 'runs successfully' do
173 if $facts['os']['family'] == 'RedHat' {
174 class { 'erlang': epel_enable => true }
175 Class['erlang'] -> Class['rabbitmq']
178 service_manage => true,
180 management_port => 11111,
181 delete_guest_user => true,
182 admin_enable => true,
185 rabbitmq_user { 'dan':
188 tags => ['monitoring', 'tag1'],
191 rabbitmq_user_permissions { 'dan@host2':
192 configure_permission => '.*',
193 read_permission => '.*',
194 write_permission => '.*',
197 rabbitmq_vhost { 'host2':
201 rabbitmq_exchange { 'exchange2@host2':
208 rabbitmq_queue { 'queue2@host2':
212 auto_delete => false,
216 rabbitmq_binding { 'exchange2@queue2@host2':
219 destination_type => 'queue',
226 apply_manifest(pp, catch_failures: true)
227 apply_manifest(pp, catch_changes: true)
230 # rubocop:disable RSpec/MultipleExpectations
231 it 'has the binding' do
232 shell('rabbitmqctl list_bindings -q -p host2') do |r|
233 expect(r.stdout).to match(%r{exchange2\sexchange\squeue2\squeue\s#})
234 expect(r.exit_code).to be_zero
238 it 'has the queue' do
239 shell('rabbitmqctl list_queues -q -p host2') do |r|
240 expect(r.stdout).to match(%r{queue2})
241 expect(r.exit_code).to be_zero
244 # rubocop:enable RSpec/MultipleExpectations