Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #373 - Postfix template issue #374

Merged
merged 2 commits into from
Nov 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions spec/integrations/postfix_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
describe 'datadog::postfix' do
expected_yaml = <<-EOF
instances:
- directory: /var/spool/postfix
queues:
- incoming
- active
- deferred
tags:
- prod
- postfix_core
- directory: /var/spool/postfix
queues:
- bounce
init_config:
EOF

before do
allow_any_instance_of(Chef::Recipe).to receive(:include_recipe).and_call_original
allow_any_instance_of(Chef::Recipe).to receive(:include_recipe).with('sudo')
allow_any_instance_of(Chef::Recipe).to receive(:sudo)
end

cached(:chef_run) do
ChefSpec::SoloRunner.new(step_into: ['datadog_monitor']) do |node|
node.automatic['languages'] = { python: { version: '2.7.2' } }

node.set['datadog'] = {
api_key: 'someapikey',
postfix: {
instances: [
{
directory: '/var/spool/postfix',
queues: ['incoming', 'active', 'deferred'],
tags: ['prod', 'postfix_core']
},
{
directory: '/var/spool/postfix',
queues: ['bounce']
}
]
}
}
end.converge(described_recipe)
end

subject { chef_run }

it_behaves_like 'datadog-agent'

it { is_expected.to include_recipe('datadog::dd-agent') }

it { is_expected.to add_datadog_monitor('postfix') }

it 'renders expected YAML config file' do
expect(chef_run).to render_file('/etc/dd-agent/conf.d/postfix.yaml').with_content { |content|
expect(YAML.load(content).to_json).to be_json_eql(YAML.load(expected_yaml).to_json)
}
end
end
2 changes: 2 additions & 0 deletions templates/default/postfix.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ instances:
<% Array(instance['queues']).each do |queue| -%>
- <%= queue %>
<% end -%>
<% if instance.key?('tags') -%>
tags:
<% Array(instance['tags']).each do |tag| -%>
- <%= tag %>
<% end -%>
<% end -%>
<% end -%>

# Postfix check does not require any init_config
Expand Down