Skip to content

Commit 43bae1c

Browse files
ewansteeletruthbk
authored andcommitted
[Agent 6] fix network integration config path (DataDog#433)
* [Agent 6] fix network integration config path * fix tests associate with the network integration
1 parent 49d40da commit 43bae1c

2 files changed

Lines changed: 48 additions & 33 deletions

File tree

manifests/integrations/network.pp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@
3131

3232
validate_legacy('Array', 'validate_array', $excluded_interfaces)
3333

34-
file { "${datadog_agent::params::conf_dir}/network.yaml":
34+
if !$::datadog_agent::agent5_enable {
35+
$dst = "${datadog_agent::conf6_dir}/network.yaml"
36+
} else {
37+
$dst = "${datadog_agent::conf_dir}/network.yaml"
38+
}
39+
40+
file { $dst:
3541
ensure => file,
3642
owner => $datadog_agent::params::dd_user,
3743
group => $datadog_agent::params::dd_group,
Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,52 @@
11
require 'spec_helper'
22

33
describe 'datadog_agent::integrations::network' do
4-
let(:facts) {{
5-
operatingsystem: 'Ubuntu',
6-
}}
7-
let(:conf_dir) { '/etc/dd-agent/conf.d' }
8-
let(:dd_user) { 'dd-agent' }
9-
let(:dd_group) { 'root' }
10-
let(:dd_package) { 'datadog-agent' }
11-
let(:dd_service) { 'datadog-agent' }
12-
let(:conf_file) { "#{conf_dir}/network.yaml" }
4+
context 'supported agents - v5 and v6' do
5+
agents = { '5' => true, '6' => false }
6+
agents.each do |_, enabled|
7+
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" }
8+
let(:facts) {{
9+
operatingsystem: 'Ubuntu',
10+
}}
11+
if enabled
12+
let(:conf_dir) { '/etc/dd-agent/conf.d' }
13+
else
14+
let(:conf_dir) { '/etc/datadog-agent/conf.d' }
15+
end
16+
let(:dd_user) { 'dd-agent' }
17+
let(:dd_group) { 'root' }
18+
let(:dd_package) { 'datadog-agent' }
19+
let(:dd_service) { 'datadog-agent' }
20+
let(:conf_file) { "#{conf_dir}/network.yaml" }
1321

14-
context 'with default parameters' do
15-
it { should compile }
16-
end
22+
context 'with default parameters' do
23+
it { should compile }
24+
end
1725

18-
context 'with collect_connection_state set' do
19-
let(:params) {{
20-
collect_connection_state: true,
21-
}}
26+
context 'with collect_connection_state set' do
27+
let(:params) {{
28+
collect_connection_state: true,
29+
}}
2230

23-
it { should compile.with_all_deps }
24-
it { should contain_file(conf_file).with(
25-
owner: dd_user,
26-
group: dd_group,
27-
mode: '0600',
28-
)}
29-
it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") }
30-
it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") }
31+
it { should compile.with_all_deps }
32+
it { should contain_file(conf_file).with(
33+
owner: dd_user,
34+
group: dd_group,
35+
mode: '0600',
36+
)}
37+
it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") }
38+
it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") }
3139

32-
it { should contain_file(conf_file).with_content(%r{collect_connection_state: true}) }
33-
it { should contain_file(conf_file).without_content(%r{tags: }) }
40+
it { should contain_file(conf_file).with_content(%r{collect_connection_state: true}) }
41+
it { should contain_file(conf_file).without_content(%r{tags: }) }
3442

35-
context 'with excluded_interfaces parameter array' do
36-
let(:params) {{
37-
excluded_interfaces: %w{ lo lo0 eth0 },
38-
}}
39-
it { should contain_file(conf_file).with_content(/excluded_interfaces:[^-]+- lo\s+- lo0\s+- eth0\s*?[^-]/m) }
43+
context 'with excluded_interfaces parameter array' do
44+
let(:params) {{
45+
excluded_interfaces: %w{ lo lo0 eth0 },
46+
}}
47+
it { should contain_file(conf_file).with_content(/excluded_interfaces:[^-]+- lo\s+- lo0\s+- eth0\s*?[^-]/m) }
48+
end
49+
end
4050
end
41-
4251
end
4352
end

0 commit comments

Comments
 (0)