-
Notifications
You must be signed in to change notification settings - Fork 262
/
redis_spec.rb
83 lines (74 loc) · 2.24 KB
/
redis_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Copyright:: 2011-Present, Datadog
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
describe 'datadog::redisdb' do
expected_yaml = <<-EOF
logs: ~
init_config:
instances:
- host: localhost
port: 6379
db: 0
password: somepass
socket_timeout: 5
tags:
- optional_tag1
- optional_tag2
keys:
- key1
- key2
warn_on_missing_keys: False
slowlog-max-len: 128
command_stats: True
EOF
cached(:chef_run) do
ChefSpec::SoloRunner.new(
platform: 'ubuntu',
version: '16.04',
step_into: ['datadog_monitor']
) do |node|
node.automatic['languages'] = { python: { version: '2.7.2' } }
node.normal['datadog'] = {
api_key: 'someapikey',
redisdb: {
instances: [
{
command_stats: true,
db: 0,
keys: ['key1', 'key2'],
port: 6379,
password: 'somepass',
server: 'localhost',
'slowlog-max-len' => 128,
socket_timeout: 5,
tags: [
'optional_tag1',
'optional_tag2'
],
warn_on_missing_keys: false
}
]
}
}
end.converge(described_recipe)
end
subject { chef_run }
it_behaves_like 'datadog-agent'
it { is_expected.to include_recipe('datadog::dd-agent') }
it { is_expected.to add_datadog_monitor('redisdb') }
it 'renders expected YAML config file' do
expect(chef_run).to(render_file('/etc/datadog-agent/conf.d/redisdb.d/conf.yaml').with_content { |content|
expect(YAML.safe_load(content).to_json).to be_json_eql(YAML.safe_load(expected_yaml).to_json)
})
end
end