oslo log: check puppet resource instead of actual config in spec

- additionaly switch to usage of OSDefaults in logging spec

Change-Id: If87ed9e2ee49f277d1c51988566023e14797f8f3
This commit is contained in:
Mykyta Karpin 2017-03-14 18:03:36 +02:00
parent b87e23f774
commit 92144af37f
1 changed files with 56 additions and 71 deletions

View File

@ -32,86 +32,75 @@ describe 'keystone::logging' do
} }
end end
shared_examples 'basic default logging settings' do
it 'configures glance logging settings with default values' do
is_expected.to contain_keystone_config('DEFAULT/use_syslog').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_keystone_config('DEFAULT/use_stderr').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_keystone_config('DEFAULT/log_dir').with(:value => '/var/log/keystone')
is_expected.to contain_keystone_config('DEFAULT/log_file').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_keystone_config('DEFAULT/debug').with(:value => '<SERVICE DEFAULT>')
end
end
shared_examples 'basic non-default logging settings' do
it 'configures glance logging settings with non-default values' do
is_expected.to contain_keystone_config('DEFAULT/use_syslog').with(:value => 'true')
is_expected.to contain_keystone_config('DEFAULT/use_stderr').with(:value => 'false')
is_expected.to contain_keystone_config('DEFAULT/syslog_log_facility').with(:value => 'LOG_FOO')
is_expected.to contain_keystone_config('DEFAULT/log_dir').with(:value => '/var/log')
is_expected.to contain_keystone_config('DEFAULT/log_file').with(:value => '/var/tmp/keystone_random.log')
is_expected.to contain_keystone_config('DEFAULT/debug').with(:value => 'true')
end
end
shared_examples_for 'keystone-logging' do shared_examples_for 'keystone-logging' do
context 'with basic logging options and default settings' do context 'with basic logging options and default settings' do
it_configures 'basic default logging settings' it_behaves_like 'basic default logging settings'
end end
context 'with basic logging options and non-default settings' do context 'with basic logging options and non-default settings' do
before { params.merge!( log_params ) } before { params.merge!( log_params ) }
it_configures 'basic non-default logging settings' it_behaves_like 'basic non-default logging settings'
end end
context 'with extended logging options' do context 'with extended logging options' do
before { params.merge!( log_params ) } before { params.merge!( log_params ) }
it_configures 'logging params set' it_behaves_like 'logging params set'
end end
context 'without extended logging options' do context 'without extended logging options' do
it_configures 'logging params unset' it_behaves_like 'logging params unset'
end end
end end
shared_examples 'basic default logging settings' do
it 'configures keystone logging settings with default values' do
is_expected.to contain_oslo__log('keystone_config').with(
:use_syslog => '<SERVICE DEFAULT>',
:use_stderr => '<SERVICE DEFAULT>',
:log_dir => '/var/log/keystone',
:log_file => '<SERVICE DEFAULT>',
:debug => '<SERVICE DEFAULT>',
)
end
end
shared_examples 'basic non-default logging settings' do
it 'configures keystone logging settings with non-default values' do
is_expected.to contain_oslo__log('keystone_config').with(
:use_syslog => true,
:use_stderr => false,
:syslog_log_facility => 'LOG_FOO',
:log_dir => '/var/log',
:log_file => '/var/tmp/keystone_random.log',
:debug => true,
)
end
end
shared_examples_for 'logging params set' do shared_examples_for 'logging params set' do
it 'enables logging params' do it 'enables logging params' do
is_expected.to contain_keystone_config('DEFAULT/logging_context_format_string').with_value( is_expected.to contain_oslo__log('keystone_config').with(
'%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s') :logging_context_format_string =>
'%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s',
is_expected.to contain_keystone_config('DEFAULT/logging_default_format_string').with_value( :logging_default_format_string => '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s',
'%(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',
is_expected.to contain_keystone_config('DEFAULT/logging_debug_format_suffix').with_value( :log_config_append => '/etc/keystone/logging.conf',
'%(funcName)s %(pathname)s:%(lineno)d') :publish_errors => true,
:default_log_levels => {
is_expected.to contain_keystone_config('DEFAULT/logging_exception_prefix').with_value( 'amqp' => 'WARN', 'amqplib' => 'WARN', 'boto' => 'WARN',
'%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s') 'sqlalchemy' => 'WARN', 'suds' => 'INFO', 'iso8601' => 'WARN',
'requests.packages.urllib3.connectionpool' => 'WARN' },
is_expected.to contain_keystone_config('DEFAULT/log_config_append').with_value( :fatal_deprecations => true,
'/etc/keystone/logging.conf') :instance_format => '[instance: %(uuid)s] ',
is_expected.to contain_keystone_config('DEFAULT/publish_errors').with_value( :instance_uuid_format => '[instance: %(uuid)s] ',
true) :log_date_format => '%Y-%m-%d %H:%M:%S',
)
is_expected.to contain_keystone_config('DEFAULT/default_log_levels').with_value(
'amqp=WARN,amqplib=WARN,boto=WARN,iso8601=WARN,requests.packages.urllib3.connectionpool=WARN,sqlalchemy=WARN,suds=INFO')
is_expected.to contain_keystone_config('DEFAULT/fatal_deprecations').with_value(
true)
is_expected.to contain_keystone_config('DEFAULT/instance_format').with_value(
'[instance: %(uuid)s] ')
is_expected.to contain_keystone_config('DEFAULT/instance_uuid_format').with_value(
'[instance: %(uuid)s] ')
is_expected.to contain_keystone_config('DEFAULT/log_date_format').with_value(
'%Y-%m-%d %H:%M:%S')
end end
end end
shared_examples_for 'logging params unset' do shared_examples_for 'logging params unset' do
[ :logging_context_format_string, :logging_default_format_string, [ :logging_context_format_string, :logging_default_format_string,
:logging_debug_format_suffix, :logging_exception_prefix, :logging_debug_format_suffix, :logging_exception_prefix,
@ -119,24 +108,20 @@ describe 'keystone::logging' do
:default_log_levels, :fatal_deprecations, :default_log_levels, :fatal_deprecations,
:instance_format, :instance_uuid_format, :instance_format, :instance_uuid_format,
:log_date_format, ].each { |param| :log_date_format, ].each { |param|
it { is_expected.to contain_keystone_config("DEFAULT/#{param}").with_value('<SERVICE DEFAULT>') } it { is_expected.to contain_oslo__log('keystone_config').with("#{param}" => '<SERVICE DEFAULT>') }
} }
end end
context 'on Debian platforms' do on_supported_os({
let :facts do :supported_os => OSDefaults.get_supported_os
@default_facts.merge({ :osfamily => 'Debian' }) }).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts({}))
end
it_behaves_like 'keystone-logging'
end end
it_configures 'keystone-logging'
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
it_configures 'keystone-logging'
end end
end end