|
| 1 | +require 'spec_helper' |
| 2 | + |
| 3 | +describe 'datadog_agent::integrations::cassandra' 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}/cassandra.yaml" } |
| 13 | + |
| 14 | + context 'with password set' do |
| 15 | + let(:params) {{ |
| 16 | + user: 'datadog', |
| 17 | + password: 'foobar', |
| 18 | + }} |
| 19 | + |
| 20 | + it { should compile.with_all_deps } |
| 21 | + it { should contain_file(conf_file).with( |
| 22 | + owner: dd_user, |
| 23 | + group: dd_group, |
| 24 | + mode: '0600', |
| 25 | + )} |
| 26 | + it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } |
| 27 | + it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } |
| 28 | + |
| 29 | + it { should contain_file(conf_file).with_content(%r{password: foobar}) } |
| 30 | + it { should contain_file(conf_file).without_content(%r{tags: }) } |
| 31 | + |
| 32 | + context 'with defaults' do |
| 33 | + it { should contain_file(conf_file).with_content(%r{host: localhost}) } |
| 34 | + it { should contain_file(conf_file).with_content(%r{user: datadog}) } |
| 35 | + end |
| 36 | + |
| 37 | + context 'with parameters set' do |
| 38 | + let(:params) {{ |
| 39 | + password: 'foobar', |
| 40 | + host: 'cassandra1', |
| 41 | + user: 'baz', |
| 42 | + }} |
| 43 | + |
| 44 | + it { should contain_file(conf_file).with_content(%r{password: foobar}) } |
| 45 | + it { should contain_file(conf_file).with_content(%r{host: cassandra1}) } |
| 46 | + it { should contain_file(conf_file).with_content(%r{user: baz}) } |
| 47 | + end |
| 48 | + |
| 49 | + context 'with tags parameter array' do |
| 50 | + let(:params) {{ |
| 51 | + password: 'foobar', |
| 52 | + tags: %w{ foo bar baz }, |
| 53 | + }} |
| 54 | + it { should contain_file(conf_file).with_content(/tags:[^-]+- foo\s+- bar\s+- baz\s*?[^-]/m) } |
| 55 | + end |
| 56 | + |
| 57 | + context 'tags not array' do |
| 58 | + let(:params) {{ |
| 59 | + password: 'foobar', |
| 60 | + tags: 'aoeu', |
| 61 | + }} |
| 62 | + |
| 63 | + it { should_not compile } |
| 64 | + end |
| 65 | + end |
| 66 | +end |
0 commit comments