Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(GH-685) redis_reconnect_on_error now defaults to true #707

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/puppet/type/sensu_redis_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ def insync?(is)

newproperty(:reconnect_on_error, :parent => PuppetX::Sensu::BooleanProperty) do
desc "Attempt to reconnect to RabbitMQ on error"

defaultto :false
defaultto :true
end

newproperty(:db) do
Expand Down
6 changes: 3 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@
#
# [*redis_reconnect_on_error*]
# Boolean. In the event the connection or channel is closed by Reddis, attempt to automatically
# reconnect when possible. Default set to fault its not guaranteed to successfully reconnect.
# Default: false
# reconnect when possible.
# Default: true
# Valid values: true, false
#
# [*redis_db*]
Expand Down Expand Up @@ -420,7 +420,7 @@
$redis_host = '127.0.0.1',
$redis_port = 6379,
$redis_password = undef,
$redis_reconnect_on_error = false,
$redis_reconnect_on_error = true,
$redis_db = 0,
$redis_auto_reconnect = true,
$redis_sentinels = undef,
Expand Down
59 changes: 40 additions & 19 deletions spec/classes/sensu_redis_spec.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,50 @@
require 'spec_helper'

describe 'sensu' do
describe 'sensu', :type => :class do
let(:facts) { { :fqdn => 'testhost.domain.com', :osfamily => 'RedHat' } }
let(:pre_condition) { 'Package{ provider => "yum"}' }

context 'redis config' do

context 'default settings' do

it { should contain_file('/etc/sensu/conf.d/redis.json').with(
:ensure => 'present',
:owner => 'sensu',
:group => 'sensu',
:mode => '0440',
:before => 'Sensu_redis_config[testhost.domain.com]',
)}

it { should contain_sensu_redis_config('testhost.domain.com').with(
:host => '127.0.0.1',
:port => 6379,
:db => 0,
:auto_reconnect => true
:ensure => 'present',
:base_path => '/etc/sensu/conf.d',
:host => '127.0.0.1',
:port => 6379,
:reconnect_on_error => true,
:db => 0,
:auto_reconnect => true,
:sentinels => nil,
:master => nil,
)}
end # default settings

[true,false].each do |value|
context "with reconnect_on_error specified as #{value}" do
let(:params) { { :redis_reconnect_on_error => value } }

it { should contain_sensu_redis_config('testhost.domain.com').with(
:reconnect_on_error => value,
)}
end
end

context 'be configurable without sentinels' do
let(:params) { {
:redis_host => 'redis.domain.com',
:redis_port => 1234,
:redis_password => 'password',
:redis_db => 1,
:redis_auto_reconnect => false
:redis_auto_reconnect => false,
} }

it { should contain_sensu_redis_config('testhost.domain.com').with(
Expand All @@ -31,7 +54,7 @@
:db => 1,
:auto_reconnect => false,
:sentinels => nil,
:master => nil
:master => nil,
)}
end # be configurable without sentinels

Expand All @@ -42,12 +65,12 @@
:redis_auto_reconnect => false,
:redis_sentinels => [{
'host' => 'redis1.domain.com',
'port' => 1234
'port' => 1234,
}, {
'host' => 'redis2.domain.com',
'port' => '5678'
'port' => '5678',
}],
:redis_master => 'master-name'
:redis_master => 'master-name',
} }

it { should contain_sensu_redis_config('testhost.domain.com').with(
Expand All @@ -58,12 +81,12 @@
:auto_reconnect => false,
:sentinels => [{
'host' => 'redis1.domain.com',
'port' => 1234
'port' => 1234,
}, {
'host' => 'redis2.domain.com',
'port' => 5678
'port' => 5678,
}],
:master => "master-name"
:master => "master-name",
)}
end # be configurable with sentinels

Expand All @@ -74,7 +97,7 @@
:ensure => 'present',
:owner => 'sensu',
:group => 'sensu',
:mode => '0440'
:mode => '0440',
).that_comes_before("Sensu_redis_config[#{facts[:fqdn]}]")
end
end # with server
Expand All @@ -86,7 +109,7 @@
:ensure => 'present',
:owner => 'sensu',
:group => 'sensu',
:mode => '0440'
:mode => '0440',
).that_comes_before("Sensu_redis_config[#{facts[:fqdn]}]")
end
end # with api
Expand All @@ -98,12 +121,10 @@
:api => false,
:client => false,
:enterprise => false,
:transport_type => 'rabbitmq'
:transport_type => 'rabbitmq',
} }

it { should contain_file('/etc/sensu/conf.d/redis.json').with_ensure('absent') }
end # purge configs

end #redis config

end
4 changes: 2 additions & 2 deletions spec/unit/sensu_redis_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def create_type_instance(resource_hash)
end

describe 'reconnect_on_error property' do
it 'defaults to false' do
expect(type_instance[:reconnect_on_error]).to be :false
it 'defaults to true' do
expect(type_instance[:reconnect_on_error]).to be :true
end

[true, :true, 'true', 'True', :yes, 'yes'].each do |v|
Expand Down