From d22ad66cc2862994718e067b738d021ef157bb77 Mon Sep 17 00:00:00 2001 From: Mykyta Karpin Date: Fri, 7 Apr 2017 12:38:29 +0300 Subject: [PATCH] oslo log: check puppet resource instead of actual config in spec Change-Id: I892f333e069604ae04e3e9af04622edd32a3451c --- spec/classes/glare_logging_spec.rb | 84 +++++++++++++----------------- 1 file changed, 36 insertions(+), 48 deletions(-) diff --git a/spec/classes/glare_logging_spec.rb b/spec/classes/glare_logging_spec.rb index 25a5c89..f32e614 100644 --- a/spec/classes/glare_logging_spec.rb +++ b/spec/classes/glare_logging_spec.rb @@ -17,8 +17,7 @@ describe 'glare::logging' do :publish_errors => true, :default_log_levels => { 'amqp' => 'WARN', 'amqplib' => 'WARN', 'boto' => 'WARN', - 'qpid' => 'WARN', 'sqlalchemy' => 'WARN', 'suds' => 'INFO', - 'iso8601' => 'WARN', + 'sqlalchemy' => 'WARN', 'suds' => 'INFO', 'iso8601' => 'WARN', 'requests.packages.urllib3.connectionpool' => 'WARN' }, :fatal_deprecations => true, :instance_format => '[instance: %(uuid)s] ', @@ -28,7 +27,7 @@ describe 'glare::logging' do :use_stderr => false, :syslog_log_facility => 'LOG_FOO', :log_dir => '/var/log', - :log_file => '/var/log/glare.log', + :log_file => '/var/tmp/glare_random.log', :debug => true, } end @@ -57,63 +56,52 @@ describe 'glare::logging' do shared_examples 'basic default logging settings' do it 'configures glare logging settings with default values' do - is_expected.to contain_glare_config('DEFAULT/use_syslog').with(:value => '') - is_expected.to contain_glare_config('DEFAULT/use_stderr').with(:value => '') - is_expected.to contain_glare_config('DEFAULT/syslog_log_facility').with(:value => '') - is_expected.to contain_glare_config('DEFAULT/log_dir').with(:value => '/var/log/glare') - is_expected.to contain_glare_config('DEFAULT/log_file').with(:value => '/var/log/glare/glare.log') - is_expected.to contain_glare_config('DEFAULT/debug').with(:value => '') + is_expected.to contain_oslo__log('glare_config').with( + :use_syslog => '', + :use_stderr => '', + :syslog_log_facility => '', + :log_dir => '/var/log/glare', + :log_file => '/var/log/glare/glare.log', + :debug => '', + ) end end shared_examples 'basic non-default logging settings' do it 'configures glare logging settings with non-default values' do - is_expected.to contain_glare_config('DEFAULT/use_syslog').with(:value => 'true') - is_expected.to contain_glare_config('DEFAULT/use_stderr').with(:value => 'false') - is_expected.to contain_glare_config('DEFAULT/syslog_log_facility').with(:value => 'LOG_FOO') - is_expected.to contain_glare_config('DEFAULT/log_dir').with(:value => '/var/log') - is_expected.to contain_glare_config('DEFAULT/log_file').with(:value => '/var/log/glare.log') - is_expected.to contain_glare_config('DEFAULT/debug').with(:value => 'true') + is_expected.to contain_oslo__log('glare_config').with( + :use_syslog => true, + :use_stderr => false, + :syslog_log_facility => 'LOG_FOO', + :log_dir => '/var/log', + :log_file => '/var/tmp/glare_random.log', + :debug => true, + ) end end shared_examples_for 'logging params set' do it 'enables logging params' do - is_expected.to contain_glare_config('DEFAULT/logging_context_format_string').with_value( - '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s') - - is_expected.to contain_glare_config('DEFAULT/logging_default_format_string').with_value( - '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s') - - is_expected.to contain_glare_config('DEFAULT/logging_debug_format_suffix').with_value( - '%(funcName)s %(pathname)s:%(lineno)d') - - is_expected.to contain_glare_config('DEFAULT/logging_exception_prefix').with_value( - '%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s') - - is_expected.to contain_glare_config('DEFAULT/log_config_append').with_value( - '/etc/glare/logging.conf') - is_expected.to contain_glare_config('DEFAULT/publish_errors').with_value( - true) - - is_expected.to contain_glare_config('DEFAULT/default_log_levels').with_value( - 'amqp=WARN,amqplib=WARN,boto=WARN,iso8601=WARN,qpid=WARN,requests.packages.urllib3.connectionpool=WARN,sqlalchemy=WARN,suds=INFO') - - is_expected.to contain_glare_config('DEFAULT/fatal_deprecations').with_value( - true) - - is_expected.to contain_glare_config('DEFAULT/instance_format').with_value( - '[instance: %(uuid)s] ') - - is_expected.to contain_glare_config('DEFAULT/instance_uuid_format').with_value( - '[instance: %(uuid)s] ') - - is_expected.to contain_glare_config('DEFAULT/log_date_format').with_value( - '%Y-%m-%d %H:%M:%S') + is_expected.to contain_oslo__log('glare_config').with( + :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/glare/logging.conf', + :publish_errors => true, + :default_log_levels => { + 'amqp' => 'WARN', 'amqplib' => 'WARN', 'boto' => 'WARN', + 'sqlalchemy' => 'WARN', 'suds' => 'INFO', 'iso8601' => 'WARN', + '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', + ) end end - shared_examples_for 'logging params unset' do [ :logging_context_format_string, :logging_default_format_string, :logging_debug_format_suffix, :logging_exception_prefix, @@ -121,7 +109,7 @@ describe 'glare::logging' do :default_log_levels, :fatal_deprecations, :instance_format, :instance_uuid_format, :log_date_format, ].each { |param| - it { is_expected.to contain_glare_config("DEFAULT/#{param}").with_value('') } + it { is_expected.to contain_oslo__log('glare_config').with("#{param}" => '') } } end