This commit adds the initial project files.

Unit tests: added

Packages for Debian and RedHat family OS are not known. Until that
package installation has been removed from init.pp file.

Change-Id: I79f41e1168d26ee7ed4785ef46783a24a246f21b
This commit is contained in:
Daniel Pawlik 2016-06-07 14:57:13 +00:00
parent 812594b6d9
commit 58c20a1869
4 changed files with 854 additions and 4 deletions

View File

@ -1,3 +1,4 @@
Copyright 2016 OVH Group
Copyright 2016 OpenStack Foundation
Licensed under the Apache License, Version 2.0 (the "License");

29
manifests/deps.pp Normal file
View File

@ -0,0 +1,29 @@
# == Class: watcher::deps
#
# watcher anchors and dependency management
#
class watcher::deps {
anchor { 'watcher::install::begin': }
-> Package<| tag == 'watcher-package'|>
~> anchor { 'watcher::install::end': }
-> anchor { 'watcher::config::begin': }
-> Watcher_config<||>
~> anchor { 'watcher::config::end': }
~> anchor { 'watcher::db::begin': }
~> anchor { 'watcher::db::end': }
~> anchor { 'watcher::db::create_schema::begin': }
~> anchor { 'watcher::db::create_schema::end': }
~> anchor { 'watcher::db::upgrade::begin': }
~> anchor { 'watcher::db::upgrade::end': }
~> anchor { 'watcher::service::begin': }
~> Service<| tag == 'watcher-service' |>
~> anchor { 'watcher::service::end': }
Anchor['watcher::install::end'] ~> Anchor['watcher::service::begin']
Anchor['watcher::config::end'] ~> Anchor['watcher::service::begin']
anchor { 'watcher-start':
require => Anchor['watcher::install::end'],
before => Anchor['watcher::config::begin'],
}
}

View File

@ -2,13 +2,509 @@
#
# Full description of class watcher here.
#
# === Parameters
# === Parameters:
#
# [*sample_parameter*]
# Explanation of what this parameter affects and what it defaults to.
# [*use_ssl*]
# (required) Enable SSL on the API server.
# Defaults to false.
#
class watcher {
# [*package_ensure*]
# (optional) The state of watcher packages.
# Defaults to 'present'
#
# [*ceilometer_client_api_version*]
# (required) Version of Ceilometer API to use in ceilometerclient.
# Default is 2.
#
# [*cinder_client_api_version*]
# (required) Version of Cinder API to use in cinderclient.
# Default is 2.
#
# [*glance_client_api_version*]
# (required) Version of Glance API to use in glanceclient.
# Default is 2.
#
# [*neutron_client_api_version*]
# (required) Version of Neutron API to use in neutronclient.
# Default is 2.
#
# [*nova_client_api_version*]
# (required) Version of Nova API to use in novaclient.
# Default is 2.
#
# [*rpc_backend*]
# (optional) The messaging driver to use, defaults to rabbit. Other drivers
# include amqp and zmq.
# Defaults to 'rabbit'.
#
# [*ensure_package*]
# (optional) Whether the watcher api package will be installed
# Defaults to 'present'
#
# [*rabbit_host*]
# (required) The RabbitMQ broker address where a single node is used.
# Defaults to $::os_service_default
#
# [*rabbit_hosts*]
# (optional) RabbitMQ HA cluster host:port pairs.
# Defaults to $::os_service_default
#
# [*rabbit_password*]
# (optional) The RabbitMQ password.
# Defaults to $::os_service_default
#
# [*rabbit_login_method*]
# (optional) The RabbitMQ login method. (string value)
# Defaults to $::os_service_default
#
# [*rabbit_port*]
# (required) The RabbitMQ broker port where a single node is used.
# Defaults to $::os_service_default
#
# [*rabbit_userid*]
# (required) The RabbitMQ userid.
# Defaults to $::os_service_default
#
# [*rabbit_virtual_host*]
# (required) The RabbitMQ virtual host.
# Defaults to $::os_service_default
#
# [*rabbit_retry_interval*]
# (Optional) How frequently to retry connecting with RabbitMQ.
# (integer value)
# Defaults to $::os_service_default
#
# [*rabbit_retry_backoff*]
# (Optional) How long to backoff for between retries when connecting
# to RabbitMQ. (integer value)
# Defaults to $::os_service_default
#
# [*rabbit_interval_max*]
# (Optional) Maximum interval of RabbitMQ connection retries. (integer value)
# Defaults to $::os_service_default
#
# [*rabbit_max_retries*]
# (Optional) Maximum number of RabbitMQ connection retries. (integer value)
# Defaults to $::os_service_default
#
# [*rabbit_use_ssl*]
# (optional) Connect over SSL for RabbitMQ.
# Defaults to $::os_service_default
#
# [*rabbit_heartbeat_rate*]
# (optional) ow often times during the heartbeat_timeout_threshold we
# check the heartbeat.
# Defaults to $::os_service_default
#
# [*rabbit_ha_queues*]
# (optional) Use HA queues in RabbitMQ (x-ha-policy: all). If you change this
# option, you must wipe the RabbitMQ database.
# Defaults to $::os_service_default
#
# [*rabbit_transient_queues_ttl*]
# (Optional) Positive integer representing duration in seconds for
# queue TTL (x-expires). Queues which are unused for the duration
# of the TTL are automatically deleted.
# The parameter affects only reply and fanout queues. (integer value)
# Min to 1
# Defaults to $::os_service_default
#
# [*rabbit_heartbeat_timeout_threshold*]
# (Optional) Number of seconds after which the Rabbit broker is
# considered down if heartbeat's keep-alive fails
# (0 disable the heartbeat). EXPERIMENTAL. (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 and SSLv23. SSLv2, SSLv3, TLSv1_1, and TLSv1_2 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
#
# [*kombu_missing_consumer_retry_timeout*]
# (optional)How long to wait a missing client beforce abandoning to send it
# its replies. This value should not be longer than rpc_response_timeout.
# Defaults to $::os_service_default
#
# [*kombu_failover_strategy*]
# (Optional) Determines how the next RabbitMQ node is chosen in case the one
# we are currently connected to becomes unavailable. Takes effect only if
# more than one RabbitMQ node is provided in config. (string value)
# Defaults to $::os_service_default
#
# [*kombu_compression*]
# (optional) Possible values are: gzip, bz2. If not set compression will not
# be used. This option may notbe available in future versions. EXPERIMENTAL.
# (string value)
# Defaults to $::os_service_default
#
# [*amqp_durable_queues*]
# (optional) Use durable queues in AMQP.
# Defaults to $::os_service_default
#
# [*default_transport_url*]
# (Optional) A URL representing the messaging driver to use and its full
# configuration. If not set, we fall back to the rpc_backend option
# and driver specific configuration.
# Defaults to $::os_service_default
#
# [*rpc_response_timeout*]
# (Optional) Seconds to wait for a response from a call.
# Defaults to $::os_service_default
#
# [*control_exchange*]
# (Optional) The default exchange under which topics are scoped. May be
# overridden by an exchange name specified in the transport_url
# option.
# Defaults to $::os_service_default
#
# [*amqp_password*]
# (Optional) Password for message broker authentication.
# Defaults to $::os_service_default
#
# [*amqp_username*]
# (Optional) User name for message broker authentication.
# Defaults to $::os_service_default
#
# [*amqp_ssl_ca_file*]
# (Optional) CA certificate PEM file to verify server certificate.
# Defaults to $::os_service_default
#
# [*amqp_ssl_key_file*]
# (Optional) Private key PEM file used to sign cert_file certificate.
# Defaults to $::os_service_default
#
# [*amqp_container_name*]
# (Optional) Name for the AMQP container.
# Defaults to $::os_service_default
#
# [*amqp_sasl_mechanisms*]
# (Optional) Space separated list of acceptable SASL mechanisms.
# Defaults to $::os_service_default
#
# [*amqp_server_request_prefix*]
# (Optional) Address prefix used when sending to a specific server.
# Defaults to $::os_service_default
#
# [*amqp_ssl_key_password*]
# (Optional) Password for decrypting ssl_key_file (if encrypted).
# Defaults to $::os_service_default
#
# [*amqp_idle_timeout*]
# (Optional) Timeout for inactive connections (in seconds).
# Defaults to $::os_service_default
#
# [*amqp_ssl_cert_file*]
# (Optional) Identifying certificate PEM file to present to clients.
# Defaults to $::os_service_default
#
# [*amqp_broadcast_prefix*]
# (Optional) Address prefix used when broadcasting to all servers.
# Defaults to $::os_service_default
#
# [*amqp_trace*]
# (Optional) Debug: dump AMQP frames to stdout.
# Defaults to $::os_service_default
#
# [*amqp_allow_insecure_clients*]
# (Optional) Accept clients using either SSL or plain TCP.
# Defaults to $::os_service_default
#
# [*amqp_sasl_config_name*]
# (Optional) Name of configuration file (without .conf suffix).
# Defaults to $::os_service_default
#
# [*amqp_sasl_config_dir*]
# (Optional) Path to directory that contains the SASL configuration.
# Defaults to $::os_service_default
#
# [*amqp_group_request_prefix*]
# (Optional) Address prefix when sending to any server in group.
# Defaults to $::os_service_default
#
# [*rpc_cast_timeout*]
# (optional) Seconds to wait before a cast expires (TTL).
# The default value of -1 specifies an infinite linger
# period. The value of 0 specifies no linger period.
# Pending messages shall be discarded immediately
# when the socket is closed. Only supported by impl_zmq.
# Defaults to $::os_service_default.
#
# [*rpc_poll_timeout*]
# (optional) The default number of seconds that poll should wait.
# Poll raises timeout exception when timeout expired.
# Defaults to $::os_service_default.
#
# [*rpc_zmq_bind_address*]
# (optional) ZeroMQ bind address.
# Should be a wildcard (*), an ethernet interface, or IP.
# The "host" option should point or resolve to this address.
# Defaults to $::os_service_default.
#
# [*rpc_zmq_bind_port_retries*]
# (optional) Number of retries to find free port number
# before fail with ZMQBindError.
# Defaults to $::os_service_default.
#
# [*rpc_zmq_concurrency*]
# (optional) Type of concurrency used.
# Either "native" or "eventlet".
# Defaults to $::os_service_default.
#
# [*rpc_zmq_contexts*]
# (optional) Number of ZeroMQ contexts.
# Defaults to $::os_service_default.
#
# [*rpc_zmq_host*]
# (optional) Name of this node.
# Must be a valid hostname, FQDN, or IP address.
# Must match "host" option, if running Nova.
# Defaults to $::os_service_default.
#
# [*rpc_zmq_ipc_dir*]
# (optional) Directory for holding IPC sockets.
# Defaults to $::os_service_default.
#
# [*rpc_zmq_matchmaker*]
# (optional) MatchMaker driver.
# Defaults to $::os_service_default.
#
# [*rpc_zmq_max_port*]
# (optional) Maximal port number for random ports range.
# Defaults to $::os_service_default.
#
# [*rpc_zmq_min_port*]
# (optional) Minimal port number for random ports range.
# Defaults to $::os_service_default.
#
# [*rpc_zmq_topic_backlog*]
# (optional) Maximum number of ingress messages to locally buffer per topic.
# Defaults to $::os_service_default.
#
# [*use_pub_sub*]
# (optional) Use PUB/SUB pattern for fanout methods.
# PUB/SUB always uses proxy.
# Defaults to $::os_service_default.
#
# [*zmq_target_expire*]
# (optional) Expiration timeout in seconds of a name service
# record about existing target ( < 0 means no timeout).
# Defaults to $::os_service_default.
#
# [*notification_transport_url*]
# (optional) A URL representing the messaging driver to use for notifications
# and its full configuration. Transport URLs take the form:
# transport://user:pass@host1:port[,hostN:portN]/virtual_host
# Defaults to $::os_service_default
#
# [*notification_driver*]
# (optional) Driver or drivers to handle sending notifications.
# Value can be a string or a list.
# Defaults to $::os_service_default
#
# [*notification_topics*]
# (optional) AMQP topic used for OpenStack notifications
# Defaults to $::os_service_default
#
# === Authors
#
# Daniel Pawlik <daniel.pawlik@corp.ovh.com>
#
class watcher (
$use_ssl = false,
$package_ensure = 'present',
$ceilometer_client_api_version = '2',
$cinder_client_api_version = '2',
$glance_client_api_version = '2',
$neutron_client_api_version = '2',
$nova_client_api_version = '2',
$rpc_backend = 'rabbit',
$ensure_package = 'present',
$rabbit_host = $::os_service_default,
$rabbit_hosts = $::os_service_default,
$rabbit_password = $::os_service_default,
$rabbit_login_method = $::os_service_default,
$rabbit_port = $::os_service_default,
$rabbit_userid = $::os_service_default,
$rabbit_virtual_host = $::os_service_default,
$rabbit_retry_interval = $::os_service_default,
$rabbit_retry_backoff = $::os_service_default,
$rabbit_interval_max = $::os_service_default,
$rabbit_max_retries = $::os_service_default,
$rabbit_use_ssl = $::os_service_default,
$rabbit_heartbeat_rate = $::os_service_default,
$rabbit_ha_queues = $::os_service_default,
$rabbit_transient_queues_ttl = $::os_service_default,
$rabbit_heartbeat_timeout_threshold = $::os_service_default,
$kombu_ssl_ca_certs = $::os_service_default,
$kombu_ssl_certfile = $::os_service_default,
$kombu_ssl_keyfile = $::os_service_default,
$kombu_ssl_version = $::os_service_default,
$kombu_reconnect_delay = $::os_service_default,
$kombu_missing_consumer_retry_timeout = $::os_service_default,
$kombu_failover_strategy = $::os_service_default,
$kombu_compression = $::os_service_default,
$amqp_durable_queues = $::os_service_default,
$default_transport_url = $::os_service_default,
$rpc_response_timeout = $::os_service_default,
$control_exchange = $::os_service_default,
# amqp
$amqp_username = $::os_service_default,
$amqp_password = $::os_service_default,
$amqp_ssl_ca_file = $::os_service_default,
$amqp_ssl_key_file = $::os_service_default,
$amqp_container_name = $::os_service_default,
$amqp_sasl_mechanisms = $::os_service_default,
$amqp_server_request_prefix = $::os_service_default,
$amqp_ssl_key_password = $::os_service_default,
$amqp_idle_timeout = $::os_service_default,
$amqp_ssl_cert_file = $::os_service_default,
$amqp_broadcast_prefix = $::os_service_default,
$amqp_trace = $::os_service_default,
$amqp_allow_insecure_clients = $::os_service_default,
$amqp_sasl_config_name = $::os_service_default,
$amqp_sasl_config_dir = $::os_service_default,
$amqp_group_request_prefix = $::os_service_default,
# zmq
$rpc_cast_timeout = $::os_service_default,
$rpc_poll_timeout = $::os_service_default,
$rpc_zmq_bind_address = $::os_service_default,
$rpc_zmq_bind_port_retries = $::os_service_default,
$rpc_zmq_concurrency = $::os_service_default,
$rpc_zmq_contexts = $::os_service_default,
$rpc_zmq_host = $::os_service_default,
$rpc_zmq_ipc_dir = $::os_service_default,
$rpc_zmq_matchmaker = $::os_service_default,
$rpc_zmq_max_port = $::os_service_default,
$rpc_zmq_min_port = $::os_service_default,
$rpc_zmq_topic_backlog = $::os_service_default,
$use_pub_sub = $::os_service_default,
$zmq_target_expire = $::os_service_default,
# messaging
$notification_transport_url = $::os_service_default,
$notification_driver = $::os_service_default,
$notification_topics = $::os_service_default,
) {
include ::openstacklib::openstackclient
include ::watcher::deps
include ::watcher::params
include ::watcher::db
include ::watcher::logging
watcher_config {
'ceilometer_client/api_version': value => $ceilometer_client_api_version;
'cinder_client/api_version': value => $cinder_client_api_version;
'glance_client/api_version': value => $glance_client_api_version;
'neutron_client/api_version': value => $neutron_client_api_version;
'nova_client/api_version': value => $nova_client_api_version;
}
if $rpc_backend == 'rabbit' {
if ! $rabbit_password {
fail('Please specify a rabbit_password parameter.')
}
oslo::messaging::rabbit { 'watcher_config':
amqp_durable_queues => $amqp_durable_queues,
kombu_ssl_version => $kombu_ssl_version,
kombu_ssl_keyfile => $kombu_ssl_keyfile,
kombu_ssl_certfile => $kombu_ssl_certfile,
kombu_ssl_ca_certs => $kombu_ssl_ca_certs,
kombu_reconnect_delay => $kombu_reconnect_delay,
kombu_missing_consumer_retry_timeout => $kombu_missing_consumer_retry_timeout,
kombu_failover_strategy => $kombu_failover_strategy,
kombu_compression => $kombu_compression,
rabbit_host => $rabbit_host,
rabbit_port => $rabbit_port,
rabbit_hosts => $rabbit_hosts,
rabbit_use_ssl => $rabbit_use_ssl,
rabbit_userid => $rabbit_userid,
rabbit_password => $rabbit_password,
rabbit_login_method => $rabbit_login_method,
rabbit_virtual_host => $rabbit_virtual_host,
rabbit_retry_interval => $rabbit_retry_interval,
rabbit_retry_backoff => $rabbit_retry_backoff,
rabbit_interval_max => $rabbit_interval_max,
rabbit_max_retries => $rabbit_max_retries,
rabbit_ha_queues => $rabbit_ha_queues,
rabbit_transient_queues_ttl => $rabbit_transient_queues_ttl,
heartbeat_timeout_threshold => $rabbit_heartbeat_timeout_threshold,
heartbeat_rate => $rabbit_heartbeat_rate,
}
} elsif $rpc_backend == 'amqp' {
if ! $amqp_password {
fail('Please specify a amqp_password parameter.')
}
oslo::messaging::amqp { 'watcher_config':
username => $amqp_username,
password => $amqp_password,
server_request_prefix => $amqp_server_request_prefix,
broadcast_prefix => $amqp_broadcast_prefix,
group_request_prefix => $amqp_group_request_prefix,
container_name => $amqp_container_name,
idle_timeout => $amqp_idle_timeout,
trace => $amqp_trace,
ssl_ca_file => $amqp_ssl_ca_file,
ssl_cert_file => $amqp_ssl_cert_file,
ssl_key_file => $amqp_ssl_key_file,
ssl_key_password => $amqp_ssl_key_password,
allow_insecure_clients => $amqp_allow_insecure_clients,
sasl_mechanisms => $amqp_sasl_mechanisms,
sasl_config_dir => $amqp_sasl_config_dir,
sasl_config_name => $amqp_sasl_config_name,
}
} elsif $rpc_backend == 'zmq' {
oslo::messaging::zmq { 'watcher_config':
rpc_cast_timeout => $rpc_cast_timeout,
rpc_poll_timeout => $rpc_poll_timeout,
rpc_zmq_bind_address => $rpc_zmq_bind_address,
rpc_zmq_bind_port_retries => $rpc_zmq_bind_port_retries,
rpc_zmq_concurrency => $rpc_zmq_concurrency,
rpc_zmq_contexts => $rpc_zmq_contexts,
rpc_zmq_host => $rpc_zmq_host,
rpc_zmq_ipc_dir => $rpc_zmq_ipc_dir,
rpc_zmq_matchmaker => $rpc_zmq_matchmaker,
rpc_zmq_max_port => $rpc_zmq_max_port,
rpc_zmq_min_port => $rpc_zmq_min_port,
rpc_zmq_topic_backlog => $rpc_zmq_topic_backlog,
use_pub_sub => $use_pub_sub,
zmq_target_expire => $zmq_target_expire,
}
} else {
watcher_config { 'DEFAULT/rpc_backend': value => $rpc_backend }
}
oslo::messaging::default { 'watcher_config':
transport_url => $default_transport_url,
rpc_response_timeout => $rpc_response_timeout,
control_exchange => $control_exchange,
}
oslo::messaging::notifications { 'watcher_config':
transport_url => $notification_transport_url,
driver => $notification_driver,
topics => $notification_topics,
}
}

View File

@ -0,0 +1,324 @@
require 'spec_helper'
describe 'watcher' do
shared_examples 'watcher' do
context 'with default parameters' do
it 'contains the logging class' do
is_expected.to contain_class('watcher::logging')
end
it 'contains the db class' do
is_expected.to contain_class('watcher::db')
end
it 'configures rabbit' do
is_expected.to contain_watcher_config('DEFAULT/rpc_backend').with_value('rabbit')
is_expected.to contain_watcher_config('DEFAULT/transport_url').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_host').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_password').with_value('<SERVICE DEFAULT>').with_secret(true)
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_port').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_userid').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_login_method').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_virtual_host').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_retry_interval').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_retry_backoff').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_interval_max').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_max_retries').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_transient_queues_ttl').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/heartbeat_rate').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/kombu_compression').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('DEFAULT/transport_url').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('DEFAULT/rpc_response_timeout').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('DEFAULT/control_exchange').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_notifications/transport_url').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_notifications/driver').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_notifications/topics').with_value('<SERVICE DEFAULT>')
end
end
context 'with overridden parameters' do
let :params do
{
:default_transport_url => 'rabbit://rabbit_user:password@localhost:5673',
:rabbit_host => 'rabbit',
:rabbit_userid => 'rabbit_user',
:rabbit_port => '5673',
:rabbit_password => 'password',
:rabbit_ha_queues => 'undef',
:rabbit_heartbeat_timeout_threshold => '60',
:rabbit_heartbeat_rate => '10',
:kombu_compression => 'gzip',
:notification_transport_url => 'rabbit://rabbit_user:password@localhost:5673',
:notification_topics => 'notifications',
}
end
it 'configures rabbit' do
is_expected.to contain_watcher_config('DEFAULT/rpc_backend').with_value('rabbit')
is_expected.to contain_watcher_config('DEFAULT/transport_url').with_value('rabbit://rabbit_user:password@localhost:5673')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_host').with_value('rabbit')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_password').with_value('password').with_secret(true)
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_port').with_value('5673')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_userid').with_value('rabbit_user')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_virtual_host').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('60')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/heartbeat_rate').with_value('10')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_login_method').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_retry_interval').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_retry_backoff').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_interval_max').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_max_retries').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_transient_queues_ttl').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/kombu_compression').with_value('gzip')
end
it 'configures various things' do
is_expected.to contain_watcher_config('oslo_messaging_notifications/transport_url').with_value('rabbit://rabbit_user:password@localhost:5673')
is_expected.to contain_watcher_config('oslo_messaging_notifications/topics').with_value('notifications')
end
end
context 'with rabbit_hosts parameter' do
let :params do
{ :rabbit_hosts => ['rabbit:5673', 'rabbit2:5674'] }
end
it 'configures rabbit' do
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_host').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_port').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_hosts').with_value('rabbit:5673,rabbit2:5674')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value(true)
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/kombu_reconnect_delay').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/amqp_durable_queues').with_value('<SERVICE DEFAULT>')
end
end
context 'with rabbit_hosts parameter (one server)' do
let :params do
{ :rabbit_hosts => ['rabbit:5673'] }
end
it 'configures rabbit' do
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_host').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_port').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_hosts').with_value('rabbit:5673')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/kombu_reconnect_delay').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/amqp_durable_queues').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/kombu_missing_consumer_retry_timeout').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/kombu_failover_strategy').with_value('<SERVICE DEFAULT>')
end
end
context 'with kombu_reconnect_delay set to 5.0' do
let :params do
{ :kombu_reconnect_delay => '5.0' }
end
it 'configures rabbit' do
is_expected.to contain_watcher_config('oslo_messaging_rabbit/kombu_reconnect_delay').with_value('5.0')
end
end
context 'with rabbit_ha_queues set to true' do
let :params do
{ :rabbit_ha_queues => 'true' }
end
it 'configures rabbit' do
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value(true)
end
end
context 'with rabbit_ha_queues set to false and with rabbit_hosts' do
let :params do
{ :rabbit_ha_queues => 'false',
:rabbit_hosts => ['rabbit:5673'] }
end
it 'configures rabbit' do
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value(false)
end
end
context 'with amqp_durable_queues parameter' do
let :params do
{ :rabbit_hosts => ['rabbit:5673'],
:amqp_durable_queues => 'true' }
end
it 'configures rabbit' do
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_host').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_port').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_hosts').with_value('rabbit:5673')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/amqp_durable_queues').with_value(true)
end
end
context 'with rabbit ssl enabled with kombu' do
let :params do
{ :rabbit_hosts => ['rabbit:5673'],
:rabbit_use_ssl => true,
:kombu_ssl_ca_certs => '/etc/ca.cert',
:kombu_ssl_certfile => '/etc/certfile',
:kombu_ssl_keyfile => '/etc/key',
:kombu_ssl_version => 'TLSv1', }
end
it 'configures rabbit' do
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value(true)
is_expected.to contain_watcher_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_value('/etc/ca.cert')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_value('/etc/certfile')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_value('/etc/key')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/kombu_ssl_version').with_value('TLSv1')
end
end
context 'with rabbit ssl enabled without kombu' do
let :params do
{ :rabbit_hosts => ['rabbit:5673'],
:rabbit_use_ssl => true, }
end
it 'configures rabbit' do
is_expected.to contain_watcher_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value(true)
is_expected.to contain_watcher_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_rabbit/kombu_ssl_version').with_value('<SERVICE DEFAULT>')
end
end
context 'with amqp rpc_backend' do
let :params do
{ :rpc_backend => 'amqp' }
end
context 'with default parameters' do
it 'configures amqp' do
is_expected.to contain_watcher_config('DEFAULT/rpc_backend').with_value('amqp')
is_expected.to contain_watcher_config('oslo_messaging_amqp/server_request_prefix').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_amqp/broadcast_prefix').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_amqp/group_request_prefix').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_amqp/container_name').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_amqp/idle_timeout').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_amqp/trace').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_amqp/ssl_ca_file').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_amqp/ssl_cert_file').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_amqp/ssl_key_file').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_amqp/ssl_key_password').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_amqp/allow_insecure_clients').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_amqp/sasl_mechanisms').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_amqp/sasl_config_dir').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_amqp/sasl_config_name').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_amqp/username').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('oslo_messaging_amqp/password').with_value('<SERVICE DEFAULT>')
end
end
end
context 'with overriden amqp parameters' do
let :params do
{ :rpc_backend => 'amqp',
:default_transport_url => 'amqp://amqp_user:password@localhost:5672',
:amqp_idle_timeout => '60',
:amqp_trace => true,
:amqp_ssl_ca_file => '/etc/ca.cert',
:amqp_ssl_cert_file => '/etc/certfile',
:amqp_ssl_key_file => '/etc/key',
:amqp_username => 'amqp_user',
:amqp_password => 'password',
}
end
it 'configures amqp' do
is_expected.to contain_watcher_config('DEFAULT/rpc_backend').with_value('amqp')
is_expected.to contain_watcher_config('DEFAULT/transport_url').with_value('amqp://amqp_user:password@localhost:5672')
is_expected.to contain_watcher_config('oslo_messaging_amqp/idle_timeout').with_value('60')
is_expected.to contain_watcher_config('oslo_messaging_amqp/trace').with_value('true')
is_expected.to contain_watcher_config('oslo_messaging_amqp/ssl_ca_file').with_value('/etc/ca.cert')
is_expected.to contain_watcher_config('oslo_messaging_amqp/ssl_cert_file').with_value('/etc/certfile')
is_expected.to contain_watcher_config('oslo_messaging_amqp/ssl_key_file').with_value('/etc/key')
is_expected.to contain_watcher_config('oslo_messaging_amqp/username').with_value('amqp_user')
is_expected.to contain_watcher_config('oslo_messaging_amqp/password').with_value('password')
end
end
context 'with zmq rpc_backend' do
let :params do
{ :rpc_backend => 'zmq' }
end
context 'with default parameters' do
it 'configures zmq' do
is_expected.to contain_watcher_config('DEFAULT/rpc_cast_timeout').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('DEFAULT/rpc_poll_timeout').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('DEFAULT/rpc_zmq_bind_address').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('DEFAULT/rpc_zmq_bind_port_retries').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('DEFAULT/rpc_zmq_concurrency').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('DEFAULT/rpc_zmq_contexts').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('DEFAULT/rpc_zmq_host').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('DEFAULT/rpc_zmq_ipc_dir').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('DEFAULT/rpc_zmq_matchmaker').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('DEFAULT/rpc_zmq_max_port').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('DEFAULT/rpc_zmq_min_port').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('DEFAULT/rpc_zmq_topic_backlog').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('DEFAULT/use_pub_sub').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('DEFAULT/zmq_target_expire').with_value('<SERVICE DEFAULT>')
end
end
end
context 'with overriden zmq parameters' do
let :params do
{ :rpc_backend => 'zmq',
:default_transport_url => 'zmq://zmq_user:password@localhost:5555',
:rpc_zmq_min_port => '49200',
:rpc_zmq_max_port => '65000',
:rpc_zmq_bind_port_retries => '120',
:rpc_zmq_contexts => '2',
:rpc_zmq_host => 'localhost',
}
end
it 'configures zmq' do
is_expected.to contain_watcher_config('DEFAULT/transport_url').with_value('zmq://zmq_user:password@localhost:5555')
is_expected.to contain_watcher_config('DEFAULT/rpc_cast_timeout').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('DEFAULT/rpc_poll_timeout').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('DEFAULT/rpc_zmq_bind_address').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('DEFAULT/rpc_zmq_bind_port_retries').with_value('120')
is_expected.to contain_watcher_config('DEFAULT/rpc_zmq_concurrency').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('DEFAULT/rpc_zmq_contexts').with_value('2')
is_expected.to contain_watcher_config('DEFAULT/rpc_zmq_host').with_value('localhost')
is_expected.to contain_watcher_config('DEFAULT/rpc_zmq_ipc_dir').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('DEFAULT/rpc_zmq_matchmaker').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('DEFAULT/rpc_zmq_max_port').with_value('65000')
is_expected.to contain_watcher_config('DEFAULT/rpc_zmq_min_port').with_value('49200')
is_expected.to contain_watcher_config('DEFAULT/rpc_zmq_topic_backlog').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('DEFAULT/use_pub_sub').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('DEFAULT/zmq_target_expire').with_value('<SERVICE DEFAULT>')
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())
end
it_behaves_like 'watcher'
end
end
end