Skip to content

Commit 69c779d

Browse files
author
Roberto Valentini
committed
Fix Test
initial refactoring of acceptance port test to rspec-mock remove unused erlang module from fixture bump dependency version user facts['service_provider] instead facts[systemd]
1 parent 4bf82ef commit 69c779d

39 files changed

+846
-1019
lines changed

.fixtures.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@ fixtures:
33
stdlib: 'https://github.com/puppetlabs/puppetlabs-stdlib'
44
apt: 'https://github.com/puppetlabs/puppetlabs-apt'
55
archive: 'https://github.com/voxpupuli/puppet-archive'
6-
erlang: 'https://github.com/garethr/garethr-erlang'
76
systemd: 'https://github.com/voxpupuli/puppet-systemd'
87
yumrepo_core: 'https://github.com/puppetlabs/puppetlabs-yumrepo_core'

lib/facter/rabbitmq_nodename.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
if Facter::Util::Resolution.which('rabbitmqctl')
66
rabbitmq_nodename = Facter::Core::Execution.execute('rabbitmqctl status 2>&1')
77
begin
8-
%r{^Status of node '?([\w.\-]+@[\w.\-]+)'?}.match(rabbitmq_nodename)[1]
8+
%r{^Status of node '?([\w.-]+@[\w.-]+)'?}.match(rabbitmq_nodename)[1]
99
rescue StandardError
1010
Facter.debug("Error: rabbitmq_nodename facter failed. Output was #{rabbitmq_nodename}")
1111
end

manifests/config.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@
234234
default: {}
235235
}
236236
237-
if $facts['systemd'] { # systemd fact provided by systemd module
237+
if $facts['service_provider'] == 'systemd' { # systemd fact provided by systemd module
238238
systemd::service_limits { "${service_name}.service":
239239
selinux_ignore_defaults => ($facts['os']['family'] == 'RedHat'),
240240
limits => {

manifests/service.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
hasrestart => true,
2828
name => $service_name,
2929
}
30-
if $facts['systemd'] and defined(Class['systemd::systemctl::daemon_reload']) {
30+
if $facts['service_provider'] == 'systemd' and defined(Class['systemd::systemctl::daemon_reload']) {
3131
Class['systemd::systemctl::daemon_reload'] -> Service['rabbitmq-server']
3232
}
3333
}

metadata.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@
5858
"dependencies": [
5959
{
6060
"name": "puppetlabs/stdlib",
61-
"version_requirement": ">= 4.25.0 < 9.0.0"
61+
"version_requirement": ">= 4.25.0 < 10.0.0"
6262
},
6363
{
6464
"name": "puppet/archive",
65-
"version_requirement": ">= 2.0.0 < 7.0.0"
65+
"version_requirement": ">= 2.0.0 < 8.0.0"
6666
},
6767
{
6868
"name": "puppet/systemd",
69-
"version_requirement": ">= 2.10.0 < 5.0.0"
69+
"version_requirement": ">= 2.10.0 < 7.0.0"
7070
}
7171
],
7272
"tags": [

spec/acceptance/binding_spec.rb

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper_acceptance'
4+
5+
describe 'rabbitmq_binding:' do
6+
before do
7+
pp = <<-EOS
8+
class { 'rabbitmq':
9+
service_manage => true,
10+
port => 5672,
11+
delete_guest_user => true,
12+
admin_enable => true,
13+
}
14+
-> rabbitmq_user { 'dan':
15+
admin => true,
16+
password => 'bar',
17+
tags => ['monitoring', 'tag1'],
18+
}
19+
-> rabbitmq_user_permissions { 'dan@host1':
20+
configure_permission => '.*',
21+
read_permission => '.*',
22+
write_permission => '.*',
23+
}
24+
rabbitmq_vhost { 'host1':
25+
ensure => present,
26+
}
27+
-> rabbitmq_exchange { 'exchange1@host1':
28+
user => 'dan',
29+
password => 'bar',
30+
type => 'topic',
31+
ensure => present,
32+
}
33+
-> rabbitmq_queue { 'queue1@host1':
34+
user => 'dan',
35+
password => 'bar',
36+
durable => true,
37+
auto_delete => false,
38+
ensure => present,
39+
}
40+
EOS
41+
42+
apply_manifest(pp, catch_failures: true)
43+
end
44+
45+
context 'when using one routing_key' do
46+
it_behaves_like 'an idempotent resource' do
47+
let(:manifest) do
48+
<<-PUPPET
49+
rabbitmq_binding { 'exchange1@queue1@host1':
50+
user => 'dan',
51+
password => 'bar',
52+
destination_type => 'queue',
53+
routing_key => '#',
54+
ensure => present,
55+
}
56+
PUPPET
57+
end
58+
end
59+
60+
it 'binding exist' do
61+
shell('rabbitmqctl list_bindings -q -p host1') do |r|
62+
expect(r.stdout).to match(%r{exchange1\sexchange\squeue1\squeue\s#})
63+
expect(r.exit_code).to be_zero
64+
end
65+
end
66+
67+
it 'resource has the queue' do
68+
shell('rabbitmqctl list_queues -q -p host1') do |r|
69+
expect(r.stdout).to match(%r{queue1})
70+
expect(r.exit_code).to be_zero
71+
end
72+
end
73+
end
74+
75+
context 'when using two routing_keys' do
76+
it_behaves_like 'an idempotent resource' do
77+
let(:manifest) do
78+
<<-PUPPET
79+
rabbitmq_binding { 'binding 1':
80+
source => 'exchange1',
81+
destination => 'queue1',
82+
user => 'dan',
83+
vhost => 'host1',
84+
password => 'bar',
85+
destination_type => 'queue',
86+
routing_key => 'test1',
87+
ensure => present,
88+
}
89+
-> rabbitmq_binding { 'binding 2':
90+
source => 'exchange1',
91+
destination => 'queue1',
92+
user => 'dan',
93+
vhost => 'host1',
94+
password => 'bar',
95+
destination_type => 'queue',
96+
routing_key => 'test2',
97+
ensure => present,
98+
}
99+
PUPPET
100+
end
101+
end
102+
103+
it 'resource has the bindings' do
104+
shell('rabbitmqctl list_bindings -q -p host1') do |r|
105+
expect(r.stdout).to match(%r{exchange1\sexchange\squeue1\squeue\stest1})
106+
expect(r.stdout).to match(%r{exchange1\sexchange\squeue1\squeue\stest2})
107+
expect(r.exit_code).to be_zero
108+
end
109+
end
110+
111+
it 'puppet resource shows a binding' do
112+
shell('puppet resource rabbitmq_binding') do |r|
113+
expect(r.stdout).to match(%r{source\s+=>\s+'exchange1',})
114+
end
115+
end
116+
end
117+
end

0 commit comments

Comments
 (0)