2015-11-21 20:04:02 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'mistral::api' do
|
|
|
|
|
|
|
|
let :params do
|
2016-08-11 10:46:56 +02:00
|
|
|
{ :api_workers => '1',
|
|
|
|
:enabled => true,
|
2015-11-21 20:04:02 -05:00
|
|
|
:manage_service => true,
|
|
|
|
:bind_host => '127.0.0.1',
|
|
|
|
:bind_port => '1234',
|
2016-10-28 20:19:16 +08:00
|
|
|
:enable_proxy_headers_parsing => false,
|
2015-11-21 20:04:02 -05:00
|
|
|
:allow_action_execution_deletion => false}
|
|
|
|
end
|
|
|
|
|
2018-06-12 22:12:45 +02:00
|
|
|
let :pre_condition do
|
|
|
|
"class { '::mistral::keystone::authtoken':
|
|
|
|
password => 'foo',
|
|
|
|
}"
|
|
|
|
end
|
|
|
|
|
2015-11-21 20:04:02 -05:00
|
|
|
shared_examples_for 'mistral-api' do
|
|
|
|
|
|
|
|
context 'config params' do
|
|
|
|
|
|
|
|
it { is_expected.to contain_class('mistral::params') }
|
2016-02-05 06:31:27 +01:00
|
|
|
it { is_expected.to contain_class('mistral::policy') }
|
2015-11-21 20:04:02 -05:00
|
|
|
|
2016-08-11 10:46:56 +02:00
|
|
|
it { is_expected.to contain_mistral_config('api/api_workers').with_value( params[:api_workers] ) }
|
2015-11-21 20:04:02 -05:00
|
|
|
it { is_expected.to contain_mistral_config('api/host').with_value( params[:bind_host] ) }
|
|
|
|
it { is_expected.to contain_mistral_config('api/port').with_value( params[:bind_port] ) }
|
2018-03-21 11:27:40 +08:00
|
|
|
it { is_expected.to contain_oslo__middleware('mistral_config').with(
|
|
|
|
:enable_proxy_headers_parsing => params[:enable_proxy_headers_parsing],
|
|
|
|
)}
|
2015-11-21 20:04:02 -05:00
|
|
|
it { is_expected.to contain_mistral_config('api/allow_action_execution_deletion').with_value( params[:allow_action_execution_deletion] ) }
|
|
|
|
|
|
|
|
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 mistral-api service' do
|
|
|
|
|
|
|
|
is_expected.to contain_service('mistral-api').with(
|
|
|
|
:ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
|
|
|
|
:name => platform_params[:api_service_name],
|
|
|
|
:enable => params[:enabled],
|
|
|
|
:hasstatus => true,
|
|
|
|
:hasrestart => true,
|
|
|
|
:tag => 'mistral-service',
|
|
|
|
)
|
|
|
|
is_expected.to contain_service('mistral-api').that_subscribes_to(nil)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-10-28 20:19:16 +08:00
|
|
|
context 'with enable_proxy_headers_parsing' do
|
|
|
|
before do
|
|
|
|
params.merge!({:enable_proxy_headers_parsing => true })
|
|
|
|
end
|
|
|
|
|
2018-03-21 11:27:40 +08:00
|
|
|
it { is_expected.to contain_oslo__middleware('mistral_config').with(
|
|
|
|
:enable_proxy_headers_parsing => params[:enable_proxy_headers_parsing],
|
|
|
|
)}
|
2016-10-28 20:19:16 +08:00
|
|
|
end
|
|
|
|
|
2015-11-21 20:04:02 -05:00
|
|
|
context 'with disabled service managing' do
|
|
|
|
before do
|
|
|
|
params.merge!({
|
|
|
|
:manage_service => false,
|
|
|
|
:enabled => false })
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'configures mistral-api service' do
|
|
|
|
|
|
|
|
is_expected.to contain_service('mistral-api').with(
|
|
|
|
:ensure => nil,
|
|
|
|
:name => platform_params[:api_service_name],
|
|
|
|
:enable => false,
|
|
|
|
:hasstatus => true,
|
|
|
|
:hasrestart => true,
|
|
|
|
:tag => 'mistral-service',
|
|
|
|
)
|
|
|
|
is_expected.to contain_service('mistral-api').that_subscribes_to(nil)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-02-05 11:14:11 +01:00
|
|
|
context 'when running mistral-api in wsgi' do
|
|
|
|
before do
|
|
|
|
params.merge!({ :service_name => 'httpd' })
|
|
|
|
end
|
|
|
|
|
|
|
|
let :pre_condition do
|
|
|
|
"include ::apache
|
|
|
|
include ::mistral::db
|
2018-06-12 22:12:45 +02:00
|
|
|
class { '::mistral': }"
|
2016-02-05 11:14:11 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'configures mistral-api service with Apache' do
|
|
|
|
is_expected.to contain_service('mistral-api').with(
|
|
|
|
:ensure => 'stopped',
|
|
|
|
:name => platform_params[:api_service_name],
|
|
|
|
:enable => false,
|
|
|
|
:tag => ['mistral-service'],
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when service_name is not valid' do
|
|
|
|
before do
|
|
|
|
params.merge!({ :service_name => 'foobar' })
|
|
|
|
end
|
|
|
|
|
|
|
|
it_raises 'a Puppet::Error', /Invalid service_name/
|
|
|
|
end
|
2015-11-21 20:04:02 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'on Debian platforms' do
|
|
|
|
let :facts do
|
2016-02-05 11:14:11 +01:00
|
|
|
@default_facts.merge({
|
|
|
|
:osfamily => 'Debian',
|
|
|
|
:operatingsystem => 'Debian',
|
|
|
|
:operatingsystemrelease => '8.0',
|
|
|
|
:concat_basedir => '/var/lib/puppet/concat',
|
|
|
|
:fqdn => 'some.host.tld',
|
|
|
|
})
|
2015-11-21 20:04:02 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
let :platform_params do
|
|
|
|
{ :api_service_name => 'mistral-api' }
|
|
|
|
end
|
|
|
|
|
|
|
|
it_configures 'mistral-api'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'on RedHat platforms' do
|
|
|
|
let :facts do
|
2016-02-05 11:14:11 +01:00
|
|
|
@default_facts.merge({
|
|
|
|
:osfamily => 'RedHat',
|
|
|
|
:operatingsystem => 'RedHat',
|
|
|
|
:operatingsystemrelease => '7.1',
|
|
|
|
:fqdn => 'some.host.tld',
|
|
|
|
:concat_basedir => '/var/lib/puppet/concat',
|
|
|
|
})
|
2015-11-21 20:04:02 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
let :platform_params do
|
|
|
|
{ :api_service_name => 'openstack-mistral-api' }
|
|
|
|
end
|
|
|
|
|
|
|
|
it_configures 'mistral-api'
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|