X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Frabbitmq%2Fspec%2Facceptance%2Fclass_spec.rb;h=b5b50cd346e486e3c8bdf22f5fd9be178e735324;hb=e107504bce7d9b21cc301124fc7c39fdb0762374;hp=bfb70e0d4cedb527d605ff68508dc88aefb8b04a;hpb=921e69100a563cf143f56a3905d8362336d939ff;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/rabbitmq/spec/acceptance/class_spec.rb b/3rdparty/modules/rabbitmq/spec/acceptance/class_spec.rb index bfb70e0d4..b5b50cd34 100644 --- a/3rdparty/modules/rabbitmq/spec/acceptance/class_spec.rb +++ b/3rdparty/modules/rabbitmq/spec/acceptance/class_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper_acceptance' describe 'rabbitmq class:' do - case fact('os.family') + case fact('osfamily') when 'RedHat' package_name = 'rabbitmq-server' service_name = 'rabbitmq-server' @@ -16,199 +16,80 @@ describe 'rabbitmq class:' do service_name = 'rabbitmq' end - context 'default class inclusion' do - let(:pp) do - <<-EOS + context "default class inclusion" do + it 'should run successfully' do + pp = <<-EOS class { 'rabbitmq': } - if $facts['os']['family'] == 'RedHat' { + if $::osfamily == 'RedHat' { class { 'erlang': epel_enable => true} Class['erlang'] -> Class['rabbitmq'] } EOS - end - it_behaves_like 'an idempotent resource' + # Apply twice to ensure no errors the second time. + apply_manifest(pp, :catch_failures => true) + expect(apply_manifest(pp, :catch_changes => true).exit_code).to be_zero + end describe package(package_name) do - it { is_expected.to be_installed } + it { should be_installed } end describe service(service_name) do - it { is_expected.to be_enabled } - it { is_expected.to be_running } + it { should be_enabled } + it { should be_running } end 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'] - } + context "disable and stop service" do + it 'should run successfully' do + pp = <<-EOS + class { 'rabbitmq': + service_ensure => 'stopped', + } + if $::osfamily == 'RedHat' { + class { 'erlang': epel_enable => true} + Class['erlang'] -> Class['rabbitmq'] + } EOS - end - it_behaves_like 'an idempotent resource' + apply_manifest(pp, :catch_failures => true) + end describe service(service_name) do - it { is_expected.not_to be_enabled } - it { is_expected.not_to be_running } + it { should_not be_enabled } + it { should_not be_running } end end - context 'service is unmanaged' do - it 'runs successfully' do + context "service is unmanaged" do + it 'should run successfully' do pp_pre = <<-EOS - class { 'rabbitmq': } - if $facts['os']['family'] == 'RedHat' { - class { 'erlang': epel_enable => true} - Class['erlang'] -> Class['rabbitmq'] - } + class { 'rabbitmq': } + if $::osfamily == '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) - apply_manifest(pp, catch_failures: true) - end - - describe service(service_name) do - it { is_expected.to be_enabled } - it { is_expected.to be_running } - end - 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' + service_manage => false, + service_ensure => 'stopped', + } + if $::osfamily == 'RedHat' { + class { 'erlang': epel_enable => true} + Class['erlang'] -> Class['rabbitmq'] } EOS - end - - it_behaves_like 'an idempotent resource' - - describe service(service_name) do - it { is_expected.to be_running } - end - describe port(5672) do - it { is_expected.to be_listening.on('0.0.0.0').with('tcp') } - end - describe port(15_672) do - it { is_expected.to be_listening.on('0.0.0.0').with('tcp') } - end - describe port(25_672) do - xit 'Is on 55672 instead on older rmq versions' do - is_expected.to be_listening.on('0.0.0.0').with('tcp') - end - end - 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 - end - - it_behaves_like 'an idempotent resource' - - describe service(service_name) do - it { is_expected.to be_running } - end - describe port(5672) do - it { is_expected.to be_listening.on('127.0.0.1').with('tcp') } - end - describe port(15_672) do - it { is_expected.to be_listening.on('127.0.0.1').with('tcp') } - end - # This listens on all interfaces regardless of these settings - describe port(25_672) do - xit 'Is on 55672 instead on older rmq versions' do - is_expected.to be_listening.on('0.0.0.0').with('tcp') - end - end - 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 - end - - it_behaves_like 'an idempotent resource' - describe service(service_name) do - it { is_expected.to be_running } - end - describe port(5671) do - it { is_expected.to be_listening.on('0.0.0.0').with('tcp') } + apply_manifest(pp_pre, :catch_failures => true) + apply_manifest(pp, :catch_failures => true) end - describe port(15_671) do - it { is_expected.to be_listening.on('0.0.0.0').with('tcp') } - end - end - - context 'different management_ip_address and node_ip_address' do - let(:pp) do - <<-EOS - 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 - end - - it_behaves_like 'an idempotent resource' describe service(service_name) do - it { is_expected.to be_running } - end - describe port(5672) do - it { is_expected.to be_listening.on('0.0.0.0').with('tcp') } - end - describe port(15_672) do - it { is_expected.to be_listening.on('127.0.0.1').with('tcp') } - end - describe port(25_672) do - xit 'Is on 55672 instead on older rmq versions' do - is_expected.to be_listening.on('0.0.0.0').with('tcp') - end + it { should be_enabled } + it { should be_running } end end end