-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simplify fluentd template, add tests
Refs #191
- Loading branch information
1 parent
170c4ff
commit 33a3640
Showing
4 changed files
with
52 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../helpers/serverspec/Gemfile |
34 changes: 34 additions & 0 deletions
34
test/integration/datadog_fluentd/serverspec/fluentd_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |