From f2718c32e9fabc49121b5bda499a64bc59154d6f Mon Sep 17 00:00:00 2001 From: Mike Fiedler Date: Thu, 9 Apr 2015 10:12:41 +0300 Subject: [PATCH] Add test for ntp recipe, doc updates Fixes #182 --- .kitchen.yml | 14 ++++++++ CHANGELOG.md | 2 ++ recipes/ntp.rb | 5 +-- .../datadog_ntp/serverspec/Gemfile | 1 + .../datadog_ntp/serverspec/ntp_spec.rb | 36 +++++++++++++++++++ 5 files changed, 56 insertions(+), 2 deletions(-) create mode 120000 test/integration/datadog_ntp/serverspec/Gemfile create mode 100644 test/integration/datadog_ntp/serverspec/ntp_spec.rb diff --git a/.kitchen.yml b/.kitchen.yml index 6d19dccf..b3fdf1b4 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -220,6 +220,20 @@ suites: - host: localhost port: 27017 +- name: datadog_ntp + run_list: + - recipe[datadog::ntp] + attributes: + datadog: + <<: *DATADOG + ntp: + instances: + - offset_threshold: 600 + host: europe.pool.ntp.org + port: 9999 + version: 4 + timeout: 10 + - name: datadog_kafka run_list: - recipe[datadog::kafka] diff --git a/CHANGELOG.md b/CHANGELOG.md index f615d05c..49c532cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ Changes # 2.1.0 / Unreleased +* [FEATURE] Add support for `ntp` check, [#182][] [@chrissnell][], [@miketheman][] * [OPTIMIZE] Remove long-dead `debug_mode` and replace with `log_level`, [#187][] [@remh][] * [FEATURE] Add support for `http` & `tcp` monitoring check, [#177][] [@mtougeron][], [#178][] [@chrissnell][], [@miketheman][] * [FEATURE] Add support for `fluentd` monitoring check, [#191][] [@takus][], [#192][] [@miketheman][] @@ -253,6 +254,7 @@ A fix has gone in to `apt` 2.1.0 that relaxes this condition, and plays well wit [#171]: https://github.com/DataDog/chef-datadog/issues/171 [#177]: https://github.com/DataDog/chef-datadog/issues/177 [#178]: https://github.com/DataDog/chef-datadog/issues/178 +[#182]: https://github.com/DataDog/chef-datadog/issues/182 [#187]: https://github.com/DataDog/chef-datadog/issues/187 [#190]: https://github.com/DataDog/chef-datadog/issues/190 [#191]: https://github.com/DataDog/chef-datadog/issues/191 diff --git a/recipes/ntp.rb b/recipes/ntp.rb index f52f8921..739b4848 100644 --- a/recipes/ntp.rb +++ b/recipes/ntp.rb @@ -1,11 +1,12 @@ include_recipe 'datadog::dd-agent' # Build a data structure with configuration. -# @see https://github.com/DataDog/dd-agent/blob/master/conf.d/ntp.yaml.example +# @note NTP check is enabled by default since datadog-agent 5.3.0. +# @see https://github.com/DataDog/dd-agent/blob/master/conf.d/ntp.yaml.default # @example # node.override['datadog']['ntp']['instances'] = [ # { -# 'offset_threshold' => '600', +# 'offset_threshold' => '60', # 'host' => 'pool.ntp.org', # 'port' => 'ntp', # 'version' => '3', diff --git a/test/integration/datadog_ntp/serverspec/Gemfile b/test/integration/datadog_ntp/serverspec/Gemfile new file mode 120000 index 00000000..74f9789f --- /dev/null +++ b/test/integration/datadog_ntp/serverspec/Gemfile @@ -0,0 +1 @@ +../../helpers/serverspec/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_ntp/serverspec/ntp_spec.rb b/test/integration/datadog_ntp/serverspec/ntp_spec.rb new file mode 100644 index 00000000..9a29ba84 --- /dev/null +++ b/test/integration/datadog_ntp/serverspec/ntp_spec.rb @@ -0,0 +1,36 @@ +# 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/ntp.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' => [ + { + 'offset_threshold' => 600, + 'host' => 'europe.pool.ntp.org', + 'port' => 9999, + 'version' => 4, + 'timeout' => 10 + } + ], + 'init_config' => nil + } + + expect(generated.to_json).to be_json_eql expected.to_json + end +end