Generate separate db for murano service broker

Implement some changes for murano-cfapi service, mainly
including:
1.Add separate murano-cfapi.conf for murano-cfapi service
2.Add separate command murano-cfapi-db-manage for murano_cfapi db

Change-Id: I2a675a30e84ce03cc3cd5fb6fb5a6318498ac913
Closes-Bug: #1589445
This commit is contained in:
Xing Zhou 2016-12-01 10:36:20 +08:00
parent 9a9b7b1782
commit 44900a04a4
16 changed files with 768 additions and 21 deletions

View File

@ -17,7 +17,8 @@
# Defaults to 'present'
#
# [*tenant*]
# (Required) Tenant for cloudfoundry api
# (Optional) Tenant for cloudfoundry api
# Defaults to 'admin'
#
# [*bind_host*]
# (Optional) Host on which murano cloudfoundry api should listen
@ -31,14 +32,26 @@
# (Optional) Public identity endpoint
# Defaults to 'http://127.0.0.1:5000'.
#
# [*user_domain_name*]
# (Optional) User Domain name for connecting to Murano CFAPI services in
# admin context through the OpenStack Identity service.
# Defaults to $::os_service_default.
#
# [*project_domain_name*]
# (Optional) Project Domain name for connecting to Murano CFAPI services in
# admin context through the OpenStack Identity service.
# Defaults to $::os_service_default.
#
class murano::cfapi(
$tenant,
$manage_service = true,
$enabled = true,
$package_ensure = 'present',
$bind_host = $::os_service_default,
$bind_port = $::os_service_default,
$auth_url = 'http://127.0.0.1:5000',
$tenant = 'admin',
$manage_service = true,
$enabled = true,
$package_ensure = 'present',
$bind_host = $::os_service_default,
$bind_port = $::os_service_default,
$auth_url = 'http://127.0.0.1:5000',
$user_domain_name = $::os_service_default,
$project_domain_name = $::os_service_default,
) {
include ::murano::deps
@ -54,10 +67,12 @@ class murano::cfapi(
}
murano_cfapi_config {
'cfapi/tenant': value => $tenant;
'cfapi/bind_host': value => $bind_host;
'cfapi/bind_port': value => $bind_port;
'cfapi/auth_url': value => $auth_url;
'cfapi/tenant': value => $tenant;
'cfapi/bind_host': value => $bind_host;
'cfapi/bind_port': value => $bind_port;
'cfapi/auth_url': value => $auth_url;
'cfapi/user_domain_name': value => $user_domain_name;
'cfapi/project_domain_name': value => $project_domain_name;
}
package { 'murano-cfapi':

View File

@ -0,0 +1,58 @@
# == Class: murano::db::mysql_cfapi
#
# The murano::db::mysql_cfapi class creates a MySQL database for murano_cfapi.
# It must be used on the MySQL server.
#
# === Parameters
#
# [*password*]
# (Required) Password to connect to the database.
#
# [*dbname*]
# (Optional) Name of the database.
# Defaults to 'murano_cfapi'.
#
# [*user*]
# (Optional) User to connect to the database.
# Defaults to 'murano_cfapi'.
#
# [*host*]
# (Optional) The default source host user is allowed to connect from.
# Defaults to '127.0.0.1'
#
# [*allowed_hosts*]
# (Optional) Other hosts the user is allowed to connect from.
# Defaults to 'undef'.
#
# [*charset*]
# (Optional) The database charset.
# Defaults to 'utf8'.
#
# [*collate*]
# (Optional) Charset collate of murano_cfapi database.
# Defaults to 'utf8_general_ci'.
#
class murano::db::mysql_cfapi(
$password,
$dbname = 'murano_cfapi',
$user = 'murano_cfapi',
$host = '127.0.0.1',
$allowed_hosts = undef,
$charset = 'utf8',
$collate = 'utf8_general_ci',
) {
validate_string($password)
::openstacklib::db::mysql{ 'murano_cfapi':
user => $user,
password_hash => mysql_password($password),
dbname => $dbname,
host => $host,
charset => $charset,
collate => $collate,
allowed_hosts => $allowed_hosts,
}
::Openstacklib::Db::Mysql['murano_cfapi'] ~> Exec<| title == 'murano-cfapi-dbmanage' |>
}

View File

@ -0,0 +1,47 @@
# == Class: murano::db::postgresql_cfapi
#
# The murano::db::postgresql_cfapi creates a PostgreSQL database for murano_cfapi.
# It must be used on the PostgreSQL server.
#
# === Parameters
#
# [*password*]
# (Required) Password to connect to the database.
#
# [*dbname*]
# (Optional) Name of the database.
# Defaults to 'murano_cfapi'.
#
# [*user*]
# (Optional) User to connect to the database.
# Defaults to 'murano_cfapi'.
#
# [*encoding*]
# (Optional) The charset to use for the database.
# Default to undef.
#
# [*privileges*]
# (Optional) Privileges given to the database user.
# Default to 'ALL'
#
class murano::db::postgresql_cfapi(
$password,
$dbname = 'murano_cfapi',
$user = 'murano_cfapi',
$encoding = undef,
$privileges = 'ALL',
) {
validate_string($password)
::openstacklib::db::postgresql { 'murano_cfapi':
password_hash => postgresql_password($user, $password),
dbname => $dbname,
user => $user,
encoding => $encoding,
privileges => $privileges,
}
::Openstacklib::Db::Postgresql['murano_cfapi'] ~> Exec<| title == 'murano-cfapi-dbmanage' |>
}

View File

@ -0,0 +1,23 @@
#
# Class to execute murano_cfapi dbsync
#
class murano::db::sync_cfapi {
include ::murano::params
Package <| title == 'murano-common' |> ~> Exec['murano-cfapi-dbmanage']
Exec['murano-cfapi-dbmanage'] ~> Service <| tag == 'murano-service' |>
Murano_cfapi_config <| title == 'database/connection' |> ~> Exec['murano-cfapi-dbmanage']
exec { 'murano-cfapi-dbmanage':
command => $::murano::params::cfapi_dbmanage_command,
path => '/usr/bin',
user => 'murano_cfapi',
refreshonly => true,
try_sleep => 5,
tries => 10,
logoutput => on_failure,
}
}

68
manifests/db_cfapi.pp Normal file
View File

@ -0,0 +1,68 @@
# == Class: murano:db_cfapi
#
# Configure the Murano CFAPI database
#
# == Parameters
#
# [*database_connection*]
# (optional) Connection url to connect to CFAPI Murano database.
# Defaults to $::os_service_default
#
# [*database_max_retries*]
# (Optional) Maximum number of database connection retries during startup.
# Set to -1 to specify an infinite retry count.
# Defaults to $::os_service_default.
#
# [*database_idle_timeout*]
# (Optional) Timeout before idle SQL connections are reaped.
# Defaults to $::os_service_default.
#
# [*database_retry_interval*]
# (optional) Interval between retries of opening a database connection.
# Defaults to $::os_service_default.
#
# [*database_min_pool_size*]
# (optional) Minimum number of SQL connections to keep open in a pool.
# Defaults to $::os_service_default.
#
# [*database_max_pool_size*]
# (optional) Maximum number of SQL connections to keep open in a pool.
# Defaults to $::os_service_default.
#
# [*database_max_overflow*]
# (optional) If set, use this value for max_overflow with sqlalchemy.
# Defaults to $::os_service_default.
#
# [*database_db_max_retries*]
# (Optional) Maximum retries in case of connection error or deadlock error
# before error is raised. Set to -1 to specify an infinite retry count.
# Defaults to $::os_service_default
#
class murano::db_cfapi (
$database_connection = $::os_service_default,
$database_idle_timeout = $::os_service_default,
$database_min_pool_size = $::os_service_default,
$database_max_pool_size = $::os_service_default,
$database_max_retries = $::os_service_default,
$database_retry_interval = $::os_service_default,
$database_max_overflow = $::os_service_default,
$database_db_max_retries = $::os_service_default,
) {
if !is_service_default($database_connection) {
validate_re($database_connection, '^(mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
oslo::db { 'murano_cfapi_config':
connection => $database_connection,
idle_timeout => $database_idle_timeout,
min_pool_size => $database_min_pool_size,
max_pool_size => $database_max_pool_size,
max_retries => $database_max_retries,
retry_interval => $database_retry_interval,
max_overflow => $database_max_overflow,
db_max_retries => $database_db_max_retries,
}
}
}

View File

@ -132,4 +132,5 @@ class murano::logging(
instance_format => $instance_format,
instance_uuid_format => $instance_uuid_format,
}
}

125
manifests/logging_cfapi.pp Normal file
View File

@ -0,0 +1,125 @@
# == Class murano::logging_cfapi
#
# murano_cfapi extended logging configuration
#
# === Parameters
#
# [*debug*]
# (Optional) Should the daemons log debug messages
# Defaults to $::os_service_default.
#
# [*use_syslog*]
# Use syslog for logging.
# (Optional) Defaults to $::os_service_default.
#
# [*use_stderr*]
# (optional) Use stderr for logging
# Defaults to $::os_service_default
#
# [*log_facility*]
# Syslog facility to receive log lines.
# (Optional) Defaults to $::os_service_default.
#
# [*log_dir*]
# (optional) Directory where logs should be stored.
# If set to $::os_service_default, it will not log to any directory.
# Defaults to '/var/log/murano_cfapi'
#
# [*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',
# 'sqlalchemy' => 'WARN', 'suds' => 'INFO', 'iso8601' => 'WARN',
# 'requests.packages.urllib3.connectionpool' => 'WARN' }
#
# [*publish_errors*]
# (optional) Publish error events (boolean value).
# Defaults to $::os_service_default (false if unconfigured).
#
# [*fatal_deprecations*]
# (optional) Make deprecations fatal (boolean value)
# Defaults to $::os_service_default (false if unconfigured).
#
# [*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 murano::logging_cfapi(
$debug = $::os_service_default,
$use_syslog = $::os_service_default,
$use_stderr = $::os_service_default,
$log_facility = $::os_service_default,
$log_dir = '/var/log/murano_cfapi',
$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,
) {
oslo::log { 'murano_cfapi_config':
debug => $debug,
use_syslog => $use_syslog,
use_stderr => $use_stderr,
log_dir => $log_dir,
syslog_log_facility => $log_facility,
logging_context_format_string => $logging_context_format_string,
logging_default_format_string => $logging_default_format_string,
logging_debug_format_suffix => $logging_debug_format_suffix,
logging_exception_prefix => $logging_exception_prefix,
log_config_append => $log_config_append,
default_log_levels => $default_log_levels,
publish_errors => $publish_errors,
fatal_deprecations => $fatal_deprecations,
log_date_format => $log_date_format,
instance_format => $instance_format,
instance_uuid_format => $instance_uuid_format,
}
}

View File

@ -6,6 +6,7 @@ class murano::params {
include ::openstacklib::defaults
$dbmanage_command = 'murano-db-manage --config-file /etc/murano/murano.conf upgrade'
$cfapi_dbmanage_command = 'murano-cfapi-db-manage --config-file /etc/murano/murano-cfapi.conf upgrade'
$default_external_network = 'public'
# service names
$api_service_name = 'murano-api'

View File

@ -0,0 +1,4 @@
---
features:
- Add separate db for Murano Service Broker, so we can use
murano service broker independently.

View File

@ -20,6 +20,8 @@ describe 'murano::cfapi' do
it { is_expected.to contain_murano_cfapi_config('cfapi/bind_host').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_murano_cfapi_config('cfapi/bind_port').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_murano_cfapi_config('cfapi/auth_url').with_value('http://127.0.0.1:5000') }
it { is_expected.to contain_murano_cfapi_config('cfapi/user_domain_name').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_murano_cfapi_config('cfapi/project_domain_name').with_value('<SERVICE DEFAULT>') }
end
shared_examples_for 'with parameters override' do
@ -27,7 +29,7 @@ describe 'murano::cfapi' do
:tenant => 'services',
:bind_host => '0.0.0.0',
:bind_port => 8080,
:auth_url => 'http://127.0.0.1:5000/v2.0/'
:auth_url => 'http://127.0.0.1:5000/v2.0/',
}
end

View File

@ -0,0 +1,107 @@
require 'spec_helper'
describe 'murano::db_cfapi' do
shared_examples 'murano::db_cfapi' do
context 'with default parameters' do
it { is_expected.to_not contain_murano_cfapi_config('database/connection') }
it { is_expected.to_not contain_murano_cfapi_config('database/idle_timeout') }
it { is_expected.to_not contain_murano_cfapi_config('database/min_pool_size') }
it { is_expected.to_not contain_murano_cfapi_config('database/max_retries') }
it { is_expected.to_not contain_murano_cfapi_config('database/retry_interval') }
it { is_expected.to_not contain_murano_cfapi_config('database/max_pool_size') }
it { is_expected.to_not contain_murano_cfapi_config('database/max_overflow') }
it { is_expected.to_not contain_murano_cfapi_config('database/db_max_retries') }
end
context 'with specific parameters' do
let :params do
{ :database_connection => 'mysql+pymysql://murano_cfapi:murano_cfapi@localhost/murano_cfapi',
:database_idle_timeout => '3601',
:database_min_pool_size => '2',
:database_max_retries => '11',
:database_retry_interval => '11',
:database_max_pool_size => '11',
:database_max_overflow => '21',
:database_db_max_retries => '-1',
}
end
it { is_expected.to contain_murano_cfapi_config('database/connection').with_value('mysql+pymysql://murano_cfapi:murano_cfapi@localhost/murano_cfapi') }
it { is_expected.to contain_murano_cfapi_config('database/idle_timeout').with_value('3601') }
it { is_expected.to contain_murano_cfapi_config('database/min_pool_size').with_value('2') }
it { is_expected.to contain_murano_cfapi_config('database/max_retries').with_value('11') }
it { is_expected.to contain_murano_cfapi_config('database/retry_interval').with_value('11') }
it { is_expected.to contain_murano_cfapi_config('database/max_pool_size').with_value('11') }
it { is_expected.to contain_murano_cfapi_config('database/max_overflow').with_value('21') }
it { is_expected.to contain_murano_cfapi_config('database/db_max_retries').with_value('-1') }
end
context 'with postgresql backend' do
let :params do
{ :database_connection => 'postgresql://murano_cfapi:murano_cfapi@localhost/murano_cfapi', }
end
it 'install the proper backend package' do
is_expected.to contain_package('python-psycopg2').with(:ensure => 'present')
end
end
context 'with MySQL-python library as backend package' do
let :params do
{ :database_connection => 'mysql://murano_cfapi:murano_cfapi@localhost/murano_cfapi', }
end
it { is_expected.to contain_package('python-mysqldb').with(:ensure => 'present') }
end
context 'with incorrect database_connection string' do
let :params do
{ :database_connection => 'sqlite://murano_cfapi:murano_cfapi@localhost/murano_cfapi', }
end
it_raises 'a Puppet::Error', /validate_re/
end
context 'with incorrect pymysql database_connection string' do
let :params do
{ :database_connection => 'foo+pymysql://murano_cfapi:murano_cfapi@localhost/murano_cfapi', }
end
it_raises 'a Puppet::Error', /validate_re/
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())
end
it_behaves_like 'murano::db_cfapi'
context 'using pymysql driver' do
let :params do
{ :database_connection => 'mysql+pymysql://murano_cfapi:murano_cfapi@localhost/murano_cfapi' }
end
case facts[:osfamily]
when 'Debian'
it { is_expected.to contain_package('db_backend_package').with(
:ensure => 'present',
:name => 'python-pymysql',
:tag => 'openstack'
)}
when 'RedHat'
it { is_expected.not_to contain_package('db_backend_package') }
end
end
end
end
end

View File

@ -0,0 +1,86 @@
require 'spec_helper'
describe 'murano::db::mysql_cfapi' do
let :pre_condition do
['include mysql::server']
end
let :params do
{ :dbname => 'murano_cfapi',
:password => 's3cr3t',
:user => 'murano_cfapi',
:charset => 'utf8',
:collate => 'utf8_general_ci',
:host => '127.0.0.1',
}
end
shared_examples_for 'murano_cfapi mysql database' do
context 'when omiting the required parameter password' do
before { params.delete(:password) }
it { expect { is_expected.to raise_error(Puppet::Error) } }
end
it 'creates a mysql database' do
is_expected.to contain_openstacklib__db__mysql('murano_cfapi').with(
:user => params[:user],
:dbname => params[:dbname],
:password_hash => '*58C036CDA51D8E8BBBBF2F9EA5ABF111ADA444F0',
:host => params[:host],
:charset => params[:charset]
)
end
context 'overriding allowed_hosts param to array' do
before :each do
params.merge!(
:allowed_hosts => ['127.0.0.1','%']
)
end
it {
is_expected.to contain_openstacklib__db__mysql('murano_cfapi').with(
:user => params[:user],
:dbname => params[:dbname],
:password_hash => '*58C036CDA51D8E8BBBBF2F9EA5ABF111ADA444F0',
:host => params[:host],
:charset => params[:charset],
:allowed_hosts => ['127.0.0.1','%']
)}
end
context 'overriding allowed_hosts param to string' do
before :each do
params.merge!(
:allowed_hosts => '192.168.1.1'
)
end
it {
is_expected.to contain_openstacklib__db__mysql('murano_cfapi').with(
:user => params[:user],
:dbname => params[:dbname],
:password_hash => '*58C036CDA51D8E8BBBBF2F9EA5ABF111ADA444F0',
:host => params[:host],
:charset => params[:charset],
:allowed_hosts => '192.168.1.1'
)}
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())
end
it_behaves_like 'murano_cfapi mysql database'
end
end
end

View File

@ -0,0 +1,41 @@
require 'spec_helper'
describe 'murano::db::postgresql_cfapi' do
shared_examples_for 'murano::db::postgresql_cfapi' do
let :req_params do
{ :password => 'pw' }
end
let :pre_condition do
'include postgresql::server'
end
context 'with only required parameters' do
let :params do
req_params
end
it { is_expected.to contain_postgresql__server__db('murano_cfapi').with(
:user => 'murano_cfapi',
:password => 'md594583175c7aca1cf386f1c97c50fda19'
)}
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({
:concat_basedir => '/var/lib/puppet/concat'
}))
end
it_configures 'murano::db::postgresql_cfapi'
end
end
end

View File

@ -3,6 +3,7 @@ require 'spec_helper'
describe 'murano::db' do
shared_examples 'murano::db' do
context 'with default parameters' do
it { is_expected.to contain_murano_config('database/connection').with_value('mysql://murano:secrete@localhost:3306/murano') }
it { is_expected.to contain_murano_config('database/idle_timeout').with_value('<SERVICE DEFAULT>') }
@ -16,14 +17,14 @@ describe 'murano::db' do
context 'with specific parameters' do
let :params do
{ :database_connection => 'mysql+pymysql://murano:murano@localhost/murano',
:database_idle_timeout => '3601',
:database_min_pool_size => '2',
:database_max_retries => '11',
:database_retry_interval => '11',
:database_max_pool_size => '11',
:database_max_overflow => '21',
:database_db_max_retries => '-1',
{ :database_connection => 'mysql+pymysql://murano:murano@localhost/murano',
:database_idle_timeout => '3601',
:database_min_pool_size => '2',
:database_max_retries => '11',
:database_retry_interval => '11',
:database_max_pool_size => '11',
:database_max_overflow => '21',
:database_db_max_retries => '-1',
}
end

View File

@ -0,0 +1,33 @@
require 'spec_helper'
describe 'murano::db::sync_cfapi' do
shared_examples_for 'murano-dbsync-cfapi' do
it 'runs murano-cfapi-dbmanage' do
is_expected.to contain_exec('murano-cfapi-dbmanage').with(
:command => 'murano-cfapi-db-manage --config-file /etc/murano/murano-cfapi.conf upgrade',
:path => '/usr/bin',
:user => 'murano_cfapi',
:refreshonly => 'true',
:logoutput => 'on_failure'
)
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({
:concat_basedir => '/var/lib/puppet/concat'
}))
end
it_configures 'murano-dbsync-cfapi'
end
end
end

View File

@ -0,0 +1,135 @@
require 'spec_helper'
describe 'murano::logging_cfapi' do
let :params do
{
}
end
let :log_params do
{
:debug => 'true',
:use_syslog => 'true',
:use_stderr => 'false',
:log_facility => 'LOG_LOCAL0',
:log_dir => '/tmp/murano_cfapi',
: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/murano/logging-cfapi.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
shared_examples_for 'murano-logging-cfapi' do
context 'with basic logging options defaults' do
it_configures 'basic logging options defaults'
end
context 'with basic logging options passed' do
before { params.merge!( log_params ) }
it_configures 'basic logging options passed'
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_for 'basic logging options defaults' do
context 'with defaults' do
it { is_expected.to contain_murano_cfapi_config('DEFAULT/use_stderr').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_murano_cfapi_config('DEFAULT/use_syslog').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_murano_cfapi_config('DEFAULT/debug').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_murano_cfapi_config('DEFAULT/log_dir').with_value('/var/log/murano_cfapi') }
end
context 'with syslog enabled and default log facility' do
let :params do
{ :use_syslog => 'true' }
end
it { is_expected.to contain_murano_cfapi_config('DEFAULT/use_syslog').with_value(true) }
it { is_expected.to contain_murano_cfapi_config('DEFAULT/syslog_log_facility').with_value('<SERVICE DEFAULT>') }
end
end
shared_examples_for 'basic logging options passed' do
context 'with passed params' do
it { is_expected.to contain_murano_cfapi_config('DEFAULT/debug').with_value(true) }
it { is_expected.to contain_murano_cfapi_config('DEFAULT/use_syslog').with_value(true) }
it { is_expected.to contain_murano_cfapi_config('DEFAULT/use_stderr').with_value(false) }
it { is_expected.to contain_murano_cfapi_config('DEFAULT/syslog_log_facility').with_value('LOG_LOCAL0') }
it { is_expected.to contain_murano_cfapi_config('DEFAULT/log_dir').with_value('/tmp/murano_cfapi') }
end
end
shared_examples_for 'logging params set' do
it 'enables logging params' do
is_expected.to contain_murano_cfapi_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_murano_cfapi_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_murano_cfapi_config('DEFAULT/logging_debug_format_suffix').with_value(
'%(funcName)s %(pathname)s:%(lineno)d')
is_expected.to contain_murano_cfapi_config('DEFAULT/logging_exception_prefix').with_value(
'%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s')
is_expected.to contain_murano_cfapi_config('DEFAULT/log_config_append').with_value('/etc/murano/logging-cfapi.conf')
is_expected.to contain_murano_cfapi_config('DEFAULT/publish_errors').with_value(true)
is_expected.to contain_murano_cfapi_config('DEFAULT/default_log_levels').with_value(
'amqp=WARN,amqplib=WARN,boto=WARN,iso8601=WARN,requests.packages.urllib3.connectionpool=WARN,sqlalchemy=WARN,suds=INFO')
is_expected.to contain_murano_cfapi_config('DEFAULT/fatal_deprecations').with_value(true)
is_expected.to contain_murano_cfapi_config('DEFAULT/instance_format').with_value('[instance: %(uuid)s] ')
is_expected.to contain_murano_cfapi_config('DEFAULT/instance_uuid_format').with_value('[instance: %(uuid)s] ')
is_expected.to contain_murano_cfapi_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_murano_cfapi_config("DEFAULT/#{param}").with_value('<SERVICE DEFAULT>') }
}
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())
end
it_configures 'murano-logging-cfapi'
end
end
end