Skip to content

Commit

Permalink
simplify fluentd template, add tests
Browse files Browse the repository at this point in the history
Refs #191
  • Loading branch information
miketheman committed Apr 4, 2015
1 parent 170c4ff commit 33a3640
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 16 deletions.
16 changes: 16 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,22 @@ suites:
- kitchen
- sink

- name: datadog_fluentd
run_list:
- recipe[datadog::fluentd]
attributes:
datadog:
<<: *DATADOG
fluentd:
instances:
- monitor_agent_url: http://localhost.com:24220/api/plugins.json
plugin_ids:
- api
- plugin
tags:
- kitchen
- sink

- name: datadog_haproxy
run_list:
- recipe[datadog::haproxy]
Expand Down
17 changes: 1 addition & 16 deletions templates/default/fluentd.yaml.erb
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
instances:
<% @instances.each do |i| -%>
- monitor_agent_url: <%= i['monitor_agent_url'] %>
<% if i.key?('plugin_ids') -%>
plugin_ids:
<% i['plugin_ids'].each do |p| -%>
- <%= p %>
<% end -%>
<% end -%>
<% if i.key?('tags') -%>
tags:
<% i['tags'].each do |t| -%>
- <%= t %>
<% end -%>
<% end -%>
<% end -%>
<%= JSON.parse(({ 'instances' => @instances }).to_json).to_yaml %>

# Nothing to configure here
init_config:
1 change: 1 addition & 0 deletions test/integration/datadog_fluentd/serverspec/Gemfile
34 changes: 34 additions & 0 deletions test/integration/datadog_fluentd/serverspec/fluentd_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Encoding: utf-8
require 'json_spec'
require 'serverspec'
require 'yaml'

set :backend, :exec
set :path, '/sbin:/usr/local/sbin:$PATH'

AGENT_CONFIG = '/etc/dd-agent/conf.d/fluentd.yaml'

describe service('datadog-agent') do
it { should be_running }
end

describe file(AGENT_CONFIG) do
it { should be_a_file }

it 'is valid yaml matching input values' do
generated = YAML.load_file(AGENT_CONFIG)

expected = {
'instances' => [
{
'monitor_agent_url' => 'http://localhost.com:24220/api/plugins.json',
'plugin_ids' => ['api', 'plugin'],
'tags' => ['kitchen', 'sink']
}
],
'init_config' => nil
}

expect(generated.to_json).to be_json_eql expected.to_json
end
end

0 comments on commit 33a3640

Please sign in to comment.