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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
require 'spec_helper'
describe 'mistral::api' do
let :params do
{
:api_workers => '1',
:enabled => true,
:manage_service => true,
:bind_host => '127.0.0.1',
:bind_port => '1234',
:enable_proxy_headers_parsing => false,
:max_request_body_size => '102400',
:allow_action_execution_deletion => false
}
end
let :pre_condition do
"class { 'mistral::keystone::authtoken':
password => 'foo',
}"
end
shared_examples 'mistral::api' do
context 'config params' do
it { is_expected.to contain_class('mistral::params') }
it { is_expected.to contain_class('mistral::policy') }
it { is_expected.to contain_class('mistral::keystone::authtoken') }
it { is_expected.to contain_mistral_config('api/api_workers').with_value( params[:api_workers] ) }
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] ) }
it { is_expected.to contain_oslo__middleware('mistral_config').with(
:enable_proxy_headers_parsing => params[:enable_proxy_headers_parsing],
:max_request_body_size => params[:max_request_body_size],
)}
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[: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
context 'with enable_proxy_headers_parsing' do
before do
params.merge!({:enable_proxy_headers_parsing => true })
end
it { is_expected.to contain_oslo__middleware('mistral_config').with(
:enable_proxy_headers_parsing => params[:enable_proxy_headers_parsing],
)}
end
context 'with max_request_body_size' do
before do
params.merge!({:max_request_body_size => '102400' })
end
it { is_expected.to contain_oslo__middleware('mistral_config').with(
:max_request_body_size => params[:max_request_body_size],
)}
end
context 'with disabled service managing' do
before do
params.merge!({
:manage_service => false
})
end
it 'does not configure mistral-api service' do
is_expected.to_not contain_service('mistral-api')
end
end
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
class { 'mistral': }
class { 'mistral::keystone::authtoken':
password => 'foo',
}"
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 { should raise_error(Puppet::Error, /Invalid service_name/) }
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'
{ :api_service_name => 'mistral-api' }
when 'RedHat'
{ :api_service_name => 'openstack-mistral-api' }
end
end
it_behaves_like 'mistral::api'
end
end
end
|