|
| 1 | +require 'spec_helper' |
| 2 | + |
| 3 | +describe 'datadog_agent::integrations::dns_check' 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}/dns_check.yaml" } |
| 13 | + |
| 14 | + it { should compile.with_all_deps } |
| 15 | + it { should contain_file(conf_file).with( |
| 16 | + owner: dd_user, |
| 17 | + group: dd_group, |
| 18 | + mode: '0600', |
| 19 | + )} |
| 20 | + it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } |
| 21 | + it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } |
| 22 | + |
| 23 | + context 'with default parameters' do |
| 24 | + it { should contain_file(conf_file).with_content(%r{hostname: google.com}) } |
| 25 | + it { should contain_file(conf_file).with_content(%r{nameserver: 8.8.8.8}) } |
| 26 | + it { should contain_file(conf_file).with_content(%r{timeout: 5}) } |
| 27 | + end |
| 28 | + |
| 29 | + context 'with parameters set' do |
| 30 | + let(:params) {{ |
| 31 | + checks: [ |
| 32 | + { |
| 33 | + 'hostname' => 'example.com', |
| 34 | + 'nameserver' => '1.2.3.4', |
| 35 | + 'timeout' => 5, |
| 36 | + }, |
| 37 | + { |
| 38 | + 'hostname' => 'localdomain.com', |
| 39 | + 'nameserver' => '4.3.2.1', |
| 40 | + 'timeout' => 3, |
| 41 | + } |
| 42 | + ] |
| 43 | + }} |
| 44 | + |
| 45 | + it { should contain_file(conf_file).with_content(%r{hostname: example.com}) } |
| 46 | + it { should contain_file(conf_file).with_content(%r{nameserver: 1.2.3.4}) } |
| 47 | + it { should contain_file(conf_file).with_content(%r{timeout: 5}) } |
| 48 | + it { should contain_file(conf_file).with_content(%r{hostname: localdomain.com}) } |
| 49 | + it { should contain_file(conf_file).with_content(%r{nameserver: 4.3.2.1}) } |
| 50 | + it { should contain_file(conf_file).with_content(%r{timeout: 3}) } |
| 51 | + end |
| 52 | +end |
0 commit comments