@@ -232,6 +232,9 @@ def set_env_var(name, value)
232
232
end
233
233
end
234
234
235
+ # Allow a hash for Agent version 6
236
+ # ----------------------
237
+
235
238
context 'allows a hash for agent version' do
236
239
context 'when ubuntu' do
237
240
cached ( :chef_run ) do
@@ -240,7 +243,7 @@ def set_env_var(name, value)
240
243
:version => '14.04'
241
244
) do |node |
242
245
node . normal [ 'datadog' ] = {
243
- 'agent6' => false ,
246
+ 'agent6' => true ,
244
247
'api_key' => 'somethingnotnil' ,
245
248
'agent6_version' => {
246
249
'debian' => '1:6.9.0-1' ,
@@ -298,7 +301,7 @@ def set_env_var(name, value)
298
301
:version => '25'
299
302
) do |node |
300
303
node . normal [ 'datadog' ] = {
301
- 'agent6' => false ,
304
+ 'agent6' => true ,
302
305
'api_key' => 'somethingnotnil' ,
303
306
'agent6_version' => {
304
307
'debian' => '1:6.9.0-1' ,
@@ -321,7 +324,7 @@ def set_env_var(name, value)
321
324
:version => '6.9'
322
325
) do |node |
323
326
node . normal [ 'datadog' ] = {
324
- 'agent6' => false ,
327
+ 'agent6' => true ,
325
328
'api_key' => 'somethingnotnil' ,
326
329
'agent6_version' => {
327
330
'debian' => '1:6.9.0-1' ,
@@ -338,6 +341,107 @@ def set_env_var(name, value)
338
341
end
339
342
end
340
343
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
+
341
445
context 'package action' do
342
446
context 'default :install' do
343
447
cached ( :chef_run ) do
0 commit comments