|
| 1 | +require 'spec_helper' |
| 2 | + |
| 3 | +describe 'datadog_agent::integrations::supervisord' 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}/supervisord.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{name: server0\s+host: localhost\s+port: 9001}) } |
| 25 | + end |
| 26 | + |
| 27 | + context 'with one supervisord' do |
| 28 | + context 'without processes' do |
| 29 | + let(:params) {{ |
| 30 | + instances: [ |
| 31 | + { |
| 32 | + 'servername' => 'server0', |
| 33 | + 'socket' => 'unix://var/run/supervisor.sock', |
| 34 | + }, |
| 35 | + ] |
| 36 | + }} |
| 37 | + it { should contain_file(conf_file).with_content(%r{name: server0\s+socket: unix://var/run/supervisor.sock}) } |
| 38 | + end |
| 39 | + context 'with processes' do |
| 40 | + let(:params) {{ |
| 41 | + instances: [ |
| 42 | + { |
| 43 | + 'servername' => 'server0', |
| 44 | + 'socket' => 'unix://var/run/supervisor.sock', |
| 45 | + 'proc_names' => %w{ java apache2 }, |
| 46 | + }, |
| 47 | + ] |
| 48 | + }} |
| 49 | + it { should contain_file(conf_file).with_content(%r{name: server0\s+socket: unix://var/run/supervisor.sock\s+proc_names:\s+- java\s+- apache2}) } |
| 50 | + end |
| 51 | + end |
| 52 | + |
| 53 | + context 'with multiple supervisord' do |
| 54 | + context 'without processes parameter array' do |
| 55 | + let(:params) {{ |
| 56 | + instances: [ |
| 57 | + { |
| 58 | + 'servername' => 'server0', |
| 59 | + 'socket' => 'unix://var/run/supervisor.sock', |
| 60 | + }, |
| 61 | + { |
| 62 | + 'servername' => 'server1', |
| 63 | + 'hostname' => 'localhost', |
| 64 | + 'port' => '9001', |
| 65 | + }, |
| 66 | + ] |
| 67 | + }} |
| 68 | + it { should contain_file(conf_file).with_content(%r{name: server0\s+socket: unix://var/run/supervisor.sock}) } |
| 69 | + it { should contain_file(conf_file).with_content(%r{name: server1\s+host: localhost\s+port: 9001}) } |
| 70 | + end |
| 71 | + context 'with processes parameter array' do |
| 72 | + let(:params) {{ |
| 73 | + instances: [ |
| 74 | + { |
| 75 | + 'servername' => 'server0', |
| 76 | + 'socket' => 'unix://var/run/supervisor.sock', |
| 77 | + 'proc_names' => %w{ webapp nginx }, |
| 78 | + }, |
| 79 | + { |
| 80 | + 'servername' => 'server1', |
| 81 | + 'hostname' => 'localhost', |
| 82 | + 'port' => '9001', |
| 83 | + 'proc_names' => %w{ java apache2 }, |
| 84 | + }, |
| 85 | + ] |
| 86 | + }} |
| 87 | + it { should contain_file(conf_file).with_content(%r{name: server0\s+socket: unix://var/run/supervisor.sock\s+proc_names:\s+- webapp\s+- nginx}) } |
| 88 | + it { should contain_file(conf_file).with_content(%r{name: server1\s+host: localhost\s+port: 9001\s+proc_names:\s+- java\s+- apache2}) } |
| 89 | + end |
| 90 | + end |
| 91 | +end |
0 commit comments