| 1 |
require 'spec_helper' |
| 2 |
|
| 3 |
describe 'cloudkitty::processor' do |
| 4 |
|
| 5 |
let :params do |
| 6 |
{ :enabled => true, |
| 7 |
:manage_service => true, |
| 8 |
:collector => 'gnocchi', |
| 9 |
:period => '60', |
| 10 |
:wait_periods => '1', |
| 11 |
:window => '3600', |
| 12 |
:region_name => 'RegionOne', |
| 13 |
:interface => 'publicURL' |
| 14 |
} |
| 15 |
end |
| 16 |
|
| 17 |
shared_examples_for 'cloudkitty-processor' do |
| 18 |
|
| 19 |
context 'when enabled' do |
| 20 |
it { is_expected.to contain_class('cloudkitty::params') } |
| 21 |
it { is_expected.to contain_class('cloudkitty::deps') } |
| 22 |
|
| 23 |
it { is_expected.to contain_cloudkitty_config('collect/collector').with_value( params[:collector] ) } |
| 24 |
it { is_expected.to contain_cloudkitty_config('collect/window').with_value( params[:window] ) } |
| 25 |
it { is_expected.to contain_cloudkitty_config('collect/period').with_value( params[:period] ) } |
| 26 |
it { is_expected.to contain_cloudkitty_config('collect/wait_periods').with_value( params[:wait_periods] ) } |
| 27 |
it { is_expected.to contain_cloudkitty_config('collector_gnocchi/auth_type').with_value('password') } |
| 28 |
it { is_expected.to contain_cloudkitty_config('collector_gnocchi/auth_section').with_value('keystone_authtoken') } |
| 29 |
it { is_expected.to contain_cloudkitty_config('collector_gnocchi/region_name').with_value( params[:region_name] ) } |
| 30 |
it { is_expected.to contain_cloudkitty_config('collector_gnocchi/interface').with_value( params[:interface] ) } |
| 31 |
|
| 32 |
it 'installs cloudkitty-processor package' do |
| 33 |
is_expected.to contain_package('cloudkitty-processor').with( |
| 34 |
:name => platform_params[:processor_package_name], |
| 35 |
:ensure => 'present', |
| 36 |
:tag => ['openstack', 'cloudkitty-package'] |
| 37 |
) |
| 38 |
end |
| 39 |
|
| 40 |
it 'configures cloudkitty-processor service' do |
| 41 |
is_expected.to contain_service('cloudkitty-processor').with( |
| 42 |
:ensure => 'running', |
| 43 |
:name => platform_params[:processor_service_name], |
| 44 |
:enable => true, |
| 45 |
:hasstatus => true, |
| 46 |
:hasrestart => true, |
| 47 |
:tag => 'cloudkitty-service', |
| 48 |
) |
| 49 |
end |
| 50 |
|
| 51 |
end |
| 52 |
|
| 53 |
context 'when disabled' do |
| 54 |
let :params do |
| 55 |
{ :enabled => false } |
| 56 |
end |
| 57 |
|
| 58 |
# Catalog compilation does not crash for lack of cloudkitty::db |
| 59 |
it { is_expected.to compile } |
| 60 |
it 'configures cloudkitty-processor service' do |
| 61 |
is_expected.to contain_service('cloudkitty-processor').with( |
| 62 |
:ensure => 'stopped', |
| 63 |
:name => platform_params[:processor_service_name], |
| 64 |
:enable => false, |
| 65 |
:hasstatus => true, |
| 66 |
:hasrestart => true, |
| 67 |
:tag => 'cloudkitty-service', |
| 68 |
) |
| 69 |
end |
| 70 |
end |
| 71 |
|
| 72 |
context 'when service management is disabled' do |
| 73 |
let :params do |
| 74 |
{ :enabled => false, |
| 75 |
:manage_service => false } |
| 76 |
end |
| 77 |
|
| 78 |
it 'does not configure cloudkitty-processor service' do |
| 79 |
is_expected.to_not contain_service('cloudkitty-processor') |
| 80 |
end |
| 81 |
end |
| 82 |
end |
| 83 |
|
| 84 |
on_supported_os({ |
| 85 |
:supported_os => OSDefaults.get_supported_os |
| 86 |
}).each do |os,facts| |
| 87 |
context "on #{os}" do |
| 88 |
let (:facts) do |
| 89 |
facts.merge!(OSDefaults.get_facts()) |
| 90 |
end |
| 91 |
|
| 92 |
let(:platform_params) do |
| 93 |
case facts[:os]['family'] |
| 94 |
when 'Debian' |
| 95 |
{ :processor_package_name => 'cloudkitty-processor', |
| 96 |
:processor_service_name => 'cloudkitty-processor' } |
| 97 |
when 'RedHat' |
| 98 |
{ :processor_package_name => 'openstack-cloudkitty-processor', |
| 99 |
:processor_service_name => 'cloudkitty-processor' } |
| 100 |
end |
| 101 |
end |
| 102 |
it_configures 'cloudkitty-processor' |
| 103 |
end |
| 104 |
end |
| 105 |
|
| 106 |
end |