|
1 | 1 | require 'spec_helper' |
2 | 2 |
|
3 | 3 | 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" } |
13 | 21 |
|
14 | | - context 'with default parameters' do |
15 | | - it { should compile } |
16 | | - end |
| 22 | + context 'with default parameters' do |
| 23 | + it { should compile } |
| 24 | + end |
17 | 25 |
|
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 | + }} |
22 | 30 |
|
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}]") } |
31 | 39 |
|
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: }) } |
34 | 42 |
|
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 |
40 | 50 | end |
41 | | - |
42 | 51 | end |
43 | 52 | end |
0 commit comments