2014-09-01 12:27:30 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'cinder::logging' do
|
|
|
|
|
|
|
|
let :params do
|
|
|
|
{
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
let :log_params do
|
|
|
|
{
|
|
|
|
:logging_context_format_string => '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s',
|
|
|
|
:logging_default_format_string => '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s',
|
|
|
|
:logging_debug_format_suffix => '%(funcName)s %(pathname)s:%(lineno)d',
|
|
|
|
:logging_exception_prefix => '%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s',
|
|
|
|
:log_config_append => '/etc/cinder/logging.conf',
|
|
|
|
:publish_errors => true,
|
2015-09-24 14:27:12 +02:00
|
|
|
:default_log_levels => {
|
2014-09-01 12:27:30 +00:00
|
|
|
'amqp' => 'WARN', 'amqplib' => 'WARN', 'boto' => 'WARN',
|
2016-04-18 13:39:31 +03:00
|
|
|
'sqlalchemy' => 'WARN', 'suds' => 'INFO', 'iso8601' => 'WARN',
|
2014-09-01 12:27:30 +00:00
|
|
|
'requests.packages.urllib3.connectionpool' => 'WARN' },
|
|
|
|
:fatal_deprecations => true,
|
|
|
|
:instance_format => '[instance: %(uuid)s] ',
|
|
|
|
:instance_uuid_format => '[instance: %(uuid)s] ',
|
|
|
|
:log_date_format => '%Y-%m-%d %H:%M:%S',
|
2016-05-31 11:18:25 -03:00
|
|
|
:use_syslog => false,
|
2015-09-24 14:27:12 +02:00
|
|
|
:use_stderr => false,
|
|
|
|
:log_facility => 'LOG_USER',
|
|
|
|
:log_dir => '/var/log',
|
|
|
|
:debug => true,
|
2014-09-01 12:27:30 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
shared_examples_for 'cinder-logging' do
|
|
|
|
|
2015-09-24 14:27:12 +02:00
|
|
|
context 'with basic logging options and default settings' do
|
|
|
|
it_configures 'basic default logging settings'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with basic logging options and non-default settings' do
|
|
|
|
before { params.merge!( log_params ) }
|
|
|
|
it_configures 'basic non-default logging settings'
|
|
|
|
end
|
|
|
|
|
2014-09-01 12:27:30 +00:00
|
|
|
context 'with extended logging options' do
|
|
|
|
before { params.merge!( log_params ) }
|
|
|
|
it_configures 'logging params set'
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2015-09-24 14:27:12 +02:00
|
|
|
shared_examples 'basic default logging settings' do
|
2017-03-13 20:08:59 +08:00
|
|
|
it 'configures cinder logging settings with default values' do
|
2016-05-31 11:18:25 -03:00
|
|
|
is_expected.to contain_cinder_config('DEFAULT/use_syslog').with(:value => '<SERVICE DEFAULT>')
|
2015-09-24 14:27:12 +02:00
|
|
|
is_expected.to contain_cinder_config('DEFAULT/use_stderr').with(:value => '<SERVICE DEFAULT>')
|
|
|
|
is_expected.to contain_cinder_config('DEFAULT/syslog_log_facility').with(:value => '<SERVICE DEFAULT>')
|
2015-11-04 10:59:50 -06:00
|
|
|
is_expected.to contain_cinder_config('DEFAULT/log_dir').with(:value => '/var/log/cinder')
|
2015-09-24 14:27:12 +02:00
|
|
|
is_expected.to contain_cinder_config('DEFAULT/debug').with(:value => '<SERVICE DEFAULT>')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
shared_examples 'basic non-default logging settings' do
|
2017-03-13 20:08:59 +08:00
|
|
|
it 'configures cinder logging settings with non-default values' do
|
2016-05-31 11:18:25 -03:00
|
|
|
is_expected.to contain_cinder_config('DEFAULT/use_syslog').with(:value => 'false')
|
2015-09-24 14:27:12 +02:00
|
|
|
is_expected.to contain_cinder_config('DEFAULT/use_stderr').with(:value => 'false')
|
|
|
|
is_expected.to contain_cinder_config('DEFAULT/syslog_log_facility').with(:value => 'LOG_USER')
|
|
|
|
is_expected.to contain_cinder_config('DEFAULT/log_dir').with(:value => '/var/log')
|
|
|
|
is_expected.to contain_cinder_config('DEFAULT/debug').with(:value => 'true')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-09-01 12:27:30 +00:00
|
|
|
shared_examples_for 'logging params set' do
|
|
|
|
it 'enables logging params' do
|
2015-02-22 22:29:32 +01:00
|
|
|
is_expected.to contain_cinder_config('DEFAULT/logging_context_format_string').with_value(
|
2014-09-01 12:27:30 +00:00
|
|
|
'%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s')
|
|
|
|
|
2015-02-22 22:29:32 +01:00
|
|
|
is_expected.to contain_cinder_config('DEFAULT/logging_default_format_string').with_value(
|
2014-09-01 12:27:30 +00:00
|
|
|
'%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s')
|
|
|
|
|
2015-02-22 22:29:32 +01:00
|
|
|
is_expected.to contain_cinder_config('DEFAULT/logging_debug_format_suffix').with_value(
|
2014-09-01 12:27:30 +00:00
|
|
|
'%(funcName)s %(pathname)s:%(lineno)d')
|
|
|
|
|
2015-02-22 22:29:32 +01:00
|
|
|
is_expected.to contain_cinder_config('DEFAULT/logging_exception_prefix').with_value(
|
2014-09-01 12:27:30 +00:00
|
|
|
'%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s')
|
|
|
|
|
2015-02-22 22:29:32 +01:00
|
|
|
is_expected.to contain_cinder_config('DEFAULT/log_config_append').with_value(
|
2014-09-01 12:27:30 +00:00
|
|
|
'/etc/cinder/logging.conf')
|
2015-02-22 22:29:32 +01:00
|
|
|
is_expected.to contain_cinder_config('DEFAULT/publish_errors').with_value(
|
2014-09-01 12:27:30 +00:00
|
|
|
true)
|
|
|
|
|
2015-02-22 22:29:32 +01:00
|
|
|
is_expected.to contain_cinder_config('DEFAULT/default_log_levels').with_value(
|
2016-04-18 13:39:31 +03:00
|
|
|
'amqp=WARN,amqplib=WARN,boto=WARN,iso8601=WARN,requests.packages.urllib3.connectionpool=WARN,sqlalchemy=WARN,suds=INFO')
|
2014-09-01 12:27:30 +00:00
|
|
|
|
2015-02-22 22:29:32 +01:00
|
|
|
is_expected.to contain_cinder_config('DEFAULT/fatal_deprecations').with_value(
|
2014-09-01 12:27:30 +00:00
|
|
|
true)
|
|
|
|
|
2015-02-22 22:29:32 +01:00
|
|
|
is_expected.to contain_cinder_config('DEFAULT/instance_format').with_value(
|
2014-09-01 12:27:30 +00:00
|
|
|
'[instance: %(uuid)s] ')
|
|
|
|
|
2015-02-22 22:29:32 +01:00
|
|
|
is_expected.to contain_cinder_config('DEFAULT/instance_uuid_format').with_value(
|
2014-09-01 12:27:30 +00:00
|
|
|
'[instance: %(uuid)s] ')
|
|
|
|
|
2015-02-22 22:29:32 +01:00
|
|
|
is_expected.to contain_cinder_config('DEFAULT/log_date_format').with_value(
|
2014-09-01 12:27:30 +00:00
|
|
|
'%Y-%m-%d %H:%M:%S')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-11-05 22:42:08 -06:00
|
|
|
on_supported_os({
|
|
|
|
:supported_os => OSDefaults.get_supported_os
|
|
|
|
}).each do |os,facts|
|
|
|
|
context "on #{os}" do
|
|
|
|
let (:facts) do
|
2016-10-04 20:33:40 +03:00
|
|
|
facts.merge(OSDefaults.get_facts({:os_workers => 8}))
|
2015-11-05 22:42:08 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
it_configures 'cinder-logging'
|
2014-09-01 12:27:30 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|