Rework oslo-messaging-rabbit class
Implement the same logic for rabbitmq parameters as it's already used in all puppet modules. Fix 'if' logic according to $::os_service_default. Additional changes: * add amqp_durable_queues parameter * add kombu_compression parameter - new for Mitaka https://review.openstack.org/#/c/249215 * add 'secret => true' to rabbit password * fix doc strings (make them < 80 characters) * specify types for each parameter Change-Id: Id41a07ad6a77e956493aca34fc892a51221d0aa2
This commit is contained in:
parent
484912d874
commit
14b9a2d9f6
|
@ -3,119 +3,135 @@
|
|||
# Configure oslo_messaging_rabbit options
|
||||
#
|
||||
# This resource configures Oslo messaging resources for an OpenStack service.
|
||||
# It will manage the [oslo_messaging_rabbit] section in the given config resource.
|
||||
# It manages the [oslo_messaging_rabbit] section in the given config resource.
|
||||
#
|
||||
# === Parameters:
|
||||
#
|
||||
# [*amqp_durable_queues*]
|
||||
# (optional) Define queues as "durable" to rabbitmq. (boolean value)
|
||||
# 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 undef.
|
||||
# Valid values are TLSv1 and SSLv23. SSLv2, SSLv3, TLSv1_1,
|
||||
# and TLSv1_2 may be available on some distributions. (string value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*kombu_ssl_keyfile*]
|
||||
# (Optional) SSL key file (valid only if SSL enabled)
|
||||
# Defaults to undef.
|
||||
# (Optional) SSL key file (valid only if SSL enabled). (string value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*kombu_ssl_certfile*]
|
||||
# (Optional) SSL cert file (valid only if SSL enabled)
|
||||
# Defaults to undef.
|
||||
# (Optional) SSL cert file (valid only if SSL enabled). (string value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*kombu_ssl_ca_certs*]
|
||||
# (Optional) SSL certification authority file (valid only if SSL enabled)
|
||||
# Defaults to undef.
|
||||
# (Optional) SSL certification authority file (valid only if SSL enabled).
|
||||
# (string value)
|
||||
# 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 '1'.
|
||||
# (Optional) How long to wait before reconnecting in response
|
||||
# to an AMQP consumer cancel notification. (floating point value)
|
||||
# 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 '60'.
|
||||
# (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.
|
||||
# (integer value)
|
||||
# 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.
|
||||
# Defaults to 'round-robin'.
|
||||
# (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
|
||||
#
|
||||
# [*rabbit_host*]
|
||||
# (Optional) The RabbitMQ broker address where a single node is used.
|
||||
# Defaults to 'localhost'.
|
||||
# (string value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*rabbit_port*]
|
||||
# (Optional) The RabbitMQ broker port where a single node is used.
|
||||
# Defaults to '5672'.
|
||||
# (port value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*rabbit_hosts*]
|
||||
# (Optional) RabbitMQ HA cluster host:port pairs.
|
||||
# Defaults to ['localhost:5672'].
|
||||
# (Optional) RabbitMQ HA cluster host:port pairs. (array value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*rabbit_use_ssl*]
|
||||
# (Optional) Connect over SSL for RabbitMQ.
|
||||
# Defaults to false.
|
||||
# (Optional) Connect over SSL for RabbitMQ. (boolean value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*rabbit_userid*]
|
||||
# (Optional) The RabbitMQ userid.
|
||||
# Defaults to 'guest'.
|
||||
# (Optional) The RabbitMQ userid. (string value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*rabbit_password*]
|
||||
# (Optional) The RabbitMQ password.
|
||||
# Defaults to undef.
|
||||
# (Optional) The RabbitMQ password. (string value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*rabbit_login_method*]
|
||||
# (Optional) The RabbitMQ login method.
|
||||
# Defaults to 'AMQPLAIN'.
|
||||
# (Optional) The RabbitMQ login method. (string value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*rabbit_virtual_host*]
|
||||
# (Optional) The RabbitMQ virtual host.
|
||||
# Defaults to '/'.
|
||||
# (Optional) The RabbitMQ virtual host. (string value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*rabbit_retry_interval*]
|
||||
# (Optional) How frequently to retry connecting with RabbitMQ.
|
||||
# Defaults to 1.
|
||||
# (integer value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*rabbit_retry_backoff*]
|
||||
# (Optional) How long to backoff for between retries when connecting to RabbitMQ.
|
||||
# Defaults to 2.
|
||||
# (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.
|
||||
# Defaults to 30.
|
||||
# (Optional) Maximum interval of RabbitMQ connection retries. (integer value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*rabbit_max_retries*]
|
||||
# (Optional) Maximum number of RabbitMQ connection retries.
|
||||
# Defaults to 0.
|
||||
# (Optional) Maximum number of RabbitMQ connection retries. (integer value)
|
||||
# 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 false.
|
||||
# (Optional) Use HA queues in RabbitMQ (x-ha-policy: all). If you change this
|
||||
# option, you must wipe the RabbitMQ database. (boolean value)
|
||||
# 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.
|
||||
# The parameter affects only reply and fanout queues. (integer value)
|
||||
# Min to 1
|
||||
# Defaults to 600.
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*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")
|
||||
# Defaults to 60.
|
||||
# (0 disable the heartbeat). EXPERIMENTAL. (integer value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*heartbeat_rate*]
|
||||
# (Optional) How often times during the heartbeat_timeout_threshold
|
||||
# we check the heartbeat.
|
||||
# Defaults to 2.
|
||||
# we check the heartbeat. (integer value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# DEPRECATED:
|
||||
# [*fake_rabbit*]
|
||||
|
||||
define oslo::messaging_rabbit(
|
||||
$amqp_durable_queues = $::os_service_default,
|
||||
$kombu_ssl_version = $::os_service_default,
|
||||
$kombu_ssl_keyfile = $::os_service_default,
|
||||
$kombu_ssl_certfile = $::os_service_default,
|
||||
|
@ -123,6 +139,7 @@ define oslo::messaging_rabbit(
|
|||
$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,
|
||||
$rabbit_host = $::os_service_default,
|
||||
$rabbit_port = $::os_service_default,
|
||||
$rabbit_hosts = $::os_service_default,
|
||||
|
@ -139,35 +156,75 @@ define oslo::messaging_rabbit(
|
|||
$rabbit_transient_queues_ttl = $::os_service_default,
|
||||
$heartbeat_timeout_threshold = $::os_service_default,
|
||||
$heartbeat_rate = $::os_service_default,
|
||||
$fake_rabbit = $::os_service_default,
|
||||
){
|
||||
|
||||
if ! is_service_default($fake_rabbit) {
|
||||
warning('fake_rabbit is deprecated, please use use rpc_backend=kombu+memory or rpc_backend=fake')
|
||||
if $rabbit_use_ssl != true {
|
||||
if ! is_service_default($kombu_ssl_ca_certs) and ($kombu_ssl_ca_certs) {
|
||||
fail('The kombu_ssl_ca_certs parameter requires rabbit_use_ssl to be set to true')
|
||||
}
|
||||
if ! is_service_default($kombu_ssl_certfile) and ($kombu_ssl_certfile) {
|
||||
fail('The kombu_ssl_certfile parameter requires rabbit_use_ssl to be set to true')
|
||||
}
|
||||
if ! is_service_default($kombu_ssl_keyfile) and ($kombu_ssl_keyfile) {
|
||||
fail('The kombu_ssl_keyfile parameter requires rabbit_use_ssl to be set to true')
|
||||
}
|
||||
if !is_service_default($kombu_ssl_version) and ($kombu_ssl_version) {
|
||||
fail('The kombu_ssl_version parameter requires rabbit_use_ssl to be set to true')
|
||||
}
|
||||
}
|
||||
|
||||
create_resources($name, {'oslo_messaging_rabbit/kombu_ssl_version' => { value => $kombu_ssl_version }})
|
||||
create_resources($name, {'oslo_messaging_rabbit/kombu_ssl_keyfile' => { value => $kombu_ssl_keyfile }})
|
||||
create_resources($name, {'oslo_messaging_rabbit/kombu_ssl_certfile' => { value => $kombu_ssl_certfile }})
|
||||
create_resources($name, {'oslo_messaging_rabbit/kombu_ssl_ca_certs' => { value => $kombu_ssl_ca_certs }})
|
||||
create_resources($name, {'oslo_messaging_rabbit/kombu_reconnect_delay' => { value => $kombu_reconnect_delay }})
|
||||
create_resources($name, {'oslo_messaging_rabbit/kombu_missing_consumer_retry_timeout' => { value => $kombu_missing_consumer_retry_timeout }})
|
||||
create_resources($name, {'oslo_messaging_rabbit/kombu_failover_strategy' => { value => $kombu_failover_strategy }})
|
||||
create_resources($name, {'oslo_messaging_rabbit/rabbit_host' => { value => $rabbit_host }})
|
||||
create_resources($name, {'oslo_messaging_rabbit/rabbit_port' => { value => $rabbit_port }})
|
||||
create_resources($name, {'oslo_messaging_rabbit/rabbit_hosts' => { value => $rabbit_hosts }})
|
||||
create_resources($name, {'oslo_messaging_rabbit/rabbit_use_ssl' => { value => $rabbit_use_ssl }})
|
||||
create_resources($name, {'oslo_messaging_rabbit/rabbit_userid' => { value => $rabbit_userid }})
|
||||
create_resources($name, {'oslo_messaging_rabbit/rabbit_password' => { value => $rabbit_password }})
|
||||
create_resources($name, {'oslo_messaging_rabbit/rabbit_login_method' => { value => $rabbit_login_method }})
|
||||
create_resources($name, {'oslo_messaging_rabbit/rabbit_virtual_host' => { value => $rabbit_virtual_host }})
|
||||
create_resources($name, {'oslo_messaging_rabbit/rabbit_retry_interval' => { value => $rabbit_retry_interval }})
|
||||
create_resources($name, {'oslo_messaging_rabbit/rabbit_retry_backoff' => { value => $rabbit_retry_backoff }})
|
||||
create_resources($name, {'oslo_messaging_rabbit/rabbit_interval_max' => { value => $rabbit_interval_max }})
|
||||
create_resources($name, {'oslo_messaging_rabbit/rabbit_max_retries' => { value => $rabbit_max_retries }})
|
||||
create_resources($name, {'oslo_messaging_rabbit/rabbit_ha_queues' => { value => $rabbit_ha_queues }})
|
||||
create_resources($name, {'oslo_messaging_rabbit/rabbit_transient_queues_ttl' => { value => $rabbit_transient_queues_ttl }})
|
||||
create_resources($name, {'oslo_messaging_rabbit/heartbeat_timeout_threshold' => { value => $heartbeat_timeout_threshold }})
|
||||
create_resources($name, {'oslo_messaging_rabbit/heartbeat_rate' => { value => $heartbeat_rate }})
|
||||
create_resources($name, {'oslo_messaging_rabbit/fake_rabbit' => { value => $fake_rabbit }})
|
||||
if !is_service_default($kombu_compression) and !($kombu_compression in ['gzip','bz2']) {
|
||||
fail('Unsupported Kombu compression. Possible values are gzip and bz2')
|
||||
}
|
||||
|
||||
if !is_service_default($rabbit_hosts) and !is_array($rabbit_hosts) {
|
||||
fail('Rabbit hosts should be an array')
|
||||
}
|
||||
|
||||
if !is_service_default($rabbit_hosts) {
|
||||
$rabbit_hosts_orig = join($rabbit_hosts, ',')
|
||||
if size($rabbit_hosts) > 1 and is_service_default($rabbit_ha_queues) {
|
||||
$rabbit_ha_queues_orig = true
|
||||
} else {
|
||||
$rabbit_ha_queues_orig = $rabbit_ha_queues
|
||||
}
|
||||
# Do not set rabbit_port and rabbit_host
|
||||
$rabbit_port_orig = $::os_service_default
|
||||
$rabbit_host_orig = $::os_service_default
|
||||
} else {
|
||||
$rabbit_hosts_orig = "${rabbit_host}:${rabbit_port}"
|
||||
$rabbit_port_orig = $rabbit_port
|
||||
$rabbit_host_orig = $rabbit_host
|
||||
$rabbit_ha_queues_orig = $rabbit_ha_queues
|
||||
}
|
||||
|
||||
$rabbit_options = { 'oslo_messaging_rabbit/amqp_durable_queues' => { value => $amqp_durable_queues },
|
||||
'oslo_messaging_rabbit/heartbeat_rate' => { value => $heartbeat_rate },
|
||||
'oslo_messaging_rabbit/heartbeat_timeout_threshold' => { value => $heartbeat_timeout_threshold },
|
||||
'oslo_messaging_rabbit/kombu_compression' => { value => $kombu_compression },
|
||||
'oslo_messaging_rabbit/kombu_failover_strategy' => { value => $kombu_failover_strategy },
|
||||
'oslo_messaging_rabbit/kombu_missing_consumer_retry_timeout' => { value => $kombu_missing_consumer_retry_timeout },
|
||||
'oslo_messaging_rabbit/kombu_reconnect_delay' => { value => $kombu_reconnect_delay },
|
||||
'oslo_messaging_rabbit/rabbit_interval_max' => { value => $rabbit_interval_max },
|
||||
'oslo_messaging_rabbit/rabbit_login_method' => { value => $rabbit_login_method },
|
||||
'oslo_messaging_rabbit/rabbit_max_retries' => { value => $rabbit_max_retries },
|
||||
'oslo_messaging_rabbit/rabbit_password' => { value => $rabbit_password, secret => true },
|
||||
'oslo_messaging_rabbit/rabbit_retry_backoff' => { value => $rabbit_retry_backoff },
|
||||
'oslo_messaging_rabbit/rabbit_retry_interval' => { value => $rabbit_retry_interval },
|
||||
'oslo_messaging_rabbit/rabbit_transient_queues_ttl' => { value => $rabbit_transient_queues_ttl },
|
||||
'oslo_messaging_rabbit/rabbit_use_ssl' => { value => $rabbit_use_ssl },
|
||||
'oslo_messaging_rabbit/rabbit_userid' => { value => $rabbit_userid },
|
||||
'oslo_messaging_rabbit/rabbit_virtual_host' => { value => $rabbit_virtual_host },
|
||||
'oslo_messaging_rabbit/rabbit_hosts' => { value => $rabbit_hosts_orig },
|
||||
'oslo_messaging_rabbit/rabbit_port' => { value => $rabbit_port_orig },
|
||||
'oslo_messaging_rabbit/rabbit_host' => { value => $rabbit_host_orig },
|
||||
'oslo_messaging_rabbit/rabbit_ha_queues' => { value => $rabbit_ha_queues_orig },
|
||||
'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_ssl_version' => { value => $kombu_ssl_version },
|
||||
'DEFAULT/rpc_backend' => { value => 'rabbit' },
|
||||
}
|
||||
|
||||
create_resources($name, $rabbit_options)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,187 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'oslo::messaging_rabbit' do
|
||||
|
||||
let (:title) { 'keystone_config' }
|
||||
|
||||
shared_examples 'shared examples' do
|
||||
|
||||
context 'with default parameters' do
|
||||
it 'configure oslo_messaging_rabbit default params' do
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/amqp_durable_queues').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/kombu_reconnect_delay').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/kombu_missing_consumer_retry_timeout').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/kombu_failover_strategy').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/kombu_compression').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_host').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_port').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_userid').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_password').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_login_method').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_virtual_host').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_retry_interval').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_retry_backoff').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_interval_max').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_max_retries').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_transient_queues_ttl').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/heartbeat_rate').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('DEFAULT/rpc_backend').with_value('rabbit')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with overridden parameters' do
|
||||
let :params do
|
||||
{ :rabbit_host => 'rabbit',
|
||||
:rabbit_userid => 'rabbit_user',
|
||||
:rabbit_port => '5673',
|
||||
:rabbit_password => 'password',
|
||||
:heartbeat_timeout_threshold => '60',
|
||||
:heartbeat_rate => '10',
|
||||
:rabbit_virtual_host => '/',
|
||||
:kombu_compression => 'bz2', }
|
||||
end
|
||||
|
||||
it 'configures rabbit' do
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_host').with_value('rabbit')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_password').with_value('password').with_secret(true)
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_port').with_value('5673')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_userid').with_value('rabbit_user')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_virtual_host').with_value('/')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('60')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/heartbeat_rate').with_value('10')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/kombu_compression').with_value('bz2')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with rabbit_hosts parameter (one server)' do
|
||||
let :params do
|
||||
{ :rabbit_hosts => ['rabbit:5672'] }
|
||||
end
|
||||
|
||||
it 'configures rabbit' do
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_host').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_port').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_hosts').with_value('rabbit:5672')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value('<SERVICE DEFAULT>')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with rabbit_hosts parameter' do
|
||||
let :params do
|
||||
{ :rabbit_hosts => ['rabbit1:5672', 'rabbit2:5673'] }
|
||||
end
|
||||
|
||||
it 'configures rabbit' do
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_host').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_port').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_hosts').with_value('rabbit1:5672,rabbit2:5673')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value(true)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with rabbit_hosts parameter and disabled rabbit_ha_queues' do
|
||||
let :params do
|
||||
{ :rabbit_hosts => ['rabbit1:5672', 'rabbit2:5673'],
|
||||
:rabbit_ha_queues => false, }
|
||||
end
|
||||
|
||||
it 'configures rabbit' do
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_host').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_port').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_hosts').with_value('rabbit1:5672,rabbit2:5673')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value(false)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with rabbit ssl enabled with kombu' do
|
||||
let :params do
|
||||
{ :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_keystone_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value(true)
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_value('/etc/ca.cert')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_value('/etc/certfile')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_value('/etc/key')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/kombu_ssl_version').with_value('TLSv1')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with rabbit ssl enabled without kombu' do
|
||||
let :params do
|
||||
{ :rabbit_use_ssl => true }
|
||||
end
|
||||
|
||||
it 'configures rabbit' do
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value(true)
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('oslo_messaging_rabbit/kombu_ssl_version').with_value('<SERVICE DEFAULT>')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with incorrect rabbit hosts' do
|
||||
let :params do
|
||||
{ :rabbit_hosts => 'rabbit1:5672,rabbit2:5673' }
|
||||
end
|
||||
|
||||
it { is_expected.to raise_error Puppet::Error, /Rabbit hosts should be an array/ }
|
||||
end
|
||||
|
||||
context 'with incorrect kombu compression' do
|
||||
let :params do
|
||||
{ :kombu_compression => 'foo' }
|
||||
end
|
||||
|
||||
it { is_expected.to raise_error Puppet::Error, /Unsupported Kombu compression. Possible values are gzip and bz2/ }
|
||||
end
|
||||
|
||||
context 'with kombu_ssl_ca_certs enabled without ssl usage' do
|
||||
let :params do
|
||||
{ :kombu_ssl_ca_certs => '/etc/ca.cert' }
|
||||
end
|
||||
|
||||
it { is_expected.to raise_error Puppet::Error, /The kombu_ssl_ca_certs parameter requires rabbit_use_ssl to be set to true/ }
|
||||
end
|
||||
|
||||
context 'with kombu_ssl_certfile set without rabbit ssl usage' do
|
||||
let :params do
|
||||
{ :kombu_ssl_certfile => '/tmp/foo' }
|
||||
end
|
||||
|
||||
it { is_expected.to raise_error Puppet::Error, /The kombu_ssl_certfile parameter requires rabbit_use_ssl to be set to true/ }
|
||||
end
|
||||
|
||||
context 'with kombu_ssl_version set without rabbit ssl usage' do
|
||||
let :params do
|
||||
{ :kombu_ssl_version => 'foo' }
|
||||
end
|
||||
|
||||
it { is_expected.to raise_error Puppet::Error, /The kombu_ssl_version parameter requires rabbit_use_ssl to be set to true/ }
|
||||
end
|
||||
end
|
||||
|
||||
context 'on a Debian osfamily' do
|
||||
let :facts do
|
||||
@default_facts.merge({ :osfamily => "Debian" })
|
||||
end
|
||||
|
||||
include_examples 'shared examples'
|
||||
end
|
||||
|
||||
context 'on a RedHat osfamily' do
|
||||
let :facts do
|
||||
@default_facts.merge({ :osfamily => 'RedHat' })
|
||||
end
|
||||
|
||||
include_examples 'shared examples'
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue