puppet-ceilometer/spec/classes/ceilometer_wsgi_apache_spec.rb
Xing Zhou 29e54fbb8d Add customization for wsgi process display name
Change-Id: I86495b73f386ff69bacd972947d702ea6861f94c
Related-Bug: #1626550
2016-12-21 12:56:30 +08:00

139 lines
5.1 KiB
Ruby

require 'spec_helper'
describe 'ceilometer::wsgi::apache' do
let :global_facts do
{
:os_workers => 8,
:concat_basedir => '/var/lib/puppet/concat',
:fqdn => 'some.host.tld'
}
end
let :pre_condition do
"class { 'ceilometer': telemetry_secret => 's3cr3t' }"
end
shared_examples_for 'apache serving ceilometer with mod_wsgi' do
it { is_expected.to contain_service('httpd').with_name(platform_parameters[:httpd_service_name]) }
it { is_expected.to contain_class('ceilometer::params') }
it { is_expected.to contain_class('apache') }
it { is_expected.to contain_class('apache::mod::wsgi') }
describe 'with default parameters' do
it { is_expected.to contain_file("#{platform_parameters[:wsgi_script_path]}").with(
'ensure' => 'directory',
'owner' => 'ceilometer',
'group' => 'ceilometer',
'require' => 'Package[httpd]'
)}
it { is_expected.to contain_file('ceilometer_wsgi').with(
'ensure' => 'file',
'path' => "#{platform_parameters[:wsgi_script_path]}/app",
'source' => platform_parameters[:wsgi_script_source],
'owner' => 'ceilometer',
'group' => 'ceilometer',
'mode' => '0644'
)}
it { is_expected.to contain_file('ceilometer_wsgi').that_requires("File[#{platform_parameters[:wsgi_script_path]}]") }
it { is_expected.to contain_apache__vhost('ceilometer_wsgi').with(
'servername' => 'some.host.tld',
'ip' => nil,
'port' => '8777',
'docroot' => "#{platform_parameters[:wsgi_script_path]}",
'docroot_owner' => 'ceilometer',
'docroot_group' => 'ceilometer',
'ssl' => 'true',
'wsgi_daemon_process' => 'ceilometer',
'wsgi_daemon_process_options' => {
'user' => 'ceilometer',
'group' => 'ceilometer',
'processes' => 1,
'threads' => "#{global_facts[:os_workers]}",
'display-name' => 'ceilometer_wsgi',
},
'wsgi_process_group' => 'ceilometer',
'wsgi_script_aliases' => { '/' => "#{platform_parameters[:wsgi_script_path]}/app" },
'require' => 'File[ceilometer_wsgi]'
)}
it { is_expected.to contain_concat("#{platform_parameters[:httpd_ports_file]}") }
end
describe 'when overriding parameters using different ports' do
let :params do
{
:servername => 'dummy.host',
:bind_host => '10.42.51.1',
:port => 12345,
:ssl => false,
:wsgi_process_display_name => 'ceilometer',
:workers => 37,
}
end
it { is_expected.to contain_apache__vhost('ceilometer_wsgi').with(
'servername' => 'dummy.host',
'ip' => '10.42.51.1',
'port' => '12345',
'docroot' => "#{platform_parameters[:wsgi_script_path]}",
'docroot_owner' => 'ceilometer',
'docroot_group' => 'ceilometer',
'ssl' => 'false',
'wsgi_daemon_process' => 'ceilometer',
'wsgi_daemon_process_options' => {
'user' => 'ceilometer',
'group' => 'ceilometer',
'processes' => '37',
'threads' => "#{global_facts[:os_workers]}",
'display-name' => 'ceilometer',
},
'wsgi_process_group' => 'ceilometer',
'wsgi_script_aliases' => { '/' => "#{platform_parameters[:wsgi_script_path]}/app" },
'require' => 'File[ceilometer_wsgi]'
)}
it { is_expected.to contain_concat("#{platform_parameters[:httpd_ports_file]}") }
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({
:os_workers => 8,
:concat_basedir => '/var/lib/puppet/concat',
:fqdn => 'some.host.tld'
}))
end
let :platform_parameters do
case facts[:osfamily]
when 'Debian'
{
:httpd_service_name => 'apache2',
:httpd_ports_file => '/etc/apache2/ports.conf',
:wsgi_script_path => '/usr/lib/cgi-bin/ceilometer',
:wsgi_script_source => '/usr/lib/python2.7/dist-packages/ceilometer/api/app.wsgi'
}
when 'RedHat'
{
:httpd_service_name => 'httpd',
:httpd_ports_file => '/etc/httpd/conf/ports.conf',
:wsgi_script_path => '/var/www/cgi-bin/ceilometer',
:wsgi_script_source => '/usr/lib/python2.7/site-packages/ceilometer/api/app.wsgi'
}
end
end
it_behaves_like 'apache serving ceilometer with mod_wsgi'
end
end
end