puppet-mistral/spec/classes/mistral_logging_spec.rb
Emilien Macchi 9f19d11c16 Refactor puppet-mistral
The module was written in a way that was not consistent with other
Puppet OpenStack modules, the interface was very different.

This patch:
* add db.pp
* update logging.pp with usual parameters
* drop useless parameters in keystone/auth.pp
* cleanup params.pp
* drop services.pp, which is useless
* Update unit tests
* Add coordination support in init.pp
* Some alignment issues
* Add more doc in README
* Stop including ::mistral in all classes
* Include mistral::policy in mistral::api

This is a non-backward compatible change, but since the module has no
release and no stable branch, also very new, this is not something we
need to care at this stage.
People using this module at this stage will have to update their
manifests otherwise their Puppet catalog will fail.

Change-Id: I979e21caa71ee35337dc01b225878701868e966a
2016-02-09 07:34:50 -05:00

125 lines
5.1 KiB
Ruby

require 'spec_helper'
describe 'mistral::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/mistral/logging.conf',
:publish_errors => true,
:default_log_levels => {
'amqp' => 'WARN', 'amqplib' => 'WARN', 'boto' => 'WARN',
'qpid' => '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',
:use_syslog => false,
:use_stderr => false,
:log_facility => 'LOG_USER',
:log_dir => '/var/log',
:verbose => true,
:debug => true,
}
end
shared_examples_for 'mistral-logging' do
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
context 'with extended logging options' do
before { params.merge!( log_params ) }
it_configures 'logging params set'
end
end
shared_examples 'basic default logging settings' do
it 'configures mistral logging settins with default values' do
is_expected.to contain_mistral_config('DEFAULT/use_syslog').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('DEFAULT/use_stderr').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('DEFAULT/syslog_log_facility').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('DEFAULT/log_dir').with(:value => '/var/log/mistral')
is_expected.to contain_mistral_config('DEFAULT/verbose').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('DEFAULT/debug').with(:value => '<SERVICE DEFAULT>')
end
end
shared_examples 'basic non-default logging settings' do
it 'configures mistral logging settins with non-default values' do
is_expected.to contain_mistral_config('DEFAULT/use_syslog').with(:value => 'false')
is_expected.to contain_mistral_config('DEFAULT/use_stderr').with(:value => 'false')
is_expected.to contain_mistral_config('DEFAULT/syslog_log_facility').with(:value => 'LOG_USER')
is_expected.to contain_mistral_config('DEFAULT/log_dir').with(:value => '/var/log')
is_expected.to contain_mistral_config('DEFAULT/verbose').with(:value => 'true')
is_expected.to contain_mistral_config('DEFAULT/debug').with(:value => 'true')
end
end
shared_examples_for 'logging params set' do
it 'enables logging params' do
is_expected.to contain_mistral_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_mistral_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_mistral_config('DEFAULT/logging_debug_format_suffix').with_value(
'%(funcName)s %(pathname)s:%(lineno)d')
is_expected.to contain_mistral_config('DEFAULT/logging_exception_prefix').with_value(
'%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s')
is_expected.to contain_mistral_config('DEFAULT/log_config_append').with_value(
'/etc/mistral/logging.conf')
is_expected.to contain_mistral_config('DEFAULT/publish_errors').with_value(
true)
is_expected.to contain_mistral_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_mistral_config('DEFAULT/fatal_deprecations').with_value(
true)
is_expected.to contain_mistral_config('DEFAULT/instance_format').with_value(
'[instance: %(uuid)s] ')
is_expected.to contain_mistral_config('DEFAULT/instance_uuid_format').with_value(
'[instance: %(uuid)s] ')
is_expected.to contain_mistral_config('DEFAULT/log_date_format').with_value(
'%Y-%m-%d %H:%M:%S')
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({:processorcount => 8}))
end
it_configures 'mistral-logging'
end
end
end