Skip to content

Commit

Permalink
Fix Test
Browse files Browse the repository at this point in the history
initial refactoring of acceptance
fix test failing on puppet 8
remove unused erlang module from fixture
bump dependency version
  • Loading branch information
Roberto Valentini committed Apr 2, 2024
1 parent c4785ff commit 13e510c
Show file tree
Hide file tree
Showing 15 changed files with 105 additions and 243 deletions.
1 change: 0 additions & 1 deletion .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ fixtures:
stdlib: 'https://github.com/puppetlabs/puppetlabs-stdlib'
apt: 'https://github.com/puppetlabs/puppetlabs-apt'
archive: 'https://github.com/voxpupuli/puppet-archive'
erlang: 'https://github.com/garethr/garethr-erlang'
systemd: 'https://github.com/voxpupuli/puppet-systemd'
yumrepo_core: 'https://github.com/puppetlabs/puppetlabs-yumrepo_core'
2 changes: 2 additions & 0 deletions lib/puppet/type/rabbitmq_parameter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ def munge_value(value)
return value if value(:autoconvert) == :false

value.each do |k, v|
next if v.is_a?(Array)

value[k] = v.to_i if v =~ %r{\A[-+]?[0-9]+\z}
end
value
Expand Down
6 changes: 3 additions & 3 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@
"dependencies": [
{
"name": "puppetlabs/stdlib",
"version_requirement": ">= 4.25.0 < 9.0.0"
"version_requirement": ">= 4.25.0 < 10.0.0"
},
{
"name": "puppet/archive",
"version_requirement": ">= 2.0.0 < 7.0.0"
"version_requirement": ">= 2.0.0 < 8.0.0"
},
{
"name": "puppet/systemd",
"version_requirement": ">= 2.10.0 < 5.0.0"
"version_requirement": ">= 2.10.0 < 7.0.0"
}
],
"tags": [
Expand Down
132 changes: 60 additions & 72 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,14 @@
end

context 'default class inclusion' do
let(:pp) do
<<-EOS
class { 'rabbitmq': }
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
EOS
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'rabbitmq': }
PUPPET
end
end

it_behaves_like 'an idempotent resource'

describe package(package_name) do
it { is_expected.to be_installed }

Check failure on line 25 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 - CentOS 7

rabbitmq class: default class inclusion Package "rabbitmq-server" is expected to be installed Failure/Error: it { is_expected.to be_installed } expected Package "rabbitmq-server" to be installed
end
Expand All @@ -49,20 +45,20 @@ class { 'erlang': epel_enable => true}
end

context 'disable and stop service' do
let(:pp) do
<<-EOS
class { 'rabbitmq':
service_ensure => 'stopped',
}
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
EOS
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'rabbitmq':
service_ensure => 'stopped',
}
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
PUPPET
end
end

it_behaves_like 'an idempotent resource'

describe service(service_name) do
it { is_expected.not_to be_enabled }
it { is_expected.not_to be_running }
Expand All @@ -73,21 +69,13 @@ class { 'erlang': epel_enable => true}
it 'runs successfully' do
pp_pre = <<-EOS
class { 'rabbitmq': }
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
EOS

pp = <<-EOS
class { 'rabbitmq':
service_manage => false,
service_ensure => 'stopped',
}
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
EOS

apply_manifest(pp_pre, catch_failures: true)
Expand All @@ -101,19 +89,19 @@ class { 'erlang': epel_enable => true}
end

context 'binding on all interfaces' do
let(:pp) do
<<-EOS
class { 'rabbitmq':
service_manage => true,
port => 5672,
admin_enable => true,
node_ip_address => '0.0.0.0'
}
EOS
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'rabbitmq':
service_manage => true,
port => 5672,
admin_enable => true,
node_ip_address => '0.0.0.0'
}
PUPPET
end
end

it_behaves_like 'an idempotent resource'

describe service(service_name) do
it { is_expected.to be_running }
end
Expand All @@ -134,19 +122,19 @@ class { 'rabbitmq':
end

context 'binding to localhost only' do
let(:pp) do
<<-EOS
class { 'rabbitmq':
service_manage => true,
port => 5672,
admin_enable => true,
node_ip_address => '127.0.0.1'
}
EOS
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'rabbitmq':
service_manage => true,
port => 5672,
admin_enable => true,
node_ip_address => '127.0.0.1'
}
PUPPET
end
end

it_behaves_like 'an idempotent resource'

describe service(service_name) do
it { is_expected.to be_running }
end
Expand All @@ -169,23 +157,23 @@ class { 'rabbitmq':
end

context 'ssl enabled' do
let(:pp) do
<<-EOS
class { 'rabbitmq':
service_manage => true,
admin_enable => true,
node_ip_address => '0.0.0.0',
ssl_interface => '0.0.0.0',
ssl => true,
ssl_cacert => '/tmp/cacert.crt',
ssl_cert => '/tmp/rabbitmq.crt',
ssl_key => '/tmp/rabbitmq.key',
}
EOS
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'rabbitmq':
service_manage => true,
admin_enable => true,
node_ip_address => '0.0.0.0',
ssl_interface => '0.0.0.0',
ssl => true,
ssl_cacert => '/tmp/cacert.crt',
ssl_cert => '/tmp/rabbitmq.crt',
ssl_key => '/tmp/rabbitmq.key',
}
PUPPET
end
end

it_behaves_like 'an idempotent resource'

describe service(service_name) do
it { is_expected.to be_running }
end
Expand All @@ -200,20 +188,20 @@ class { 'rabbitmq':
end

context 'different management_ip_address and node_ip_address' do
let(:pp) do
<<-EOS
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'rabbitmq':
service_manage => true,
port => 5672,
admin_enable => true,
node_ip_address => '0.0.0.0',
management_ip_address => '127.0.0.1'
}
EOS
PUPPET
end
end

it_behaves_like 'an idempotent resource'

describe service(service_name) do
it { is_expected.to be_running }
end
Expand Down
12 changes: 0 additions & 12 deletions spec/acceptance/clustering_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ class { 'rabbitmq':
erlang_cookie => 'TESTCOOKIE',
wipe_db_on_cookie_change => false,
}
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
EOS

apply_manifest(pp, expect_failures: true)
Expand All @@ -39,10 +35,6 @@ class { 'rabbitmq':
erlang_cookie => 'TESTCOOKIE',
wipe_db_on_cookie_change => true,
}
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
EOS

apply_manifest(pp, catch_failures: true)
Expand Down Expand Up @@ -84,10 +76,6 @@ class { 'rabbitmq':
environment_variables => { 'NODENAME' => 'rabbit@foobar' },
erlang_cookie => 'TESTCOOKIE',
}
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
EOS

apply_manifest(pp, expect_failures: true)
Expand Down
4 changes: 0 additions & 4 deletions spec/acceptance/delete_guest_user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ class { 'rabbitmq':
port => 5672,
delete_guest_user => true,
}
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
EOS

apply_manifest(pp, catch_failures: true)
Expand Down
4 changes: 0 additions & 4 deletions spec/acceptance/parameter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
context 'create parameter resource' do
it 'runs successfully' do
pp = <<-EOS
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true }
Class['erlang'] -> Class['rabbitmq']
}
class { 'rabbitmq':
service_manage => true,
port => 5672,
Expand Down
4 changes: 0 additions & 4 deletions spec/acceptance/policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
context 'create policy resource' do
it 'runs successfully' do
pp = <<-EOS
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true }
Class['erlang'] -> Class['rabbitmq']
}
class { 'rabbitmq':
service_manage => true,
port => 5672,
Expand Down
12 changes: 0 additions & 12 deletions spec/acceptance/queue_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
context 'create binding and queue resources when using default management port' do
it 'runs successfully' do
pp = <<-EOS
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true }
Class['erlang'] -> Class['rabbitmq']
}
class { 'rabbitmq':
service_manage => true,
port => 5672,
Expand Down Expand Up @@ -80,10 +76,6 @@ class { 'rabbitmq':
context 'create multiple bindings when same source / destination / vhost but different routing keys' do
it 'runs successfully' do
pp = <<-EOS
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true }
Class['erlang'] -> Class['rabbitmq']
}
class { 'rabbitmq':
service_manage => true,
port => 5672,
Expand Down Expand Up @@ -168,10 +160,6 @@ class { 'rabbitmq':
context 'create binding and queue resources when using a non-default management port' do
it 'runs successfully' do
pp = <<-EOS
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true }
Class['erlang'] -> Class['rabbitmq']
}
class { 'rabbitmq':
service_manage => true,
port => 5672,
Expand Down
16 changes: 0 additions & 16 deletions spec/acceptance/rabbitmqadmin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ class { 'rabbitmq':
admin_enable => true,
service_manage => true,
}
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
EOS

apply_manifest(pp, catch_failures: true)
Expand All @@ -31,10 +27,6 @@ class { 'rabbitmq':
admin_enable => true,
service_manage => false,
}
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
EOS

shell('rm -f /var/lib/rabbitmq/rabbitmqadmin')
Expand All @@ -55,10 +47,6 @@ class { 'rabbitmq':
default_user => 'foobar',
default_pass => 'bazblam',
}
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
EOS

pp = <<-EOS
Expand All @@ -68,10 +56,6 @@ class { 'rabbitmq':
default_user => 'foobar',
default_pass => 'bazblam',
}
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
EOS

shell('rm -f /var/lib/rabbitmq/rabbitmqadmin')
Expand Down
4 changes: 0 additions & 4 deletions spec/acceptance/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
context 'create user resource' do
it 'runs successfully' do
pp = <<-EOS
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true }
Class['erlang'] -> Class['rabbitmq']
}
class { 'rabbitmq':
service_manage => true,
port => 5672,
Expand Down
Loading

0 comments on commit 13e510c

Please sign in to comment.