Skip to content

Commit

Permalink
Merge branch 'master' into remeh/deprecate-options
Browse files Browse the repository at this point in the history
  • Loading branch information
remeh committed May 17, 2019
2 parents 99d1722 + dfebb51 commit 71dde6c
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 5 deletions.
11 changes: 10 additions & 1 deletion .kitchen.docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@ driver:
use_sudo: false

platforms:
- name: ubuntu-14.04
# Exclude this OS for now, due to some odd behavior with the NTP check on CircleCI systems.
# See https://circleci.com/gh/DataDog/chef-datadog/19
# and http://support.ntp.org/bin/view/Support/KnownOsIssues#Section_9.2.4.2.5.3.
# - name: ubuntu-12.04

- name: ubuntu-14.04
driver_config:
require_chef_omnibus: 14.12
- name: centos-6.6
driver_config:
require_chef_omnibus: 14.12
- name: centos-7.7
driver_config:
require_chef_omnibus: 14.12
- name: debian-8.11
driver_config:
require_chef_omnibus: 14.12

suites:
- name: dd-agent-handler
Expand Down
2 changes: 1 addition & 1 deletion recipes/dd-handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
end

if node['datadog']['chef_handler_version'] &&
Gem::Version.new(node['datadog']['chef_handler_version']) < Gem::Version.new('0.10.0')
Gem::Version.new(node['datadog']['chef_handler_version']) < Gem::Version.new('0.10.0')
Chef::Log.error('We do not support chef_handler_version < v0.10.0 anymore, please use a more recent version.')
return
end
Expand Down
110 changes: 107 additions & 3 deletions spec/dd-agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ def set_env_var(name, value)
end
end

# Allow a hash for Agent version 6
# ----------------------

context 'allows a hash for agent version' do
context 'when ubuntu' do
cached(:chef_run) do
Expand All @@ -240,7 +243,7 @@ def set_env_var(name, value)
:version => '14.04'
) do |node|
node.normal['datadog'] = {
'agent6' => false,
'agent6' => true,
'api_key' => 'somethingnotnil',
'agent6_version' => {
'debian' => '1:6.9.0-1',
Expand Down Expand Up @@ -298,7 +301,7 @@ def set_env_var(name, value)
:version => '25'
) do |node|
node.normal['datadog'] = {
'agent6' => false,
'agent6' => true,
'api_key' => 'somethingnotnil',
'agent6_version' => {
'debian' => '1:6.9.0-1',
Expand All @@ -321,7 +324,7 @@ def set_env_var(name, value)
:version => '6.9'
) do |node|
node.normal['datadog'] = {
'agent6' => false,
'agent6' => true,
'api_key' => 'somethingnotnil',
'agent6_version' => {
'debian' => '1:6.9.0-1',
Expand All @@ -338,6 +341,107 @@ def set_env_var(name, value)
end
end

# Allow a hash for Agent version 5
# ----------------------

context 'allows a hash for agent version v5' do
context 'when ubuntu' do
cached(:chef_run) do
ChefSpec::SoloRunner.new(
:platform => 'ubuntu',
:version => '14.04'
) do |node|
node.normal['datadog'] = {
'agent6' => false,
'api_key' => 'somethingnotnil',
'agent_version' => {
'debian' => '1:5.32.2-1',
'rhel' => '5.32.2-1',
'windows' => '5.4.0'
},
}
end.converge described_recipe
end

it_behaves_like 'debianoids datadog-agent v5'
end

context 'when windows' do
cached(:chef_run) do
set_env_var('ProgramData', 'C:\ProgramData')
ChefSpec::SoloRunner.new(
:platform => 'windows',
:version => '2012R2',
:file_cache_path => 'C:/chef/cache'
) do |node|
node.normal['datadog'] = {
'agent6' => false,
'api_key' => 'somethingnotnil',
'agent_version' => {
'debian' => '1:5.32.2-1',
'rhel' => '5.32.2-1',
'windows' => '5.4.0'
},
}
end.converge described_recipe
end

temp_file = ::File.join('C:/chef/cache', 'ddagent-cli.msi')

it_behaves_like 'windows Datadog Agent v5', :msi
# remote_file source gets converted to an array, so we need to do
# some tricky things to be able to regex against it
# Relevant: http://stackoverflow.com/a/12325983
# But we should probably assert the full default attribute somewhere...
it 'installs agent 5.4.0' do
expect(chef_run.remote_file(temp_file).source.to_s)
.to match(/ddagent-cli-5.4.0.msi/)
end
end

context 'when fedora' do
cached(:chef_run) do
ChefSpec::SoloRunner.new(
:platform => 'fedora',
:version => '25'
) do |node|
node.normal['datadog'] = {
'agent6' => false,
'api_key' => 'somethingnotnil',
'agent6_version' => {
'debian' => '1:5.32.2-1',
'rhel' => '5.32.2-1',
'windows' => '5.4.0'
},
}
end.converge described_recipe
end

it_behaves_like 'rhellions datadog-agent v5'
end

context 'when rhel' do
cached(:chef_run) do
ChefSpec::SoloRunner.new(
:platform => 'redhat',
:version => '6.9'
) do |node|
node.normal['datadog'] = {
'agent6' => false,
'api_key' => 'somethingnotnil',
'agent_version' => {
'debian' => '1:5.32.2-1',
'rhel' => '5.32.2-1',
'windows' => '5.4.0'
},
}
end.converge described_recipe
end

it_behaves_like 'rhellions datadog-agent v5'
end
end

context 'package action' do
context 'default :install' do
cached(:chef_run) do
Expand Down
20 changes: 20 additions & 0 deletions spec/shared_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,22 @@
end
end

shared_examples_for 'datadog-agent v5' do
it_behaves_like 'common linux resources v5'
end

shared_examples_for 'datadog-agent' do
it_behaves_like 'common linux resources'
end

shared_examples_for 'debianoids datadog-agent v5' do
it_behaves_like 'datadog-agent v5'

it 'installs the datadog-agent' do
expect(chef_run).to install_apt_package 'datadog-agent'
end
end

shared_examples_for 'debianoids datadog-agent' do
it_behaves_like 'datadog-agent'

Expand All @@ -58,6 +70,14 @@
end
end

shared_examples_for 'rhellions datadog-agent v5' do
it_behaves_like 'datadog-agent v5'

it 'installs the datadog-agent' do
expect(chef_run).to install_yum_package 'datadog-agent'
end
end

shared_examples_for 'rhellions datadog-agent' do
it_behaves_like 'datadog-agent'

Expand Down

0 comments on commit 71dde6c

Please sign in to comment.