| 1 |
require 'spec_helper' |
| 2 |
|
| 3 |
describe 'cloudkitty::api' do |
| 4 |
|
| 5 |
let :params do |
| 6 |
{ :enabled => true, |
| 7 |
:manage_service => true, |
| 8 |
:host_ip => '127.0.0.1', |
| 9 |
:port => '8889', |
| 10 |
:pecan_debug => false, |
| 11 |
:enable_proxy_headers_parsing => true, |
| 12 |
:max_request_body_size => 102400,} |
| 13 |
end |
| 14 |
|
| 15 |
let :pre_condition do |
| 16 |
"include cloudkitty::db |
| 17 |
include apache |
| 18 |
class { 'cloudkitty': } |
| 19 |
class { 'cloudkitty::keystone::authtoken': |
| 20 |
password => 'a_big_secret', |
| 21 |
}" |
| 22 |
end |
| 23 |
|
| 24 |
shared_examples 'cloudkitty-api' do |
| 25 |
context 'with required params' do |
| 26 |
it { is_expected.to contain_class('cloudkitty') } |
| 27 |
it { is_expected.to contain_class('cloudkitty::params') } |
| 28 |
it { is_expected.to contain_class('cloudkitty::deps') } |
| 29 |
it { is_expected.to contain_class('cloudkitty::policy') } |
| 30 |
|
| 31 |
it { is_expected.to contain_cloudkitty_config('api/host_ip').with_value( params[:host_ip] ) } |
| 32 |
it { is_expected.to contain_cloudkitty_config('api/port').with_value( params[:port] ) } |
| 33 |
it { is_expected.to contain_cloudkitty_config('api/pecan_debug').with_value( params[:pecan_debug] ) } |
| 34 |
it { is_expected.to contain_oslo__middleware('cloudkitty_config').with( |
| 35 |
:enable_proxy_headers_parsing => params[:enable_proxy_headers_parsing], |
| 36 |
:max_request_body_size => params[:max_request_body_size], |
| 37 |
) } |
| 38 |
|
| 39 |
it 'installs cloudkitty-api package' do |
| 40 |
is_expected.to contain_package('cloudkitty-api').with( |
| 41 |
:ensure => 'present', |
| 42 |
:name => platform_params[:api_package_name], |
| 43 |
:tag => ['openstack', 'cloudkitty-package'], |
| 44 |
) |
| 45 |
end |
| 46 |
end |
| 47 |
|
| 48 |
context 'when running cloudkitty-api in wsgi' do |
| 49 |
before do |
| 50 |
params.merge!({ :service_name => 'httpd' }) |
| 51 |
end |
| 52 |
|
| 53 |
it 'configures cloudkitty-api service with Apache' do |
| 54 |
is_expected.to contain_service('cloudkitty-api').with( |
| 55 |
:ensure => 'stopped', |
| 56 |
:name => platform_params[:api_service_name], |
| 57 |
:enable => false, |
| 58 |
:tag => 'cloudkitty-service', |
| 59 |
) |
| 60 |
end |
| 61 |
end |
| 62 |
|
| 63 |
context 'when running cloudkitty-api as standalone' do |
| 64 |
before do |
| 65 |
params.merge!({ :service_name => platform_params[:api_service_name] }) |
| 66 |
end |
| 67 |
|
| 68 |
it 'configures cloudkitty-api service as standalone' do |
| 69 |
is_expected.to contain_service('cloudkitty-api').with( |
| 70 |
:ensure => 'running', |
| 71 |
:name => platform_params[:api_service_name], |
| 72 |
:enable => true, |
| 73 |
:hasstatus => true, |
| 74 |
:hasrestart => true, |
| 75 |
:tag => 'cloudkitty-service', |
| 76 |
) |
| 77 |
end |
| 78 |
end |
| 79 |
|
| 80 |
context 'with $sync_db set to false in ::cloudkitty' do |
| 81 |
before do |
| 82 |
params.merge!({ |
| 83 |
:sync_db => false, |
| 84 |
}) |
| 85 |
end |
| 86 |
|
| 87 |
it 'configures cloudkitty-api service to not subscribe to the dbsync resource' do |
| 88 |
is_expected.to contain_service('cloudkitty-api').that_subscribes_to(nil) |
| 89 |
end |
| 90 |
end |
| 91 |
end |
| 92 |
|
| 93 |
on_supported_os({ |
| 94 |
:supported_os => OSDefaults.get_supported_os |
| 95 |
}).each do |os,facts| |
| 96 |
context "on #{os}" do |
| 97 |
let (:facts) do |
| 98 |
facts.merge!(OSDefaults.get_facts()) |
| 99 |
end |
| 100 |
|
| 101 |
let :platform_params do |
| 102 |
case facts[:os]['family'] |
| 103 |
when 'Debian' |
| 104 |
{ :api_package_name => 'cloudkitty-api', |
| 105 |
:api_service_name => 'cloudkitty-api' } |
| 106 |
when 'RedHat' |
| 107 |
{ :api_package_name => 'openstack-cloudkitty-api', |
| 108 |
:api_service_name => 'cloudkitty-api' } |
| 109 |
end |
| 110 |
end |
| 111 |
|
| 112 |
it_behaves_like 'cloudkitty-api' |
| 113 |
end |
| 114 |
end |
| 115 |
end |