Skip to content

Commit 71dde6c

Browse files
committed
Merge branch 'master' into remeh/deprecate-options
2 parents 99d1722 + dfebb51 commit 71dde6c

File tree

4 files changed

+138
-5
lines changed

4 files changed

+138
-5
lines changed

.kitchen.docker.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,23 @@ driver:
44
use_sudo: false
55

66
platforms:
7-
- name: ubuntu-14.04
87
# Exclude this OS for now, due to some odd behavior with the NTP check on CircleCI systems.
98
# See https://circleci.com/gh/DataDog/chef-datadog/19
109
# and http://support.ntp.org/bin/view/Support/KnownOsIssues#Section_9.2.4.2.5.3.
1110
# - name: ubuntu-12.04
11+
12+
- name: ubuntu-14.04
13+
driver_config:
14+
require_chef_omnibus: 14.12
1215
- name: centos-6.6
16+
driver_config:
17+
require_chef_omnibus: 14.12
1318
- name: centos-7.7
19+
driver_config:
20+
require_chef_omnibus: 14.12
1421
- name: debian-8.11
22+
driver_config:
23+
require_chef_omnibus: 14.12
1524

1625
suites:
1726
- name: dd-agent-handler

recipes/dd-handler.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
end
2727

2828
if node['datadog']['chef_handler_version'] &&
29-
Gem::Version.new(node['datadog']['chef_handler_version']) < Gem::Version.new('0.10.0')
29+
Gem::Version.new(node['datadog']['chef_handler_version']) < Gem::Version.new('0.10.0')
3030
Chef::Log.error('We do not support chef_handler_version < v0.10.0 anymore, please use a more recent version.')
3131
return
3232
end

spec/dd-agent_spec.rb

Lines changed: 107 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ def set_env_var(name, value)
232232
end
233233
end
234234

235+
# Allow a hash for Agent version 6
236+
# ----------------------
237+
235238
context 'allows a hash for agent version' do
236239
context 'when ubuntu' do
237240
cached(:chef_run) do
@@ -240,7 +243,7 @@ def set_env_var(name, value)
240243
:version => '14.04'
241244
) do |node|
242245
node.normal['datadog'] = {
243-
'agent6' => false,
246+
'agent6' => true,
244247
'api_key' => 'somethingnotnil',
245248
'agent6_version' => {
246249
'debian' => '1:6.9.0-1',
@@ -298,7 +301,7 @@ def set_env_var(name, value)
298301
:version => '25'
299302
) do |node|
300303
node.normal['datadog'] = {
301-
'agent6' => false,
304+
'agent6' => true,
302305
'api_key' => 'somethingnotnil',
303306
'agent6_version' => {
304307
'debian' => '1:6.9.0-1',
@@ -321,7 +324,7 @@ def set_env_var(name, value)
321324
:version => '6.9'
322325
) do |node|
323326
node.normal['datadog'] = {
324-
'agent6' => false,
327+
'agent6' => true,
325328
'api_key' => 'somethingnotnil',
326329
'agent6_version' => {
327330
'debian' => '1:6.9.0-1',
@@ -338,6 +341,107 @@ def set_env_var(name, value)
338341
end
339342
end
340343

344+
# Allow a hash for Agent version 5
345+
# ----------------------
346+
347+
context 'allows a hash for agent version v5' do
348+
context 'when ubuntu' do
349+
cached(:chef_run) do
350+
ChefSpec::SoloRunner.new(
351+
:platform => 'ubuntu',
352+
:version => '14.04'
353+
) do |node|
354+
node.normal['datadog'] = {
355+
'agent6' => false,
356+
'api_key' => 'somethingnotnil',
357+
'agent_version' => {
358+
'debian' => '1:5.32.2-1',
359+
'rhel' => '5.32.2-1',
360+
'windows' => '5.4.0'
361+
},
362+
}
363+
end.converge described_recipe
364+
end
365+
366+
it_behaves_like 'debianoids datadog-agent v5'
367+
end
368+
369+
context 'when windows' do
370+
cached(:chef_run) do
371+
set_env_var('ProgramData', 'C:\ProgramData')
372+
ChefSpec::SoloRunner.new(
373+
:platform => 'windows',
374+
:version => '2012R2',
375+
:file_cache_path => 'C:/chef/cache'
376+
) do |node|
377+
node.normal['datadog'] = {
378+
'agent6' => false,
379+
'api_key' => 'somethingnotnil',
380+
'agent_version' => {
381+
'debian' => '1:5.32.2-1',
382+
'rhel' => '5.32.2-1',
383+
'windows' => '5.4.0'
384+
},
385+
}
386+
end.converge described_recipe
387+
end
388+
389+
temp_file = ::File.join('C:/chef/cache', 'ddagent-cli.msi')
390+
391+
it_behaves_like 'windows Datadog Agent v5', :msi
392+
# remote_file source gets converted to an array, so we need to do
393+
# some tricky things to be able to regex against it
394+
# Relevant: http://stackoverflow.com/a/12325983
395+
# But we should probably assert the full default attribute somewhere...
396+
it 'installs agent 5.4.0' do
397+
expect(chef_run.remote_file(temp_file).source.to_s)
398+
.to match(/ddagent-cli-5.4.0.msi/)
399+
end
400+
end
401+
402+
context 'when fedora' do
403+
cached(:chef_run) do
404+
ChefSpec::SoloRunner.new(
405+
:platform => 'fedora',
406+
:version => '25'
407+
) do |node|
408+
node.normal['datadog'] = {
409+
'agent6' => false,
410+
'api_key' => 'somethingnotnil',
411+
'agent6_version' => {
412+
'debian' => '1:5.32.2-1',
413+
'rhel' => '5.32.2-1',
414+
'windows' => '5.4.0'
415+
},
416+
}
417+
end.converge described_recipe
418+
end
419+
420+
it_behaves_like 'rhellions datadog-agent v5'
421+
end
422+
423+
context 'when rhel' do
424+
cached(:chef_run) do
425+
ChefSpec::SoloRunner.new(
426+
:platform => 'redhat',
427+
:version => '6.9'
428+
) do |node|
429+
node.normal['datadog'] = {
430+
'agent6' => false,
431+
'api_key' => 'somethingnotnil',
432+
'agent_version' => {
433+
'debian' => '1:5.32.2-1',
434+
'rhel' => '5.32.2-1',
435+
'windows' => '5.4.0'
436+
},
437+
}
438+
end.converge described_recipe
439+
end
440+
441+
it_behaves_like 'rhellions datadog-agent v5'
442+
end
443+
end
444+
341445
context 'package action' do
342446
context 'default :install' do
343447
cached(:chef_run) do

spec/shared_examples.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,22 @@
4646
end
4747
end
4848

49+
shared_examples_for 'datadog-agent v5' do
50+
it_behaves_like 'common linux resources v5'
51+
end
52+
4953
shared_examples_for 'datadog-agent' do
5054
it_behaves_like 'common linux resources'
5155
end
5256

57+
shared_examples_for 'debianoids datadog-agent v5' do
58+
it_behaves_like 'datadog-agent v5'
59+
60+
it 'installs the datadog-agent' do
61+
expect(chef_run).to install_apt_package 'datadog-agent'
62+
end
63+
end
64+
5365
shared_examples_for 'debianoids datadog-agent' do
5466
it_behaves_like 'datadog-agent'
5567

@@ -58,6 +70,14 @@
5870
end
5971
end
6072

73+
shared_examples_for 'rhellions datadog-agent v5' do
74+
it_behaves_like 'datadog-agent v5'
75+
76+
it 'installs the datadog-agent' do
77+
expect(chef_run).to install_yum_package 'datadog-agent'
78+
end
79+
end
80+
6181
shared_examples_for 'rhellions datadog-agent' do
6282
it_behaves_like 'datadog-agent'
6383

0 commit comments

Comments
 (0)