-
Notifications
You must be signed in to change notification settings - Fork 259
Expand file tree
/
Copy pathdatadog_agent_integrations_kafka_spec.rb
More file actions
131 lines (117 loc) · 3.78 KB
/
datadog_agent_integrations_kafka_spec.rb
File metadata and controls
131 lines (117 loc) · 3.78 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
require 'spec_helper'
describe 'datadog_agent::integrations::kafka' do
let(:facts) {{
operatingsystem: 'Ubuntu',
}}
let(:conf_dir) { '/etc/dd-agent/conf.d' }
let(:dd_user) { 'dd-agent' }
let(:dd_group) { 'root' }
let(:dd_package) { 'datadog-agent' }
let(:dd_service) { 'datadog-agent' }
let(:conf_file) { "#{conf_dir}/kafka.yaml" }
it { should compile.with_all_deps }
it { should contain_file(conf_file).with(
owner: dd_user,
group: dd_group,
mode: '0600',
)}
it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") }
it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") }
context 'with default parameters' do
it { should contain_file(conf_file).with_content(%r{- host: localhost\s+port: 9999}) }
it { should contain_file(conf_file).without_content(%r{tags:}) }
end
context 'with one kafka broker' do
let(:params) {{
servers: [
{
'host' => 'localhost',
'port' => '9997',
'tags' => %w{ kafka:broker tag1:value1 },
}
]
}}
it { should contain_file(conf_file).with_content(%r{host: localhost\s+port: 9997\s+tags:\s+- kafka:broker\s+- tag1:value1}) }
end
context 'with two kafka brokers' do
let(:params) {{
servers: [
{
'host' => 'localhost',
'port' => '9997',
'tags' => %w{ kafka:broker tag1:value1 },
},
{
'host' => 'remotehost',
'port' => '9998',
'tags' => %w{ kafka:remote tag2:value2 },
}
]
}}
it { should contain_file(conf_file).with_content(%r{host: localhost\s+port: 9997\s+tags:\s+- kafka:broker\s+- tag1:value1}) }
it { should contain_file(conf_file).with_content(%r{host: remotehost\s+port: 9998\s+tags:\s+- kafka:remote\s+- tag2:value2}) }
end
context 'one kafka broker all options' do
let(:params) {{
servers: [
{
'host' => 'localhost',
'port' => '9997',
'tags' => %w{ kafka:broker tag1:value1 },
'username' => 'username',
'password' => 'password',
'process_name_regex' => 'regex',
'tools_jar_path' => 'tools.jar',
'name' => 'kafka_instance',
'java_bin_path' => '/path/to/java',
'trust_store_path' => '/path/to/trustStore.jks',
'trust_store_password' => 'password'
}
]
}}
it { should contain_file(conf_file).with_content(%r{host: localhost\s+port: 9997\s+tags:\s+- kafka:broker\s+- tag1:value1\s+user: username\s+password: password\s+process_name_regex: regex\s+tools_jar_path: tools.jar\s+name: kafka_instance\s+java_bin_path: /path/to/java\s+trust_store_path: /path/to/trustStore.jks\s+trust_store_password: password}) }
end
=begin
context 'with multiple mongos' do
let(:params) {{
servers: [
{
'host' => '127.0.0.1',
'port' => '34567',
'tags' => %w{foo bar},
},
{
'host' => '127.0.0.2',
'port' => '45678',
'tags' => %w{baz bat},
}
]
}}
it { should contain_file(conf_file).with_content(%r{server: mongodb://127.0.0.1:34567/\s+tags:\s+- foo\s+- bar}) }
it { should contain_file(conf_file).with_content(%r{server: mongodb://127.0.0.2:45678/\s+tags:\s+- baz\s+- bat}) }
it { should contain_file(conf_file).with_content(%r{server:.*127.0.0.1.*server:.*127.0.0.2}m) }
end
context 'without tags' do
let(:params) {{
servers: [
{
'host' => '127.0.0.1',
'port' => '12345',
}
]
}}
end
context 'weird tags' do
let(:params) {{
servers: [
{
'host' => '127.0.0.1',
'port' => '56789',
'tags' => 'word'
}
]
}}
it { should_not compile }
end
=end
end