| 1 |
require 'spec_helper' |
| 2 |
|
| 3 |
describe 'nova::logging' do |
| 4 |
|
| 5 |
let :params do |
| 6 |
{ |
| 7 |
} |
| 8 |
end |
| 9 |
|
| 10 |
let :log_params do |
| 11 |
{ |
| 12 |
:logging_context_format_string => '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s', |
| 13 |
:logging_default_format_string => '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s', |
| 14 |
:logging_debug_format_suffix => '%(funcName)s %(pathname)s:%(lineno)d', |
| 15 |
:logging_exception_prefix => '%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s', |
| 16 |
:log_config_append => '/etc/nova/logging.conf', |
| 17 |
:publish_errors => true, |
| 18 |
:default_log_levels => { |
| 19 |
'amqp' => 'WARN', 'amqplib' => 'WARN', 'boto' => 'WARN', |
| 20 |
'sqlalchemy' => 'WARN', 'suds' => 'INFO', 'iso8601' => 'WARN', |
| 21 |
'requests.packages.urllib3.connectionpool' => 'WARN' }, |
| 22 |
:fatal_deprecations => true, |
| 23 |
:instance_format => '[instance: %(uuid)s] ', |
| 24 |
:instance_uuid_format => '[instance: %(uuid)s] ', |
| 25 |
:log_date_format => '%Y-%m-%d %H:%M:%S', |
| 26 |
:use_syslog => true, |
| 27 |
:use_json => true, |
| 28 |
:use_journal => true, |
| 29 |
:use_stderr => false, |
| 30 |
:log_facility => 'LOG_FOO', |
| 31 |
:log_dir => '/var/log/foo', |
| 32 |
:log_file => '/var/log/foo/nova.log', |
| 33 |
:debug => true, |
| 34 |
} |
| 35 |
end |
| 36 |
|
| 37 |
shared_examples_for 'nova-logging' do |
| 38 |
|
| 39 |
context 'with basic logging options and default settings' do |
| 40 |
it_configures 'basic default logging settings' |
| 41 |
end |
| 42 |
|
| 43 |
context 'with basic logging options and non-default settings' do |
| 44 |
before { params.merge!( log_params ) } |
| 45 |
it_configures 'basic non-default logging settings' |
| 46 |
end |
| 47 |
|
| 48 |
context 'with extended logging options' do |
| 49 |
before { params.merge!( log_params ) } |
| 50 |
it_configures 'logging params set' |
| 51 |
end |
| 52 |
|
| 53 |
context 'without extended logging options' do |
| 54 |
it_configures 'logging params unset' |
| 55 |
end |
| 56 |
|
| 57 |
end |
| 58 |
|
| 59 |
shared_examples 'basic default logging settings' do |
| 60 |
it 'configures nova logging settings with default values' do |
| 61 |
is_expected.to contain_oslo__log('nova_config').with( |
| 62 |
:use_syslog => '<SERVICE DEFAULT>', |
| 63 |
:use_json => '<SERVICE DEFAULT>', |
| 64 |
:use_journal => '<SERVICE DEFAULT>', |
| 65 |
:use_stderr => '<SERVICE DEFAULT>', |
| 66 |
:log_dir => '/var/log/nova', |
| 67 |
:log_file => '<SERVICE DEFAULT>', |
| 68 |
:debug => '<SERVICE DEFAULT>', |
| 69 |
) |
| 70 |
end |
| 71 |
end |
| 72 |
|
| 73 |
shared_examples 'basic non-default logging settings' do |
| 74 |
it 'configures nova logging settings with non-default values' do |
| 75 |
is_expected.to contain_oslo__log('nova_config').with( |
| 76 |
:use_syslog => true, |
| 77 |
:use_json => true, |
| 78 |
:use_journal => true, |
| 79 |
:use_stderr => false, |
| 80 |
:syslog_log_facility => 'LOG_FOO', |
| 81 |
:log_dir => '/var/log/foo', |
| 82 |
:log_file => '/var/log/foo/nova.log', |
| 83 |
:debug => true, |
| 84 |
) |
| 85 |
end |
| 86 |
end |
| 87 |
|
| 88 |
shared_examples_for 'logging params set' do |
| 89 |
it 'enables logging params' do |
| 90 |
is_expected.to contain_oslo__log('nova_config').with( |
| 91 |
:logging_context_format_string => |
| 92 |
'%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s', |
| 93 |
:logging_default_format_string => '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s', |
| 94 |
:logging_debug_format_suffix => '%(funcName)s %(pathname)s:%(lineno)d', |
| 95 |
:logging_exception_prefix => '%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s', |
| 96 |
:log_config_append => '/etc/nova/logging.conf', |
| 97 |
:publish_errors => true, |
| 98 |
:default_log_levels => { |
| 99 |
'amqp' => 'WARN', 'amqplib' => 'WARN', 'boto' => 'WARN', |
| 100 |
'sqlalchemy' => 'WARN', 'suds' => 'INFO', 'iso8601' => 'WARN', |
| 101 |
'requests.packages.urllib3.connectionpool' => 'WARN' }, |
| 102 |
:fatal_deprecations => true, |
| 103 |
:instance_format => '[instance: %(uuid)s] ', |
| 104 |
:instance_uuid_format => '[instance: %(uuid)s] ', |
| 105 |
:log_date_format => '%Y-%m-%d %H:%M:%S', |
| 106 |
) |
| 107 |
end |
| 108 |
end |
| 109 |
|
| 110 |
|
| 111 |
shared_examples_for 'logging params unset' do |
| 112 |
[ :logging_context_format_string, :logging_default_format_string, |
| 113 |
:logging_debug_format_suffix, :logging_exception_prefix, |
| 114 |
:log_config_append, :publish_errors, |
| 115 |
:default_log_levels, :fatal_deprecations, |
| 116 |
:instance_format, :instance_uuid_format, |
| 117 |
:log_date_format, ].each { |param| |
| 118 |
it { is_expected.to contain_oslo__log('nova_config').with("#{param}" => '<SERVICE DEFAULT>') } |
| 119 |
} |
| 120 |
end |
| 121 |
|
| 122 |
|
| 123 |
on_supported_os({ |
| 124 |
:supported_os => OSDefaults.get_supported_os |
| 125 |
}).each do |os,facts| |
| 126 |
context "on #{os}" do |
| 127 |
let (:facts) do |
| 128 |
facts.merge!(OSDefaults.get_facts()) |
| 129 |
end |
| 130 |
|
| 131 |
it_configures 'nova-logging' |
| 132 |
end |
| 133 |
end |
| 134 |
|
| 135 |
end |