]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/rabbitmq/spec/acceptance/queue_spec.rb
move to puppetlabs rabbitmq module
[dsa-puppet.git] / 3rdparty / modules / rabbitmq / spec / acceptance / queue_spec.rb
1 require 'spec_helper_acceptance'
2
3 describe 'rabbitmq binding:' do
4
5
6   context "create binding and queue resources when rabbit using default management port" do
7     it 'should run successfully' do
8       pp = <<-EOS
9       if $::osfamily == 'RedHat' {
10         class { 'erlang': epel_enable => true }
11         Class['erlang'] -> Class['::rabbitmq']
12       }
13       class { '::rabbitmq':
14         service_manage    => true,
15         port              => '5672',
16         delete_guest_user => true,
17         admin_enable      => true,
18       } ->
19
20       rabbitmq_user { 'dan':
21         admin    => true,
22         password => 'bar',
23         tags     => ['monitoring', 'tag1'],
24       } ->
25       
26       rabbitmq_user_permissions { 'dan@host1':
27         configure_permission => '.*',
28         read_permission      => '.*',
29         write_permission     => '.*',
30       }
31
32       rabbitmq_vhost { 'host1':
33         ensure => present,
34       } ->
35
36       rabbitmq_exchange { 'exchange1@host1':
37         user     => 'dan',
38         password => 'bar',
39         type     => 'topic',
40         ensure   => present,
41       } ->
42
43       rabbitmq_queue { 'queue1@host1':
44         user        => 'dan',
45         password    => 'bar',
46         durable     => true,
47         auto_delete => false,
48         ensure      => present,
49       } ->
50
51       rabbitmq_binding { 'exchange1@queue1@host1':
52         user             => 'dan',
53         password         => 'bar',
54         destination_type => 'queue',
55         routing_key      => '#',
56         ensure           => present,
57       }
58       
59       EOS
60
61       apply_manifest(pp, :catch_failures => true)
62       apply_manifest(pp, :catch_changes => true)
63     end
64
65     it 'should have the binding' do
66       shell('rabbitmqctl list_bindings -q -p host1') do |r|
67         expect(r.stdout).to match(/exchange1\sexchange\squeue1\squeue\s#/)
68         expect(r.exit_code).to be_zero
69       end
70     end
71     
72     it 'should have the queue' do
73       shell('rabbitmqctl list_queues -q -p host1') do |r|
74         expect(r.stdout).to match(/queue1/)
75         expect(r.exit_code).to be_zero
76       end
77     end
78
79   end
80   
81   context "create binding and queue resources when rabbit using a non-default management port" do
82     it 'should run successfully' do
83       pp = <<-EOS
84       if $::osfamily == 'RedHat' {
85         class { 'erlang': epel_enable => true }
86         Class['erlang'] -> Class['::rabbitmq']
87       }
88       class { '::rabbitmq':
89         service_manage    => true,
90         port              => '5672',
91         management_port   => '11111',
92         delete_guest_user => true,
93         admin_enable      => true,
94       } ->
95
96       rabbitmq_user { 'dan':
97         admin    => true,
98         password => 'bar',
99         tags     => ['monitoring', 'tag1'],
100       } ->
101       
102       rabbitmq_user_permissions { 'dan@host2':
103         configure_permission => '.*',
104         read_permission      => '.*',
105         write_permission     => '.*',
106       }
107
108       rabbitmq_vhost { 'host2':
109         ensure => present,
110       } ->
111
112       rabbitmq_exchange { 'exchange2@host2':
113         user     => 'dan',
114         password => 'bar',
115         type     => 'topic',
116         ensure   => present,
117       } ->
118
119       rabbitmq_queue { 'queue2@host2':
120         user        => 'dan',
121         password    => 'bar',
122         durable     => true,
123         auto_delete => false,
124         ensure      => present,
125       } ->
126
127       rabbitmq_binding { 'exchange2@queue2@host2':
128         user             => 'dan',
129         password         => 'bar',
130         destination_type => 'queue',
131         routing_key      => '#',
132         ensure           => present,
133       }
134      
135       EOS
136
137       apply_manifest(pp, :catch_failures => true)
138       apply_manifest(pp, :catch_changes => true)
139     end
140
141     it 'should have the binding' do
142       shell('rabbitmqctl list_bindings -q -p host2') do |r|
143         expect(r.stdout).to match(/exchange2\sexchange\squeue2\squeue\s#/)
144         expect(r.exit_code).to be_zero
145       end
146     end
147     
148     it 'should have the queue' do
149       shell('rabbitmqctl list_queues -q -p host2') do |r|
150         expect(r.stdout).to match(/queue2/)
151         expect(r.exit_code).to be_zero
152       end
153     end
154
155   end
156   
157 end