2016-12-02 12:15:37 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'nova::wsgi::apache_api' do
|
|
|
|
shared_examples_for 'apache serving nova with mod_wsgi' do
|
2017-07-13 12:59:31 -06:00
|
|
|
context 'with default parameters' do
|
2016-12-02 12:15:37 -05:00
|
|
|
|
|
|
|
let :pre_condition do
|
|
|
|
"include nova
|
2019-12-08 23:13:08 +01:00
|
|
|
class { 'nova::keystone::authtoken':
|
2016-12-02 12:15:37 -05:00
|
|
|
password => 'secrete',
|
|
|
|
}
|
2019-12-08 23:13:08 +01:00
|
|
|
class { 'nova::api':
|
2016-12-02 12:15:37 -05:00
|
|
|
service_name => 'httpd',
|
|
|
|
}"
|
|
|
|
end
|
2017-07-13 12:59:31 -06:00
|
|
|
it { is_expected.to contain_class('nova::params') }
|
|
|
|
it { is_expected.to contain_openstacklib__wsgi__apache('nova_api_wsgi').with(
|
2017-09-18 11:41:23 +02:00
|
|
|
:bind_port => 8774,
|
|
|
|
:group => 'nova',
|
|
|
|
:path => '/',
|
2022-08-02 20:40:31 +09:00
|
|
|
:priority => 10,
|
2023-03-02 11:41:04 +09:00
|
|
|
:servername => 'foo.example.com',
|
2022-05-06 21:02:39 +09:00
|
|
|
:ssl => false,
|
2017-10-13 07:55:49 +03:00
|
|
|
:threads => 1,
|
2017-09-18 11:41:23 +02:00
|
|
|
:user => 'nova',
|
2017-10-13 07:55:49 +03:00
|
|
|
:workers => facts[:os_workers],
|
2017-09-18 11:41:23 +02:00
|
|
|
:wsgi_daemon_process => 'nova-api',
|
|
|
|
:wsgi_process_group => 'nova-api',
|
|
|
|
:wsgi_script_dir => platform_params[:wsgi_script_path],
|
|
|
|
:wsgi_script_file => 'nova-api',
|
|
|
|
:wsgi_script_source => platform_params[:api_wsgi_script_source],
|
2022-07-01 10:56:03 +09:00
|
|
|
:headers => nil,
|
|
|
|
:request_headers => nil,
|
2017-09-18 11:41:23 +02:00
|
|
|
:custom_wsgi_process_options => {},
|
2022-08-02 20:40:31 +09:00
|
|
|
:access_log_file => nil,
|
2022-08-26 16:34:48 +09:00
|
|
|
:access_log_pipe => nil,
|
|
|
|
:access_log_syslog => nil,
|
2022-08-02 20:40:31 +09:00
|
|
|
:access_log_format => nil,
|
2017-10-03 12:55:02 +03:00
|
|
|
:error_log_file => nil,
|
2022-08-26 16:34:48 +09:00
|
|
|
:error_log_pipe => nil,
|
|
|
|
:error_log_syslog => nil,
|
2016-12-02 12:15:37 -05:00
|
|
|
)}
|
|
|
|
end
|
|
|
|
|
2022-07-01 10:56:03 +09:00
|
|
|
context 'when overriding parameters' do
|
2016-12-02 12:15:37 -05:00
|
|
|
let :pre_condition do
|
|
|
|
"include nova
|
2019-12-08 23:13:08 +01:00
|
|
|
class { 'nova::keystone::authtoken':
|
2016-12-02 12:15:37 -05:00
|
|
|
password => 'secrete',
|
|
|
|
}
|
2019-12-08 23:13:08 +01:00
|
|
|
class { 'nova::api':
|
2016-12-02 12:15:37 -05:00
|
|
|
service_name => 'httpd',
|
|
|
|
}"
|
|
|
|
end
|
|
|
|
|
|
|
|
let :params do
|
|
|
|
{
|
2017-09-18 11:41:23 +02:00
|
|
|
:servername => 'dummy.host',
|
|
|
|
:bind_host => '10.42.51.1',
|
2023-01-23 10:32:15 +09:00
|
|
|
:port => 12345,
|
2022-05-06 21:02:39 +09:00
|
|
|
:ssl => true,
|
2020-08-11 10:56:59 -04:00
|
|
|
:vhost_custom_fragment => 'Timeout 99',
|
2017-09-18 11:41:23 +02:00
|
|
|
:wsgi_process_display_name => 'nova-api',
|
|
|
|
:workers => 37,
|
|
|
|
:custom_wsgi_process_options => {
|
|
|
|
'python_path' => '/my/python/path',
|
|
|
|
},
|
2022-07-01 10:56:03 +09:00
|
|
|
:headers => ['set X-XSS-Protection "1; mode=block"'],
|
|
|
|
:request_headers => ['set Content-Type "application/json"'],
|
2016-12-02 12:15:37 -05:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2017-07-13 12:59:31 -06:00
|
|
|
it { is_expected.to contain_class('nova::params') }
|
|
|
|
it { is_expected.to contain_openstacklib__wsgi__apache('nova_api_wsgi').with(
|
2017-09-18 11:41:23 +02:00
|
|
|
:bind_host => '10.42.51.1',
|
|
|
|
:bind_port => 12345,
|
|
|
|
:group => 'nova',
|
|
|
|
:path => '/',
|
|
|
|
:servername => 'dummy.host',
|
2022-05-06 21:02:39 +09:00
|
|
|
:ssl => true,
|
2017-10-13 07:55:49 +03:00
|
|
|
:threads => 1,
|
2017-09-18 11:41:23 +02:00
|
|
|
:user => 'nova',
|
2020-08-11 10:56:59 -04:00
|
|
|
:vhost_custom_fragment => 'Timeout 99',
|
2017-09-18 11:41:23 +02:00
|
|
|
:workers => 37,
|
|
|
|
:wsgi_daemon_process => 'nova-api',
|
|
|
|
:wsgi_process_display_name => 'nova-api',
|
|
|
|
:wsgi_process_group => 'nova-api',
|
|
|
|
:wsgi_script_dir => platform_params[:wsgi_script_path],
|
|
|
|
:wsgi_script_file => 'nova-api',
|
|
|
|
:wsgi_script_source => platform_params[:api_wsgi_script_source],
|
2022-07-01 10:56:03 +09:00
|
|
|
:headers => ['set X-XSS-Protection "1; mode=block"'],
|
|
|
|
:request_headers => ['set Content-Type "application/json"'],
|
2017-09-18 11:41:23 +02:00
|
|
|
:custom_wsgi_process_options => {
|
|
|
|
'python_path' => '/my/python/path',
|
|
|
|
},
|
2016-12-02 12:15:37 -05:00
|
|
|
)}
|
|
|
|
end
|
|
|
|
|
2020-11-19 20:56:41 +09:00
|
|
|
context 'when nova::api is missing in the composition layer' do
|
2016-12-02 12:15:37 -05:00
|
|
|
|
|
|
|
let :pre_condition do
|
|
|
|
"include nova"
|
|
|
|
end
|
|
|
|
|
2020-11-19 20:56:41 +09:00
|
|
|
it { should raise_error(Puppet::Error, /nova::api class must be declared in composition layer./) }
|
2016-12-02 12:15:37 -05:00
|
|
|
end
|
|
|
|
|
2022-08-26 16:34:48 +09:00
|
|
|
context 'with custom access logging' do
|
|
|
|
let :pre_condition do
|
|
|
|
"include nova
|
|
|
|
class { 'nova::keystone::authtoken':
|
|
|
|
password => 'secrete',
|
|
|
|
}
|
|
|
|
class { 'nova::api':
|
|
|
|
service_name => 'httpd',
|
|
|
|
}"
|
|
|
|
end
|
|
|
|
|
|
|
|
let :params do
|
|
|
|
{
|
|
|
|
:access_log_format => 'foo',
|
|
|
|
:access_log_syslog => 'syslog:local0',
|
|
|
|
:error_log_syslog => 'syslog:local1',
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
it { should contain_openstacklib__wsgi__apache('nova_api_wsgi').with(
|
|
|
|
:access_log_format => params[:access_log_format],
|
|
|
|
:access_log_syslog => params[:access_log_syslog],
|
|
|
|
:error_log_syslog => params[:error_log_syslog],
|
|
|
|
)}
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with access_log_file' do
|
|
|
|
let :pre_condition do
|
|
|
|
"include nova
|
|
|
|
class { 'nova::keystone::authtoken':
|
|
|
|
password => 'secrete',
|
|
|
|
}
|
|
|
|
class { 'nova::api':
|
|
|
|
service_name => 'httpd',
|
|
|
|
}"
|
|
|
|
end
|
|
|
|
|
|
|
|
let :params do
|
|
|
|
{
|
|
|
|
:access_log_file => '/path/to/file',
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
it { should contain_openstacklib__wsgi__apache('nova_api_wsgi').with(
|
|
|
|
:access_log_file => params[:access_log_file],
|
|
|
|
)}
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with access_log_pipe' do
|
|
|
|
let :pre_condition do
|
|
|
|
"include nova
|
|
|
|
class { 'nova::keystone::authtoken':
|
|
|
|
password => 'secrete',
|
|
|
|
}
|
|
|
|
class { 'nova::api':
|
|
|
|
service_name => 'httpd',
|
|
|
|
}"
|
|
|
|
end
|
|
|
|
|
|
|
|
let :params do
|
|
|
|
{
|
|
|
|
:access_log_pipe => 'pipe',
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
it { should contain_openstacklib__wsgi__apache('nova_api_wsgi').with(
|
|
|
|
:access_log_pipe => params[:access_log_pipe],
|
|
|
|
)}
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with error_log_file' do
|
|
|
|
let :pre_condition do
|
|
|
|
"include nova
|
|
|
|
class { 'nova::keystone::authtoken':
|
|
|
|
password => 'secrete',
|
|
|
|
}
|
|
|
|
class { 'nova::api':
|
|
|
|
service_name => 'httpd',
|
|
|
|
}"
|
|
|
|
end
|
|
|
|
|
|
|
|
let :params do
|
|
|
|
{
|
|
|
|
:error_log_file => '/path/to/file',
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
it { should contain_openstacklib__wsgi__apache('nova_api_wsgi').with(
|
|
|
|
:error_log_file => params[:error_log_file],
|
|
|
|
)}
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with error_log_pipe' do
|
|
|
|
let :pre_condition do
|
|
|
|
"include nova
|
|
|
|
class { 'nova::keystone::authtoken':
|
|
|
|
password => 'secrete',
|
|
|
|
}
|
|
|
|
class { 'nova::api':
|
|
|
|
service_name => 'httpd',
|
|
|
|
}"
|
|
|
|
end
|
|
|
|
|
|
|
|
let :params do
|
|
|
|
{
|
|
|
|
:error_log_pipe => 'pipe',
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
it { should contain_openstacklib__wsgi__apache('nova_api_wsgi').with(
|
|
|
|
:error_log_pipe => params[:error_log_pipe],
|
|
|
|
)}
|
|
|
|
end
|
2016-12-02 12:15:37 -05:00
|
|
|
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({
|
2023-03-02 11:41:04 +09:00
|
|
|
:os_workers => 42,
|
2016-12-02 12:15:37 -05:00
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:platform_params) do
|
2023-03-02 11:41:04 +09:00
|
|
|
case facts[:os]['family']
|
2016-12-02 12:15:37 -05:00
|
|
|
when 'Debian'
|
|
|
|
{
|
|
|
|
:wsgi_script_path => '/usr/lib/cgi-bin/nova',
|
2017-06-26 10:50:02 -04:00
|
|
|
:api_wsgi_script_source => '/usr/bin/nova-api-wsgi',
|
2016-12-02 12:15:37 -05:00
|
|
|
}
|
|
|
|
when 'RedHat'
|
|
|
|
{
|
|
|
|
:wsgi_script_path => '/var/www/cgi-bin/nova',
|
2017-05-16 15:15:26 -04:00
|
|
|
:api_wsgi_script_source => '/usr/bin/nova-api-wsgi',
|
2016-12-02 12:15:37 -05:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'apache serving nova with mod_wsgi'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|