beaker 1.4.1 → 1.5.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/lib/beaker/cli.rb +15 -10
- data/lib/beaker/dsl/install_utils.rb +15 -0
- data/lib/beaker/dsl/roles.rb +9 -2
- data/lib/beaker/network_manager.rb +4 -7
- data/lib/beaker/options/command_line_parser.rb +13 -6
- data/lib/beaker/options/hosts_file_parser.rb +1 -0
- data/lib/beaker/options/parser.rb +9 -4
- data/lib/beaker/options/presets.rb +2 -2
- data/lib/beaker/test_suite.rb +2 -2
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/cli_spec.rb +156 -0
- data/spec/beaker/dsl/roles_spec.rb +8 -3
- data/spec/beaker/options/command_line_parser_spec.rb +2 -2
- data/spec/beaker/options/parser_spec.rb +3 -3
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODViOGJiN2ZhMDlmNjQ4NmQxNTNkMjZiNjhlYTc5MjI0NzIyNmEzMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
N2U1MDk2NWUwZjNmNGE2Zjc0MDQ2Y2ZhMzk3M2ZjYTJkMWNhMmJhYw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Yjg1OTYzNGNmZTBiOTU2YWMwZjA5NjUyOTc5M2JhZjY2NTMwOTQxNzk2NTNk
|
10
|
+
OWYzNGU4NzgxNjA0NGIxYmMyNWQzNzYxM2Q4Y2U1MWY4MTE3MDg5M2I1Y2Ey
|
11
|
+
NGUwYWI5OTIyZGRlNTU4MjYzYmMwMTkxZTUxMTkwYWFmMDk5NDE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZWZjY2FlNzE2MzNmZDE4MDJlMjFiMzEyMjNlOWFiZDZmNDExMjU5Y2U1YWQw
|
14
|
+
MDUyODBlMzIwM2VmNDNhMmVjOWZjOWRlMGQxODYzZTFmNzQ2OWVhOWI4MDU0
|
15
|
+
Njk1YWEzMDk3M2JlMDlhZjZmMDkxNDNiNjAwZWE5ZWUxODQyZGM=
|
data/lib/beaker/cli.rb
CHANGED
@@ -67,7 +67,7 @@ module Beaker
|
|
67
67
|
[:add_master_entry, "Update /etc/hosts on master with master's ip", Proc.new {@setup.add_master_entry}]]
|
68
68
|
begin
|
69
69
|
#setup phase
|
70
|
-
setup_steps.each do |step|
|
70
|
+
setup_steps.each do |step|
|
71
71
|
if (not @options.has_key?(step[0])) or @options[step[0]]
|
72
72
|
@logger.notify ""
|
73
73
|
@logger.notify "Setup: #{step[1]}"
|
@@ -91,8 +91,10 @@ module Beaker
|
|
91
91
|
validate
|
92
92
|
setup
|
93
93
|
|
94
|
+
errored = false
|
95
|
+
|
94
96
|
#pre acceptance phase
|
95
|
-
run_suite(:pre_suite, :
|
97
|
+
run_suite(:pre_suite, :fast)
|
96
98
|
|
97
99
|
#testing phase
|
98
100
|
begin
|
@@ -100,8 +102,10 @@ module Beaker
|
|
100
102
|
#post acceptance phase
|
101
103
|
rescue => e
|
102
104
|
#post acceptance on failure
|
103
|
-
#
|
104
|
-
|
105
|
+
#run post-suite if we are in fail-slow mode
|
106
|
+
if @options[:fail_mode] =~ /slow/
|
107
|
+
run_suite(:post_suite)
|
108
|
+
end
|
105
109
|
raise e
|
106
110
|
else
|
107
111
|
#post acceptance on success
|
@@ -110,9 +114,8 @@ module Beaker
|
|
110
114
|
#cleanup phase
|
111
115
|
rescue => e
|
112
116
|
#cleanup on error
|
113
|
-
|
114
|
-
|
115
|
-
if @options[:fail_mode] != "stop"
|
117
|
+
if @options[:preserve_hosts] =~ /(never)/
|
118
|
+
@logger.notify "Cleanup: cleaning up after failed run"
|
116
119
|
if @network_manager
|
117
120
|
@network_manager.cleanup
|
118
121
|
end
|
@@ -120,9 +123,11 @@ module Beaker
|
|
120
123
|
raise "Failed to execute tests!"
|
121
124
|
else
|
122
125
|
#cleanup on success
|
123
|
-
@
|
124
|
-
|
125
|
-
@network_manager
|
126
|
+
if @options[:preserve_hosts] =~ /(never)|(onfail)/
|
127
|
+
@logger.notify "Cleanup: cleaning up after successful run"
|
128
|
+
if @network_manager
|
129
|
+
@network_manager.cleanup
|
130
|
+
end
|
126
131
|
end
|
127
132
|
end
|
128
133
|
end
|
@@ -238,6 +238,17 @@ module Beaker
|
|
238
238
|
end
|
239
239
|
end
|
240
240
|
|
241
|
+
#Classify the master so that it can deploy frictionless packages for a given host.
|
242
|
+
# @param [Host] host The host to install pacakges for
|
243
|
+
# @api private
|
244
|
+
def deploy_frictionless_to_master(host)
|
245
|
+
klass = host['platform'].gsub(/-/, '_').gsub(/\./,'')
|
246
|
+
klass = "pe_repo::platform::#{klass}"
|
247
|
+
on dashboard, "cd /opt/puppet/share/puppet-dashboard && /opt/puppet/bin/bundle exec rake nodeclass:add[#{klass},skip]"
|
248
|
+
on dashboard, "cd /opt/puppet/share/puppet-dashboard && /opt/puppet/bin/bundle exec rake node:addclass[#{master},#{klass}]"
|
249
|
+
on master, "puppet agent -t", :acceptable_exit_codes => [0,2]
|
250
|
+
end
|
251
|
+
|
241
252
|
#Perform a Puppet Enterprise upgrade or install
|
242
253
|
# @param [Array<Host>] hosts The hosts to install or upgrade PE on
|
243
254
|
# @param [Hash{Symbol=>Symbol, String}] options The options
|
@@ -289,6 +300,10 @@ module Beaker
|
|
289
300
|
if (! host['roles'].include? 'frictionless') || version_is_less(version, '3.2.0')
|
290
301
|
answers = Beaker::Answers.answers(options[:pe_ver] || host['pe_ver'], hosts, master_certname, options)
|
291
302
|
create_remote_file host, "#{host['working_dir']}/answers", Beaker::Answers.answer_string(host, answers)
|
303
|
+
else
|
304
|
+
# If We're *not* running the classic installer, we want
|
305
|
+
# to make sure the master has packages for us.
|
306
|
+
deploy_frictionless_to_master(host)
|
292
307
|
end
|
293
308
|
|
294
309
|
on host, installer_cmd(host, options)
|
data/lib/beaker/dsl/roles.rb
CHANGED
@@ -29,7 +29,10 @@ module Beaker
|
|
29
29
|
hosts_as 'agent'
|
30
30
|
end
|
31
31
|
|
32
|
-
# The host for which ['roles'] include 'master'
|
32
|
+
# The host for which ['roles'] include 'master'.
|
33
|
+
# If no host has the 'master' role, then use the host defined as 'default'.
|
34
|
+
# If no host is defined as a 'master' and there is no 'default' host defined then
|
35
|
+
# raise an error.
|
33
36
|
#
|
34
37
|
# @return [Array<Host>]
|
35
38
|
# @raise [Beaker::DSL::Outcomes::FailTest] if there are less
|
@@ -39,7 +42,11 @@ module Beaker
|
|
39
42
|
# on, master, 'cat /etc/puppet/puppet.conf'
|
40
43
|
#
|
41
44
|
def master
|
42
|
-
|
45
|
+
begin
|
46
|
+
find_only_one :master
|
47
|
+
rescue DSL::Outcomes::FailTest => e
|
48
|
+
default
|
49
|
+
end
|
43
50
|
end
|
44
51
|
|
45
52
|
# The host for which ['roles'] include 'database'
|
@@ -64,16 +64,13 @@ module Beaker
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def cleanup
|
67
|
-
#only cleanup if we aren't preserving hosts
|
68
67
|
#shut down connections
|
69
68
|
@hosts.each {|host| host.close }
|
70
69
|
|
71
|
-
if
|
72
|
-
|
73
|
-
@provisioned_set
|
74
|
-
|
75
|
-
@provisioned_set[type].cleanup
|
76
|
-
end
|
70
|
+
if @provisioned_set
|
71
|
+
@provisioned_set.each_key do |type|
|
72
|
+
if @provisioned_set[type]
|
73
|
+
@provisioned_set[type].cleanup
|
77
74
|
end
|
78
75
|
end
|
79
76
|
end
|
@@ -66,9 +66,14 @@ module Beaker
|
|
66
66
|
@cmd_options[:provision] = bool
|
67
67
|
end
|
68
68
|
|
69
|
-
opts.on '--
|
70
|
-
'
|
71
|
-
|
69
|
+
opts.on '--preserve-hosts [MODE]',
|
70
|
+
'How should SUTs be treated post test',
|
71
|
+
'Possible values:',
|
72
|
+
'always (keep SUTs alive)',
|
73
|
+
'onfail (keep SUTs alive if failures occur during testing)',
|
74
|
+
'never (cleanup SUTs - shutdown and destroy any changes made during testing)',
|
75
|
+
'(default: never)' do |mode|
|
76
|
+
@cmd_options[:preserve_hosts] = mode || 'always'
|
72
77
|
end
|
73
78
|
|
74
79
|
opts.on '--root-keys',
|
@@ -145,9 +150,11 @@ module Beaker
|
|
145
150
|
opts.on '--fail-mode [MODE]',
|
146
151
|
'How should the harness react to errors/failures',
|
147
152
|
'Possible values:',
|
148
|
-
'fast (skip all subsequent tests
|
149
|
-
'
|
150
|
-
|
153
|
+
'fast (skip all subsequent tests)',
|
154
|
+
'slow (attempt to continue run post test failure)',
|
155
|
+
'stop (DEPRECATED, please use fast)',
|
156
|
+
'(default: slow)' do |mode|
|
157
|
+
@cmd_options[:fail_mode] = mode =~ /stop/ ? 'fast' : mode
|
151
158
|
end
|
152
159
|
|
153
160
|
opts.on '--[no-]ntp',
|
@@ -239,8 +239,13 @@ module Beaker
|
|
239
239
|
end
|
240
240
|
|
241
241
|
#check for valid fail mode
|
242
|
-
if
|
243
|
-
parser_error "--fail-mode must be one of fast,
|
242
|
+
if @options[:fail_mode] !~ /stop|fast|slow/
|
243
|
+
parser_error "--fail-mode must be one of fast or slow, not '#{@options[:fail_mode]}'"
|
244
|
+
end
|
245
|
+
|
246
|
+
#check for valid preserve_hosts option
|
247
|
+
if @options[:preserve_hosts] !~ /always|onfail|never/
|
248
|
+
parser_error "--preserve_hosts must be one of always, onfail or never, not '#{@options[:preserve_hosts]}'"
|
244
249
|
end
|
245
250
|
|
246
251
|
#check for config files necessary for different hypervisors
|
@@ -273,8 +278,8 @@ module Beaker
|
|
273
278
|
parser_error "Only agent nodes may have the role 'frictionless', fix #{@options[:hosts_file]}"
|
274
279
|
end
|
275
280
|
end
|
276
|
-
if master > 1
|
277
|
-
parser_error "
|
281
|
+
if master > 1
|
282
|
+
parser_error "Only one host/node may have the role 'master', fix #{@options[:hosts_file]}"
|
278
283
|
end
|
279
284
|
|
280
285
|
#check that solaris/windows/el-4 boxes are only agents
|
@@ -34,14 +34,14 @@ module Beaker
|
|
34
34
|
:options_file => nil,
|
35
35
|
:type => 'pe',
|
36
36
|
:provision => true,
|
37
|
-
:preserve_hosts =>
|
37
|
+
:preserve_hosts => 'never',
|
38
38
|
:root_keys => false,
|
39
39
|
:quiet => false,
|
40
40
|
:xml => false,
|
41
41
|
:color => true,
|
42
42
|
:dry_run => false,
|
43
43
|
:timeout => 300,
|
44
|
-
:fail_mode =>
|
44
|
+
:fail_mode => 'slow',
|
45
45
|
:timesync => false,
|
46
46
|
:repo_proxy => false,
|
47
47
|
:add_el_extras => false,
|
data/lib/beaker/test_suite.rb
CHANGED
@@ -57,10 +57,10 @@ module Beaker
|
|
57
57
|
@logger.debug msg
|
58
58
|
when :fail
|
59
59
|
@logger.error msg
|
60
|
-
break if fail_mode #all failure modes cause us to kick out early on failure
|
60
|
+
break if fail_mode !~ /slow/ #all failure modes except slow cause us to kick out early on failure
|
61
61
|
when :error
|
62
62
|
@logger.warn msg
|
63
|
-
break if fail_mode #all failure modes cause
|
63
|
+
break if fail_mode !~ /slow/ #all failure modes except slow cause us to kick out early on failure
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
data/lib/beaker/version.rb
CHANGED
@@ -0,0 +1,156 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Beaker
|
4
|
+
describe CLI, :use_fakefs => true do
|
5
|
+
let(:cli) { Beaker::CLI.new }
|
6
|
+
|
7
|
+
context 'execute!' do
|
8
|
+
before :each do
|
9
|
+
stub_const("Beaker::Logger", double().as_null_object )
|
10
|
+
File.open("sample.cfg", "w+") do |file|
|
11
|
+
file.write("HOSTS:\n")
|
12
|
+
file.write(" myhost:\n")
|
13
|
+
file.write(" roles:\n")
|
14
|
+
file.write(" - master\n")
|
15
|
+
file.write(" platform: ubuntu-x-x\n")
|
16
|
+
file.write("CONFIG:\n")
|
17
|
+
end
|
18
|
+
cli.stub(:setup).and_return(true)
|
19
|
+
cli.stub(:validate).and_return(true)
|
20
|
+
cli.stub(:provision).and_return(true)
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "test fail mode" do
|
24
|
+
it 'continues testing after failed test if using slow fail_mode' do
|
25
|
+
cli.stub(:run_suite).with(:pre_suite, :fast).and_return(true)
|
26
|
+
cli.stub(:run_suite).with(:tests).and_throw("bad test")
|
27
|
+
cli.stub(:run_suite).with(:post_suite).and_return(true)
|
28
|
+
options = cli.instance_variable_get(:@options)
|
29
|
+
options[:fail_mode] = 'slow'
|
30
|
+
cli.instance_variable_set(:@options, options)
|
31
|
+
|
32
|
+
cli.should_receive(:run_suite).exactly( 3 ).times
|
33
|
+
expect{ cli.execute! }.to raise_error
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'stops testing after failed test if using fast fail_mode' do
|
38
|
+
cli.stub(:run_suite).with(:pre_suite, :fast).and_return(true)
|
39
|
+
cli.stub(:run_suite).with(:tests).and_throw("bad test")
|
40
|
+
cli.stub(:run_suite).with(:post_suite).and_return(true)
|
41
|
+
options = cli.instance_variable_get(:@options)
|
42
|
+
options[:fail_mode] = 'fast'
|
43
|
+
cli.instance_variable_set(:@options, options)
|
44
|
+
|
45
|
+
cli.should_receive(:run_suite).twice
|
46
|
+
expect{ cli.execute! }.to raise_error
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "SUT preserve mode" do
|
52
|
+
it 'cleans up SUTs post testing if tests fail and preserve_hosts = never' do
|
53
|
+
cli.stub(:run_suite).with(:pre_suite, :fast).and_return(true)
|
54
|
+
cli.stub(:run_suite).with(:tests).and_throw("bad test")
|
55
|
+
cli.stub(:run_suite).with(:post_suite).and_return(true)
|
56
|
+
options = cli.instance_variable_get(:@options)
|
57
|
+
options[:fail_mode] = 'fast'
|
58
|
+
options[:preserve_hosts] = 'never'
|
59
|
+
cli.instance_variable_set(:@options, options)
|
60
|
+
|
61
|
+
netmanager = double(:netmanager)
|
62
|
+
cli.instance_variable_set(:@network_manager, netmanager)
|
63
|
+
netmanager.should_receive(:cleanup).once
|
64
|
+
|
65
|
+
expect{ cli.execute! }.to raise_error
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'cleans up SUTs post testing if no tests fail and preserve_hosts = never' do
|
70
|
+
cli.stub(:run_suite).with(:pre_suite, :fast).and_return(true)
|
71
|
+
cli.stub(:run_suite).with(:tests).and_return(true)
|
72
|
+
cli.stub(:run_suite).with(:post_suite).and_return(true)
|
73
|
+
options = cli.instance_variable_get(:@options)
|
74
|
+
options[:fail_mode] = 'fast'
|
75
|
+
options[:preserve_hosts] = 'never'
|
76
|
+
cli.instance_variable_set(:@options, options)
|
77
|
+
|
78
|
+
netmanager = double(:netmanager)
|
79
|
+
cli.instance_variable_set(:@network_manager, netmanager)
|
80
|
+
netmanager.should_receive(:cleanup).once
|
81
|
+
|
82
|
+
expect{ cli.execute! }.to_not raise_error
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
it 'preserves SUTs post testing if no tests fail and preserve_hosts = always' do
|
88
|
+
cli.stub(:run_suite).with(:pre_suite, :fast).and_return(true)
|
89
|
+
cli.stub(:run_suite).with(:tests).and_return(true)
|
90
|
+
cli.stub(:run_suite).with(:post_suite).and_return(true)
|
91
|
+
options = cli.instance_variable_get(:@options)
|
92
|
+
options[:fail_mode] = 'fast'
|
93
|
+
options[:preserve_hosts] = 'always'
|
94
|
+
cli.instance_variable_set(:@options, options)
|
95
|
+
|
96
|
+
netmanager = double(:netmanager)
|
97
|
+
cli.instance_variable_set(:@network_manager, netmanager)
|
98
|
+
netmanager.should_receive(:cleanup).never
|
99
|
+
|
100
|
+
expect{ cli.execute! }.to_not raise_error
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'preserves SUTs post testing if no tests fail and preserve_hosts = always' do
|
105
|
+
cli.stub(:run_suite).with(:pre_suite, :fast).and_return(true)
|
106
|
+
cli.stub(:run_suite).with(:tests).and_throw("bad test")
|
107
|
+
cli.stub(:run_suite).with(:post_suite).and_return(true)
|
108
|
+
options = cli.instance_variable_get(:@options)
|
109
|
+
options[:fail_mode] = 'fast'
|
110
|
+
options[:preserve_hosts] = 'always'
|
111
|
+
cli.instance_variable_set(:@options, options)
|
112
|
+
|
113
|
+
netmanager = double(:netmanager)
|
114
|
+
cli.instance_variable_set(:@network_manager, netmanager)
|
115
|
+
netmanager.should_receive(:cleanup).never
|
116
|
+
|
117
|
+
expect{ cli.execute! }.to raise_error
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'cleans up SUTs post testing if no tests fail and preserve_hosts = onfail' do
|
121
|
+
cli.stub(:run_suite).with(:pre_suite, :fast).and_return(true)
|
122
|
+
cli.stub(:run_suite).with(:tests).and_return(true)
|
123
|
+
cli.stub(:run_suite).with(:post_suite).and_return(true)
|
124
|
+
options = cli.instance_variable_get(:@options)
|
125
|
+
options[:fail_mode] = 'fast'
|
126
|
+
options[:preserve_hosts] = 'onfail'
|
127
|
+
cli.instance_variable_set(:@options, options)
|
128
|
+
|
129
|
+
netmanager = double(:netmanager)
|
130
|
+
cli.instance_variable_set(:@network_manager, netmanager)
|
131
|
+
netmanager.should_receive(:cleanup).once
|
132
|
+
|
133
|
+
expect{ cli.execute! }.to_not raise_error
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
it 'preserves SUTs post testing if tests fail and preserve_hosts = onfail' do
|
138
|
+
cli.stub(:run_suite).with(:pre_suite, :fast).and_return(true)
|
139
|
+
cli.stub(:run_suite).with(:tests).and_throw("bad test")
|
140
|
+
cli.stub(:run_suite).with(:post_suite).and_return(true)
|
141
|
+
options = cli.instance_variable_get(:@options)
|
142
|
+
options[:fail_mode] = 'fast'
|
143
|
+
options[:preserve_hosts] = 'onfail'
|
144
|
+
cli.instance_variable_set(:@options, options)
|
145
|
+
|
146
|
+
netmanager = double(:netmanager)
|
147
|
+
cli.instance_variable_set(:@network_manager, netmanager)
|
148
|
+
netmanager.should_receive(:cleanup).never
|
149
|
+
|
150
|
+
expect{ cli.execute! }.to raise_error
|
151
|
+
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
@@ -39,14 +39,19 @@ describe ClassMixedWithDSLRoles do
|
|
39
39
|
end
|
40
40
|
it 'raises an error if there is more than one master' do
|
41
41
|
@hosts = [ master, monolith ]
|
42
|
-
subject.should_receive( :hosts ).and_return( hosts )
|
42
|
+
subject.should_receive( :hosts ).exactly( 5 ).times.and_return( hosts )
|
43
43
|
expect { subject.master }.to raise_error Beaker::DSL::FailTest
|
44
44
|
end
|
45
|
-
it 'and raises an error if there is no master' do
|
45
|
+
it 'and raises an error if there is no master and no default' do
|
46
46
|
@hosts = [ agent1, agent2, custom ]
|
47
|
-
subject.should_receive( :hosts ).and_return( hosts )
|
47
|
+
subject.should_receive( :hosts ).exactly( 4 ).times.and_return( hosts )
|
48
48
|
expect { subject.master }.to raise_error Beaker::DSL::FailTest
|
49
49
|
end
|
50
|
+
it 'returns the default when there is no master' do
|
51
|
+
@hosts = [ agent1 ]
|
52
|
+
subject.should_receive( :hosts ).exactly( 3 ).times.and_return( hosts )
|
53
|
+
expect( subject.master ).to be == agent1
|
54
|
+
end
|
50
55
|
end
|
51
56
|
describe '#dashboard' do
|
52
57
|
it 'returns the dashboard if there is one' do
|
@@ -6,14 +6,14 @@ module Beaker
|
|
6
6
|
|
7
7
|
let(:parser) {Beaker::Options::CommandLineParser.new}
|
8
8
|
let(:test_opts) {["-h", "vcloud.cfg", "--debug", "--tests", "test.rb", "--help"]}
|
9
|
-
let(:full_opts) {["--hosts", "host.cfg", "--options", "opts_file", "--type", "pe", "--helper", "path_to_helper", "--load-path", "load_path", "--tests", "test1.rb,test2.rb,test3.rb", "--pre-suite", "pre_suite.rb", "--post-suite", "post_suite.rb", "--no-provision", "--preserve-hosts", "--root-keys", "--keyfile", "../.ssh/id_rsa", "--install", "gitrepopath", "-m", "module", "-q", "--no-xml", "--dry-run", "--no-ntp", "--repo-proxy", "--add-el-extras", "--config", "anotherfile.cfg", "--fail-mode", "fast", "--no-color", "--version", "--log-level", "info"]}
|
9
|
+
let(:full_opts) {["--hosts", "host.cfg", "--options", "opts_file", "--type", "pe", "--helper", "path_to_helper", "--load-path", "load_path", "--tests", "test1.rb,test2.rb,test3.rb", "--pre-suite", "pre_suite.rb", "--post-suite", "post_suite.rb", "--no-provision", "--preserve-hosts", "always", "--root-keys", "--keyfile", "../.ssh/id_rsa", "--install", "gitrepopath", "-m", "module", "-q", "--no-xml", "--dry-run", "--no-ntp", "--repo-proxy", "--add-el-extras", "--config", "anotherfile.cfg", "--fail-mode", "fast", "--no-color", "--version", "--log-level", "info"]}
|
10
10
|
|
11
11
|
it "can correctly read command line input" do
|
12
12
|
expect(parser.parse!(test_opts)).to be === {:hosts_file=>"vcloud.cfg", :log_level=>"debug", :tests=>"test.rb", :help=>true}
|
13
13
|
end
|
14
14
|
|
15
15
|
it "supports all our command line options" do
|
16
|
-
expect(parser.parse!(full_opts)).to be === {:hosts_file=>"anotherfile.cfg", :options_file=>"opts_file", :type=>"pe", :helper=>"path_to_helper", :load_path=>"load_path", :tests=>"test1.rb,test2.rb,test3.rb", :pre_suite=>"pre_suite.rb", :post_suite=>"post_suite.rb", :provision=>false, :preserve_hosts=>
|
16
|
+
expect(parser.parse!(full_opts)).to be === {:hosts_file=>"anotherfile.cfg", :options_file=>"opts_file", :type=>"pe", :helper=>"path_to_helper", :load_path=>"load_path", :tests=>"test1.rb,test2.rb,test3.rb", :pre_suite=>"pre_suite.rb", :post_suite=>"post_suite.rb", :provision=>false, :preserve_hosts=>"always", :root_keys=>true, :keyfile=>"../.ssh/id_rsa", :install=>"gitrepopath", :modules=>"module", :quiet=>true, :xml=>false, :dry_run=>true, :timesync=>false, :repo_proxy=>true, :add_el_extras=>true, :fail_mode=>"fast", :color=>false, :version=>true, :log_level=>"info"}
|
17
17
|
end
|
18
18
|
|
19
19
|
it "can produce a usage description" do
|
@@ -154,12 +154,12 @@ module Beaker
|
|
154
154
|
it "can correctly combine arguments from different sources" do
|
155
155
|
FakeFS.deactivate!
|
156
156
|
args = ["-h", hosts_path, "--log-level", "debug", "--type", "git", "--install", "PUPPET/1.0,HIERA/hello"]
|
157
|
-
expect(parser.parse_args(args)).to be === {:log_level=>"debug", :hosts_file=>hosts_path, :options_file=>nil, :type=>"git", :provision=>true, :preserve_hosts=>
|
157
|
+
expect(parser.parse_args(args)).to be === {:log_level=>"debug", :hosts_file=>hosts_path, :options_file=>nil, :type=>"git", :provision=>true, :preserve_hosts=>'never', :root_keys=>false, :quiet=>false, :xml=>false, :color=>true, :dry_run=>false, :timeout=>300, :fail_mode=>'slow', :timesync=>false, :repo_proxy=>false, :add_el_extras=>false, :consoleport=>443, :pe_dir=>"/opt/enterprise/dists", :pe_version_file=>"LATEST", :pe_version_file_win=>"LATEST-win", :dot_fog=>"#{home}/.fog", :help=>false, :ec2_yaml=>"config/image_templates/ec2.yaml", :ssh=>{:config=>false, :paranoid=>false, :timeout=>300, :auth_methods=>["publickey"], :port=>22, :forward_agent=>true, :keys=>["#{home}/.ssh/id_rsa"], :user_known_hosts_file=>"#{home}/.ssh/known_hosts"}, :install=>["git://github.com/puppetlabs/puppet.git#1.0", "git://github.com/puppetlabs/hiera.git#hello"], :HOSTS=>{:"pe-ubuntu-lucid"=>{:roles=>["agent", "dashboard", "database", "master"], :vmname=>"pe-ubuntu-lucid", :platform=>"ubuntu-10.04-i386", :snapshot=>"clean-w-keys", :hypervisor=>"fusion"}, :"pe-centos6"=>{:roles=>["agent"], :vmname=>"pe-centos6", :platform=>"el-6-i386", :hypervisor=>"fusion", :snapshot=>"clean-w-keys"}}, :nfs_server=>"none", :helper=>[], :load_path=>[], :tests=>[], :pre_suite=>[], :post_suite=>[], :modules=>[]}
|
158
158
|
end
|
159
159
|
|
160
|
-
it "ensures that
|
160
|
+
it "ensures that fail-mode is one of fast/slow" do
|
161
161
|
FakeFS.deactivate!
|
162
|
-
args = ["-h", hosts_path, "--log-level", "debug", "--fail-mode", "
|
162
|
+
args = ["-h", hosts_path, "--log-level", "debug", "--fail-mode", "nope"]
|
163
163
|
expect{parser.parse_args(args)}.to raise_error(ArgumentError)
|
164
164
|
end
|
165
165
|
|
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.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppetlabs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -337,6 +337,7 @@ files:
|
|
337
337
|
- lib/beaker/utils/validator.rb
|
338
338
|
- lib/beaker/version.rb
|
339
339
|
- spec/beaker/answers_spec.rb
|
340
|
+
- spec/beaker/cli_spec.rb
|
340
341
|
- spec/beaker/command_spec.rb
|
341
342
|
- spec/beaker/dsl/assertions_spec.rb
|
342
343
|
- spec/beaker/dsl/helpers_spec.rb
|
@@ -414,6 +415,7 @@ specification_version: 4
|
|
414
415
|
summary: Let's test Puppet!
|
415
416
|
test_files:
|
416
417
|
- spec/beaker/answers_spec.rb
|
418
|
+
- spec/beaker/cli_spec.rb
|
417
419
|
- spec/beaker/command_spec.rb
|
418
420
|
- spec/beaker/dsl/assertions_spec.rb
|
419
421
|
- spec/beaker/dsl/helpers_spec.rb
|