-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add multiple enpoints/api_keys conf (#317)
On both `dd-agent` and `handler`
- Loading branch information
1 parent
987bb05
commit f78252d
Showing
7 changed files
with
190 additions
and
5 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
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
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 |
---|---|---|
@@ -0,0 +1,95 @@ | ||
require 'spec_helper' | ||
|
||
shared_examples 'a chef-handler-datadog installer' do |version| | ||
it 'includes chef_handler recipe' do | ||
expect(chef_run).to include_recipe('chef_handler') | ||
end | ||
|
||
it 'installs the right version of chef-handler-datadog' do | ||
expect(chef_run).to install_chef_gem('chef-handler-datadog').with(version: version) | ||
end | ||
end | ||
|
||
shared_examples 'a chef-handler-datadog runner' do |extra_endpoints| | ||
it 'runs the handler' do | ||
handler_config = { | ||
api_key: 'somethingnotnil', | ||
application_key: 'somethingnotnil2', | ||
use_ec2_instance_id: true, | ||
tag_prefix: 'tag:', | ||
url: 'https://app.datadoghq.com', | ||
extra_endpoints: extra_endpoints || [] | ||
} | ||
|
||
expect(chef_run).to enable_chef_handler('Chef::Handler::Datadog').with( | ||
source: 'chef/handler/datadog', | ||
arguments: [handler_config] | ||
) | ||
end | ||
end | ||
|
||
describe 'datadog::dd-handler' do | ||
context 'standard usage' do | ||
cached(:chef_run) do | ||
ChefSpec::SoloRunner.new( | ||
platform: 'ubuntu', | ||
version: '14.04' | ||
) do |node| | ||
node.set['datadog']['api_key'] = 'somethingnotnil' | ||
node.set['datadog']['application_key'] = 'somethingnotnil2' | ||
node.set['datadog']['chef_handler_enable'] = true | ||
node.set['datadog']['use_ec2_instance_id'] = true | ||
end.converge described_recipe | ||
end | ||
|
||
it_behaves_like 'a chef-handler-datadog installer' | ||
|
||
it_behaves_like 'a chef-handler-datadog runner' | ||
end | ||
|
||
context 'multiple endpoints' do | ||
cached(:chef_run) do | ||
ChefSpec::SoloRunner.new( | ||
platform: 'ubuntu', | ||
version: '14.04' | ||
) do |node| | ||
node.set['datadog']['api_key'] = 'somethingnotnil' | ||
node.set['datadog']['application_key'] = 'somethingnotnil2' | ||
node.set['datadog']['chef_handler_enable'] = true | ||
node.set['datadog']['use_ec2_instance_id'] = true | ||
node.set['datadog']['extra_endpoints']['qqqq']['enabled'] = true | ||
node.set['datadog']['extra_endpoints']['qqqq']['api_key'] = 'something' | ||
node.set['datadog']['extra_endpoints']['qqqq']['application_key'] = 'something2' | ||
end.converge described_recipe | ||
end | ||
|
||
extra_endpoints = [ | ||
Mash.new(api_key: 'something', | ||
application_key: 'something2') | ||
] | ||
|
||
it_behaves_like 'a chef-handler-datadog installer' | ||
|
||
it_behaves_like 'a chef-handler-datadog runner', extra_endpoints | ||
end | ||
context 'multiple endpoints disabled' do | ||
cached(:chef_run) do | ||
ChefSpec::SoloRunner.new( | ||
platform: 'ubuntu', | ||
version: '14.04' | ||
) do |node| | ||
node.set['datadog']['api_key'] = 'somethingnotnil' | ||
node.set['datadog']['application_key'] = 'somethingnotnil2' | ||
node.set['datadog']['chef_handler_enable'] = true | ||
node.set['datadog']['use_ec2_instance_id'] = true | ||
node.set['datadog']['extra_endpoints']['qqqq']['enabled'] = false | ||
node.set['datadog']['extra_endpoints']['qqqq']['api_key'] = 'something' | ||
node.set['datadog']['extra_endpoints']['qqqq']['application_key'] = 'something2' | ||
end.converge described_recipe | ||
end | ||
|
||
it_behaves_like 'a chef-handler-datadog installer' | ||
|
||
it_behaves_like 'a chef-handler-datadog runner' | ||
end | ||
end |
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