diff --git a/manifests/messaging/redis.pp b/manifests/messaging/redis.pp new file mode 100644 index 0000000..25fa080 --- /dev/null +++ b/manifests/messaging/redis.pp @@ -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; + } + +} diff --git a/releasenotes/notes/redis_support-8a25b7ec5975e501.yaml b/releasenotes/notes/redis_support-8a25b7ec5975e501.yaml new file mode 100644 index 0000000..a23bbc6 --- /dev/null +++ b/releasenotes/notes/redis_support-8a25b7ec5975e501.yaml @@ -0,0 +1,3 @@ +--- +features: + - Support using Redis as message store. diff --git a/spec/classes/zaqar_messaging_redis_spec.rb b/spec/classes/zaqar_messaging_redis_spec.rb new file mode 100644 index 0000000..3de7465 --- /dev/null +++ b/spec/classes/zaqar_messaging_redis_spec.rb @@ -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 +