Put all the logging related parameters to the logging class
Currently logging configuration is splitted in two distinct classes, the api.pp and the logging.pp classes. This review aims to centralize all logging related parameters in a single class, the logging.pp one. The impacted parameters are : * use_syslog * use_stderr * log_facility * verbose * debug * log_dir * log_file This change remains backward compatible with what is currently in place. Related-bug: #1515273 Change-Id: I76f51876e78015db722ff0fc37f6bcd76fd651f2 Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
This commit is contained in:
parent
98ba7b3b6d
commit
0ddd0067a1
@ -34,11 +34,33 @@
|
||||
#
|
||||
# [*verbose*]
|
||||
# (optional) Rather to log the trove api service at verbose level.
|
||||
# Default: false
|
||||
# Defaults to undef
|
||||
#
|
||||
# [*debug*]
|
||||
# (optional) Rather to log the trove api service at debug level.
|
||||
# Default: false
|
||||
# Defaults to undef
|
||||
#
|
||||
# [*log_file*]
|
||||
# (optional) The path of file used for logging
|
||||
# If set to boolean false, it will not log to any file.
|
||||
# Defaults to undef
|
||||
#
|
||||
# [*log_dir*]
|
||||
# (optional) directory to which trove logs are sent.
|
||||
# If set to boolean false, it will not log to any directory.
|
||||
# Defaults to undef
|
||||
#
|
||||
# [*use_syslog*]
|
||||
# (optional) Use syslog for logging.
|
||||
# Defaults to undef
|
||||
#
|
||||
# [*use_stderr*]
|
||||
# (optional) Use stderr for logging
|
||||
# Defaults to undef
|
||||
#
|
||||
# [*log_facility*]
|
||||
# (optional) Syslog facility to receive log lines.
|
||||
# Defaults to undef.
|
||||
#
|
||||
# [*bind_host*]
|
||||
# (optional) The address of the host to bind to.
|
||||
@ -56,16 +78,6 @@
|
||||
# (optional) Number of trove API worker processes to start
|
||||
# Default: $::processorcount
|
||||
#
|
||||
# [*log_file*]
|
||||
# (optional) The path of file used for logging
|
||||
# If set to boolean false, it will not log to any file.
|
||||
# Default: /var/log/trove/trove-api.log
|
||||
#
|
||||
# [*log_dir*]
|
||||
# (optional) directory to which trove logs are sent.
|
||||
# If set to boolean false, it will not log to any directory.
|
||||
# Defaults to '/var/log/trove'
|
||||
#
|
||||
# [*auth_host*]
|
||||
# (optional) Host running auth service.
|
||||
# Defaults to '127.0.0.1'.
|
||||
@ -94,14 +106,6 @@
|
||||
# (optional) Whether to enable services.
|
||||
# Defaults to true.
|
||||
#
|
||||
# [*use_syslog*]
|
||||
# (optional) Use syslog for logging.
|
||||
# Defaults to false.
|
||||
#
|
||||
# [*log_facility*]
|
||||
# (optional) Syslog facility to receive log lines.
|
||||
# Defaults to 'LOG_USER'.
|
||||
#
|
||||
# [*purge_config*]
|
||||
# (optional) Whether to set only the specified config options
|
||||
# in the api config.
|
||||
@ -141,14 +145,17 @@
|
||||
#
|
||||
class trove::api(
|
||||
$keystone_password,
|
||||
$verbose = false,
|
||||
$debug = false,
|
||||
$verbose = undef,
|
||||
$debug = undef,
|
||||
$log_file = undef,
|
||||
$log_dir = undef,
|
||||
$use_syslog = undef,
|
||||
$use_stderr = undef,
|
||||
$log_facility = undef,
|
||||
$bind_host = '0.0.0.0',
|
||||
$bind_port = '8779',
|
||||
$backlog = '4096',
|
||||
$workers = $::processorcount,
|
||||
$log_file = '/var/log/trove/trove-api.log',
|
||||
$log_dir = '/var/log/trove',
|
||||
$auth_host = '127.0.0.1',
|
||||
$auth_url = false,
|
||||
$auth_port = '35357',
|
||||
@ -156,8 +163,6 @@ class trove::api(
|
||||
$keystone_tenant = 'services',
|
||||
$keystone_user = 'trove',
|
||||
$enabled = true,
|
||||
$use_syslog = false,
|
||||
$log_facility = 'LOG_USER',
|
||||
$purge_config = false,
|
||||
$cert_file = false,
|
||||
$key_file = false,
|
||||
@ -173,6 +178,7 @@ class trove::api(
|
||||
|
||||
require ::keystone::python
|
||||
include ::trove::db
|
||||
include ::trove::logging
|
||||
include ::trove::params
|
||||
|
||||
Trove_config<||> ~> Exec['post-trove_config']
|
||||
@ -181,8 +187,6 @@ class trove::api(
|
||||
|
||||
# basic service config
|
||||
trove_config {
|
||||
'DEFAULT/verbose': value => $verbose;
|
||||
'DEFAULT/debug': value => $debug;
|
||||
'DEFAULT/bind_host': value => $bind_host;
|
||||
'DEFAULT/bind_port': value => $bind_port;
|
||||
'DEFAULT/backlog': value => $backlog;
|
||||
@ -239,39 +243,6 @@ class trove::api(
|
||||
}
|
||||
}
|
||||
|
||||
# Logging
|
||||
if $log_file {
|
||||
trove_config {
|
||||
'DEFAULT/log_file': value => $log_file;
|
||||
}
|
||||
} else {
|
||||
trove_config {
|
||||
'DEFAULT/log_file': ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $log_dir {
|
||||
trove_config {
|
||||
'DEFAULT/log_dir': value => $log_dir;
|
||||
}
|
||||
} else {
|
||||
trove_config {
|
||||
'DEFAULT/log_dir': ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
# Syslog
|
||||
if $use_syslog {
|
||||
trove_config {
|
||||
'DEFAULT/use_syslog' : value => true;
|
||||
'DEFAULT/syslog_log_facility' : value => $log_facility;
|
||||
}
|
||||
} else {
|
||||
trove_config {
|
||||
'DEFAULT/use_syslog': value => false;
|
||||
}
|
||||
}
|
||||
|
||||
# rate limits
|
||||
trove_config {
|
||||
'DEFAULT/http_get_rate': value => $http_get_rate;
|
||||
|
156
manifests/logging.pp
Normal file
156
manifests/logging.pp
Normal file
@ -0,0 +1,156 @@
|
||||
# Class trove::logging
|
||||
#
|
||||
# Trove logging configuration
|
||||
#
|
||||
# == parameters
|
||||
#
|
||||
# [*verbose*]
|
||||
# (Optional) Should the daemons log verbose messages
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*debug*]
|
||||
# (Optional) Should the daemons log debug messages
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*use_syslog*]
|
||||
# (Optional) Use syslog for logging.
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*use_stderr*]
|
||||
# (optional) Use stderr for logging
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*log_facility*]
|
||||
# (Optional) Syslog facility to receive log lines.
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*log_dir*]
|
||||
# (optional) Directory where logs should be stored.
|
||||
# If set to boolean false, it will not log to any directory.
|
||||
# Defaults to '/var/log/trove'
|
||||
#
|
||||
# [*log_file*]
|
||||
# (optional) The path of file used for logging
|
||||
# If set to boolean false, it will not log to any file.
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*logging_context_format_string*]
|
||||
# (optional) Format string to use for log messages with context.
|
||||
# Defaults to $::os_service_default
|
||||
# Example: '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s\
|
||||
# [%(request_id)s %(user_identity)s] %(instance)s%(message)s'
|
||||
#
|
||||
# [*logging_default_format_string*]
|
||||
# (optional) Format string to use for log messages without context.
|
||||
# Defaults to $::os_service_default
|
||||
# Example: '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s\
|
||||
# [-] %(instance)s%(message)s'
|
||||
#
|
||||
# [*logging_debug_format_suffix*]
|
||||
# (optional) Formatted data to append to log format when level is DEBUG.
|
||||
# Defaults to $::os_service_default
|
||||
# Example: '%(funcName)s %(pathname)s:%(lineno)d'
|
||||
#
|
||||
# [*logging_exception_prefix*]
|
||||
# (optional) Prefix each line of exception output with this format.
|
||||
# Defaults to $::os_service_default
|
||||
# Example: '%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s'
|
||||
#
|
||||
# [*log_config_append*]
|
||||
# The name of an additional logging configuration file.
|
||||
# Defaults to $::os_service_default
|
||||
# See https://docs.python.org/2/howto/logging.html
|
||||
#
|
||||
# [*default_log_levels*]
|
||||
# (optional) Hash of logger (keys) and level (values) pairs.
|
||||
# Defaults to $::os_service_default
|
||||
# Example:
|
||||
# { 'amqp' => 'WARN', 'amqplib' => 'WARN', 'boto' => 'WARN',
|
||||
# 'qpid' => 'WARN', 'sqlalchemy' => 'WARN', 'suds' => 'INFO',
|
||||
# 'iso8601' => 'WARN',
|
||||
# 'requests.packages.urllib3.connectionpool' => 'WARN' }
|
||||
#
|
||||
# [*publish_errors*]
|
||||
# (optional) Publish error events (boolean value).
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*fatal_deprecations*]
|
||||
# (optional) Make deprecations fatal (boolean value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*instance_format*]
|
||||
# (optional) If an instance is passed with the log message, format it
|
||||
# like this (string value).
|
||||
# Defaults to $::os_service_default
|
||||
# Example: '[instance: %(uuid)s] '
|
||||
#
|
||||
# [*instance_uuid_format*]
|
||||
# (optional) If an instance UUID is passed with the log message, format
|
||||
# it like this (string value).
|
||||
# Defaults to $::os_service_default
|
||||
# Example: instance_uuid_format='[instance: %(uuid)s] '
|
||||
#
|
||||
# [*log_date_format*]
|
||||
# (optional) Format string for %%(asctime)s in log records.
|
||||
# Defaults to $::os_service_default
|
||||
# Example: 'Y-%m-%d %H:%M:%S'
|
||||
|
||||
class trove::logging(
|
||||
$use_syslog = $::os_service_default,
|
||||
$use_stderr = $::os_service_default,
|
||||
$log_facility = $::os_service_default,
|
||||
$log_dir = '/var/log/trove',
|
||||
$log_file = $::os_service_default,
|
||||
$verbose = $::os_service_default,
|
||||
$debug = $::os_service_default,
|
||||
$logging_context_format_string = $::os_service_default,
|
||||
$logging_default_format_string = $::os_service_default,
|
||||
$logging_debug_format_suffix = $::os_service_default,
|
||||
$logging_exception_prefix = $::os_service_default,
|
||||
$log_config_append = $::os_service_default,
|
||||
$default_log_levels = $::os_service_default,
|
||||
$publish_errors = $::os_service_default,
|
||||
$fatal_deprecations = $::os_service_default,
|
||||
$instance_format = $::os_service_default,
|
||||
$instance_uuid_format = $::os_service_default,
|
||||
$log_date_format = $::os_service_default,
|
||||
) {
|
||||
|
||||
# NOTE(spredzy): In order to keep backward compatibility we rely on the pick function
|
||||
# to use trove::<myparam> first then trove::logging::<myparam>.
|
||||
$use_syslog_real = pick($::trove::api::use_syslog, $use_syslog)
|
||||
$use_stderr_real = pick($::trove::api::use_stderr, $use_stderr)
|
||||
$log_facility_real = pick($::trove::api::log_facility, $log_facility)
|
||||
$log_dir_real = pick($::trove::api::log_dir, $log_dir)
|
||||
$log_file_real = pick($::trove::api::log_file, $log_file)
|
||||
$verbose_real = pick($::trove::api::verbose, $verbose)
|
||||
$debug_real = pick($::trove::api::debug, $debug)
|
||||
|
||||
if is_service_default($default_log_levels) {
|
||||
$default_log_levels_real = $default_log_levels
|
||||
} else {
|
||||
$default_log_levels_real = join(sort(join_keys_to_values($default_log_levels, '=')), ',')
|
||||
}
|
||||
|
||||
trove_config {
|
||||
'DEFAULT/debug' : value => $debug_real;
|
||||
'DEFAULT/verbose' : value => $verbose_real;
|
||||
'DEFAULT/use_stderr' : value => $use_stderr_real;
|
||||
'DEFAULT/use_syslog' : value => $use_syslog_real;
|
||||
'DEFAULT/log_dir' : value => $log_dir_real;
|
||||
'DEFAULT/log_file' : value => $log_file_real;
|
||||
'DEFAULT/syslog_log_facility' : value => $log_facility_real;
|
||||
'DEFAULT/logging_context_format_string' : value => $logging_context_format_string;
|
||||
'DEFAULT/logging_default_format_string' : value => $logging_default_format_string;
|
||||
'DEFAULT/logging_debug_format_suffix' : value => $logging_debug_format_suffix;
|
||||
'DEFAULT/logging_exception_prefix' : value => $logging_exception_prefix;
|
||||
'DEFAULT/log_config_append' : value => $log_config_append;
|
||||
'DEFAULT/default_log_levels' : value => $default_log_levels_real;
|
||||
'DEFAULT/publish_errors' : value => $publish_errors;
|
||||
'DEFAULT/fatal_deprecations' : value => $fatal_deprecations;
|
||||
'DEFAULT/instance_format' : value => $instance_format;
|
||||
'DEFAULT/instance_uuid_format' : value => $instance_uuid_format;
|
||||
'DEFAULT/log_date_format' : value => $log_date_format;
|
||||
}
|
||||
}
|
||||
|
@ -62,8 +62,6 @@ describe 'trove::api' do
|
||||
end
|
||||
|
||||
it 'configures trove-api with default parameters' do
|
||||
is_expected.to contain_trove_config('DEFAULT/verbose').with_value(false)
|
||||
is_expected.to contain_trove_config('DEFAULT/debug').with_value(false)
|
||||
is_expected.to contain_trove_config('DEFAULT/bind_host').with_value('0.0.0.0')
|
||||
is_expected.to contain_trove_config('DEFAULT/bind_port').with_value('8779')
|
||||
is_expected.to contain_trove_config('DEFAULT/backlog').with_value('4096')
|
||||
@ -193,8 +191,10 @@ describe 'trove::api' do
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian',
|
||||
:processorcount => 8 }
|
||||
@default_facts.merge({
|
||||
:osfamily => 'Debian',
|
||||
:processorcount => 8,
|
||||
})
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
@ -207,8 +207,10 @@ describe 'trove::api' do
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat',
|
||||
:processorcount => 8 }
|
||||
@default_facts.merge({
|
||||
:osfamily => 'RedHat',
|
||||
:processorcount => 8,
|
||||
})
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
|
@ -39,7 +39,7 @@ describe 'trove::client' do
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
@default_facts.merge({ :osfamily => 'Debian' })
|
||||
end
|
||||
|
||||
it_configures 'trove client'
|
||||
@ -47,7 +47,7 @@ describe 'trove::client' do
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
@default_facts.merge({ :osfamily => 'RedHat' })
|
||||
end
|
||||
|
||||
it_configures 'trove client'
|
||||
|
@ -124,8 +124,10 @@ describe 'trove::conductor' do
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian',
|
||||
:processorcount => 8 }
|
||||
@default_facts.merge({
|
||||
:osfamily => 'Debian',
|
||||
:processorcount => 8,
|
||||
})
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
@ -138,8 +140,10 @@ describe 'trove::conductor' do
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat',
|
||||
:processorcount => 8 }
|
||||
@default_facts.merge({
|
||||
:osfamily => 'RedHat',
|
||||
:processorcount => 8,
|
||||
})
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
|
@ -93,7 +93,7 @@ describe 'trove::db::mysql' do
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
@default_facts.merge({ :osfamily => 'Debian' })
|
||||
end
|
||||
|
||||
it_configures 'trove mysql database'
|
||||
@ -101,7 +101,7 @@ describe 'trove::db::mysql' do
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
@default_facts.merge({ :osfamily => 'RedHat' })
|
||||
end
|
||||
|
||||
it_configures 'trove mysql database'
|
||||
|
@ -12,11 +12,11 @@ describe 'trove::db::postgresql' do
|
||||
|
||||
context 'on a RedHat osfamily' do
|
||||
let :facts do
|
||||
{
|
||||
:osfamily => 'RedHat',
|
||||
:operatingsystemrelease => '7.0',
|
||||
:concat_basedir => '/var/lib/puppet/concat'
|
||||
}
|
||||
@default_facts.merge({
|
||||
:osfamily => 'RedHat',
|
||||
:operatingsystemrelease => '7.0',
|
||||
:concat_basedir => '/var/lib/puppet/concat'
|
||||
})
|
||||
end
|
||||
|
||||
context 'with only required parameters' do
|
||||
@ -34,12 +34,12 @@ describe 'trove::db::postgresql' do
|
||||
|
||||
context 'on a Debian osfamily' do
|
||||
let :facts do
|
||||
{
|
||||
@default_facts.merge({
|
||||
:operatingsystemrelease => '7.8',
|
||||
:operatingsystem => 'Debian',
|
||||
:osfamily => 'Debian',
|
||||
:concat_basedir => '/var/lib/puppet/concat'
|
||||
}
|
||||
:concat_basedir => '/var/lib/puppet/concat'
|
||||
})
|
||||
end
|
||||
|
||||
context 'with only required parameters' do
|
||||
|
@ -75,10 +75,11 @@ describe 'trove::db' do
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
@default_facts.merge({
|
||||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:operatingsystemrelease => 'jessie',
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
it_configures 'trove::db'
|
||||
@ -100,9 +101,10 @@ describe 'trove::db' do
|
||||
|
||||
context 'on Redhat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat',
|
||||
@default_facts.merge({
|
||||
:osfamily => 'RedHat',
|
||||
:operatingsystemrelease => '7.1',
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
it_configures 'trove::db'
|
||||
|
@ -132,8 +132,10 @@ describe 'trove::guestagent' do
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian',
|
||||
:processorcount => 8 }
|
||||
@default_facts.merge({
|
||||
:osfamily => 'Debian',
|
||||
:processorcount => 8
|
||||
})
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
@ -146,8 +148,10 @@ describe 'trove::guestagent' do
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat',
|
||||
:processorcount => 8 }
|
||||
@default_facts.merge({
|
||||
:osfamily => 'RedHat',
|
||||
:processorcount => 8
|
||||
})
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
|
@ -46,7 +46,7 @@ describe 'trove' do
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
@default_facts.merge({ :osfamily => 'Debian' })
|
||||
end
|
||||
|
||||
it_configures 'trove'
|
||||
@ -54,7 +54,7 @@ describe 'trove' do
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
@default_facts.merge({ :osfamily => 'RedHat' })
|
||||
end
|
||||
|
||||
it 'installs common package' do
|
||||
|
@ -23,7 +23,7 @@ require 'spec_helper'
|
||||
describe 'trove::keystone::auth' do
|
||||
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
@default_facts.merge({ :osfamily => 'Debian' })
|
||||
end
|
||||
|
||||
describe 'with default class parameters' do
|
||||
|
147
spec/classes/trove_logging_spec.rb
Normal file
147
spec/classes/trove_logging_spec.rb
Normal file
@ -0,0 +1,147 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'trove::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/trove/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 => true,
|
||||
:use_stderr => false,
|
||||
:log_facility => 'LOG_FOO',
|
||||
:log_dir => '/var/log',
|
||||
:log_file => '/var/log/foo.log',
|
||||
:verbose => true,
|
||||
:debug => true,
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples_for 'trove-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
|
||||
|
||||
context 'without extended logging options' do
|
||||
it_configures 'logging params unset'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
shared_examples 'basic default logging settings' do
|
||||
it 'configures trove logging settins with default values' do
|
||||
is_expected.to contain_trove_config('DEFAULT/use_syslog').with(:value => '<SERVICE DEFAULT>')
|
||||
is_expected.to contain_trove_config('DEFAULT/use_stderr').with(:value => '<SERVICE DEFAULT>')
|
||||
is_expected.to contain_trove_config('DEFAULT/syslog_log_facility').with(:value => '<SERVICE DEFAULT>')
|
||||
is_expected.to contain_trove_config('DEFAULT/log_dir').with(:value => '/var/log/trove')
|
||||
is_expected.to contain_trove_config('DEFAULT/log_file').with(:value => '<SERVICE DEFAULT>')
|
||||
is_expected.to contain_trove_config('DEFAULT/verbose').with(:value => '<SERVICE DEFAULT>')
|
||||
is_expected.to contain_trove_config('DEFAULT/debug').with(:value => '<SERVICE DEFAULT>')
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples 'basic non-default logging settings' do
|
||||
it 'configures trove logging settins with non-default values' do
|
||||
is_expected.to contain_trove_config('DEFAULT/use_syslog').with(:value => 'true')
|
||||
is_expected.to contain_trove_config('DEFAULT/use_stderr').with(:value => 'false')
|
||||
is_expected.to contain_trove_config('DEFAULT/syslog_log_facility').with(:value => 'LOG_FOO')
|
||||
is_expected.to contain_trove_config('DEFAULT/log_dir').with(:value => '/var/log')
|
||||
is_expected.to contain_trove_config('DEFAULT/log_file').with(:value => '/var/log/foo.log')
|
||||
is_expected.to contain_trove_config('DEFAULT/verbose').with(:value => 'true')
|
||||
is_expected.to contain_trove_config('DEFAULT/debug').with(:value => 'true')
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples_for 'logging params set' do
|
||||
it 'enables logging params' do
|
||||
is_expected.to contain_trove_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_trove_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_trove_config('DEFAULT/logging_debug_format_suffix').with_value(
|
||||
'%(funcName)s %(pathname)s:%(lineno)d')
|
||||
|
||||
is_expected.to contain_trove_config('DEFAULT/logging_exception_prefix').with_value(
|
||||
'%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s')
|
||||
|
||||
is_expected.to contain_trove_config('DEFAULT/log_config_append').with_value(
|
||||
'/etc/trove/logging.conf')
|
||||
is_expected.to contain_trove_config('DEFAULT/publish_errors').with_value(
|
||||
true)
|
||||
|
||||
is_expected.to contain_trove_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_trove_config('DEFAULT/fatal_deprecations').with_value(
|
||||
true)
|
||||
|
||||
is_expected.to contain_trove_config('DEFAULT/instance_format').with_value(
|
||||
'[instance: %(uuid)s] ')
|
||||
|
||||
is_expected.to contain_trove_config('DEFAULT/instance_uuid_format').with_value(
|
||||
'[instance: %(uuid)s] ')
|
||||
|
||||
is_expected.to contain_trove_config('DEFAULT/log_date_format').with_value(
|
||||
'%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,
|
||||
:log_config_append, :publish_errors,
|
||||
:default_log_levels, :fatal_deprecations,
|
||||
:instance_format, :instance_uuid_format,
|
||||
:log_date_format, ].each { |param|
|
||||
it { is_expected.to contain_trove_config("DEFAULT/#{param}").with(:value => '<SERVICE DEFAULT>') }
|
||||
}
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
@default_facts.merge({ :osfamily => 'Debian' })
|
||||
end
|
||||
|
||||
it_configures 'trove-logging'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
@default_facts.merge({ :osfamily => 'RedHat' })
|
||||
end
|
||||
|
||||
it_configures 'trove-logging'
|
||||
end
|
||||
|
||||
end
|
@ -219,8 +219,10 @@ describe 'trove::taskmanager' do
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian',
|
||||
:processorcount => 8 }
|
||||
@default_facts.merge({
|
||||
:osfamily => 'Debian',
|
||||
:processorcount => 8
|
||||
})
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
@ -233,8 +235,10 @@ describe 'trove::taskmanager' do
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat',
|
||||
:processorcount => 8 }
|
||||
@default_facts.merge({
|
||||
:osfamily => 'RedHat',
|
||||
:processorcount => 8
|
||||
})
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
|
@ -5,6 +5,9 @@ require 'webmock/rspec'
|
||||
RSpec.configure do |c|
|
||||
c.alias_it_should_behave_like_to :it_configures, 'configures'
|
||||
c.alias_it_should_behave_like_to :it_raises, 'raises'
|
||||
c.before :each do
|
||||
@default_facts = { :os_service_default => '<SERVICE DEFAULT>' }
|
||||
end
|
||||
end
|
||||
|
||||
at_exit { RSpec::Puppet::Coverage.report! }
|
||||
|
Loading…
Reference in New Issue
Block a user