1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
require 'spec_helper'
describe 'aodh::expirer' do
shared_examples 'aodh::expirer' do
let :params do
{}
end
context 'with default' do
it { is_expected.to contain_class('aodh::deps') }
it { is_expected.to contain_class('aodh::params') }
it { is_expected.to contain_aodh_config('database/alarm_histories_delete_batch_size').with_value('<SERVICE DEFAULT>') }
it 'installs aodh-expirer package' do
is_expected.to contain_package('aodh-expirer').with(
:ensure => 'present',
:name => platform_params[:expirer_package_name],
:tag => ['openstack', 'aodh-package']
)
end
it { is_expected.to contain_cron('aodh-expirer').with(
:ensure => 'present',
:command => 'aodh-expirer',
:environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
:user => 'aodh',
:minute => 1,
:hour => 0,
:monthday => '*',
:month => '*',
:weekday => '*',
:require => 'Anchor[aodh::dbsync::end]'
)}
end
context 'with overridden parameters' do
before do
params.merge!(
:ensure => 'absent',
:maxdelay => 300,
:alarm_histories_delete_batch_size => 500
)
end
it { is_expected.to contain_class('aodh::deps') }
it { is_expected.to contain_class('aodh::params') }
it { is_expected.to contain_aodh_config('database/alarm_histories_delete_batch_size').with_value(500) }
it 'installs aodh-expirer package' do
is_expected.to contain_package('aodh-expirer').with(
:ensure => 'present',
:name => platform_params[:expirer_package_name],
:tag => ['openstack', 'aodh-package']
)
end
it { is_expected.to contain_cron('aodh-expirer').with(
:ensure => 'absent',
:command => 'sleep `expr ${RANDOM} \\% 300`; aodh-expirer',
:environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
:user => 'aodh',
:minute => 1,
:hour => 0,
:monthday => '*',
:month => '*',
:weekday => '*',
:require => 'Anchor[aodh::dbsync::end]'
)}
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
let(:platform_params) do
case facts[:os]['family']
when 'Debian'
{ :expirer_package_name => 'aodh-expirer' }
when 'RedHat'
{ :expirer_package_name => 'openstack-aodh-expirer' }
end
end
it_behaves_like 'aodh::expirer'
end
end
end
|