|
| 1 | +require 'spec_helper' |
| 2 | + |
| 3 | +describe 'datadog_agent::integrations::fluentd' 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}/fluentd.yaml" } |
| 13 | + |
| 14 | + context 'with default parameters' do |
| 15 | + it { should compile } |
| 16 | + end |
| 17 | + |
| 18 | + context 'with monitor_agent_url set' do |
| 19 | + let(:params) {{ |
| 20 | + monitor_agent_url: 'foobar', |
| 21 | + }} |
| 22 | + |
| 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 | + |
| 32 | + it { should contain_file(conf_file).with_content(%r{monitor_agent_url: foobar}) } |
| 33 | + it { should contain_file(conf_file).without_content(%r{tags: }) } |
| 34 | + |
| 35 | + context 'with plugin_ids parameter array' do |
| 36 | + let(:params) {{ |
| 37 | + monitor_agent_url: 'foobar', |
| 38 | + plugin_ids: %w{ foo bar baz }, |
| 39 | + }} |
| 40 | + it { should contain_file(conf_file).with_content(/plugin_ids:[^-]+- foo\s+- bar\s+- baz\s*?[^-]/m) } |
| 41 | + end |
| 42 | + |
| 43 | + context 'plugin_ids not array' do |
| 44 | + let(:params) {{ |
| 45 | + monitor_agent_url: 'foobar', |
| 46 | + plugin_ids: 'aoeu', |
| 47 | + }} |
| 48 | + |
| 49 | + it { should_not compile } |
| 50 | + end |
| 51 | + end |
| 52 | +end |
0 commit comments