From 0ddd0067a19473a088b14575f477c284d18ba393 Mon Sep 17 00:00:00 2001 From: Gael Chamoulaud Date: Fri, 6 Nov 2015 09:42:39 +0100 Subject: [PATCH] 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 --- manifests/api.pp | 93 +++++--------- manifests/logging.pp | 156 +++++++++++++++++++++++ spec/classes/trove_api_spec.rb | 14 +- spec/classes/trove_client_spec.rb | 4 +- spec/classes/trove_conductor_spec.rb | 12 +- spec/classes/trove_db_mysql_spec.rb | 4 +- spec/classes/trove_db_postgresql_spec.rb | 16 +-- spec/classes/trove_db_spec.rb | 12 +- spec/classes/trove_guestagent_spec.rb | 12 +- spec/classes/trove_init_spec.rb | 4 +- spec/classes/trove_keystone_auth_spec.rb | 2 +- spec/classes/trove_logging_spec.rb | 147 +++++++++++++++++++++ spec/classes/trove_taskmanager_spec.rb | 12 +- spec/spec_helper.rb | 3 + 14 files changed, 392 insertions(+), 99 deletions(-) create mode 100644 manifests/logging.pp create mode 100644 spec/classes/trove_logging_spec.rb diff --git a/manifests/api.pp b/manifests/api.pp index 20fc9f6d..fe4b27e2 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -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; diff --git a/manifests/logging.pp b/manifests/logging.pp new file mode 100644 index 00000000..bcb41921 --- /dev/null +++ b/manifests/logging.pp @@ -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:: first then trove::logging::. + $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; + } +} + diff --git a/spec/classes/trove_api_spec.rb b/spec/classes/trove_api_spec.rb index ca1ab089..6d6b0c84 100644 --- a/spec/classes/trove_api_spec.rb +++ b/spec/classes/trove_api_spec.rb @@ -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 diff --git a/spec/classes/trove_client_spec.rb b/spec/classes/trove_client_spec.rb index eb4f049a..43b9abc4 100644 --- a/spec/classes/trove_client_spec.rb +++ b/spec/classes/trove_client_spec.rb @@ -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' diff --git a/spec/classes/trove_conductor_spec.rb b/spec/classes/trove_conductor_spec.rb index 1414e77d..c64ce9b7 100644 --- a/spec/classes/trove_conductor_spec.rb +++ b/spec/classes/trove_conductor_spec.rb @@ -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 diff --git a/spec/classes/trove_db_mysql_spec.rb b/spec/classes/trove_db_mysql_spec.rb index c55b1a9e..437a2c02 100644 --- a/spec/classes/trove_db_mysql_spec.rb +++ b/spec/classes/trove_db_mysql_spec.rb @@ -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' diff --git a/spec/classes/trove_db_postgresql_spec.rb b/spec/classes/trove_db_postgresql_spec.rb index 2b516205..70d37cc5 100644 --- a/spec/classes/trove_db_postgresql_spec.rb +++ b/spec/classes/trove_db_postgresql_spec.rb @@ -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 diff --git a/spec/classes/trove_db_spec.rb b/spec/classes/trove_db_spec.rb index f8d277ca..a24cbe22 100644 --- a/spec/classes/trove_db_spec.rb +++ b/spec/classes/trove_db_spec.rb @@ -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' diff --git a/spec/classes/trove_guestagent_spec.rb b/spec/classes/trove_guestagent_spec.rb index 317fe7ac..a04875d7 100644 --- a/spec/classes/trove_guestagent_spec.rb +++ b/spec/classes/trove_guestagent_spec.rb @@ -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 diff --git a/spec/classes/trove_init_spec.rb b/spec/classes/trove_init_spec.rb index 39b7357c..483148a9 100644 --- a/spec/classes/trove_init_spec.rb +++ b/spec/classes/trove_init_spec.rb @@ -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 diff --git a/spec/classes/trove_keystone_auth_spec.rb b/spec/classes/trove_keystone_auth_spec.rb index ac2ea14e..10ed3169 100644 --- a/spec/classes/trove_keystone_auth_spec.rb +++ b/spec/classes/trove_keystone_auth_spec.rb @@ -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 diff --git a/spec/classes/trove_logging_spec.rb b/spec/classes/trove_logging_spec.rb new file mode 100644 index 00000000..b2d6519d --- /dev/null +++ b/spec/classes/trove_logging_spec.rb @@ -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 => '') + is_expected.to contain_trove_config('DEFAULT/use_stderr').with(:value => '') + is_expected.to contain_trove_config('DEFAULT/syslog_log_facility').with(:value => '') + 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 => '') + is_expected.to contain_trove_config('DEFAULT/verbose').with(:value => '') + is_expected.to contain_trove_config('DEFAULT/debug').with(:value => '') + 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 => '') } + } + 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 diff --git a/spec/classes/trove_taskmanager_spec.rb b/spec/classes/trove_taskmanager_spec.rb index 3eb49eef..5b426808 100644 --- a/spec/classes/trove_taskmanager_spec.rb +++ b/spec/classes/trove_taskmanager_spec.rb @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3df4cede..9bc7bcf9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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 => '' } + end end at_exit { RSpec::Puppet::Coverage.report! }