beaker 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/beaker.gemspec +1 -1
- data/lib/beaker/dsl/helpers.rb +34 -8
- data/spec/beaker/dsl/helpers_spec.rb +77 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWYxNzhkNWRkYTM2NzkxODFjODhjMDlhMmE2YWZhOWI0OWU1NjM3ZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZWM4OWNhOTU3NzRlZGU1ZmUzODkyN2M5MmI1ZTRmYWEzYmNlY2I5Mw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NmZiYzYyYWQ5MDY1NGE0MmI2ZjZhY2QxZWVkZmE4OTY0MWI0ZjA2MDlkYjQx
|
10
|
+
ZTczY2E5ODUzMzcyY2QxNjg1YzllNjNiZDIzNjQwNDRlODRiNzJmMGZjZWY0
|
11
|
+
YTI4ZGEyN2FjOWEzOGI1MDI3MmY2ZGE0Mzk5MDcwMDlhMzZmOTA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzgxNDdiNjYyMDEwMTYzM2I0M2RlZWU2NmMzNTVhZGQxMGZkMWUzOGQ5Mjc0
|
14
|
+
M2Q0YmIyMzZmOGQzZDVlYzZiMzRiOTJiZmQyYmJhNDJmNDhjMTczNjg4NDk1
|
15
|
+
MmFhMjM1YjUwYzRmNTBkOTkxMDZiM2M2ZDM3OTE1YmRhYTNkMzI=
|
data/beaker.gemspec
CHANGED
data/lib/beaker/dsl/helpers.rb
CHANGED
@@ -636,13 +636,28 @@ module Beaker
|
|
636
636
|
# the "--trace" command line parameter will be
|
637
637
|
# passed to the 'puppet apply' command.
|
638
638
|
#
|
639
|
+
# @option opts [Array<Integer>] :acceptable_exit_codes ([0]) The list of exit
|
640
|
+
# codes that will NOT raise an error when found upon
|
641
|
+
# command completion. If provided, these values will
|
642
|
+
# be combined with those used in :catch_failures and
|
643
|
+
# :expect_failures to create the full list of
|
644
|
+
# passing exit codes.
|
645
|
+
#
|
646
|
+
# @options opts [Hash] :environment Additional environment variables to be
|
647
|
+
# passed to the 'puppet apply' command
|
648
|
+
#
|
639
649
|
# @option opts [Boolean] :catch_failures (false) By default
|
640
|
-
#
|
650
|
+
# `puppet --apply` will exit with 0,
|
641
651
|
# which does not count as a test
|
642
652
|
# failure, even if there were errors applying
|
643
653
|
# the manifest. This option enables detailed
|
644
654
|
# exit codes and causes a test failure if
|
645
|
-
#
|
655
|
+
# `puppet --apply` indicates there was a
|
656
|
+
# failure during its execution.
|
657
|
+
#
|
658
|
+
# @option opts [Boolean] :expect_failures (false) This option enables
|
659
|
+
# detailed exit codes and causes a test failure
|
660
|
+
# if `puppet --apply` indicates there were no
|
646
661
|
# failure during its execution.
|
647
662
|
#
|
648
663
|
# @param [Block] block This method will yield to a block of code passed
|
@@ -651,20 +666,31 @@ module Beaker
|
|
651
666
|
#
|
652
667
|
def apply_manifest_on(host, manifest, opts = {}, &block)
|
653
668
|
on_options = {:stdin => manifest + "\n"}
|
654
|
-
on_options[:acceptable_exit_codes] = opts.delete(:acceptable_exit_codes)
|
669
|
+
on_options[:acceptable_exit_codes] = Array(opts.delete(:acceptable_exit_codes))
|
655
670
|
args = ["--verbose"]
|
656
671
|
args << "--parseonly" if opts[:parseonly]
|
657
672
|
args << "--trace" if opts[:trace]
|
658
673
|
|
674
|
+
# From puppet help:
|
675
|
+
# "... an exit code of '2' means there were changes, an exit code of
|
676
|
+
# '4' means there were failures during the transaction, and an exit
|
677
|
+
# code of '6' means there were both changes and failures."
|
678
|
+
if opts[:catch_failures] and opts[:expect_failures]
|
679
|
+
raise(ArgumentError, "Cannot specify both `catch_failures` and `expect_failures` for a single manifest")
|
680
|
+
end
|
659
681
|
if opts[:catch_failures]
|
660
682
|
args << '--detailed-exitcodes'
|
661
683
|
|
662
|
-
#
|
663
|
-
# "... an exit code of '2' means there were changes, an exit code of
|
664
|
-
# '4' means there were failures during the transaction, and an exit
|
665
|
-
# code of '6' means there were both changes and failures."
|
666
|
-
# We're after failures specifically so catch exit codes 4 and 6 only.
|
684
|
+
# We're after only complete success so allow exit codes 0 and 2 only.
|
667
685
|
on_options[:acceptable_exit_codes] |= [0, 2]
|
686
|
+
elsif opts[:expect_failures]
|
687
|
+
args << '--detailed-exitcodes'
|
688
|
+
|
689
|
+
# We're after failures specifically so allow exit codes 1, 4, and 6 only.
|
690
|
+
on_options[:acceptable_exit_codes] |= [1, 4, 6]
|
691
|
+
else
|
692
|
+
# Either use the provided acceptable_exit_codes or default to [0]
|
693
|
+
on_options[:acceptable_exit_codes] |= [0]
|
668
694
|
end
|
669
695
|
|
670
696
|
# Not really thrilled with this implementation, might want to improve it
|
@@ -297,6 +297,33 @@ describe ClassMixedWithDSLHelpers do
|
|
297
297
|
end
|
298
298
|
|
299
299
|
describe '#apply_manifest_on' do
|
300
|
+
it 'calls puppet' do
|
301
|
+
subject.should_receive( :puppet ).
|
302
|
+
with( 'apply', '--verbose').
|
303
|
+
and_return( 'puppet_command' )
|
304
|
+
|
305
|
+
subject.should_receive( :on ).
|
306
|
+
with( 'my_host', 'puppet_command',
|
307
|
+
:acceptable_exit_codes => [0],
|
308
|
+
:stdin => "class { \"boo\": }\n" )
|
309
|
+
|
310
|
+
subject.apply_manifest_on( 'my_host', 'class { "boo": }')
|
311
|
+
end
|
312
|
+
it 'adds acceptable exit codes with :catch_failures' do
|
313
|
+
subject.should_receive( :puppet ).
|
314
|
+
with( 'apply', '--verbose', '--trace', '--detailed-exitcodes' ).
|
315
|
+
and_return( 'puppet_command' )
|
316
|
+
|
317
|
+
subject.should_receive( :on ).
|
318
|
+
with( 'my_host', 'puppet_command',
|
319
|
+
:acceptable_exit_codes => [0,2],
|
320
|
+
:stdin => "class { \"boo\": }\n" )
|
321
|
+
|
322
|
+
subject.apply_manifest_on( 'my_host',
|
323
|
+
'class { "boo": }',
|
324
|
+
:trace => true,
|
325
|
+
:catch_failures => true )
|
326
|
+
end
|
300
327
|
it 'allows acceptable exit codes through :catch_failures' do
|
301
328
|
subject.should_receive( :puppet ).
|
302
329
|
with( 'apply', '--verbose', '--trace', '--detailed-exitcodes' ).
|
@@ -313,6 +340,56 @@ describe ClassMixedWithDSLHelpers do
|
|
313
340
|
:trace => true,
|
314
341
|
:catch_failures => true )
|
315
342
|
end
|
343
|
+
it 'enforces exit codes through :expect_failures' do
|
344
|
+
subject.should_receive( :puppet ).
|
345
|
+
with( 'apply', '--verbose', '--trace', '--detailed-exitcodes' ).
|
346
|
+
and_return( 'puppet_command' )
|
347
|
+
|
348
|
+
subject.should_receive( :on ).with(
|
349
|
+
'my_host',
|
350
|
+
'puppet_command',
|
351
|
+
:acceptable_exit_codes => [1,4,6],
|
352
|
+
:stdin => "class { \"boo\": }\n"
|
353
|
+
)
|
354
|
+
|
355
|
+
subject.apply_manifest_on(
|
356
|
+
'my_host',
|
357
|
+
'class { "boo": }',
|
358
|
+
:trace => true,
|
359
|
+
:expect_failures => true
|
360
|
+
)
|
361
|
+
end
|
362
|
+
it 'enforces exit codes through :expect_failures' do
|
363
|
+
expect {
|
364
|
+
subject.apply_manifest_on(
|
365
|
+
'my_host',
|
366
|
+
'class { "boo": }',
|
367
|
+
:trace => true,
|
368
|
+
:expect_failures => true,
|
369
|
+
:catch_failures => true
|
370
|
+
)
|
371
|
+
}.to raise_error ArgumentError, /catch_failures.+expect_failures/
|
372
|
+
end
|
373
|
+
it 'enforces added exit codes through :expect_failures' do
|
374
|
+
subject.should_receive( :puppet ).
|
375
|
+
with( 'apply', '--verbose', '--trace', '--detailed-exitcodes' ).
|
376
|
+
and_return( 'puppet_command' )
|
377
|
+
|
378
|
+
subject.should_receive( :on ).with(
|
379
|
+
'my_host',
|
380
|
+
'puppet_command',
|
381
|
+
:acceptable_exit_codes => [1,2,3,4,5,6],
|
382
|
+
:stdin => "class { \"boo\": }\n"
|
383
|
+
)
|
384
|
+
|
385
|
+
subject.apply_manifest_on(
|
386
|
+
'my_host',
|
387
|
+
'class { "boo": }',
|
388
|
+
:acceptable_exit_codes => (1..5),
|
389
|
+
:trace => true,
|
390
|
+
:expect_failures => true
|
391
|
+
)
|
392
|
+
end
|
316
393
|
end
|
317
394
|
|
318
395
|
describe "#apply_manifest" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beaker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppetlabs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|