Skip to content

Commit

Permalink
Merge pull request #527 from DataDog/albertvaka/integer-slowlog_max_len
Browse files Browse the repository at this point in the history
Fix trying to call .empty? on an integer
  • Loading branch information
albertvaka authored May 28, 2019
2 parents 2f03da3 + 37a4344 commit 4f0369e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
25 changes: 23 additions & 2 deletions spec/classes/datadog_agent_integrations_redis_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
host: 'redis1',
password: 'hunter2',
port: 867,
slowlog_max_len: '5309',
slowlog_max_len: 5309,
tags: %w{foo bar},
keys: %w{baz bat},
warn_on_missing_keys: false,
Expand All @@ -69,7 +69,7 @@
host: 'redis1',
password: 'hunter2',
ports: %w(2379 2380 2381),
slowlog_max_len: '5309',
slowlog_max_len: 5309,
tags: %w{foo bar},
keys: %w{baz bat},
warn_on_missing_keys: false,
Expand All @@ -87,6 +87,27 @@
it { should contain_file(conf_file).with_content(%r{port: 2381}) }
end

context 'with strings instead of ints' do
let(:params) {{
host: 'redis1',
password: 'hunter2',
port: '867',
slowlog_max_len: '5309',
tags: %w{foo bar},
keys: %w{baz bat},
warn_on_missing_keys: false,
command_stats: true,
}}
it { should contain_file(conf_file).with_content(%r{host: redis1}) }
it { should contain_file(conf_file).with_content(%r{^[^#]*password: hunter2}) }
it { should contain_file(conf_file).with_content(%r{port: 867}) }
it { should contain_file(conf_file).with_content(%r{^[^#]*slowlog-max-len: 5309}) }
it { should contain_file(conf_file).with_content(%r{tags:.*\s+- foo\s+- bar}) }
it { should contain_file(conf_file).with_content(%r{keys:.*\s+- baz\s+- bat}) }
it { should contain_file(conf_file).with_content(%r{warn_on_missing_keys: false}) }
it { should contain_file(conf_file).with_content(%r{command_stats: true}) }
end

context 'with instances set' do
let(:params) {{
instances: [
Expand Down
2 changes: 1 addition & 1 deletion templates/agent-conf.d/redisdb.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ instances:
<% if instance['password'] and ! instance['password'].empty? -%>
password: <%= instance['password'] %>
<% end -%>
<% if instance['slowlog_max_len'] and ! instance['slowlog_max_len'].empty? -%>
<% if instance['slowlog_max_len'] and ! instance['slowlog_max_len'].to_s.empty? -%>
# unix_socket_path: /var/run/redis/redis.sock # optional, can be used in lieu of host/port
slowlog-max-len: <%= instance['slowlog_max_len'] %>
<% end -%>
Expand Down

0 comments on commit 4f0369e

Please sign in to comment.