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
This commit is contained in:
Emilien Macchi 2016-02-05 06:31:27 +01:00
parent 62d274cd4c
commit 9f19d11c16
17 changed files with 831 additions and 505 deletions

View File

@ -71,19 +71,18 @@ Whether to hide the value from Puppet logs. Defaults to `false`.
If value is equal to ensure_absent_val then the resource will behave as if `ensure => absent` was specified. Defaults to `<SERVICE DEFAULT>` If value is equal to ensure_absent_val then the resource will behave as if `ensure => absent` was specified. Defaults to `<SERVICE DEFAULT>`
Limitations
-----------
### Packages Beaker-Rspec
------------
For now there aren't supported packages for Mistral. This module has beaker-rspec tests
Instructions for building the rpm on the trunk:
1. Clone mistral repo to your machine: ```git clone https://github.com/openstack/mistral.git```
2. In the mistral repo run the command: ```python ./setup.py bdist_rpm```
To run:
``shell
bundle install
bundle exec rspec spec/acceptance
``
Development Development
----------- -----------

View File

@ -38,8 +38,11 @@ class mistral::api (
$allow_action_execution_deletion = $::os_service_default, $allow_action_execution_deletion = $::os_service_default,
) { ) {
include ::mistral
include ::mistral::params include ::mistral::params
include ::mistral::policy
Package['mistral-api'] -> Class['mistral::policy']
Class['mistral::policy'] ~> Service['mistral-api']
package { 'mistral-api': package { 'mistral-api':
ensure => $package_ensure, ensure => $package_ensure,

101
manifests/db.pp Normal file
View File

@ -0,0 +1,101 @@
# == Class: mistral::db
#
# Configure the Mistral database
#
# === Parameters
#
# [*database_connection*]
# Url used to connect to database.
# (Optional) Defaults to 'sqlite:////var/lib/mistral/mistral.sqlite'
#
# [*database_idle_timeout*]
# Timeout when db connections should be reaped.
# (Optional) Defaults to $::os_service_default
#
# [*database_min_pool_size*]
# Minimum number of SQL connections to keep open in a pool.
# (Optional) Defaults to $::os_service_default
#
# [*database_max_pool_size*]
# Maximum number of SQL connections to keep open in a pool.
# (Optional) Defaults to $::os_service_default
#
# [*database_max_retries*]
# Maximum db connection retries during startup.
# Setting -1 implies an infinite retry count.
# (Optional) Defaults to $::os_service_default
#
# [*database_retry_interval*]
# Interval between retries of opening a sql connection.
# (Optional) Defaults to $::os_service_default
#
# [*database_max_overflow*]
# If set, use this value for max_overflow with sqlalchemy.
# (Optional) Defaults to $::os_service_default
#
class mistral::db (
$database_connection = 'sqlite:////var/lib/mistral/mistral.sqlite',
$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,
) {
include ::mistral::params
# NOTE(spredzy): In order to keep backward compatibility we rely on the pick function
# to use mistral::<myparam> if mistral::db::<myparam> isn't specified.
$database_connection_real = pick($::mistral::database_connection,$database_connection)
$database_idle_timeout_real = pick($::mistral::database_idle_timeout,$database_idle_timeout)
$database_min_pool_size_real = pick($::mistral::database_min_pool_size,$database_min_pool_size)
$database_max_pool_size_real = pick($::mistral::database_max_pool_size,$database_max_pool_size)
$database_max_retries_real = pick($::mistral::database_max_retries,$database_max_retries)
$database_retry_interval_real = pick($::mistral::database_retry_interval,$database_retry_interval)
$database_max_overflow_real = pick($::mistral::database_max_overflow,$database_max_overflow)
validate_re($database_connection_real,
'^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
case $database_connection_real {
/^mysql(\+pymysql)?:\/\//: {
require 'mysql::bindings'
require 'mysql::bindings::python'
if $database_connection_real =~ /^mysql\+pymysql/ {
$backend_package = $::mistral::params::pymysql_package_name
} else {
$backend_package = false
}
}
/^postgresql:\/\//: {
$backend_package = false
require 'postgresql::lib::python'
}
/^sqlite:\/\//: {
$backend_package = $::mistral::params::sqlite_package_name
}
default: {
fail('Unsupported backend configured')
}
}
if $backend_package and !defined(Package[$backend_package]) {
package {'mistral-backend-package':
ensure => present,
name => $backend_package,
tag => 'openstack',
}
}
mistral_config {
'database/connection': value => $database_connection_real, secret => true;
'database/idle_timeout': value => $database_idle_timeout_real;
'database/min_pool_size': value => $database_min_pool_size_real;
'database/max_retries': value => $database_max_retries_real;
'database/retry_interval': value => $database_retry_interval_real;
'database/max_pool_size': value => $database_max_pool_size_real;
'database/max_overflow': value => $database_max_overflow_real;
}
}

View File

@ -43,7 +43,6 @@ class mistral::engine (
$execution_field_size_limit_kb = $::os_service_default, $execution_field_size_limit_kb = $::os_service_default,
) { ) {
include ::mistral
include ::mistral::params include ::mistral::params
package { 'mistral-engine': package { 'mistral-engine':

View File

@ -53,7 +53,6 @@ class mistral::executor (
$older_than = $::os_service_default, $older_than = $::os_service_default,
) { ) {
include ::mistral
include ::mistral::params include ::mistral::params
package { 'mistral-executor': package { 'mistral-executor':
@ -80,11 +79,11 @@ class mistral::executor (
} }
mistral_config { mistral_config {
'executor/host' : value => $host; 'executor/host' : value => $host;
'executor/topic' : value => $topic; 'executor/topic' : value => $topic;
'executor/version' : value => $version; 'executor/version' : value => $version;
'execution_expiration_policy/evaluation_interval' : value => $evaluation_interval; 'execution_expiration_policy/evaluation_interval' : value => $evaluation_interval;
'execution_expiration_policy/older_than' : value => $older_than; 'execution_expiration_policy/older_than' : value => $older_than;
} }
} }

View File

@ -1,135 +1,293 @@
# == Class: mistral # == Class: mistral
# #
# Full description of class mistral here. # Mistral base package & configuration
# #
# === Parameters # === Parameters
# [*package_ensure*] # [*package_ensure*]
# (Optional) Ensure state for package. # (Optional) Ensure state for package.
# Defaults to 'present' # Defaults to 'present'.
# #
# [*rpc_backend*] # [*rpc_backend*]
# The rpc backend. Default 'rabbit' # (optional) The rpc backend.
# Defaults to 'rabbit'.
#
# [*auth_uri*]
# (optional) Specifies the public Identity URI for Mistral to use.
# Default 'http://localhost:5000/v2.0/'.
# #
# [*auth_uri*]
# Specifies the public Identity URI for Mistral to use.
# Default 'http://localhost:5000/v2.0/'
# [*identity_uri*] # [*identity_uri*]
# Specifies the admin Identity URI for Mistral to use. # (optional) Specifies the admin Identity URI for Mistral to use.
# Default 'http://localhost:35357/' # Default 'http://localhost:35357/'.
# #
# [*admin_user*] # [*keystone_user*]
# The user name from 'mistral::keystone::auth'. Default 'mistral' # (optional) The name of the auth user
# Defaults to 'mistral'.
# #
# [*admin_tenant_name*] # [*keystone_tenant*]
# The tenant name from 'mistral::keystone::auth'. Default 'service' # (optional) The tenant of the auth user
# Defaults to 'services'.
# #
# [*admin_password*] # [*keystone_password*]
# The password from 'mistral::keystone::auth'. Default 'password' # (required) The password of the auth user.
# #
# [*log_dir*] # [*log_dir*]
# Path to the log dir. Default '$::mistral::params::log_dir' # (optional) Directory where logs should be stored.
# If set to boolean false or the $::os_service_default, it will not log to
# any directory.
# Defaults to '/var/log/mistral'.
# #
# [*mysql_vip*] # [*use_syslog*]
# ip for the my sql DB. Default '127.0.0.1' # (Optional) Use syslog for logging.
# Defaults to undef.
# #
# [*mistral_db_pass*] # [*use_stderr*]
# password for thr DB. Shulde be the same as mistral::db::mysql. # (optional) Use stderr for logging
# Default 'password' # Defaults to undef.
# #
# [*auth_version*] # [*log_facility*]
# Keystone Api version. Default 'v2.0' # (Optional) Syslog facility to receive log lines.
# Defaults to undef.
# #
# [*rabbit_hostname*] # [*verbose*]
# The name/ip of rabbit. Default 'localhost' # (Optional) Should the daemons log verbose messages
# Defaults to undef.
# #
# [*rabbit_userid*] # [*debug*]
# User id for rabbit. Default 'guest' # (Optional) Should the daemons log debug messages
# Defaults to undef.
# #
# [*rabbit_password*] # [*database_connection*]
# password for rabbit. Default 'guest' # (optional) Url used to connect to database.
# Defaults to undef.
#
# [*database_idle_timeout*]
# Timeout when db connections should be reaped.
# (Optional) Defaults to undef.
#
# [*database_min_pool_size*]
# Minimum number of SQL connections to keep open in a pool.
# (Optional) Defaults to undef.
#
# [*database_max_pool_size*]
# Maximum number of SQL connections to keep open in a pool.
# (Optional) Defaults to undef.
#
# [*database_max_retries*]
# Maximum db connection retries during startup.
# Setting -1 implies an infinite retry count.
# (Optional) Defaults to undef.
#
# [*database_retry_interval*]
# Interval between retries of opening a sql connection.
# (Optional) Defaults to underf.
#
# [*database_max_overflow*]
# If set, use this value for max_overflow with sqlalchemy.
# (Optional) Defaults to undef.
#
# [*rabbit_host*]
# (Optional) IP or hostname of the rabbit server.
# Defaults to '127.0.0.1'
# #
# [*rabbit_port*] # [*rabbit_port*]
# The port of rabbit. Default $::os_service_default # (Optional) Port of the rabbit server.
# Defaults to 5672.
# #
# [*auth_protocol*] # [*rabbit_hosts*]
# Keystone protocol # (Optional) Array of host:port (used with HA queues).
# If defined, will remove rabbit_host & rabbit_port parameters from config
# Defaults to undef.
# #
# DEPRECATED PARAMETERS # [*rabbit_userid*]
# (Optional) User to connect to the rabbit server.
# Defaults to 'guest'
# #
# [*qpid_hostname*] # [*rabbit_password*]
# The name/ip of qpid. Default undef # (Required) Password to connect to the rabbit_server.
# Defaults to empty. Required if using the Rabbit (kombu)
# backend.
# #
# [*qpid_port*] # [*rabbit_virtual_host*]
# The port of qpid. Default undef # (Optional) Virtual_host to use.
# Defaults to '/'
# #
# [*qpid_username*] # [*rabbit_ha_queues*]
# User name for qpid. Default undef # (optional) Use HA queues in RabbitMQ (x-ha-policy: all).
# Defaults to undef
# #
# [*qpid_password*] # [*rabbit_heartbeat_timeout_threshold*]
# password for qpid. Default undef # (optional) Number of seconds after which the RabbitMQ broker is considered
# down if the heartbeat keepalive fails. Any value >0 enables heartbeats.
# Heartbeating helps to ensure the TCP connection to RabbitMQ isn't silently
# closed, resulting in missed or lost messages from the queue.
# (Requires kombu >= 3.0.7 and amqp >= 1.4.0)
# Defaults to 0
# #
# [*qpid_protocol*] # [*rabbit_heartbeat_rate*]
# protocol for qpid. Default undef # (optional) How often during the rabbit_heartbeat_timeout_threshold period to
# check the heartbeat on RabbitMQ connection. (i.e. rabbit_heartbeat_rate=2
# when rabbit_heartbeat_timeout_threshold=60, the heartbeat will be checked
# every 30 seconds.
# Defaults to 2
# #
# [*qpid_tcp_nodelay*] # [*rabbit_use_ssl*]
# Should tcp be no delay for qpid. Default undef # (optional) Connect over SSL for RabbitMQ
# Defaults to false
#
# [*report_interval*]
# (optional) Interval, in seconds, between nodes reporting state to
# datastore (integer value).
# Defaults to $::os_service_default
#
# [*service_down_time*]
# (optional) Maximum time since last check-in for a service to be
# considered up (integer value).
# Defaults to $::os_service_default
#
# [*kombu_ssl_ca_certs*]
# (optional) SSL certification authority file (valid only if SSL enabled).
# Defaults to $::os_service_default
#
# [*kombu_ssl_certfile*]
# (optional) SSL cert file (valid only if SSL enabled).
# Defaults to $::os_service_default
#
# [*kombu_ssl_keyfile*]
# (optional) SSL key file (valid only if SSL enabled).
# Defaults to $::os_service_default
#
# [*kombu_ssl_version*]
# (optional) SSL version to use (valid only if SSL enabled).
# Valid values are TLSv1, SSLv23 and SSLv3. SSLv2 may be
# available on some distributions.
# Defaults to $::os_service_default
#
# [*kombu_reconnect_delay*]
# (optional) How long to wait before reconnecting in response to an AMQP
# consumer cancel notification.
# Defaults to $::os_service_default
#
# [*amqp_durable_queues*]
# Use durable queues in amqp.
# (Optional) Defaults to false.
#
# [*control_exchange*]
# (Optional)
# Defaults to 'openstack'.
#
# [*coordination_backend_url*]
# (optional) The backend URL to be used for coordination.
# Defaults to $::os_service_default
#
# [*coordination_heartbeat_interval*]
# (optional) Number of seconds between heartbeats for coordination.
# Defaults to $::os_service_default
# #
class mistral( class mistral(
$package_ensure = 'present', $keystone_password,
$rpc_backend = 'rabbit', $keystone_user = 'mistral',
$auth_uri = 'http://localhost:5000/v2.0/', $keystone_tenant = 'services',
$identity_uri = 'http://localhost:35357/', $package_ensure = 'present',
$admin_user = 'mistral', $database_connection = undef,
$admin_tenant_name = 'services', $rpc_backend = 'rabbit',
$admin_password = 'password', $auth_uri = 'http://localhost:5000/',
$log_dir = $::mistral::params::log_dir, $identity_uri = 'http://localhost:35357/',
$mysql_vip = '127.0.0.1', $control_exchange = 'openstack',
$mistral_db_pass = 'password', $rabbit_host = '127.0.0.1',
$auth_version = 'v2.0', $rabbit_port = 5672,
$auth_protocol = 'http', $rabbit_hosts = undef,
$rabbit_hostname = 'localhost', $rabbit_virtual_host = '/',
$rabbit_userid = 'guest', $rabbit_ha_queues = undef,
$rabbit_password = 'guest', $rabbit_heartbeat_timeout_threshold = 0,
$rabbit_port = $::os_service_default, $rabbit_heartbeat_rate = 2,
# DEPRECATED PARAMETERS $rabbit_userid = 'guest',
$qpid_hostname = undef, $rabbit_password = false,
$qpid_port = undef, $rabbit_use_ssl = false,
$qpid_username = undef, $service_down_time = $::os_service_default,
$qpid_password = undef, $report_interval = $::os_service_default,
$qpid_protocol = undef, $kombu_ssl_ca_certs = $::os_service_default,
$qpid_tcp_nodelay = undef, $kombu_ssl_certfile = $::os_service_default,
$kombu_ssl_keyfile = $::os_service_default,
$kombu_ssl_version = $::os_service_default,
$kombu_reconnect_delay = $::os_service_default,
$amqp_durable_queues = false,
$use_syslog = undef,
$use_stderr = undef,
$log_dir = '/var/log/mistral',
$log_facility = undef,
$verbose = undef,
$debug = undef,
$coordination_backend_url = $::os_service_default,
$coordination_heartbeat_interval = $::os_service_default,
){ ){
include ::mistral::params include ::mistral::params
include ::mistral::db
include ::mistral::logging
validate_string($keystone_password)
package { 'mistral-common': package { 'mistral-common':
ensure => $package_ensure, ensure => $package_ensure,
name => $::mistral::params::common_package_name, name => $::mistral::params::common_package_name,
tag => ['openstack', 'mistral-package'], tag => ['openstack', 'mistral-package'],
} }
$database_connection = "mysql://mistral:${mistral_db_pass}@${mysql_vip}/mistral"
mistral_config { mistral_config {
'DEFAULT/log_dir' : value => $log_dir; 'DEFAULT/rpc_backend': value => $rpc_backend;
'DEFAULT/rpc_backend' : value => $rpc_backend; 'keystone_authtoken/auth_uri': value => $auth_uri;
'keystone_authtoken/auth_uri' : value => $auth_uri; 'keystone_authtoken/identity_uri': value => $identity_uri;
'keystone_authtoken/identity_uri' : value => $identity_uri; 'keystone_authtoken/admin_user': value => $keystone_user;
'keystone_authtoken/auth_version' : value => $auth_version; 'keystone_authtoken/admin_password': value => $keystone_password;
'keystone_authtoken/auth_protocol' : value => $auth_protocol; 'keystone_authtoken/admin_tenant_name': value => $keystone_tenant;
'keystone_authtoken/admin_user' : value => $admin_user; 'coordination/backend_url': value => $coordination_backend_url;
'keystone_authtoken/admin_password' : value => $admin_password; 'coordination/heartbeat_interval': value => $coordination_heartbeat_interval;
'keystone_authtoken/admin_tenant_name' : value => $admin_tenant_name; 'DEFAULT/control_exchange': value => $control_exchange;
'database/connection' : value => $database_connection; 'DEFAULT/report_interval': value => $report_interval;
} 'DEFAULT/service_down_time': value => $service_down_time;
if $rpc_backend == 'qpid' {
warning('Qpid driver is removed from Oslo.messaging in the Mitaka release')
} }
if $rpc_backend == 'rabbit' { if $rpc_backend == 'rabbit' {
mistral_config {
'oslo_messaging_rabbit/rabbit_host' : value => $rabbit_hostname; if ! $rabbit_password {
'oslo_messaging_rabbit/rabbit_port' : value => $rabbit_port; fail('Please specify a rabbit_password parameter.')
'oslo_messaging_rabbit/rabbit_userid' : value => $rabbit_userid;
'oslo_messaging_rabbit/rabbit_password' : value => $rabbit_password;
} }
mistral_config {
'oslo_messaging_rabbit/rabbit_password': value => $rabbit_password, secret => true;
'oslo_messaging_rabbit/rabbit_userid': value => $rabbit_userid;
'oslo_messaging_rabbit/rabbit_virtual_host': value => $rabbit_virtual_host;
'oslo_messaging_rabbit/rabbit_use_ssl': value => $rabbit_use_ssl;
'oslo_messaging_rabbit/kombu_ssl_version': value => $kombu_ssl_version;
'oslo_messaging_rabbit/kombu_ssl_ca_certs': value => $kombu_ssl_ca_certs;
'oslo_messaging_rabbit/kombu_ssl_certfile': value => $kombu_ssl_certfile;
'oslo_messaging_rabbit/kombu_ssl_keyfile': value => $kombu_ssl_keyfile;
'oslo_messaging_rabbit/kombu_reconnect_delay': value => $kombu_reconnect_delay;
'oslo_messaging_rabbit/heartbeat_timeout_threshold': value => $rabbit_heartbeat_timeout_threshold;
'oslo_messaging_rabbit/heartbeat_rate': value => $rabbit_heartbeat_rate;
'oslo_messaging_rabbit/amqp_durable_queues': value => $amqp_durable_queues;
}
if $rabbit_hosts {
mistral_config { 'oslo_messaging_rabbit/rabbit_hosts': value => join(any2array($rabbit_hosts), ',') }
mistral_config { 'oslo_messaging_rabbit/rabbit_host': ensure => absent }
mistral_config { 'oslo_messaging_rabbit/rabbit_port': ensure => absent }
} else {
mistral_config { 'oslo_messaging_rabbit/rabbit_host': value => $rabbit_host }
mistral_config { 'oslo_messaging_rabbit/rabbit_port': value => $rabbit_port }
mistral_config { 'oslo_messaging_rabbit/rabbit_hosts': value => "${rabbit_host}:${rabbit_port}" }
}
# By default rabbit_ha_queues is undef
if $rabbit_ha_queues == undef {
if size($rabbit_hosts) > 1 {
mistral_config { 'oslo_messaging_rabbit/rabbit_ha_queues': value => true }
} else {
mistral_config { 'oslo_messaging_rabbit/rabbit_ha_queues': value => false }
}
} else {
mistral_config { 'oslo_messaging_rabbit/rabbit_ha_queues': value => $rabbit_ha_queues }
}
} }
} }

View File

@ -45,7 +45,6 @@
# (optional) Name of the service. # (optional) Name of the service.
# Defaults to the value of auth_name. # Defaults to the value of auth_name.
# #
#
# [*configure_service*] # [*configure_service*]
# Should mistral service be configured? Defaults to 'true'. # Should mistral service be configured? Defaults to 'true'.
# #
@ -57,55 +56,6 @@
# (optional) Whether to configure the admin role for the service user. # (optional) Whether to configure the admin role for the service user.
# Defaults to true # Defaults to true
# #
# [*version*]
# (optional) DEPRECATED: Use public_url, internal_url and admin_url instead.
# API version endpoint. (Defaults to 'v2')
# Setting this parameter overrides public_url, internal_url and admin_url parameters.
#
# [*port*]
# (optional) DEPRECATED: Use public_url, internal_url and admin_url instead.
# Default port for endpoints. (Defaults to 8989)
# Setting this parameter overrides public_url, internal_url and admin_url parameters.
#
# [*public_port*]
# (optional) DEPRECATED: Use public_url, internal_url and admin_url instead.
# Default public port for endpoints. (Defaults to 8989)
# Setting this parameter overrides public_url, internal_url and admin_url parameters.
#
# [*public_protocol*]
# (optional) DEPRECATED: Use public_url instead.
# Protocol for public endpoint. (Defaults to 'http')
# Setting this parameter overrides public_url parameter.
#
# [*public_address*]
# (optional) DEPRECATED: Use public_url instead.
# Public address for endpoint. (Defaults to '127.0.0.1')
# Setting this parameter overrides public_url parameter.
#
# [*internal_protocol*]
# (optional) DEPRECATED: Use internal_url instead.
# Protocol for internal endpoint. (Defaults to 'http')
# Setting this parameter overrides internal_url parameter.
#
# [*internal_address*]
# (optional) DEPRECATED: Use internal_url instead.
# Internal address for endpoint. (Defaults to '127.0.0.1')
# Setting this parameter overrides internal_url parameter.
#
# [*admin_protocol*]
# (optional) DEPRECATED: Use admin_url instead.
# Protocol for admin endpoint. (Defaults to 'http')
# Setting this parameter overrides admin_url parameter.
#
# [*admin_address*]
# (optional) DEPRECATED: Use admin_url instead.
# Admin address for endpoint. (Defaults to '127.0.0.1')
# Setting this parameter overrides admin_url parameter.
# === Deprecation notes
#
# If any value is provided for public_protocol, public_address or port parameters,
# public_url will be completely ignored. The same applies for internal and admin parameters.
#
class mistral::keystone::auth( class mistral::keystone::auth(
$password, $password,
$email = 'mistral@localhost', $email = 'mistral@localhost',
@ -121,7 +71,7 @@ class mistral::keystone::auth(
$configure_service = true, $configure_service = true,
$configure_user = true, $configure_user = true,
$configure_user_role = true, $configure_user_role = true,
$service_description = 'Openstack workflow Service', $service_description = 'OpenStack Workflow Service',
) { ) {
validate_string($password) validate_string($password)

View File

@ -1,211 +1,149 @@
# Class mistral::logging # == Class: mistral::logging
# #
# mistral extended logging configuration # Mistral logging configuration
# #
# == parameters # === 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 or $::os_service_default, it will not log to any
# directory.
# Defaults to '/var/log/mistral'
# #
# [*logging_context_format_string*] # [*logging_context_format_string*]
# (optional) Format string to use for log messages with context. # (Optional) Format string to use for log messages with context.
# Defaults to undef. # Defaults to $::os_service_default
# Example: '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s\ # Example: '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s\
# [%(request_id)s %(user_identity)s] %(instance)s%(message)s' # [%(request_id)s %(user_identity)s] %(instance)s%(message)s'
# #
# [*logging_default_format_string*] # [*logging_default_format_string*]
# (optional) Format string to use for log messages without context. # (Optional) Format string to use for log messages without context.
# Defaults to undef. # Defaults to $::os_service_default
# Example: '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s\ # Example: '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s\
# [-] %(instance)s%(message)s' # [-] %(instance)s%(message)s'
# #
# [*logging_debug_format_suffix*] # [*logging_debug_format_suffix*]
# (optional) Formatted data to append to log format when level is DEBUG. # (Optional) Formatted data to append to log format when level is DEBUG.
# Defaults to undef. # Defaults to $::os_service_default
# Example: '%(funcName)s %(pathname)s:%(lineno)d' # Example: '%(funcName)s %(pathname)s:%(lineno)d'
# #
# [*logging_exception_prefix*] # [*logging_exception_prefix*]
# (optional) Prefix each line of exception output with this format. # (Optional) Prefix each line of exception output with this format.
# Defaults to undef. # Defaults to $::os_service_default
# Example: '%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s' # Example: '%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s'
# #
# [*log_config_append*] # [*log_config_append*]
# The name of an additional logging configuration file. # The name of an additional logging configuration file.
# Defaults to undef. # Defaults to $::os_service_default
# See https://docs.python.org/2/howto/logging.html # See https://docs.python.org/2/howto/logging.html
# #
# [*default_log_levels*] # [*default_log_levels*]
# (optional) Hash of logger (keys) and level (values) pairs. # (optional) Hash of logger (keys) and level (values) pairs.
# Defaults to undef. # Defaults to $::os_service_default.
# Example: # Example:
# { 'amqp' => 'WARN', 'amqplib' => 'WARN', 'boto' => 'WARN', # { 'amqp' => 'WARN', 'amqplib' => 'WARN', 'boto' => 'WARN',
# 'qpid' => 'WARN', 'sqlalchemy' => 'WARN', 'suds' => 'INFO', # 'qpid' => 'WARN', 'sqlalchemy' => 'WARN', 'suds' => 'INFO',
# 'oslo.messaging' => 'INFO', 'iso8601' => 'WARN', # 'iso8601' => 'WARN',
# 'requests.packages.urllib3.connectionpool' => 'WARN', # 'requests.packages.urllib3.connectionpool' => 'WARN' }
# 'urllib3.connectionpool' => 'WARN',
# 'websocket' => 'WARN', 'mistralmiddleware' => 'WARN',
# 'routes.middleware' => 'WARN', stevedore => 'WARN' }
# #
# [*publish_errors*] # [*publish_errors*]
# (optional) Publish error events (boolean value). # (optional) Publish error events (boolean value).
# Defaults to undef (false if unconfigured). # Defaults to $::os_service_default
# #
# [*fatal_deprecations*] # [*fatal_deprecations*]
# (optional) Make deprecations fatal (boolean value) # (optional) Make deprecations fatal (boolean value)
# Defaults to undef (false if unconfigured). # Defaults to $::os_service_default
# #
# [*instance_format*] # [*instance_format*]
# (optional) If an instance is passed with the log message, format it # (optional) If an instance is passed with the log message, format it
# like this (string value). # like this (string value).
# Defaults to undef. # Defaults to $::os_service_default
# Example: '[instance: %(uuid)s] ' # Example: '[instance: %(uuid)s] '
# #
# [*instance_uuid_format*] # [*instance_uuid_format*]
# (optional) If an instance UUID is passed with the log message, format # (optional) If an instance UUID is passed with the log message, format
# it like this (string value). # it like this (string value).
# Defaults to undef. # Defaults to $::os_service_default
# Example: instance_uuid_format='[instance: %(uuid)s] ' # Example: instance_uuid_format='[instance: %(uuid)s] '
#
# [*log_date_format*] # [*log_date_format*]
# (optional) Format string for %%(asctime)s in log records. # (optional) Format string for %%(asctime)s in log records.
# Defaults to undef. # Defaults to $::os_service_default
# Example: 'Y-%m-%d %H:%M:%S' # Example: 'Y-%m-%d %H:%M:%S'
#
class mistral::logging( class mistral::logging(
$logging_context_format_string = undef, $use_syslog = $::os_service_default,
$logging_default_format_string = undef, $use_stderr = $::os_service_default,
$logging_debug_format_suffix = undef, $log_facility = $::os_service_default,
$logging_exception_prefix = undef, $log_dir = '/var/log/mistral',
$log_config_append = undef, $verbose = $::os_service_default,
$default_log_levels = undef, $debug = $::os_service_default,
$publish_errors = undef, $logging_context_format_string = $::os_service_default,
$fatal_deprecations = undef, $logging_default_format_string = $::os_service_default,
$instance_format = undef, $logging_debug_format_suffix = $::os_service_default,
$instance_uuid_format = undef, $logging_exception_prefix = $::os_service_default,
$log_date_format = undef, $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,
) { ) {
if $logging_context_format_string { # NOTE(spredzy): In order to keep backward compatibility we rely on the pick function
mistral_config { # to use mistral::<myparam> if mistral::logging::<myparam> isn't specified.
'DEFAULT/logging_context_format_string' : $use_syslog_real = pick($::mistral::use_syslog,$use_syslog)
value => $logging_context_format_string; $use_stderr_real = pick($::mistral::use_stderr,$use_stderr)
} $log_facility_real = pick($::mistral::log_facility,$log_facility)
} $log_dir_real = pick($::mistral::log_dir,$log_dir)
else { $verbose_real = pick($::mistral::verbose,$verbose)
mistral_config { $debug_real = pick($::mistral::debug,$debug)
'DEFAULT/logging_context_format_string' : ensure => absent;
}
}
if $logging_default_format_string { if is_service_default($default_log_levels) {
mistral_config { $default_log_levels_real = $default_log_levels
'DEFAULT/logging_default_format_string' : } else {
value => $logging_default_format_string; $default_log_levels_real = join(sort(join_keys_to_values($default_log_levels, '=')), ',')
} }
}
else {
mistral_config {
'DEFAULT/logging_default_format_string' : ensure => absent;
}
}
if $logging_debug_format_suffix {
mistral_config {
'DEFAULT/logging_debug_format_suffix' :
value => $logging_debug_format_suffix;
}
}
else {
mistral_config {
'DEFAULT/logging_debug_format_suffix' : ensure => absent;
}
}
if $logging_exception_prefix {
mistral_config {
'DEFAULT/logging_exception_prefix' : value => $logging_exception_prefix;
}
}
else {
mistral_config {
'DEFAULT/logging_exception_prefix' : ensure => absent;
}
}
if $log_config_append {
mistral_config {
'DEFAULT/log_config_append' : value => $log_config_append;
}
}
else {
mistral_config {
'DEFAULT/log_config_append' : ensure => absent;
}
}
if $default_log_levels {
mistral_config {
'DEFAULT/default_log_levels' :
value => join(sort(join_keys_to_values($default_log_levels, '=')), ',');
}
}
else {
mistral_config {
'DEFAULT/default_log_levels' : ensure => absent;
}
}
if $publish_errors {
mistral_config {
'DEFAULT/publish_errors' : value => $publish_errors;
}
}
else {
mistral_config {
'DEFAULT/publish_errors' : ensure => absent;
}
}
if $fatal_deprecations {
mistral_config {
'DEFAULT/fatal_deprecations' : value => $fatal_deprecations;
}
}
else {
mistral_config {
'DEFAULT/fatal_deprecations' : ensure => absent;
}
}
if $instance_format {
mistral_config {
'DEFAULT/instance_format' : value => $instance_format;
}
}
else {
mistral_config {
'DEFAULT/instance_format' : ensure => absent;
}
}
if $instance_uuid_format {
mistral_config {
'DEFAULT/instance_uuid_format' : value => $instance_uuid_format;
}
}
else {
mistral_config {
'DEFAULT/instance_uuid_format' : ensure => absent;
}
}
if $log_date_format {
mistral_config {
'DEFAULT/log_date_format' : value => $log_date_format;
}
}
else {
mistral_config {
'DEFAULT/log_date_format' : ensure => absent;
}
}
mistral_config {
'DEFAULT/use_syslog' : value => $use_syslog_real;
'DEFAULT/use_stderr' : value => $use_stderr_real;
'DEFAULT/syslog_log_facility' : value => $log_facility_real;
'DEFAULT/log_dir' : value => $log_dir_real;
'DEFAULT/verbose' : value => $verbose_real;
'DEFAULT/debug' : value => $debug_real;
'DEFAULT/default_log_levels' : value => $default_log_levels_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/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;
}
} }

View File

@ -4,34 +4,30 @@
# #
class mistral::params { class mistral::params {
$mistral_conf_dir = '/etc/mistral' $client_package = 'python-mistralclient'
$mistral_conf = "${mistral_conf_dir}/mistral.conf" $db_sync_command = 'mistral-db-manage --config-file=/etc/mistral/mistral.conf upgrade head'
$mistral_log_dir='/var/log/mistral' $db_populate_command = 'mistral-db-manage --config-file=/etc/mistral/mistral.conf populate'
$service_log_file="${mistral_log_dir}/mistral-server.log"
$client_package = 'python-mistralclient'
$log_dir ='/var/log/mistral'
$db_sync_command = "mistral-db-manage --config-file=${mistral_conf} upgrade head"
$db_populate_command = "mistral-db-manage --config-file=${mistral_conf} populate"
$update_service_command = '/usr/bin/systemctl daemon-reload'
case $::osfamily { case $::osfamily {
'RedHat': { 'RedHat': {
$common_package_name = 'openstack-mistral-common' $common_package_name = 'openstack-mistral-common'
$api_package_name = 'openstack-mistral-api' $api_package_name = 'openstack-mistral-api'
$api_service_name = 'openstack-mistral-api' $api_service_name = 'openstack-mistral-api'
$engine_package_name = 'openstack-mistral-engine' $engine_package_name = 'openstack-mistral-engine'
$engine_service_name = 'openstack-mistral-engine' $engine_service_name = 'openstack-mistral-engine'
$executor_package_name = 'openstack-mistral-executor' $executor_package_name = 'openstack-mistral-executor'
$executor_service_name = 'openstack-mistral-executor' $executor_service_name = 'openstack-mistral-executor'
$pymysql_package_name = undef
} }
'Debian': { 'Debian': {
$common_package_name = 'mistral' $common_package_name = 'mistral'
$api_package_name = 'mistral-api' $api_package_name = 'mistral-api'
$api_service_name = 'mistral-api' $api_service_name = 'mistral-api'
$engine_package_name = 'mistral-engine' $engine_package_name = 'mistral-engine'
$engine_service_name = 'mistral-engine' $engine_service_name = 'mistral-engine'
$executor_package_name = 'mistral-executor' $executor_package_name = 'mistral-executor'
$executor_service_name = 'mistral-executor' $executor_service_name = 'mistral-executor'
$pymysql_package_name = 'python-pymysql'
} }
default: { default: {
fail("Unsupported osfamily: ${::osfamily} operatingsystem: \ fail("Unsupported osfamily: ${::osfamily} operatingsystem: \

View File

@ -1,100 +0,0 @@
# == Class: mistral::services
#
# Start mistral services
#
# === Parameters
#
# [*is_engine*]
# start mistral engine? Defaults to 'true'.
#
# [*is_api*]
# start mistral api? Defaults to 'true'.
#
# [*is_executor*]
# start mistral executor? Defaults to 'true'.
#
# [*conf_file*]
# path to the conf file. Defaults '$::mistral::params::mistral_conf'
#
# [*log_file*]
# path to the service log file. Defaults '$::mistral::params::service_log_file'
#
class mistral::services(
$is_engine = true,
$is_api = true,
$is_executor = true,
$conf_file = $::mistral::params::mistral_conf,
$log_file = $::mistral::params::service_log_file
) inherits ::mistral::params {
if $is_engine {
notify { 'Start mistral-engine': }
file { 'openstack-mistral-engine':
path => '/usr/lib/systemd/system/openstack-mistral-engine
.service',
owner => 'mistral',
group => 'mistral',
mode => '0644',
content => template('mistral/openstack-mistral-engine.service.erb'),
require => Package['mistral']
}
service { 'openstack-mistral-engine':
ensure => running,
enable => true,
require => File['openstack-mistral-engine'],
subscribe => File[$::mistral::params::mistral_conf]
}
}
if $is_api {
notify { 'Start mistral-api': }
file { 'openstack-mistral-api':
path => '/usr/lib/systemd/system/openstack-mistral-api.service',
owner => 'mistral',
group => 'mistral',
mode => '0644',
content => template('mistral/openstack-mistral-api.service.erb'),
require => Package['mistral']
}
service { 'openstack-mistral-api':
ensure => running,
enable => true,
require => File['openstack-mistral-api'],
subscribe => File[$::mistral::params::mistral_conf]
}
}
if $is_executor {
notify { 'Start mistral-executor': }
file { 'openstack-mistral-executor':
path => '/usr/lib/systemd/system/openstack-mistral-executor
.service',
owner => 'mistral',
group => 'mistral',
mode => '0644',
content => template('mistral/openstack-mistral-executor.service.erb'),
require => Package['mistral']
}
service { 'openstack-mistral-executor':
ensure => running,
enable => true,
require => File['openstack-mistral-executor'],
subscribe => File[$::mistral::params::mistral_conf]
}
}
exec { 'update-service':
command => $::mistral::params::update_service_command,
path => '/usr/bin',
user => 'root',
logoutput => on_failure,
subscribe => [File['openstack-mistral-executor'],
File['openstack-mistral-api'], File['openstack-mistral-engine']]
}
}

View File

@ -14,8 +14,8 @@ describe 'mistral::api' do
context 'config params' do context 'config params' do
it { is_expected.to contain_class('mistral') }
it { is_expected.to contain_class('mistral::params') } it { is_expected.to contain_class('mistral::params') }
it { is_expected.to contain_class('mistral::policy') }
it { is_expected.to contain_mistral_config('api/host').with_value( params[:bind_host] ) } it { is_expected.to contain_mistral_config('api/host').with_value( params[:bind_host] ) }
it { is_expected.to contain_mistral_config('api/port').with_value( params[:bind_port] ) } it { is_expected.to contain_mistral_config('api/port').with_value( params[:bind_port] ) }

View File

@ -0,0 +1,115 @@
require 'spec_helper'
describe 'mistral::db' do
shared_examples 'mistral::db' do
context 'with default parameters' do
it { is_expected.to contain_mistral_config('database/connection').with_value('sqlite:////var/lib/mistral/mistral.sqlite').with_secret(true) }
it { is_expected.to contain_mistral_config('database/idle_timeout').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_mistral_config('database/min_pool_size').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_mistral_config('database/max_retries').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_mistral_config('database/retry_interval').with_value('<SERVICE DEFAULT>') }
end
context 'with specific parameters' do
let :params do
{ :database_connection => 'mysql+pymysql://mistral:mistral@localhost/mistral',
:database_idle_timeout => '3601',
:database_min_pool_size => '2',
:database_max_retries => '11',
:database_retry_interval => '11', }
end
it { is_expected.to contain_mistral_config('database/connection').with_value('mysql+pymysql://mistral:mistral@localhost/mistral').with_secret(true) }
it { is_expected.to contain_mistral_config('database/idle_timeout').with_value('3601') }
it { is_expected.to contain_mistral_config('database/min_pool_size').with_value('2') }
it { is_expected.to contain_mistral_config('database/max_retries').with_value('11') }
it { is_expected.to contain_mistral_config('database/retry_interval').with_value('11') }
end
context 'with postgresql backend' do
let :params do
{ :database_connection => 'postgresql://mistral:mistral@localhost/mistral', }
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://mistral:mistral@localhost/mistral', }
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 => 'redis://mistral:mistral@localhost/mistral', }
end
it_raises 'a Puppet::Error', /validate_re/
end
context 'with incorrect pymysql database_connection string' do
let :params do
{ :database_connection => 'foo+pymysql://mistral:mistral@localhost/mistral', }
end
it_raises 'a Puppet::Error', /validate_re/
end
end
context 'on Debian platforms' do
let :facts do
OSDefaults.get_facts({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => 'jessie'
})
end
it_configures 'mistral::db'
context 'using pymysql driver' do
let :params do
{ :database_connection => 'mysql+pymysql://mistral:mistral@localhost/mistral', }
end
it 'install the proper backend package' do
is_expected.to contain_package('mistral-backend-package').with(
:ensure => 'present',
:name => 'python-pymysql',
:tag => 'openstack'
)
end
end
end
context 'on Redhat platforms' do
let :facts do
OSDefaults.get_facts({
:osfamily => 'RedHat',
:operatingsystemrelease => '7.1',
})
end
it_configures 'mistral::db'
context 'using pymysql driver' do
let :params do
{ :database_connection => 'mysql+pymysql://mistral:mistral@localhost/mistral', }
end
it { is_expected.not_to contain_package('mistral-backend-package') }
end
end
end

View File

@ -15,7 +15,6 @@ describe 'mistral::engine' do
context 'config params' do context 'config params' do
it { is_expected.to contain_class('mistral') }
it { is_expected.to contain_class('mistral::params') } it { is_expected.to contain_class('mistral::params') }
it { is_expected.to contain_mistral_config('engine/host').with_value( params[:host] ) } it { is_expected.to contain_mistral_config('engine/host').with_value( params[:host] ) }

View File

@ -16,7 +16,6 @@ describe 'mistral::executor' do
context 'config params' do context 'config params' do
it { is_expected.to contain_class('mistral') }
it { is_expected.to contain_class('mistral::params') } it { is_expected.to contain_class('mistral::params') }
it { is_expected.to contain_mistral_config('executor/host').with_value( params[:host] ) } it { is_expected.to contain_mistral_config('executor/host').with_value( params[:host] ) }

View File

@ -1,58 +1,211 @@
require 'spec_helper' require 'spec_helper'
describe 'mistral' do describe 'mistral' do
let :req_params do
let :params do
{ {
:auth_uri => 'http://127.0.0.1:5000/', :rabbit_password => 'guest',
:identity_uri => 'http://127.0.0.1:35357/', :database_connection => 'mysql://user:password@host/database',
:keystone_password => 'foo',
} }
end end
shared_examples_for 'mistral' do let :facts do
OSDefaults.get_facts({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => 'jessie',
})
end
describe 'with only required params' do
let :params do
req_params
end
it { is_expected.to contain_class('mistral::logging') }
it { is_expected.to contain_class('mistral::params') } it { is_expected.to contain_class('mistral::params') }
it { is_expected.to contain_class('mysql::bindings::python') }
it 'configures auth_uri' do it 'should contain default config' do
is_expected.to contain_mistral_config('keystone_authtoken/auth_uri').with_value( params[:auth_uri] ) is_expected.to contain_mistral_config('DEFAULT/rpc_backend').with(:value => 'rabbit')
end is_expected.to contain_mistral_config('DEFAULT/control_exchange').with(:value => 'openstack')
is_expected.to contain_mistral_config('DEFAULT/report_interval').with(:value => '<SERVICE DEFAULT>')
it 'configures identity_uri' do is_expected.to contain_mistral_config('DEFAULT/service_down_time').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('keystone_authtoken/identity_uri').with_value( params[:identity_uri] ) is_expected.to contain_mistral_config('oslo_messaging_rabbit/rabbit_password').with(:value => 'guest', :secret => true)
end is_expected.to contain_mistral_config('oslo_messaging_rabbit/rabbit_host').with(:value => '127.0.0.1')
is_expected.to contain_mistral_config('oslo_messaging_rabbit/rabbit_port').with(:value => '5672')
it 'installs mistral package' do is_expected.to contain_mistral_config('oslo_messaging_rabbit/rabbit_hosts').with(:value => '127.0.0.1:5672')
is_expected.to contain_package('mistral-common').with( is_expected.to contain_mistral_config('oslo_messaging_rabbit/rabbit_ha_queues').with(:value => false)
:ensure => 'present', is_expected.to contain_mistral_config('oslo_messaging_rabbit/rabbit_virtual_host').with(:value => '/')
:name => platform_params[:common_package_name], is_expected.to contain_mistral_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('0')
:tag => ['openstack', 'mistral-package'], is_expected.to contain_mistral_config('oslo_messaging_rabbit/heartbeat_rate').with_value('2')
is_expected.to contain_mistral_config('oslo_messaging_rabbit/rabbit_userid').with(:value => 'guest')
is_expected.to contain_mistral_config('oslo_messaging_rabbit/kombu_reconnect_delay').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('coordination/backend_url').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('coordination/heartbeat_interval').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('keystone_authtoken/auth_uri').with(
:value => 'http://localhost:5000/'
)
is_expected.to contain_mistral_config('keystone_authtoken/identity_uri').with(
:value => 'http://localhost:35357/'
)
is_expected.to contain_mistral_config('keystone_authtoken/admin_tenant_name').with(
:value => 'services'
)
is_expected.to contain_mistral_config('keystone_authtoken/admin_user').with(
:value => 'mistral'
)
is_expected.to contain_mistral_config('keystone_authtoken/admin_password').with(
:value => 'foo'
) )
end end
end end
describe 'with modified rabbit_hosts' do
context 'on Debian platforms' do let :params do
let :facts do req_params.merge({'rabbit_hosts' => ['rabbit1:5672', 'rabbit2:5672']})
{ :osfamily => 'Debian' }
end end
let :platform_params do it 'should contain many' do
{ :common_package_name => 'mistral' } is_expected.to contain_mistral_config('oslo_messaging_rabbit/rabbit_host').with(:value => nil)
is_expected.to contain_mistral_config('oslo_messaging_rabbit/rabbit_port').with(:value => nil)
is_expected.to contain_mistral_config('oslo_messaging_rabbit/rabbit_hosts').with(:value => 'rabbit1:5672,rabbit2:5672')
is_expected.to contain_mistral_config('oslo_messaging_rabbit/rabbit_ha_queues').with(:value => true)
end end
it_configures 'mistral'
end end
context 'on RedHat platforms' do describe 'with a single rabbit_hosts entry' do
let :facts do let :params do
{ :osfamily => 'RedHat' } req_params.merge({'rabbit_hosts' => ['rabbit1:5672']})
end end
let :platform_params do it 'should contain many' do
{ :common_package_name => 'openstack-mistral-common' } is_expected.to contain_mistral_config('oslo_messaging_rabbit/rabbit_host').with(:value => nil)
is_expected.to contain_mistral_config('oslo_messaging_rabbit/rabbit_port').with(:value => nil)
is_expected.to contain_mistral_config('oslo_messaging_rabbit/rabbit_hosts').with(:value => 'rabbit1:5672')
is_expected.to contain_mistral_config('oslo_messaging_rabbit/rabbit_ha_queues').with(:value => false)
end
end
describe 'a single rabbit_host with enable ha queues' do
let :params do
req_params.merge({'rabbit_ha_queues' => true})
end end
it_configures 'mistral' it 'should contain rabbit_ha_queues' do
is_expected.to contain_mistral_config('oslo_messaging_rabbit/rabbit_ha_queues').with(:value => true)
end
end
describe 'with rabbitmq heartbeats' do
let :params do
req_params.merge({'rabbit_heartbeat_timeout_threshold' => '60', 'rabbit_heartbeat_rate' => '10'})
end
it 'should contain heartbeat config' do
is_expected.to contain_mistral_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('60')
is_expected.to contain_mistral_config('oslo_messaging_rabbit/heartbeat_rate').with_value('10')
end
end
describe 'with SSL enabled with kombu' do
let :params do
req_params.merge!({
:rabbit_use_ssl => true,
:kombu_ssl_ca_certs => '/path/to/ssl/ca/certs',
:kombu_ssl_certfile => '/path/to/ssl/cert/file',
:kombu_ssl_keyfile => '/path/to/ssl/keyfile',
:kombu_ssl_version => 'TLSv1'
})
end
it do
is_expected.to contain_mistral_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value('true')
is_expected.to contain_mistral_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_value('/path/to/ssl/ca/certs')
is_expected.to contain_mistral_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_value('/path/to/ssl/cert/file')
is_expected.to contain_mistral_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_value('/path/to/ssl/keyfile')
is_expected.to contain_mistral_config('oslo_messaging_rabbit/kombu_ssl_version').with_value('TLSv1')
end
end
describe 'with SSL enabled without kombu' do
let :params do
req_params.merge!({
:rabbit_use_ssl => true,
})
end
it do
is_expected.to contain_mistral_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value('true')
is_expected.to contain_mistral_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_value('<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_value('<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_value('<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('oslo_messaging_rabbit/kombu_ssl_version').with_value('<SERVICE DEFAULT>')
end
end
describe 'with SSL disabled' do
let :params do
req_params.merge!({
:rabbit_use_ssl => false,
:kombu_ssl_ca_certs => '<SERVICE DEFAULT>',
:kombu_ssl_certfile => '<SERVICE DEFAULT>',
:kombu_ssl_keyfile => '<SERVICE DEFAULT>',
:kombu_ssl_version => '<SERVICE DEFAULT>'
})
end
it do
is_expected.to contain_mistral_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value('false')
is_expected.to contain_mistral_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_value('<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_value('<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_value('<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('oslo_messaging_rabbit/kombu_ssl_version').with_value('<SERVICE DEFAULT>')
end
end
describe 'with amqp_durable_queues disabled' do
let :params do
req_params
end
it { is_expected.to contain_mistral_config('oslo_messaging_rabbit/amqp_durable_queues').with_value(false) }
end
describe 'with amqp_durable_queues enabled' do
let :params do
req_params.merge({
:amqp_durable_queues => true,
})
end
it { is_expected.to contain_mistral_config('oslo_messaging_rabbit/amqp_durable_queues').with_value(true) }
end
describe 'with postgresql' do
let :params do
req_params.merge({
:database_connection => 'postgresql://user:drowssap@host/database',
:rabbit_password => 'guest',
})
end
it { is_expected.to_not contain_class('mysql::python') }
it { is_expected.to_not contain_class('mysql::bindings') }
it { is_expected.to_not contain_class('mysql::bindings::python') }
end
describe 'with coordination' do
let :params do
req_params.merge({
:coordination_backend_url => 'redis://127.0.0.1',
:coordination_heartbeat_interval => '10.0',
})
end
it 'should contain coordination config' do
is_expected.to contain_mistral_config('coordination/backend_url').with(:value => 'redis://127.0.0.1')
is_expected.to contain_mistral_config('coordination/heartbeat_interval').with(:value => '10.0')
end
end end
end end

View File

@ -28,7 +28,7 @@ describe 'mistral::keystone::auth' do
it { is_expected.to contain_keystone_service('mistral::workflowv2').with( it { is_expected.to contain_keystone_service('mistral::workflowv2').with(
:ensure => 'present', :ensure => 'present',
:description => 'Openstack workflow Service' :description => 'OpenStack Workflow Service'
) } ) }
it { is_expected.to contain_keystone_endpoint('RegionOne/mistral::workflowv2').with( it { is_expected.to contain_keystone_endpoint('RegionOne/mistral::workflowv2').with(
@ -77,7 +77,7 @@ describe 'mistral::keystone::auth' do
it { is_expected.to contain_keystone_user_role('mistral@services') } it { is_expected.to contain_keystone_user_role('mistral@services') }
it { is_expected.to contain_keystone_service('mistral::workflowv2').with( it { is_expected.to contain_keystone_service('mistral::workflowv2').with(
:ensure => 'present', :ensure => 'present',
:description => 'Openstack workflow Service' :description => 'OpenStack Workflow Service'
) } ) }
end end
@ -96,7 +96,7 @@ describe 'mistral::keystone::auth' do
it { is_expected.not_to contain_keystone_user_role('mistral@services') } it { is_expected.not_to contain_keystone_user_role('mistral@services') }
it { is_expected.to contain_keystone_service('mistral::workflowv2').with( it { is_expected.to contain_keystone_service('mistral::workflowv2').with(
:ensure => 'present', :ensure => 'present',
:description => 'Openstack workflow Service' :description => 'OpenStack Workflow Service'
) } ) }
end end

View File

@ -24,20 +24,53 @@ describe 'mistral::logging' do
:instance_format => '[instance: %(uuid)s] ', :instance_format => '[instance: %(uuid)s] ',
:instance_uuid_format => '[instance: %(uuid)s] ', :instance_uuid_format => '[instance: %(uuid)s] ',
:log_date_format => '%Y-%m-%d %H:%M:%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 end
shared_examples_for 'mistral-logging' do 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 context 'with extended logging options' do
before { params.merge!( log_params ) } before { params.merge!( log_params ) }
it_configures 'logging params set' it_configures 'logging params set'
end end
context 'without extended logging options' do end
it_configures 'logging params unset'
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 end
shared_examples_for 'logging params set' do shared_examples_for 'logging params set' do
@ -76,32 +109,16 @@ describe 'mistral::logging' do
end end
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
shared_examples_for 'logging params unset' do it_configures 'mistral-logging'
[ :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_mistral_config("DEFAULT/#{param}").with_ensure('absent') }
}
end
context 'on Debian platforms' do
let :facts do
{ :osfamily => 'Debian' }
end end
it_configures 'mistral-logging'
end
context 'on RedHat platforms' do
let :facts do
{ :osfamily => 'RedHat' }
end
it_configures 'mistral-logging'
end end
end end