Add support for redis message store

This adds new class to setup redis as the messaging backend.

Change-Id: I0ef259f2dfcc661a30b5a55c23eac3eb1240f462
This commit is contained in:
Thomas Herve 2017-08-29 14:13:35 +02:00
parent 53eba0e5f8
commit a868904ac0
3 changed files with 98 additions and 0 deletions

View File

@ -0,0 +1,31 @@
# == class: zaqar::messaging::redis
#
# [*uri*]
# Redis Connection URI. Required.
#
# [*max_reconnect_attempts*]
# Maximum number of times to retry an operation that failed due to a
# primary node failover. (integer value)
# Defaults to $::os_service_default.
#
# [*reconnect_sleep*]
# Base sleep interval between attempts to reconnect after a primary
# node failover. The actual sleep time increases exponentially (power
# of 2) each time the operation is retried. (floating point value)
# Defaults to $::os_service_default.
#
class zaqar::messaging::redis(
$uri,
$max_reconnect_attempts = $::os_service_default,
$reconnect_sleep = $::os_service_default,
) {
include ::zaqar::deps
zaqar_config {
'drivers:message_store:redis/uri': value => $uri, secret => true;
'drivers:message_store:redis/max_reconnect_attempts': value => $max_reconnect_attempts;
'drivers:message_store:redis/reconnect_sleep': value => $reconnect_sleep;
}
}

View File

@ -0,0 +1,3 @@
---
features:
- Support using Redis as message store.

View File

@ -0,0 +1,64 @@
require 'spec_helper'
describe 'zaqar::messaging::redis' do
shared_examples_for 'zaqar::messaging::redis' do
let :pre_condition do
"class { '::zaqar::keystone::authtoken':
password =>'foo',
}
class { '::zaqar':
message_store =>'redis',
}"
end
let :req_params do
{
:uri => 'redis://127.0.0.1:6379',
}
end
describe 'with only required params' do
let :params do
req_params
end
it 'should config redis messaging driver' do
is_expected.to contain_zaqar_config('drivers/message_store').with(
:value => 'redis'
)
is_expected.to contain_zaqar_config('drivers:message_store:redis/uri').with(
:value => 'redis://127.0.0.1:6379'
)
end
end
describe 'with custom values' do
let :params do
req_params.merge!({
:max_reconnect_attempts => '4',
:reconnect_sleep => '5',
})
end
it 'configures custom values' do
is_expected.to contain_zaqar_config('drivers:message_store:redis/max_reconnect_attempts').with_value('4')
is_expected.to contain_zaqar_config('drivers:message_store:redis/reconnect_sleep').with_value('5')
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_configures 'zaqar::messaging::redis'
end
end
end