2015-10-20 09:11:14 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'aodh::api' do
|
|
|
|
|
|
|
|
let :pre_condition do
|
|
|
|
"class { 'aodh': }
|
2016-09-27 23:13:12 -03:00
|
|
|
include ::aodh::db
|
|
|
|
class { '::aodh::keystone::authtoken':
|
|
|
|
password => 'a_big_secret',
|
|
|
|
}"
|
2015-10-20 09:11:14 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
let :params do
|
2016-07-22 00:02:54 -03:00
|
|
|
{ :enabled => true,
|
|
|
|
:manage_service => true,
|
|
|
|
:package_ensure => 'latest',
|
2015-10-20 09:11:14 -04:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
shared_examples_for 'aodh-api' do
|
|
|
|
|
2016-11-25 10:14:13 +08:00
|
|
|
it { is_expected.to contain_class('aodh::deps') }
|
2015-10-20 09:11:14 -04:00
|
|
|
it { is_expected.to contain_class('aodh::params') }
|
|
|
|
it { is_expected.to contain_class('aodh::policy') }
|
|
|
|
|
|
|
|
it 'installs aodh-api package' do
|
|
|
|
is_expected.to contain_package('aodh-api').with(
|
|
|
|
:ensure => 'latest',
|
|
|
|
:name => platform_params[:api_package_name],
|
|
|
|
:tag => ['openstack', 'aodh-package'],
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2016-07-22 00:02:54 -03:00
|
|
|
it 'configures api' do
|
2017-07-18 14:43:34 +02:00
|
|
|
is_expected.to contain_aodh_config('api/gnocchi_external_project_owner').with_value( 'services' )
|
2017-08-17 12:22:36 +10:00
|
|
|
is_expected.to contain_aodh_config('api/paste_config').with_value('<SERVICE DEFAULT>')
|
2018-03-21 11:09:14 +08:00
|
|
|
is_expected.to contain_oslo__middleware('aodh_config').with(
|
|
|
|
:enable_proxy_headers_parsing => '<SERVICE DEFAULT>',
|
|
|
|
)
|
2015-10-20 09:11:14 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
[{:enabled => true}, {:enabled => false}].each do |param_hash|
|
|
|
|
context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do
|
|
|
|
before do
|
|
|
|
params.merge!(param_hash)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'configures aodh-api service' do
|
|
|
|
is_expected.to contain_service('aodh-api').with(
|
|
|
|
:ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
|
|
|
|
:name => platform_params[:api_service_name],
|
|
|
|
:enable => params[:enabled],
|
|
|
|
:hasstatus => true,
|
|
|
|
:hasrestart => true,
|
|
|
|
:tag => 'aodh-service',
|
|
|
|
)
|
|
|
|
end
|
2016-11-25 10:14:13 +08:00
|
|
|
it { is_expected.to contain_service('aodh-api').that_subscribes_to('Anchor[aodh::service::begin]')}
|
|
|
|
it { is_expected.to contain_service('aodh-api').that_notifies('Anchor[aodh::service::end]')}
|
2015-10-20 09:11:14 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-04-07 12:00:12 -04:00
|
|
|
context 'with sync_db set to true' do
|
|
|
|
before do
|
|
|
|
params.merge!(
|
|
|
|
:sync_db => true)
|
|
|
|
end
|
|
|
|
it { is_expected.to contain_class('aodh::db::sync') }
|
|
|
|
end
|
|
|
|
|
2016-10-10 12:02:32 +03:00
|
|
|
context 'with enable_proxy_headers_parsing' do
|
|
|
|
before do
|
|
|
|
params.merge!({:enable_proxy_headers_parsing => true })
|
|
|
|
end
|
|
|
|
|
2018-03-21 11:09:14 +08:00
|
|
|
it { is_expected.to contain_oslo__middleware('aodh_config').with(
|
|
|
|
:enable_proxy_headers_parsing => true,
|
|
|
|
)}
|
2016-10-10 12:02:32 +03:00
|
|
|
end
|
2016-07-22 00:02:54 -03:00
|
|
|
|
2017-08-17 12:22:36 +10:00
|
|
|
context 'with paste_config' do
|
|
|
|
before do
|
|
|
|
params.merge!({:paste_config => '/etc/aodh/api-paste.ini' })
|
|
|
|
end
|
|
|
|
|
|
|
|
it { is_expected.to contain_aodh_config('api/paste_config').with_value('/etc/aodh/api-paste.ini') }
|
|
|
|
end
|
|
|
|
|
2017-07-18 14:43:34 +02:00
|
|
|
context 'with gnocchi_external_project_owner' do
|
|
|
|
before do
|
|
|
|
params.merge!({:gnocchi_external_project_owner => 'gnocchi-project' })
|
|
|
|
end
|
|
|
|
|
|
|
|
it { is_expected.to contain_aodh_config('api/gnocchi_external_project_owner').with_value('gnocchi-project') }
|
|
|
|
end
|
2015-10-20 09:11:14 -04:00
|
|
|
context 'with disabled service managing' do
|
|
|
|
before do
|
|
|
|
params.merge!({
|
|
|
|
:manage_service => false,
|
|
|
|
:enabled => false })
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'configures aodh-api service' do
|
|
|
|
is_expected.to contain_service('aodh-api').with(
|
|
|
|
:ensure => nil,
|
|
|
|
:name => platform_params[:api_service_name],
|
|
|
|
:enable => false,
|
|
|
|
:hasstatus => true,
|
|
|
|
:hasrestart => true,
|
|
|
|
:tag => 'aodh-service',
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when running aodh-api in wsgi' do
|
|
|
|
before do
|
|
|
|
params.merge!({ :service_name => 'httpd' })
|
|
|
|
end
|
|
|
|
|
|
|
|
let :pre_condition do
|
|
|
|
"include ::apache
|
|
|
|
include ::aodh::db
|
2016-09-27 23:13:12 -03:00
|
|
|
class { 'aodh': }
|
|
|
|
class { '::aodh::keystone::authtoken':
|
|
|
|
password => 'a_big_secret',
|
|
|
|
}"
|
2015-10-20 09:11:14 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'configures aodh-api service with Apache' do
|
|
|
|
is_expected.to contain_service('aodh-api').with(
|
|
|
|
:ensure => 'stopped',
|
|
|
|
:name => platform_params[:api_service_name],
|
|
|
|
:enable => false,
|
|
|
|
:tag => 'aodh-service',
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when service_name is not valid' do
|
|
|
|
before do
|
|
|
|
params.merge!({ :service_name => 'foobar' })
|
|
|
|
end
|
|
|
|
|
|
|
|
let :pre_condition do
|
|
|
|
"include ::apache
|
|
|
|
include ::aodh::db
|
2016-09-27 23:13:12 -03:00
|
|
|
class { 'aodh': }
|
|
|
|
class { '::aodh::keystone::authtoken':
|
|
|
|
password => 'a_big_secret',
|
|
|
|
}"
|
2015-10-20 09:11:14 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it_raises 'a Puppet::Error', /Invalid service_name/
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-01-11 21:26:03 -07:00
|
|
|
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({
|
|
|
|
:fqdn => 'some.host.tld',
|
|
|
|
:concat_basedir => '/var/lib/puppet/concat'
|
|
|
|
}))
|
|
|
|
end
|
2015-10-20 09:11:14 -04:00
|
|
|
|
2016-01-11 21:26:03 -07:00
|
|
|
let(:platform_params) do
|
|
|
|
case facts[:osfamily]
|
|
|
|
when 'Debian'
|
|
|
|
{ :api_package_name => 'aodh-api',
|
|
|
|
:api_service_name => 'aodh-api' }
|
|
|
|
when 'RedHat'
|
|
|
|
{ :api_package_name => 'openstack-aodh-api',
|
|
|
|
:api_service_name => 'openstack-aodh-api' }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
it_configures 'aodh-api'
|
2015-10-20 09:11:14 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|