-
Notifications
You must be signed in to change notification settings - Fork 814
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build from source (:broken_heart:) and then test.
- Loading branch information
Showing
4 changed files
with
197 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# (C) Datadog, Inc. 2010-2016 | ||
# All rights reserved | ||
# Licensed under Simplified BSD License (see LICENSE) | ||
|
||
require './ci/common' | ||
|
||
def powerdns_recursor_version | ||
ENV['FLAVOR_VERSION'] || '3.7.3' | ||
end | ||
|
||
def powerdns_recursor_rootdir | ||
"#{ENV['INTEGRATIONS_DIR']}/powerdns_recursor_#{powerdns_recursor_version}" | ||
end | ||
|
||
def boost_version | ||
'1_55_0' | ||
end | ||
|
||
namespace :ci do | ||
namespace :powerdns_recursor do |flavor| | ||
task before_install: ['ci:common:before_install'] | ||
|
||
task install: ['ci:common:install'] do | ||
unless Dir.exist? File.expand_path(File.join(powerdns_recursor_rootdir), 'pdns_recursor') | ||
# Downloads | ||
# https://downloads.powerdns.com/releases/pdns-recursor-{powerdns_recursor_version}.tar.bz2 | ||
# http://downloads.sourceforge.net/project/boost/boost/1.55.0/boost_1_55_0.tar.bz2 | ||
sh %(curl -s -L\ | ||
-o $VOLATILE_DIR/powerdns_recursor-#{powerdns_recursor_version}.tar.bz2\ | ||
https://s3.amazonaws.com/dd-agent-tarball-mirror/pdns-recursor-#{powerdns_recursor_version}.tar.bz2) | ||
sh %(mkdir -p #{powerdns_recursor_rootdir}) | ||
sh %(tar xf $VOLATILE_DIR/powerdns_recursor-#{powerdns_recursor_version}.tar.bz2\ | ||
-C #{powerdns_recursor_rootdir} --strip-components=1) | ||
sh %(curl -s -L\ | ||
-o $VOLATILE_DIR/boost_#{boost_version}.tar.bz2\ | ||
https://s3.amazonaws.com/dd-agent-tarball-mirror/boost_#{boost_version}.tar.bz2) | ||
sh %(tar xf $VOLATILE_DIR/boost_#{boost_version}.tar.bz2\ | ||
-C #{powerdns_recursor_rootdir} --strip-components=1) | ||
ENV['CPATH'] = powerdns_recursor_rootdir | ||
sh %(cd #{powerdns_recursor_rootdir} && ./configure) | ||
sh %(cd #{powerdns_recursor_rootdir} && make || echo "make didn't succeed") | ||
end | ||
end | ||
|
||
task before_script: ['ci:common:before_script'] do | ||
sh %(#{powerdns_recursor_rootdir}/pdns_recursor\ | ||
--config-dir=tests/checks/fixtures/powerdns-recursor/\ | ||
--socket-dir=#{powerdns_recursor_rootdir}) | ||
sh %(dig @127.0.0.1 -p 5353 free.fr) | ||
end | ||
|
||
task script: ['ci:common:script'] do | ||
this_provides = [ | ||
'powerdns_recursor' | ||
] | ||
Rake::Task['ci:common:run_tests'].invoke(this_provides) | ||
end | ||
|
||
task cleanup: ['ci:common:cleanup'] do | ||
sh %(kill `cat #{powerdns_recursor_rootdir}/pdns_recursor.pid` || echo 'Already dead') | ||
end | ||
|
||
task before_cache: ['ci:common:before_cache'] | ||
|
||
task cache: ['ci:common:cache'] | ||
|
||
task :execute do | ||
exception = nil | ||
begin | ||
%w(before_install install before_script | ||
script before_cache cache).each do |t| | ||
Rake::Task["#{flavor.scope.path}:#{t}"].invoke | ||
end | ||
rescue => e | ||
exception = e | ||
puts "Failed task: #{e.class} #{e.message}".red | ||
end | ||
if ENV['SKIP_CLEANUP'] | ||
puts 'Skipping cleanup, disposable environments are great'.yellow | ||
else | ||
puts 'Cleaning up' | ||
Rake::Task["#{flavor.scope.path}:cleanup"].invoke | ||
end | ||
raise exception if exception | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
local-port=5353 | ||
|
||
experimental-webserver=on | ||
experimental-webserver-address=127.0.0.1 | ||
experimental-webserver-port=8082 | ||
experimental-api-key=pdns_api_key |
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,103 @@ | ||
# 3p | ||
from nose.plugins.attrib import attr | ||
|
||
# project | ||
from tests.checks.common import AgentCheckTest | ||
|
||
|
||
@attr(requires='powerdns_recursor') | ||
class TestPowerDNSRecursorCheck(AgentCheckTest): | ||
CHECK_NAME = 'powerdns_recursor' | ||
|
||
GAUGE_METRICS = [ | ||
'cache-entries', | ||
'concurrent-queries', | ||
] | ||
RATE_METRICS = [ | ||
'all-outqueries', | ||
'answers-slow', | ||
'answers0-1', | ||
'answers1-10', | ||
'answers10-100', | ||
'answers100-1000', | ||
'cache-hits', | ||
'cache-misses', | ||
'noerror-answers', | ||
'outgoing-timeouts', | ||
'questions', | ||
'servfail-answers', | ||
'tcp-outqueries', | ||
'tcp-questions', | ||
] | ||
|
||
def __init__(self, *args, **kwargs): | ||
AgentCheckTest.__init__(self, *args, **kwargs) | ||
self.config = {"instances": [{ | ||
"host": "127.0.0.1", | ||
"port": "8082", | ||
"api_key": "pdns_api_key" | ||
}]} | ||
|
||
# Really a basic check to see if all metrics are there | ||
def test_check(self): | ||
self.run_check_twice(self.config) | ||
|
||
# Assert metrics | ||
for metric in self.GAUGE_METRICS: | ||
self.assertMetric(metric, 1.0, tags=[]) | ||
|
||
for metric in self.RATE_METRICS: | ||
self.assertMetric(metric, tags=[]) | ||
|
||
service_check_tags = ['recursor_host:127.0.0.1', 'recursor_port:8082'] | ||
self.assertServiceOK('powerdns.recursor.can_connect', tags=service_check_tags) | ||
|
||
self.coverage_report() | ||
|
||
def test_tags(self): | ||
config = self.config.copy() | ||
tags = ['foo:bar'] | ||
config['instances'][0]['tags'] = ['foo:bar'] | ||
self.run_check_twice(config) | ||
|
||
# Assert metrics | ||
for metric in self.GAUGE_METRICS: | ||
self.assertMetric(metric, 1.0, tags=tags) | ||
|
||
for metric in self.RATE_METRICS: | ||
self.assertMetric(metric, tags=tags) | ||
|
||
service_check_tags = ['recursor_host:127.0.0.1', 'recursor_port:8082'] | ||
self.assertServiceOK('powerdns.recursor.can_connect', tags=service_check_tags) | ||
|
||
self.coverage_report() | ||
|
||
def test_bad_config(self): | ||
config = self.config.copy() | ||
config['instances'][0]['port'] = 1111 | ||
service_check_tags = ['recursor_host:127.0.0.1', 'recursor_port:1111'] | ||
self.assertRaises( | ||
Exception, | ||
lambda: self.run_check(config) | ||
) | ||
self.assertServiceCheckCritical('powerdns.recursor.can_connect', tags=service_check_tags) | ||
self.coverage_report() | ||
|
||
def test_bad_api_key(self): | ||
config = self.config.copy() | ||
config['instances'][0]['api_key'] = 'nope' | ||
service_check_tags = ['recursor_host:127.0.0.1', 'recursor_port:8082'] | ||
self.assertRaises( | ||
Exception, | ||
lambda: self.run_check(config) | ||
) | ||
self.assertServiceCheckCritical('powerdns.recursor.can_connect', tags=service_check_tags) | ||
self.coverage_report() | ||
|
||
def test_very_bad_config(self): | ||
for config in [{}, {"host": "localhost"}, {"port": 1000}, {"host": "localhost", "port": 1000}]: | ||
self.assertRaises( | ||
Exception, | ||
lambda: self.run_check({"instances": [config]}) | ||
) | ||
self.coverage_report() |