Skip to content

Commit 39f4210

Browse files
authored
Merge pull request DataDog#527 from DataDog/albertvaka/integer-slowlog_max_len
Fix trying to call .empty? on an integer
2 parents e8cadef + af84cce commit 39f4210

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

spec/classes/datadog_agent_integrations_redis_spec.rb

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
host: 'redis1',
4949
password: 'hunter2',
5050
port: 867,
51-
slowlog_max_len: '5309',
51+
slowlog_max_len: 5309,
5252
tags: %w{foo bar},
5353
keys: %w{baz bat},
5454
warn_on_missing_keys: false,
@@ -69,7 +69,7 @@
6969
host: 'redis1',
7070
password: 'hunter2',
7171
ports: %w(2379 2380 2381),
72-
slowlog_max_len: '5309',
72+
slowlog_max_len: 5309,
7373
tags: %w{foo bar},
7474
keys: %w{baz bat},
7575
warn_on_missing_keys: false,
@@ -87,6 +87,27 @@
8787
it { should contain_file(conf_file).with_content(%r{port: 2381}) }
8888
end
8989

90+
context 'with strings instead of ints' do
91+
let(:params) {{
92+
host: 'redis1',
93+
password: 'hunter2',
94+
port: '867',
95+
slowlog_max_len: '5309',
96+
tags: %w{foo bar},
97+
keys: %w{baz bat},
98+
warn_on_missing_keys: false,
99+
command_stats: true,
100+
}}
101+
it { should contain_file(conf_file).with_content(%r{host: redis1}) }
102+
it { should contain_file(conf_file).with_content(%r{^[^#]*password: hunter2}) }
103+
it { should contain_file(conf_file).with_content(%r{port: 867}) }
104+
it { should contain_file(conf_file).with_content(%r{^[^#]*slowlog-max-len: 5309}) }
105+
it { should contain_file(conf_file).with_content(%r{tags:.*\s+- foo\s+- bar}) }
106+
it { should contain_file(conf_file).with_content(%r{keys:.*\s+- baz\s+- bat}) }
107+
it { should contain_file(conf_file).with_content(%r{warn_on_missing_keys: false}) }
108+
it { should contain_file(conf_file).with_content(%r{command_stats: true}) }
109+
end
110+
90111
context 'with instances set' do
91112
let(:params) {{
92113
instances: [

templates/agent-conf.d/redisdb.yaml.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ instances:
99
<% if instance['password'] and ! instance['password'].empty? -%>
1010
password: <%= instance['password'] %>
1111
<% end -%>
12-
<% if instance['slowlog_max_len'] and ! instance['slowlog_max_len'].empty? -%>
12+
<% if instance['slowlog_max_len'] and ! instance['slowlog_max_len'].to_s.empty? -%>
1313
# unix_socket_path: /var/run/redis/redis.sock # optional, can be used in lieu of host/port
1414
slowlog-max-len: <%= instance['slowlog_max_len'] %>
1515
<% end -%>

0 commit comments

Comments
 (0)